Title: [153206] trunk/Source/_javascript_Core
Revision
153206
Author
[email protected]
Date
2013-07-24 21:01:56 -0700 (Wed, 24 Jul 2013)

Log Message

fourthTier: all cached put_by_id transitions, even ones that weren't inlined by the DFG, should be propagated by the GC
https://bugs.webkit.org/show_bug.cgi?id=117170

Reviewed by Mark Hahnenberg.

* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::visitAggregate):
(JSC::CodeBlock::propagateTransitions):
(JSC):
(JSC::CodeBlock::determineLiveness):
(JSC::CodeBlock::visitWeakReferences):
(JSC::CodeBlock::finalizeUnconditionally):
* bytecode/CodeBlock.h:
(CodeBlock):
* bytecode/PolymorphicPutByIdList.h:
(JSC):
(PutByIdAccess):
(PolymorphicPutByIdList):
* bytecode/StructureStubInfo.h:
(StructureStubInfo):
* jit/JITCode.h:
(JSC::JITCode::couldBeInterpreted):
(JITCode):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (153205 => 153206)


--- trunk/Source/_javascript_Core/ChangeLog	2013-07-25 04:01:54 UTC (rev 153205)
+++ trunk/Source/_javascript_Core/ChangeLog	2013-07-25 04:01:56 UTC (rev 153206)
@@ -1,3 +1,29 @@
+2013-06-03  Filip Pizlo  <[email protected]>
+
+        fourthTier: all cached put_by_id transitions, even ones that weren't inlined by the DFG, should be propagated by the GC
+        https://bugs.webkit.org/show_bug.cgi?id=117170
+
+        Reviewed by Mark Hahnenberg.
+
+        * bytecode/CodeBlock.cpp:
+        (JSC::CodeBlock::visitAggregate):
+        (JSC::CodeBlock::propagateTransitions):
+        (JSC):
+        (JSC::CodeBlock::determineLiveness):
+        (JSC::CodeBlock::visitWeakReferences):
+        (JSC::CodeBlock::finalizeUnconditionally):
+        * bytecode/CodeBlock.h:
+        (CodeBlock):
+        * bytecode/PolymorphicPutByIdList.h:
+        (JSC):
+        (PutByIdAccess):
+        (PolymorphicPutByIdList):
+        * bytecode/StructureStubInfo.h:
+        (StructureStubInfo):
+        * jit/JITCode.h:
+        (JSC::JITCode::couldBeInterpreted):
+        (JITCode):
+
 2013-06-02  Filip Pizlo  <[email protected]>
 
         fourthTier: Get rid of StructureStubInfo::bytecodeIndex

Modified: trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp (153205 => 153206)


--- trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp	2013-07-25 04:01:54 UTC (rev 153205)
+++ trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp	2013-07-25 04:01:56 UTC (rev 153206)
@@ -48,6 +48,7 @@
 #include "JSNameScope.h"
 #include "LowLevelInterpreter.h"
 #include "Operations.h"
+#include "PolymorphicPutByIdList.h"
 #include "ReduceWhitespace.h"
 #include "RepatchBuffer.h"
 #include "SlotVisitorInlines.h"
@@ -2109,10 +2110,17 @@
     // and when it runs, it figures out whether it has any work to do.
     visitor.addUnconditionalFinalizer(this);
     
+    // There are two things that we use weak reference harvesters for: DFG fixpoint for
+    // jettisoning, and trying to find structures that would be live based on some
+    // inline cache. So it makes sense to register them regardless.
+    visitor.addWeakReferenceHarvester(this);
+    m_allTransitionsHaveBeenMarked = false;
+    
     if (shouldImmediatelyAssumeLivenessDuringScan()) {
         // This code block is live, so scan all references strongly and return.
         stronglyVisitStrongReferences(visitor);
         stronglyVisitWeakReferences(visitor);
+        propagateTransitions(visitor);
         return;
     }
     
@@ -2127,30 +2135,92 @@
     // decision by calling harvestWeakReferences().
     
     m_jitCode->dfgCommon()->livenessHasBeenProved = false;
-    m_jitCode->dfgCommon()->allTransitionsHaveBeenMarked = false;
     
-    performTracingFixpointIteration(visitor);
-
-    // GC doesn't have enough information yet for us to decide whether to keep our DFG
-    // data, so we need to register a handler to run again at the end of GC, when more
-    // information is available.
-    if (!(m_jitCode->dfgCommon()->livenessHasBeenProved && m_jitCode->dfgCommon()->allTransitionsHaveBeenMarked))
-        visitor.addWeakReferenceHarvester(this);
-    
+    propagateTransitions(visitor);
+    determineLiveness(visitor);
 #else // ENABLE(DFG_JIT)
     RELEASE_ASSERT_NOT_REACHED();
 #endif // ENABLE(DFG_JIT)
 }
 
