<https://webkit.org/b/119833> Concurrent compilation thread should not trigger WriteB...
authormhahnenberg@apple.com <mhahnenberg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Aug 2013 03:28:39 +0000 (03:28 +0000)
committermhahnenberg@apple.com <mhahnenberg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Aug 2013 03:28:39 +0000 (03:28 +0000)
Reviewed by Oliver Hunt.

The concurrent compilation thread should interact minimally with the Heap, including not
triggering WriteBarriers. This is a prerequisite for generational GC.

* JavaScriptCore.xcodeproj/project.pbxproj:
* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::addOrFindConstant):
(JSC::CodeBlock::findConstant):
* bytecode/CodeBlock.h:
(JSC::CodeBlock::addConstantLazily):
* dfg/DFGByteCodeParser.cpp:
(JSC::DFG::ByteCodeParser::getJSConstantForValue):
(JSC::DFG::ByteCodeParser::constantUndefined):
(JSC::DFG::ByteCodeParser::constantNull):
(JSC::DFG::ByteCodeParser::one):
(JSC::DFG::ByteCodeParser::constantNaN):
(JSC::DFG::ByteCodeParser::InlineStackEntry::InlineStackEntry):
* dfg/DFGCommonData.cpp:
(JSC::DFG::CommonData::notifyCompilingStructureTransition):
* dfg/DFGCommonData.h:
* dfg/DFGDesiredTransitions.cpp: Added.
(JSC::DFG::DesiredTransition::DesiredTransition):
(JSC::DFG::DesiredTransition::reallyAdd):
(JSC::DFG::DesiredTransitions::DesiredTransitions):
(JSC::DFG::DesiredTransitions::~DesiredTransitions):
(JSC::DFG::DesiredTransitions::addLazily):
(JSC::DFG::DesiredTransitions::reallyAdd):
* dfg/DFGDesiredTransitions.h: Added.
* dfg/DFGDesiredWeakReferences.cpp: Added.
(JSC::DFG::DesiredWeakReferences::DesiredWeakReferences):
(JSC::DFG::DesiredWeakReferences::~DesiredWeakReferences):
(JSC::DFG::DesiredWeakReferences::addLazily):
(JSC::DFG::DesiredWeakReferences::reallyAdd):
* dfg/DFGDesiredWeakReferences.h: Added.
* dfg/DFGDesiredWriteBarriers.cpp: Added.
(JSC::DFG::DesiredWriteBarrier::DesiredWriteBarrier):
(JSC::DFG::DesiredWriteBarrier::trigger):
(JSC::DFG::DesiredWriteBarriers::DesiredWriteBarriers):
(JSC::DFG::DesiredWriteBarriers::~DesiredWriteBarriers):
(JSC::DFG::DesiredWriteBarriers::addImpl):
(JSC::DFG::DesiredWriteBarriers::trigger):
* dfg/DFGDesiredWriteBarriers.h: Added.
(JSC::DFG::DesiredWriteBarriers::add):
(JSC::DFG::initializeLazyWriteBarrier):
* dfg/DFGFixupPhase.cpp:
(JSC::DFG::FixupPhase::truncateConstantToInt32):
* dfg/DFGGraph.h:
(JSC::DFG::Graph::convertToConstant):
* dfg/DFGJITCompiler.h:
(JSC::DFG::JITCompiler::addWeakReference):
* dfg/DFGPlan.cpp:
(JSC::DFG::Plan::Plan):
(JSC::DFG::Plan::reallyAdd):
* dfg/DFGPlan.h:
* dfg/DFGSpeculativeJIT32_64.cpp:
(JSC::DFG::SpeculativeJIT::compile):
* dfg/DFGSpeculativeJIT64.cpp:
(JSC::DFG::SpeculativeJIT::compile):
* runtime/WriteBarrier.h:
(JSC::WriteBarrierBase::set):
(JSC::WriteBarrier::WriteBarrier):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@154162 268f45cc-cd09-0410-ab3c-d52691b4dbfc

24 files changed:
Source/JavaScriptCore/CMakeLists.txt
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/GNUmakefile.list.am
Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
Source/JavaScriptCore/Target.pri
Source/JavaScriptCore/bytecode/CodeBlock.cpp
Source/JavaScriptCore/bytecode/CodeBlock.h
Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp
Source/JavaScriptCore/dfg/DFGCommonData.cpp
Source/JavaScriptCore/dfg/DFGCommonData.h
Source/JavaScriptCore/dfg/DFGDesiredTransitions.cpp [new file with mode: 0644]
Source/JavaScriptCore/dfg/DFGDesiredTransitions.h [new file with mode: 0644]
Source/JavaScriptCore/dfg/DFGDesiredWeakReferences.cpp [new file with mode: 0644]
Source/JavaScriptCore/dfg/DFGDesiredWeakReferences.h [new file with mode: 0644]
Source/JavaScriptCore/dfg/DFGDesiredWriteBarriers.cpp [new file with mode: 0644]
Source/JavaScriptCore/dfg/DFGDesiredWriteBarriers.h [new file with mode: 0644]
Source/JavaScriptCore/dfg/DFGFixupPhase.cpp
Source/JavaScriptCore/dfg/DFGGraph.h
Source/JavaScriptCore/dfg/DFGJITCompiler.h
Source/JavaScriptCore/dfg/DFGPlan.cpp
Source/JavaScriptCore/dfg/DFGPlan.h
Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp
Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp
Source/JavaScriptCore/runtime/WriteBarrier.h

