Structure should be able to tell you if it had ever been a dictionary
authorfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Sep 2015 23:07:08 +0000 (23:07 +0000)
committerfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Sep 2015 23:07:08 +0000 (23:07 +0000)
https://bugs.webkit.org/show_bug.cgi?id=149047

Reviewed by Mark Lam.

Introduces the hasBeenDictionary flag to Structure, which tells you if this structure or
any of its ancestors is a dictionary. We already implicitly tracked this for DFG
watchpoint optimizations, so this is mainly just decoupling that existing logic from
watchpoints. Having Structure::hasBeenDictionary() enables some of the heuristics in the
property type inference work (https://bugs.webkit.org/show_bug.cgi?id=148610).

* runtime/Structure.cpp:
(JSC::Structure::Structure):
(JSC::Structure::toDictionaryTransition):
(JSC::Structure::dump):
* runtime/Structure.h:

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

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/Structure.cpp
Source/JavaScriptCore/runtime/Structure.h

index 0e47f1e..ec8bef5 100644 (file)
@@ -1,3 +1,22 @@
+2015-09-10  Filip Pizlo  <fpizlo@apple.com>
+
+        Structure should be able to tell you if it had ever been a dictionary
+        https://bugs.webkit.org/show_bug.cgi?id=149047
+
+        Reviewed by Mark Lam.
+
+        Introduces the hasBeenDictionary flag to Structure, which tells you if this structure or
+        any of its ancestors is a dictionary. We already implicitly tracked this for DFG
+        watchpoint optimizations, so this is mainly just decoupling that existing logic from
+        watchpoints. Having Structure::hasBeenDictionary() enables some of the heuristics in the
+        property type inference work (https://bugs.webkit.org/show_bug.cgi?id=148610).
+
+        * runtime/Structure.cpp:
+        (JSC::Structure::Structure):
+        (JSC::Structure::toDictionaryTransition):
+        (JSC::Structure::dump):
+        * runtime/Structure.h:
+
 2015-09-10  Yusuke Suzuki  <utatane.tea@gmail.com>
 
         Unreviewed, fix Windows file loading in JSC shell after r189583
index 28f8d48..cc24b00 100644 (file)
@@ -208,6 +208,7 @@ Structure::Structure(VM& vm, JSGlobalObject* globalObject, JSValue prototype, co
     setStaticFunctionsReified(false);
     setHasRareData(false);
     setTransitionWatchpointIsLikelyToBeFired(false);
+    setHasBeenDictionary(false);
  
     ASSERT(inlineCapacity <= JSFinalObject::maxInlineCapacity());
     ASSERT(static_cast<PropertyOffset>(inlineCapacity) < firstOutOfLineOffset);
@@ -239,6 +240,7 @@ Structure::Structure(VM& vm)
     setStaticFunctionsReified(false);
     setHasRareData(false);
     setTransitionWatchpointIsLikelyToBeFired(false);
+    setHasBeenDictionary(false);
  
     TypeInfo typeInfo = TypeInfo(CellType, StructureFlags);
     m_blob = StructureIDBlob(vm.heap.structureIDTable().allocateID(this), 0, typeInfo);
@@ -268,6 +270,7 @@ Structure::Structure(VM& vm, Structure* previous, DeferredStructureTransitionWat
     setDidTransition(true);
     setStaticFunctionsReified(previous->staticFunctionsReified());
     setHasRareData(false);
+    setHasBeenDictionary(previous->hasBeenDictionary());
  
     TypeInfo typeInfo = previous->typeInfo();
     m_blob = StructureIDBlob(vm.heap.structureIDTable().allocateID(this), previous->indexingTypeIncludingHistory(), typeInfo);
@@ -537,7 +540,7 @@ Structure* Structure::toDictionaryTransition(VM& vm, Structure* structure, Dicti
     transition->m_offset = structure->m_offset;
     transition->setDictionaryKind(kind);
     transition->pin();
-    transition->setTransitionWatchpointIsLikelyToBeFired(true);
+    transition->setHasBeenDictionary(true);
 
     transition->checkOffsetConsistency();
     return transition;
@@ -1156,6 +1159,8 @@ void Structure::dump(PrintStream& out) const
 
     switch (dictionaryKind()) {
     case NoneDictionaryKind:
+        if (hasBeenDictionary())
+            out.print(", Has been dictionary");
         break;
     case CachedDictionaryKind:
         out.print(", Dictionary");
@@ -1164,6 +1169,11 @@ void Structure::dump(PrintStream& out) const
         out.print(", UncacheableDictionary");
         break;
     }
+
+    if (transitionWatchpointSetIsStillValid())
+        out.print(", Leaf");
+    else if (transitionWatchpointIsLikelyToBeFired())
+        out.print(", Shady leaf");
     
     out.print("]");
 }
index 9ba19a6..86c3413 100644 (file)
@@ -429,9 +429,13 @@ public:
         
         // - We don't watch Structures that either decided not to be watched, or whose predecessors
         //   decided not to be watched. This happens either when a transition is fired while being
-        //   watched, or if a dictionary transition occurs.
+        //   watched.
         if (transitionWatchpointIsLikelyToBeFired())
             return false;
+
+        // - Don't watch Structures that had been dictionaries.
+        if (hasBeenDictionary())
+            return false;
         
         return true;
     }
@@ -523,6 +527,7 @@ public:
     DEFINE_BITFIELD(bool, hasCustomGetterSetterProperties, HasCustomGetterSetterProperties, 1, 25);
     DEFINE_BITFIELD(bool, didWatchInternalProperties, DidWatchInternalProperties, 1, 26);
     DEFINE_BITFIELD(bool, transitionWatchpointIsLikelyToBeFired, TransitionWatchpointIsLikelyToBeFired, 1, 27);
+    DEFINE_BITFIELD(bool, hasBeenDictionary, HasBeenDictionary, 1, 28);
 
 private:
     friend class LLIntOffsetsExtractor;