-void CodeBlock::performTracingFixpointIteration(SlotVisitor& visitor)
+void CodeBlock::propagateTransitions(SlotVisitor& visitor)
 {
     UNUSED_PARAM(visitor);
+
+    if (m_allTransitionsHaveBeenMarked)
+        return;
+
+    bool allAreMarkedSoFar = true;
+        
+#if ENABLE(LLINT)
+    Interpreter* interpreter = m_vm->interpreter;
+    if (jitType() == JITCode::InterpreterThunk) {
+        const Vector<unsigned>& propertyAccessInstructions = m_unlinkedCode->propertyAccessInstructions();
+        for (size_t i = propertyAccessInstructions.size(); i--;) {
+            Instruction* instruction = &instructions()[propertyAccessInstructions[i]];
+            switch (interpreter->getOpcodeID(instruction[0].u.opcode)) {
+            case op_put_by_id_transition_direct:
+            case op_put_by_id_transition_normal:
+            case op_put_by_id_transition_direct_out_of_line:
+            case op_put_by_id_transition_normal_out_of_line: {
+                if (Heap::isMarked(instruction[4].u.structure.get()))
+                    visitor.append(&instruction[6].u.structure);
+                else
+                    allAreMarkedSoFar = false;
+                break;
+            }
+            default:
+                break;
+            }
+        }
+    }
+#endif // ENABLE(LLINT)
+
+#if ENABLE(JIT)
+    if (JITCode::isJIT(jitType())) {
+        for (unsigned i = m_structureStubInfos.size(); i--;) {
+            StructureStubInfo& stubInfo = m_structureStubInfos[i];
+            switch (stubInfo.accessType) {
+            case access_put_by_id_transition_normal:
+            case access_put_by_id_transition_direct: {
+                JSCell* origin = stubInfo.codeOrigin.codeOriginOwner();
+                if ((!origin || Heap::isMarked(origin))
+                    && Heap::isMarked(stubInfo.u.putByIdTransition.previousStructure.get()))
+                    visitor.append(&stubInfo.u.putByIdTransition.structure);
+                else
+                    allAreMarkedSoFar = false;
+                break;
+            }
+
+            case access_put_by_id_list: {
+                PolymorphicPutByIdList* list = stubInfo.u.putByIdList.list;
+                JSCell* origin = stubInfo.codeOrigin.codeOriginOwner();
+                if (origin && !Heap::isMarked(origin)) {
+                    allAreMarkedSoFar = false;
+                    break;
+                }
+                for (unsigned j = list->size(); j--;) {
+                    PutByIdAccess& access = list->m_list[j];
+                    if (!access.isTransition())
+                        continue;
+                    if (Heap::isMarked(access.oldStructure()))
+                        visitor.append(&access.m_newStructure);
+                    else
+                        allAreMarkedSoFar = false;
+                }
+                break;
+            }
+            
+            default:
+                break;
+            }
+        }
+    }
+#endif // ENABLE(JIT)
     
 #if ENABLE(DFG_JIT)
-    // Evaluate our weak reference transitions, if there are still some to evaluate.
-    DFG::CommonData* dfgCommon = m_jitCode->dfgCommon();
-    if (!dfgCommon->allTransitionsHaveBeenMarked) {
-        bool allAreMarkedSoFar = true;
+    if (JITCode::isOptimizingJIT(jitType())) {
+        DFG::CommonData* dfgCommon = m_jitCode->dfgCommon();
         for (unsigned i = 0; i < dfgCommon->transitions.size(); ++i) {
             if ((!dfgCommon->transitions[i].m_codeOrigin
                  || Heap::isMarked(dfgCommon->transitions[i].m_codeOrigin.get()))
@@ -2170,12 +2240,23 @@
             } else
                 allAreMarkedSoFar = false;
         }
-        
-        if (allAreMarkedSoFar)
-            dfgCommon->allTransitionsHaveBeenMarked = true;
     }
+#endif // ENABLE(DFG_JIT)
     
+    if (allAreMarkedSoFar)
+        m_allTransitionsHaveBeenMarked = true;
+}
+
+void CodeBlock::determineLiveness(SlotVisitor& visitor)
+{
+    UNUSED_PARAM(visitor);
+    
+    if (shouldImmediatelyAssumeLivenessDuringScan())
+        return;
+    
+#if ENABLE(DFG_JIT)
     // Check if we have any remaining work to do.
+    DFG::CommonData* dfgCommon = m_jitCode->dfgCommon();
     if (dfgCommon->livenessHasBeenProved)
         return;
     
@@ -2204,14 +2285,15 @@
 
 void CodeBlock::visitWeakReferences(SlotVisitor& visitor)
 {
-    performTracingFixpointIteration(visitor);
+    propagateTransitions(visitor);
+    determineLiveness(visitor);
 }
 
 void CodeBlock::finalizeUnconditionally()
 {
 #if ENABLE(LLINT)
     Interpreter* interpreter = m_vm->interpreter;
-    if (!!numberOfInstructions()) {
+    if (JITCode::couldBeInterpreted(jitType())) {
         const Vector<unsigned>& propertyAccessInstructions = m_unlinkedCode->propertyAccessInstructions();
         for (size_t size = propertyAccessInstructions.size(), i = 0; i < size; ++i) {
             Instruction* curInstruction = &instructions()[propertyAccessInstructions[i]];

Modified: trunk/Source/_javascript_Core/bytecode/CodeBlock.h (153205 => 153206)


--- trunk/Source/_javascript_Core/bytecode/CodeBlock.h	2013-07-25 04:01:54 UTC (rev 153205)
+++ trunk/Source/_javascript_Core/bytecode/CodeBlock.h	2013-07-25 04:01:56 UTC (rev 153206)
@@ -912,6 +912,7 @@
     ConcurrentJITLock m_lock;
     
     bool m_shouldAlwaysBeInlined;
+    bool m_allTransitionsHaveBeenMarked; // Initialized and used on every GC.
     
 protected:
 #if ENABLE(JIT)
@@ -1000,9 +1001,10 @@
 #else
     bool shouldImmediatelyAssumeLivenessDuringScan() { return true; }
 #endif
-
-    void performTracingFixpointIteration(SlotVisitor&);
-
+    
+    void propagateTransitions(SlotVisitor&);
+    void determineLiveness(SlotVisitor&);
+        
     void stronglyVisitStrongReferences(SlotVisitor&);
     void stronglyVisitWeakReferences(SlotVisitor&);
 

Modified: trunk/Source/_javascript_Core/bytecode/PolymorphicPutByIdList.h (153205 => 153206)


--- trunk/Source/_javascript_Core/bytecode/PolymorphicPutByIdList.h	2013-07-25 04:01:54 UTC (rev 153205)
+++ trunk/Source/_javascript_Core/bytecode/PolymorphicPutByIdList.h	2013-07-25 04:01:56 UTC (rev 153206)
@@ -39,6 +39,7 @@
 
 namespace JSC {
 
+class CodeBlock;
 struct StructureStubInfo;
 
 class PutByIdAccess {
@@ -132,6 +133,8 @@
     bool visitWeak() const;
     
 private:
+    friend class CodeBlock;
+    
     AccessType m_type;
     WriteBarrier<Structure> m_oldStructure;
     WriteBarrier<Structure> m_newStructure;
@@ -178,6 +181,8 @@
     bool visitWeak() const;
     
 private:
+    friend class CodeBlock;
+    
     Vector<PutByIdAccess, 2> m_list;
     PutKind m_kind;
 };

Modified: trunk/Source/_javascript_Core/bytecode/StructureStubInfo.h (153205 => 153206)


--- trunk/Source/_javascript_Core/bytecode/StructureStubInfo.h	2013-07-25 04:01:54 UTC (rev 153205)
+++ trunk/Source/_javascript_Core/bytecode/StructureStubInfo.h	2013-07-25 04:01:56 UTC (rev 153206)
@@ -197,7 +197,7 @@
         return WatchpointsOnStructureStubInfo::ensureReferenceAndAddWatchpoint(
             watchpoints, codeBlock, this);
     }
-        
+    
     int8_t accessType;
     bool seen : 1;
     bool resetByGC : 1;

Modified: trunk/Source/_javascript_Core/jit/JITCode.h (153205 => 153206)


--- trunk/Source/_javascript_Core/jit/JITCode.h	2013-07-25 04:01:54 UTC (rev 153205)
+++ trunk/Source/_javascript_Core/jit/JITCode.h	2013-07-25 04:01:56 UTC (rev 153206)
@@ -79,6 +79,17 @@
         }
     }
     
+    static bool couldBeInterpreted(JITType jitType)
+    {
+        switch (jitType) {
+        case InterpreterThunk:
+        case BaselineJIT:
+            return true;
+        default:
+            return false;
+        }
+    }
+    
     static bool isJIT(JITType jitType)
     {
         switch (jitType) {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to