index b35e786..501d2a5 100644 (file)
@@ -100,7 +100,10 @@ set(JavaScriptCore_SOURCES
     dfg/DFGDCEPhase.cpp
     dfg/DFGDesiredIdentifiers.cpp
     dfg/DFGDesiredStructureChains.cpp
+    dfg/DFGDesiredTransitions.cpp
     dfg/DFGDesiredWatchpoints.cpp
+    dfg/DFGDesiredWeakReferences.cpp
+    dfg/DFGDesiredWriteBarriers.cpp
     dfg/DFGDisassembler.cpp
     dfg/DFGDominators.cpp
     dfg/DFGDriver.cpp
index 2e67fb0..ec178e8 100644 (file)
@@ -1,3 +1,70 @@
+2013-08-15  Mark Hahnenberg  <mhahnenberg@apple.com>
+
+        <https://webkit.org/b/119833> Concurrent compilation thread should not trigger WriteBarriers
+
+        Reviewed by Oliver Hunt.
+
+        The concurrent compilation thread should interact minimally with the Heap, including not 
+        triggering WriteBarriers. This is a prerequisite for generational GC.
+
+        * JavaScriptCore.xcodeproj/project.pbxproj:
+        * bytecode/CodeBlock.cpp:
+        (JSC::CodeBlock::addOrFindConstant):
+        (JSC::CodeBlock::findConstant):
+        * bytecode/CodeBlock.h:
+        (JSC::CodeBlock::addConstantLazily):
+        * dfg/DFGByteCodeParser.cpp:
+        (JSC::DFG::ByteCodeParser::getJSConstantForValue):
+        (JSC::DFG::ByteCodeParser::constantUndefined):
+        (JSC::DFG::ByteCodeParser::constantNull):
+        (JSC::DFG::ByteCodeParser::one):
+        (JSC::DFG::ByteCodeParser::constantNaN):
+        (JSC::DFG::ByteCodeParser::InlineStackEntry::InlineStackEntry):
+        * dfg/DFGCommonData.cpp:
+        (JSC::DFG::CommonData::notifyCompilingStructureTransition):
+        * dfg/DFGCommonData.h:
+        * dfg/DFGDesiredTransitions.cpp: Added.
+        (JSC::DFG::DesiredTransition::DesiredTransition):
+        (JSC::DFG::DesiredTransition::reallyAdd):
+        (JSC::DFG::DesiredTransitions::DesiredTransitions):
+        (JSC::DFG::DesiredTransitions::~DesiredTransitions):
+        (JSC::DFG::DesiredTransitions::addLazily):
+        (JSC::DFG::DesiredTransitions::reallyAdd):
+        * dfg/DFGDesiredTransitions.h: Added.
+        * dfg/DFGDesiredWeakReferences.cpp: Added.
+        (JSC::DFG::DesiredWeakReferences::DesiredWeakReferences):
+        (JSC::DFG::DesiredWeakReferences::~DesiredWeakReferences):
+        (JSC::DFG::DesiredWeakReferences::addLazily):
+        (JSC::DFG::DesiredWeakReferences::reallyAdd):
+        * dfg/DFGDesiredWeakReferences.h: Added.
+        * dfg/DFGDesiredWriteBarriers.cpp: Added.
+        (JSC::DFG::DesiredWriteBarrier::DesiredWriteBarrier):
+        (JSC::DFG::DesiredWriteBarrier::trigger):
+        (JSC::DFG::DesiredWriteBarriers::DesiredWriteBarriers):
+        (JSC::DFG::DesiredWriteBarriers::~DesiredWriteBarriers):
+        (JSC::DFG::DesiredWriteBarriers::addImpl):
+        (JSC::DFG::DesiredWriteBarriers::trigger):
+        * dfg/DFGDesiredWriteBarriers.h: Added.
+        (JSC::DFG::DesiredWriteBarriers::add):
+        (JSC::DFG::initializeLazyWriteBarrier):
+        * dfg/DFGFixupPhase.cpp:
+        (JSC::DFG::FixupPhase::truncateConstantToInt32):
+        * dfg/DFGGraph.h:
+        (JSC::DFG::Graph::convertToConstant):
+        * dfg/DFGJITCompiler.h:
+        (JSC::DFG::JITCompiler::addWeakReference):
+        * dfg/DFGPlan.cpp:
+        (JSC::DFG::Plan::Plan):
+        (JSC::DFG::Plan::reallyAdd):
+        * dfg/DFGPlan.h:
+        * dfg/DFGSpeculativeJIT32_64.cpp:
+        (JSC::DFG::SpeculativeJIT::compile):
+        * dfg/DFGSpeculativeJIT64.cpp:
+        (JSC::DFG::SpeculativeJIT::compile):
+        * runtime/WriteBarrier.h:
+        (JSC::WriteBarrierBase::set):
+        (JSC::WriteBarrier::WriteBarrier):
+
 2013-08-15  Benjamin Poulain  <benjamin@webkit.org>
 
         Fix x86 32bits build after r154158
index 2f97ec0..4f2dd28 100644 (file)
@@ -233,8 +233,14 @@ javascriptcore_sources += \
        Source/JavaScriptCore/dfg/DFGDesiredIdentifiers.h \
        Source/JavaScriptCore/dfg/DFGDesiredStructureChains.cpp \
        Source/JavaScriptCore/dfg/DFGDesiredStructureChains.h \
+       Source/JavaScriptCore/dfg/DFGDesiredTransitions.cpp \
+       Source/JavaScriptCore/dfg/DFGDesiredTransitions.h \
        Source/JavaScriptCore/dfg/DFGDesiredWatchpoints.cpp \
        Source/JavaScriptCore/dfg/DFGDesiredWatchpoints.h \
+       Source/JavaScriptCore/dfg/DFGDesiredWeakReferences.cpp \
+       Source/JavaScriptCore/dfg/DFGDesiredWeakReferences.h \
+       Source/JavaScriptCore/dfg/DFGDesiredWriteBarriers.cpp \
+       Source/JavaScriptCore/dfg/DFGDesiredWriteBarriers.h \
        Source/JavaScriptCore/dfg/DFGDisassembler.cpp \
        Source/JavaScriptCore/dfg/DFGDisassembler.h \
        Source/JavaScriptCore/dfg/DFGDominators.cpp \
index 5e0d04d..10a5a87 100644 (file)
                C25F8BCE157544A900245B71 /* IncrementalSweeper.h in Headers */ = {isa = PBXBuildFile; fileRef = C25F8BCC157544A900245B71 /* IncrementalSweeper.h */; settings = {ATTRIBUTES = (Private, ); }; };
                C283190016FE4B7D00157BFD /* HandleBlock.h in Headers */ = {isa = PBXBuildFile; fileRef = C28318FF16FE4B7D00157BFD /* HandleBlock.h */; settings = {ATTRIBUTES = (Private, ); }; };
                C283190216FE533E00157BFD /* HandleBlockInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = C283190116FE533E00157BFD /* HandleBlockInlines.h */; };
+               C2981FD817BAEE4B00A3BC98 /* DFGDesiredWeakReferences.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C2981FD617BAEE4B00A3BC98 /* DFGDesiredWeakReferences.cpp */; };
+               C2981FD917BAEE4B00A3BC98 /* DFGDesiredWeakReferences.h in Headers */ = {isa = PBXBuildFile; fileRef = C2981FD717BAEE4B00A3BC98 /* DFGDesiredWeakReferences.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               C2981FDC17BAFF4400A3BC98 /* DFGDesiredWriteBarriers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C2981FDA17BAFF4400A3BC98 /* DFGDesiredWriteBarriers.cpp */; };
+               C2981FDD17BAFF4400A3BC98 /* DFGDesiredWriteBarriers.h in Headers */ = {isa = PBXBuildFile; fileRef = C2981FDB17BAFF4400A3BC98 /* DFGDesiredWriteBarriers.h */; settings = {ATTRIBUTES = (Private, ); }; };
                C2A7F688160432D400F76B98 /* JSDestructibleObject.h in Headers */ = {isa = PBXBuildFile; fileRef = C2A7F687160432D400F76B98 /* JSDestructibleObject.h */; settings = {ATTRIBUTES = (Private, ); }; };
                C2B916C214DA014E00CBAC86 /* MarkedAllocator.h in Headers */ = {isa = PBXBuildFile; fileRef = C2B916C114DA014E00CBAC86 /* MarkedAllocator.h */; settings = {ATTRIBUTES = (Private, ); }; };
                C2B916C514DA040C00CBAC86 /* MarkedAllocator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C2B916C414DA040C00CBAC86 /* MarkedAllocator.cpp */; };
+               C2C0F7CD17BBFC5B00464FE4 /* DFGDesiredTransitions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C2C0F7CB17BBFC5B00464FE4 /* DFGDesiredTransitions.cpp */; };
+               C2C0F7CE17BBFC5B00464FE4 /* DFGDesiredTransitions.h in Headers */ = {isa = PBXBuildFile; fileRef = C2C0F7CC17BBFC5B00464FE4 /* DFGDesiredTransitions.h */; settings = {ATTRIBUTES = (Private, ); }; };
                C2C8D02D14A3C6E000578E65 /* CopiedSpaceInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = C2C8D02B14A3C6B200578E65 /* CopiedSpaceInlines.h */; settings = {ATTRIBUTES = (Private, ); }; };
                C2C8D03014A3CEFC00578E65 /* CopiedBlock.h in Headers */ = {isa = PBXBuildFile; fileRef = C2C8D02E14A3CEFC00578E65 /* CopiedBlock.h */; settings = {ATTRIBUTES = (Private, ); }; };
                C2C8D03114A3CEFC00578E65 /* HeapBlock.h in Headers */ = {isa = PBXBuildFile; fileRef = C2C8D02F14A3CEFC00578E65 /* HeapBlock.h */; settings = {ATTRIBUTES = (Private, ); }; };
                C25F8BCC157544A900245B71 /* IncrementalSweeper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IncrementalSweeper.h; sourceTree = "<group>"; };
                C28318FF16FE4B7D00157BFD /* HandleBlock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HandleBlock.h; sourceTree = "<group>"; };
                C283190116FE533E00157BFD /* HandleBlockInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HandleBlockInlines.h; sourceTree = "<group>"; };
+               C2981FD617BAEE4B00A3BC98 /* DFGDesiredWeakReferences.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DFGDesiredWeakReferences.cpp; path = dfg/DFGDesiredWeakReferences.cpp; sourceTree = "<group>"; };
+               C2981FD717BAEE4B00A3BC98 /* DFGDesiredWeakReferences.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGDesiredWeakReferences.h; path = dfg/DFGDesiredWeakReferences.h; sourceTree = "<group>"; };
+               C2981FDA17BAFF4400A3BC98 /* DFGDesiredWriteBarriers.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DFGDesiredWriteBarriers.cpp; path = dfg/DFGDesiredWriteBarriers.cpp; sourceTree = "<group>"; };
+               C2981FDB17BAFF4400A3BC98 /* DFGDesiredWriteBarriers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGDesiredWriteBarriers.h; path = dfg/DFGDesiredWriteBarriers.h; sourceTree = "<group>"; };
                C2A7F687160432D400F76B98 /* JSDestructibleObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDestructibleObject.h; sourceTree = "<group>"; };
                C2B916C114DA014E00CBAC86 /* MarkedAllocator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MarkedAllocator.h; sourceTree = "<group>"; };
                C2B916C414DA040C00CBAC86 /* MarkedAllocator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MarkedAllocator.cpp; sourceTree = "<group>"; };
+               C2C0F7CB17BBFC5B00464FE4 /* DFGDesiredTransitions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DFGDesiredTransitions.cpp; path = dfg/DFGDesiredTransitions.cpp; sourceTree = "<group>"; };
+               C2C0F7CC17BBFC5B00464FE4 /* DFGDesiredTransitions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGDesiredTransitions.h; path = dfg/DFGDesiredTransitions.h; sourceTree = "<group>"; };
                C2C8D02B14A3C6B200578E65 /* CopiedSpaceInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CopiedSpaceInlines.h; sourceTree = "<group>"; };
                C2C8D02E14A3CEFC00578E65 /* CopiedBlock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CopiedBlock.h; sourceTree = "<group>"; };
                C2C8D02F14A3CEFC00578E65 /* HeapBlock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HeapBlock.h; sourceTree = "<group>"; };
                                0FFFC95414EF909500C72532 /* DFGVirtualRegisterAllocationPhase.h */,
                                0FDB2CE5174830A2007B3C1B /* DFGWorklist.cpp */,
                                0FDB2CE6174830A2007B3C1B /* DFGWorklist.h */,
+                               C2981FD617BAEE4B00A3BC98 /* DFGDesiredWeakReferences.cpp */,
+                               C2981FD717BAEE4B00A3BC98 /* DFGDesiredWeakReferences.h */,
+                               C2981FDA17BAFF4400A3BC98 /* DFGDesiredWriteBarriers.cpp */,
+                               C2981FDB17BAFF4400A3BC98 /* DFGDesiredWriteBarriers.h */,
+                               C2C0F7CB17BBFC5B00464FE4 /* DFGDesiredTransitions.cpp */,
+                               C2C0F7CC17BBFC5B00464FE4 /* DFGDesiredTransitions.h */,
                        );
                        name = dfg;
                        sourceTree = "<group>";
                                BC18C3E60E16F5CD00B34460 /* ArrayConstructor.h in Headers */,
                                0FB7F39515ED8E4600F167B2 /* ArrayConventions.h in Headers */,
                                0F63945515D07057006A597C /* ArrayProfile.h in Headers */,
+                               C2981FD917BAEE4B00A3BC98 /* DFGDesiredWeakReferences.h in Headers */,
+                               C2981FDD17BAFF4400A3BC98 /* DFGDesiredWriteBarriers.h in Headers */,
+                               C2C0F7CE17BBFC5B00464FE4 /* DFGDesiredTransitions.h in Headers */,
                                BC18C3E70E16F5CD00B34460 /* ArrayPrototype.h in Headers */,
                                BC18C5240E16FC8A00B34460 /* ArrayPrototype.lut.h in Headers */,
                                0FB7F39615ED8E4600F167B2 /* ArrayStorage.h in Headers */,
                                14469DE0107EC7E700650446 /* NativeErrorConstructor.cpp in Sources */,
                                14469DE1107EC7E700650446 /* NativeErrorPrototype.cpp in Sources */,
                                148F21B7107EC5470042EC2C /* Nodes.cpp in Sources */,
+                               C2981FD817BAEE4B00A3BC98 /* DFGDesiredWeakReferences.cpp in Sources */,
                                655EB29B10CE2581001A990E /* NodesCodegen.cpp in Sources */,
                                14469DE2107EC7E700650446 /* NumberConstructor.cpp in Sources */,
                                14469DE3107EC7E700650446 /* NumberObject.cpp in Sources */,
                                14280841107EC0930013E7B2 /* RegExp.cpp in Sources */,
                                A1712B3B11C7B212007A5315 /* RegExpCache.cpp in Sources */,
                                8642C510151C06A90046D4EF /* RegExpCachedResult.cpp in Sources */,
+                               C2981FDC17BAFF4400A3BC98 /* DFGDesiredWriteBarriers.cpp in Sources */,
                                14280842107EC0930013E7B2 /* RegExpConstructor.cpp in Sources */,
                                0F2B66E617B6B5AB00A7AE3F /* JSArrayBufferPrototype.cpp in Sources */,
                                8642C512151C083D0046D4EF /* RegExpMatchesArray.cpp in Sources */,
                                0FF42747158EBE91004CB9FF /* udis86_syn.c in Sources */,
                                0FF42732158EBD58004CB9FF /* UDis86Disassembler.cpp in Sources */,
                                A76F279415F13C9600517D67 /* UnlinkedCodeBlock.cpp in Sources */,
+                               C2C0F7CD17BBFC5B00464FE4 /* DFGDesiredTransitions.cpp in Sources */,
                                E18E3A590DF9278C00D90B34 /* VM.cpp in Sources */,
                                FE4A331F15BD2E07006F54F3 /* VMInspector.cpp in Sources */,
                                0FC81516140511B500CFA603 /* VTableSpectrum.cpp in Sources */,
index c761a31..849d74b 100644 (file)
@@ -137,7 +137,10 @@ SOURCES += \
     dfg/DFGDCEPhase.cpp \
     dfg/DFGDesiredIdentifiers.cpp \
     dfg/DFGDesiredStructureChains.cpp \
+    dfg/DFGDesiredTransitions.cpp \
     dfg/DFGDesiredWatchpoints.cpp \
+    dfg/DFGDesiredWeakReferences.cpp \
+    dfg/DFGDesiredWriteBarriers.cpp \
     dfg/DFGDisassembler.cpp \
     dfg/DFGDominators.cpp \
     dfg/DFGDriver.cpp \
index 5ea6fa3..7925fab 100644 (file)
@@ -2489,12 +2489,23 @@ void CodeBlock::createActivation(CallFrame* callFrame)
 
 unsigned CodeBlock::addOrFindConstant(JSValue v)
 {
+    unsigned result;
+    if (findConstant(v, result))
+        return result;
+    return addConstant(v);
+}
+
+bool CodeBlock::findConstant(JSValue v, unsigned& index)
+{
     unsigned numberOfConstants = numberOfConstantRegisters();
     for (unsigned i = 0; i < numberOfConstants; ++i) {
-        if (getConstant(FirstConstantRegisterIndex + i) == v)
-            return i;
+        if (getConstant(FirstConstantRegisterIndex + i) == v) {
+            index = i;
+            return true;
+        }
     }
-    return addConstant(v);
+    index = numberOfConstants;
+    return false;
 }
 
 #if ENABLE(JIT)
index 1dfa634..bdf710b 100644 (file)
@@ -686,7 +686,13 @@ public:
         return result;
     }
 
+    WriteBarrier<Unknown>& addConstantLazily()
+    {
+        m_constantRegisters.append(WriteBarrier<Unknown>());
+        return m_constantRegisters.last();
+    }
 
+    bool findConstant(JSValue, unsigned& result);
     unsigned addOrFindConstant(JSValue);
     WriteBarrier<Unknown>& constantRegister(int index) { return m_constantRegisters[index - FirstConstantRegisterIndex]; }
     ALWAYS_INLINE bool isConstantRegisterIndex(int index) const { return index >= FirstConstantRegisterIndex; }
index cf2a05f..12d6494 100644 (file)
@@ -400,6 +400,15 @@ private:
             return findArgumentPositionForArgument(operandToArgument(operand));
         return findArgumentPositionForLocal(operand);
     }
+
+    void addConstant(JSValue value)
+    {
+        initializeLazyWriteBarrier(
+            m_codeBlock->addConstantLazily(), 
+            m_graph.m_plan.writeBarriers, 
+            m_codeBlock->ownerExecutable(), 
+            value);
+    }
     
     void flush(int operand)
     {
@@ -496,9 +505,11 @@ private:
     // doesn't handle liveness preservation.
     Node* getJSConstantForValue(JSValue constantValue)
     {
-        unsigned constantIndex = m_codeBlock->addOrFindConstant(constantValue);
-        if (constantIndex >= m_constants.size())
+        unsigned constantIndex;
+        if (!m_codeBlock->findConstant(constantValue, constantIndex)) {
+            addConstant(constantValue);
             m_constants.append(ConstantRecord());
+        }
         
         ASSERT(m_constants.size() == m_codeBlock->numberOfConstantRegisters());
         
@@ -567,7 +578,7 @@ private:
 
             // Add undefined to the CodeBlock's constants, and add a corresponding slot in m_constants.
             ASSERT(m_constants.size() == numberOfConstants);
-            m_codeBlock->addConstant(jsUndefined());
+            addConstant(jsUndefined());
             m_constants.append(ConstantRecord());
             ASSERT(m_constants.size() == m_codeBlock->numberOfConstantRegisters());
         }
@@ -592,7 +603,7 @@ private:
 
             // Add null to the CodeBlock's constants, and add a corresponding slot in m_constants.
             ASSERT(m_constants.size() == numberOfConstants);
-            m_codeBlock->addConstant(jsNull());
+            addConstant(jsNull());
             m_constants.append(ConstantRecord());
             ASSERT(m_constants.size() == m_codeBlock->numberOfConstantRegisters());
         }
@@ -617,7 +628,7 @@ private:
 
             // Add the value 1 to the CodeBlock's constants, and add a corresponding slot in m_constants.
             ASSERT(m_constants.size() == numberOfConstants);
-            m_codeBlock->addConstant(jsNumber(1));
+            addConstant(jsNumber(1));
             m_constants.append(ConstantRecord());
             ASSERT(m_constants.size() == m_codeBlock->numberOfConstantRegisters());
         }
@@ -645,7 +656,7 @@ private:
 
             // Add the value nan to the CodeBlock's constants, and add a corresponding slot in m_constants.
             ASSERT(m_constants.size() == numberOfConstants);
-            m_codeBlock->addConstant(nan);
+            addConstant(nan);
             m_constants.append(ConstantRecord());
             ASSERT(m_constants.size() == m_codeBlock->numberOfConstantRegisters());
         }
@@ -3274,10 +3285,19 @@ ByteCodeParser::InlineStackEntry::InlineStackEntry(
         ASSERT(callsiteBlockHead);
         
         InlineCallFrame inlineCallFrame;
-        inlineCallFrame.executable.set(*byteCodeParser->m_vm, byteCodeParser->m_codeBlock->ownerExecutable(), codeBlock->ownerExecutable());
+        initializeLazyWriteBarrier(
+            inlineCallFrame.executable,
+            byteCodeParser->m_graph.m_plan.writeBarriers,
+            byteCodeParser->m_codeBlock->ownerExecutable(), 
+            codeBlock->ownerExecutable());
         inlineCallFrame.stackOffset = inlineCallFrameStart + JSStack::CallFrameHeaderSize;
-        if (callee)
-            inlineCallFrame.callee.set(*byteCodeParser->m_vm, byteCodeParser->m_codeBlock->ownerExecutable(), callee);
+        if (callee) {
+            initializeLazyWriteBarrier(
+                inlineCallFrame.callee,
+                byteCodeParser->m_graph.m_plan.writeBarriers,
+                byteCodeParser->m_codeBlock->ownerExecutable(), 
+                callee);
+        }
         inlineCallFrame.caller = byteCodeParser->currentCodeOrigin();
         inlineCallFrame.arguments.resize(argumentCountIncludingThis); // Set the number of arguments including this, but don't configure the value recoveries, yet.
         inlineCallFrame.isCall = isCall(kind);
@@ -3328,7 +3348,7 @@ ByteCodeParser::InlineStackEntry::InlineStackEntry(
             if (!value) {
                 if (byteCodeParser->m_emptyJSValueIndex == UINT_MAX) {
                     byteCodeParser->m_emptyJSValueIndex = byteCodeParser->m_codeBlock->numberOfConstantRegisters() + FirstConstantRegisterIndex;
-                    byteCodeParser->m_codeBlock->addConstant(JSValue());
+                    byteCodeParser->addConstant(JSValue());
                     byteCodeParser->m_constants.append(ConstantRecord());
                 }
                 m_constantRemap[i] = byteCodeParser->m_emptyJSValueIndex;
@@ -3336,7 +3356,7 @@ ByteCodeParser::InlineStackEntry::InlineStackEntry(
             }
             JSValueMap::AddResult result = byteCodeParser->m_jsValueMap.add(JSValue::encode(value), byteCodeParser->m_codeBlock->numberOfConstantRegisters() + FirstConstantRegisterIndex);
             if (result.isNewEntry) {
-                byteCodeParser->m_codeBlock->addConstant(value);
+                byteCodeParser->addConstant(value);
                 byteCodeParser->m_constants.append(ConstantRecord());
             }
             m_constantRemap[i] = result.iterator->value;
index f12a685..dc8b2e4 100644 (file)
 
 #include "CodeBlock.h"
 #include "DFGNode.h"
+#include "DFGPlan.h"
 #include "Operations.h"
 #include "VM.h"
 
 namespace JSC { namespace DFG {
 
-void CommonData::notifyCompilingStructureTransition(CodeBlock* codeBlock, Node* node)
+void CommonData::notifyCompilingStructureTransition(Plan& plan, CodeBlock* codeBlock, Node* node)
 {
-    transitions.append(
-        WeakReferenceTransition(
-            *codeBlock->vm(), codeBlock->ownerExecutable(),
-            node->codeOrigin.codeOriginOwner(),
-            node->structureTransitionData().previousStructure,
-            node->structureTransitionData().newStructure));
+    plan.transitions.addLazily(
+        codeBlock,
+        node->codeOrigin.codeOriginOwner(),
+        node->structureTransitionData().previousStructure,
+        node->structureTransitionData().newStructure);
 }
 
 void CommonData::shrinkToFit()
index f1cfbb4..145bb65 100644 (file)
@@ -42,6 +42,7 @@ class Identifier;
 namespace DFG {
 
 struct Node;
+struct Plan;
 
 // CommonData holds the set of data that both DFG and FTL code blocks need to know
 // about themselves.
@@ -71,7 +72,7 @@ public:
     {
     }
     
-    void notifyCompilingStructureTransition(CodeBlock*, Node*);
+    void notifyCompilingStructureTransition(Plan&, CodeBlock*, Node*);
     
     void shrinkToFit();
 
diff --git a/Source/JavaScriptCore/dfg/DFGDesiredTransitions.cpp b/Source/JavaScriptCore/dfg/DFGDesiredTransitions.cpp
new file mode 100644 (file)
index 0000000..b0e0583
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "DFGDesiredTransitions.h"
+
+#include "CodeBlock.h"
+#include "DFGCommonData.h"
+
+namespace JSC { namespace DFG {
+
+DesiredTransition::DesiredTransition(CodeBlock* codeBlock, ScriptExecutable* codeOriginOwner, Structure* oldStructure, Structure* newStructure)
+    : m_codeBlock(codeBlock)
+    , m_codeOriginOwner(codeOriginOwner)
+    , m_oldStructure(oldStructure)
+    , m_newStructure(newStructure)
+{
+}
+
+void DesiredTransition::reallyAdd(VM& vm, CommonData* common)
+{
+    common->transitions.append(
+        WeakReferenceTransition(
+            vm, m_codeBlock->ownerExecutable(),
+            m_codeOriginOwner,
+            m_oldStructure, m_newStructure));
+}
+
+DesiredTransitions::DesiredTransitions()
+{
+}
+
+DesiredTransitions::~DesiredTransitions()
+{
+}
+
+void DesiredTransitions::addLazily(CodeBlock* codeBlock, ScriptExecutable* codeOriginOwner, Structure* oldStructure, Structure* newStructure)
+{
+    m_transitions.append(DesiredTransition(codeBlock, codeOriginOwner, oldStructure, newStructure));
+}
+
+void DesiredTransitions::reallyAdd(VM& vm, CommonData* common)
+{
+    for (unsigned i = 0; i < m_transitions.size(); i++)
+        m_transitions[i].reallyAdd(vm, common);
+}
+
+} } // namespace JSC::DFG
diff --git a/Source/JavaScriptCore/dfg/DFGDesiredTransitions.h b/Source/JavaScriptCore/dfg/DFGDesiredTransitions.h
new file mode 100644 (file)
index 0000000..acfa0f1
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef DFGDesiredTransitions_h
+#define DFGDesiredTransitions_h
+
+#include <wtf/Vector.h>
+
+namespace JSC { 
+
+class CodeBlock;
+class ScriptExecutable;
+class Structure;
+class VM;
+
+namespace DFG {
+
+class CommonData;
+
+class DesiredTransition {
+public:
+    DesiredTransition(CodeBlock*, ScriptExecutable*, Structure*, Structure*);
+
+    void reallyAdd(VM&, CommonData*);
+
+private:
+    CodeBlock* m_codeBlock;
+    ScriptExecutable* m_codeOriginOwner;
+    Structure* m_oldStructure;
+    Structure* m_newStructure;
+};
+
+class DesiredTransitions {
+public:
+    DesiredTransitions();
+    ~DesiredTransitions();
+
+    void addLazily(CodeBlock*, ScriptExecutable*, Structure*, Structure*);
+    void reallyAdd(VM&, CommonData*);
+
+private:
+    Vector<DesiredTransition> m_transitions;
+};
+
+} } // namespace JSC::DFG
+
+#endif // DFGDesiredTransitions_h
diff --git a/Source/JavaScriptCore/dfg/DFGDesiredWeakReferences.cpp b/Source/JavaScriptCore/dfg/DFGDesiredWeakReferences.cpp
new file mode 100644 (file)
index 0000000..a6f0ced
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "DFGDesiredWeakReferences.h"
+
+#include "CodeBlock.h"
+#include "DFGCommonData.h"
+
+namespace JSC { namespace DFG {
+
+DesiredWeakReferences::DesiredWeakReferences(CodeBlock* codeBlock)
+    : m_codeBlock(codeBlock)
+{
+}
+
+DesiredWeakReferences::~DesiredWeakReferences()
+{
+}
+
+void DesiredWeakReferences::addLazily(JSCell* cell)
+{
+    m_references.append(cell);
+}
+
+void DesiredWeakReferences::reallyAdd(VM& vm, CommonData* common)
+{
+    for (unsigned i = 0; i < m_references.size(); i++) {
+        JSCell* target = m_references[i];
+        common->weakReferences.append(WriteBarrier<JSCell>(vm, m_codeBlock->ownerExecutable(), target));
+    }
+}
+
+} } // namespace JSC::DFG
diff --git a/Source/JavaScriptCore/dfg/DFGDesiredWeakReferences.h b/Source/JavaScriptCore/dfg/DFGDesiredWeakReferences.h
new file mode 100644 (file)
index 0000000..cecdecb
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef DFGDesiredWeakReferences_h
+#define DFGDesiredWeakReferences_h
+
+#include <wtf/Vector.h>
+
+namespace JSC { 
+
+class CodeBlock;
+class JSCell;
+class VM;
+
+namespace DFG {
+
+class CommonData;
+
+class DesiredWeakReferences {
+public:
+    DesiredWeakReferences(CodeBlock*);
+    ~DesiredWeakReferences();
+
+    void addLazily(JSCell*);
+    void reallyAdd(VM&, CommonData*);
+
+private:
+    CodeBlock* m_codeBlock;
+    Vector<JSCell*> m_references;
+};
+
+} } // namespace JSC::DFG
+
+#endif // DFGDesiredWeakReferences_h
diff --git a/Source/JavaScriptCore/dfg/DFGDesiredWriteBarriers.cpp b/Source/JavaScriptCore/dfg/DFGDesiredWriteBarriers.cpp
new file mode 100644 (file)
index 0000000..264ecb7
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "DFGDesiredWriteBarriers.h"
+
+#include "JSCJSValueInlines.h"
+
+namespace JSC { namespace DFG {
+
+DesiredWriteBarrier::DesiredWriteBarrier(WriteBarrier<Unknown>* barrier, JSCell* owner)
+    : m_barrier(barrier)
+    , m_owner(owner)
+{
+}
+
+void DesiredWriteBarrier::trigger(VM& vm)
+{
+    m_barrier->set(vm, m_owner, m_barrier->get());
+}
+
+DesiredWriteBarriers::DesiredWriteBarriers()
+{
+}
+
+DesiredWriteBarriers::~DesiredWriteBarriers()
+{
+}
+
+DesiredWriteBarrier& DesiredWriteBarriers::addImpl(WriteBarrier<Unknown>* barrier, JSCell* owner)
+{
+    m_barriers.append(DesiredWriteBarrier(barrier, owner));
+    return m_barriers.last();
+}
+
+void DesiredWriteBarriers::trigger(VM& vm)
+{
+    for (unsigned i = 0; i < m_barriers.size(); i++)
+        m_barriers[i].trigger(vm);
+}
+
+} } // namespace JSC::DFG
diff --git a/Source/JavaScriptCore/dfg/DFGDesiredWriteBarriers.h b/Source/JavaScriptCore/dfg/DFGDesiredWriteBarriers.h
new file mode 100644 (file)
index 0000000..810b98c
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef DFGDesiredWriteBarriers_h
+#define DFGDesiredWriteBarriers_h
+
+#include "WriteBarrier.h"
+#include <wtf/Vector.h>
+
+namespace JSC {
+
+class VM;
+
+namespace DFG {
+
+class DesiredWriteBarrier {
+public:
+    DesiredWriteBarrier(WriteBarrier<Unknown>*, JSCell* owner);
+
+    void trigger(VM&);
+
+private:
+    WriteBarrier<Unknown>* m_barrier;
+    JSCell* m_owner;
+};
+
+class DesiredWriteBarriers {
+public:
+    DesiredWriteBarriers();
+    ~DesiredWriteBarriers();
+
+    template <typename T>
+    DesiredWriteBarrier& add(WriteBarrier<T>& barrier, JSCell* owner)
+    {
+        return addImpl(reinterpret_cast<WriteBarrier<Unknown>*>(&barrier), owner);
+    }
+
+    void trigger(VM&);
+
+private:
+    DesiredWriteBarrier& addImpl(WriteBarrier<Unknown>*, JSCell*);
+
+    Vector<DesiredWriteBarrier> m_barriers;
+};
+
+template <typename T, typename U>
+void initializeLazyWriteBarrier(WriteBarrier<T>& barrier, DesiredWriteBarriers& barriers, JSCell* owner, U value)
+{
+    barrier = WriteBarrier<T>(barriers.add(barrier, owner), value);
+}
+
+} } // namespace JSC::DFG
+
+#endif // DFGDesiredWriteBarriers_h
index d649356..fb6c6c7 100644 (file)
@@ -1412,9 +1412,17 @@ private:
         
         value = jsNumber(JSC::toInt32(value.asNumber()));
         ASSERT(value.isInt32());
+        unsigned constantRegister;
+        if (!codeBlock()->findConstant(value, constantRegister)) {
+            initializeLazyWriteBarrier(
+                codeBlock()->addConstantLazily(),
+                m_graph.m_plan.writeBarriers,
+                codeBlock()->ownerExecutable(),
+                value);
+        }
         edge.setNode(m_insertionSet.insertNode(
             m_indexInBlock, SpecInt32, JSConstant, m_currentNode->codeOrigin,
-            OpInfo(codeBlock()->addOrFindConstant(value))));
+            OpInfo(constantRegister)));
     }
     
     void truncateConstantsIfNecessary(Node* node, AddSpeculationMode mode)
index 3c227a4..40c197a 100644 (file)
@@ -153,7 +153,15 @@ public:
     
     void convertToConstant(Node* node, JSValue value)
     {
-        convertToConstant(node, m_codeBlock->addOrFindConstant(value));
+        unsigned constantRegister;
+        if (!m_codeBlock->findConstant(value, constantRegister)) {
+            initializeLazyWriteBarrier(
+                m_codeBlock->addConstantLazily(),
+                m_plan.writeBarriers,
+                m_codeBlock->ownerExecutable(),
+                value);
+        }
+        convertToConstant(node, constantRegister);
     }
 
     // CodeBlock is optional, but may allow additional information to be dumped (e.g. Identifier names).
index fee29bc..07c58cd 100644 (file)
@@ -411,7 +411,7 @@ public:
     
     void addWeakReference(JSCell* target)
     {
-        m_jitCode->common.weakReferences.append(WriteBarrier<JSCell>(m_graph.m_vm, codeBlock()->ownerExecutable(), target));
+        m_graph.m_plan.weakReferences.addLazily(target);
     }
     
     void addWeakReferences(const StructureSet& structureSet)
index b480180..22c19f8 100644 (file)
@@ -90,6 +90,7 @@ Plan::Plan(
     , mustHandleValues(codeBlock->numParameters(), numVarsWithValues)
     , compilation(codeBlock->vm()->m_perBytecodeProfiler ? adoptRef(new Profiler::Compilation(codeBlock->vm()->m_perBytecodeProfiler->ensureBytecodesFor(codeBlock.get()), Profiler::DFG)) : 0)
     , identifiers(codeBlock.get())
+    , weakReferences(codeBlock.get())
     , isCompiled(false)
 {
 }
@@ -275,6 +276,9 @@ void Plan::reallyAdd(CommonData* commonData)
 {
     watchpoints.reallyAdd();
     identifiers.reallyAdd(vm, commonData);
+    weakReferences.reallyAdd(vm, commonData);
+    transitions.reallyAdd(vm, commonData);
+    writeBarriers.trigger(vm);
 }
 
 CompilationResult Plan::finalize(RefPtr<JSC::JITCode>& jitCode, MacroAssemblerCodePtr* jitCodeWithArityCheck)
index ae0bc1d..7d56d3e 100644 (file)
 #include "CompilationResult.h"
 #include "DFGDesiredIdentifiers.h"
 #include "DFGDesiredStructureChains.h"
+#include "DFGDesiredTransitions.h"
 #include "DFGDesiredWatchpoints.h"
+#include "DFGDesiredWeakReferences.h"
+#include "DFGDesiredWriteBarriers.h"
 #include "DFGFinalizer.h"
 #include "Operands.h"
 #include "ProfilerCompilation.h"
@@ -75,7 +78,10 @@ struct Plan : public ThreadSafeRefCounted<Plan> {
     DesiredWatchpoints watchpoints;
     DesiredIdentifiers identifiers;
     DesiredStructureChains chains;
-    
+    DesiredWeakReferences weakReferences;
+    DesiredWriteBarriers writeBarriers;
+    DesiredTransitions transitions;
+
     double beforeFTL;
     
     bool isCompiled;
index 0a958f3..92db560 100644 (file)
@@ -3975,13 +3975,13 @@ void SpeculativeJIT::compile(Node* node)
         
     case PhantomPutStructure: {
         ASSERT(isKnownCell(node->child1().node()));
-        m_jit.jitCode()->common.notifyCompilingStructureTransition(m_jit.codeBlock(), node);
+        m_jit.jitCode()->common.notifyCompilingStructureTransition(m_jit.graph().m_plan, m_jit.codeBlock(), node);
         noResult(node);
         break;
     }
 
     case PutStructure: {
-        m_jit.jitCode()->common.notifyCompilingStructureTransition(m_jit.codeBlock(), node);
+        m_jit.jitCode()->common.notifyCompilingStructureTransition(m_jit.graph().m_plan, m_jit.codeBlock(), node);
 
         SpeculateCellOperand base(this, node->child1());
         GPRReg baseGPR = base.gpr();
index 37badd0..df23261 100644 (file)
@@ -3896,13 +3896,13 @@ void SpeculativeJIT::compile(Node* node)
         
     case PhantomPutStructure: {
         ASSERT(isKnownCell(node->child1().node()));
-        m_jit.jitCode()->common.notifyCompilingStructureTransition(m_jit.codeBlock(), node);
+        m_jit.jitCode()->common.notifyCompilingStructureTransition(m_jit.graph().m_plan, m_jit.codeBlock(), node);
         noResult(node);
         break;
     }
         
     case PutStructure: {
-        m_jit.jitCode()->common.notifyCompilingStructureTransition(m_jit.codeBlock(), node);
+        m_jit.jitCode()->common.notifyCompilingStructureTransition(m_jit.graph().m_plan, m_jit.codeBlock(), node);
 
         SpeculateCellOperand base(this, node->child1());
         GPRReg baseGPR = base.gpr();
index b3bed37..53a8caa 100644 (file)
 
 namespace JSC {
 
+namespace DFG {
+class DesiredWriteBarrier;
+}
+
 class JSCell;
 class VM;
 class JSGlobalObject;
@@ -71,6 +75,7 @@ public:
     void set(VM& vm, const JSCell* owner, T* value)
     {
         ASSERT(value);
+        ASSERT(!Options::enableConcurrentJIT() || !isCompilationThread());
         validateCell(value);
         setEarlyValue(vm, owner, value);
     }
@@ -149,6 +154,7 @@ template <> class WriteBarrierBase<Unknown> {
 public:
     void set(VM&, const JSCell* owner, JSValue value)
     {
+        ASSERT(!Options::enableConcurrentJIT() || !isCompilationThread());
         m_value = JSValue::encode(value);
         Heap::writeBarrier(owner, value);
     }
@@ -202,6 +208,12 @@ public:
         this->set(vm, owner, value);
     }
 
+    WriteBarrier(DFG::DesiredWriteBarrier&, T* value)
+    {
+        ASSERT(isCompilationThread());
+        this->setWithoutWriteBarrier(value);
+    }
+
     enum MayBeNullTag { MayBeNull };
     WriteBarrier(VM& vm, const JSCell* owner, T* value, MayBeNullTag)
     {
@@ -220,6 +232,12 @@ public:
     {
         this->set(vm, owner, value);
     }
+
+    WriteBarrier(DFG::DesiredWriteBarrier&, JSValue value)
+    {
+        ASSERT(isCompilationThread());
+        this->setWithoutWriteBarrier(value);
+    }
 };
 
 template <typename U, typename V> inline bool operator==(const WriteBarrierBase<U>& lhs, const WriteBarrierBase<V>& rhs)