fourthTier: Structure should have a dump()
authoroliver@apple.com <oliver@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 25 Jul 2013 04:03:25 +0000 (04:03 +0000)
committeroliver@apple.com <oliver@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 25 Jul 2013 04:03:25 +0000 (04:03 +0000)
https://bugs.webkit.org/show_bug.cgi?id=117859

Reviewed by Geoffrey Garen.

This is pretty cool. Anywhere we previously printed Structure pointers in dumps,
we now print a bunch of other info as well. For example, for an object literal
like "{f:42, g:64, h:24}", when we print the structure we'll now get:

    0x107a0af80:[Object, {f:0, g:1, h:2}, NonArray, Proto:0x107a8fff0]

This also changes a bunch of places to use the dump method.

* bytecode/StructureSet.h:
(JSC::StructureSet::dump):
* dfg/DFGGraph.cpp:
(JSC::DFG::Graph::dump):
* dfg/DFGStructureAbstractValue.h:
(JSC::DFG::StructureAbstractValue::dump):
* runtime/JSCJSValue.cpp:
(JSC::JSValue::dump):
* runtime/Structure.cpp:
(JSC::Structure::dump):
(JSC):
* runtime/Structure.h:
(Structure):

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

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/bytecode/StructureSet.h
Source/JavaScriptCore/dfg/DFGGraph.cpp
Source/JavaScriptCore/dfg/DFGStructureAbstractValue.h
Source/JavaScriptCore/runtime/JSCJSValue.cpp
Source/JavaScriptCore/runtime/Structure.cpp
Source/JavaScriptCore/runtime/Structure.h

index e524464..2b3ee54 100644 (file)
@@ -1,5 +1,34 @@
 2013-06-20  Filip Pizlo  <fpizlo@apple.com>
 
+        fourthTier: Structure should have a dump()
+        https://bugs.webkit.org/show_bug.cgi?id=117859
+
+        Reviewed by Geoffrey Garen.
+        
+        This is pretty cool. Anywhere we previously printed Structure pointers in dumps,
+        we now print a bunch of other info as well. For example, for an object literal
+        like "{f:42, g:64, h:24}", when we print the structure we'll now get:
+
+            0x107a0af80:[Object, {f:0, g:1, h:2}, NonArray, Proto:0x107a8fff0]
+        
+        This also changes a bunch of places to use the dump method.
+
+        * bytecode/StructureSet.h:
+        (JSC::StructureSet::dump):
+        * dfg/DFGGraph.cpp:
+        (JSC::DFG::Graph::dump):
+        * dfg/DFGStructureAbstractValue.h:
+        (JSC::DFG::StructureAbstractValue::dump):
+        * runtime/JSCJSValue.cpp:
+        (JSC::JSValue::dump):
+        * runtime/Structure.cpp:
+        (JSC::Structure::dump):
+        (JSC):
+        * runtime/Structure.h:
+        (Structure):
+
+2013-06-20  Filip Pizlo  <fpizlo@apple.com>
+
         fourthTier: There should only be one table of SimpleJumpTables
         https://bugs.webkit.org/show_bug.cgi?id=117856
 
index 73ac2f4..35f87bd 100644 (file)
@@ -167,7 +167,7 @@ public:
         CommaPrinter comma;
         out.print("[");
         for (size_t i = 0; i < m_structures.size(); ++i)
-            out.print(comma, RawPointer(m_structures[i]));
+            out.print(comma, *m_structures[i]);
         out.print("]");
     }
     
index 18e987c..ac28baa 100644 (file)
@@ -187,14 +187,12 @@ void Graph::dump(PrintStream& out, const char* prefix, Node* node)
         out.print(comma, "global", globalObjectFor(node->codeOrigin)->findRegisterIndex(node->registerPointer()), "(", RawPointer(node->registerPointer()), ")");
     if (node->hasIdentifier())
         out.print(comma, "id", node->identifierNumber(), "{", identifiers()[node->identifierNumber()], "}");
-    if (node->hasStructureSet()) {
-        for (size_t i = 0; i < node->structureSet().size(); ++i)
-            out.print(comma, "struct(", RawPointer(node->structureSet()[i]), ": ", IndexingTypeDump(node->structureSet()[i]->indexingType()), ")");
-    }
+    if (node->hasStructureSet())
+        out.print(comma, node->structureSet());
     if (node->hasStructure())
-        out.print(comma, "struct(", RawPointer(node->structure()), ": ", IndexingTypeDump(node->structure()->indexingType()), ")");
+        out.print(comma, *node->structure());
     if (node->hasStructureTransitionData())
-        out.print(comma, "struct(", RawPointer(node->structureTransitionData().previousStructure), " -> ", RawPointer(node->structureTransitionData().newStructure), ")");
+        out.print(comma, *node->structureTransitionData().previousStructure, " -> ", *node->structureTransitionData().newStructure);
     if (node->hasFunction()) {
         out.print(comma, "function(", RawPointer(node->function()), ", ");
         if (node->function()->inherits(&JSFunction::s_info)) {
@@ -253,7 +251,7 @@ void Graph::dump(PrintStream& out, const char* prefix, Node* node)
         out.print(" = ", value);
     }
     if (op == WeakJSConstant)
-        out.print(comma, RawPointer(node->weakConstant()), " (structure: ", RawPointer(node->weakConstant()->structure()), ")");
+        out.print(comma, RawPointer(node->weakConstant()), " (structure: ", *node->weakConstant()->structure(), ")");
     if (node->isBranch() || node->isJump())
         out.print(comma, "T:#", node->takenBlockIndex());
     if (node->isBranch())
index fb5dfda..0a60e6b 100644 (file)
@@ -307,7 +307,7 @@ public:
         
         out.print("[");
         if (m_structure)
-            out.print(RawPointer(m_structure), "(", m_structure->classInfo()->className, ")");
+            out.print(*m_structure);
         out.print("]");
     }
 
index f47ea9c..644a4f1 100644 (file)
@@ -216,18 +216,13 @@ void JSValue::dump(PrintStream& out) const
             } else
                 out.print(" (unresolved)");
             out.print(": ", impl);
-        } else if (asCell()->inherits(&Structure::s_info)) {
-            Structure* structure = jsCast<Structure*>(asCell());
-            out.print(
-                "Structure: ", RawPointer(structure), ": ", structure->classInfo()->className,
-                ", ", IndexingTypeDump(structure->indexingTypeIncludingHistory()));
-        } else {
+        } else if (asCell()->inherits(&Structure::s_info))
+            out.print("Structure: ", *jsCast<Structure*>(asCell()));
+        else {
             out.print("Cell: ", RawPointer(asCell()));
             if (isObject() && asObject(*this)->butterfly())
                 out.print("->", RawPointer(asObject(*this)->butterfly()));
-            out.print(
-                " (", RawPointer(asCell()->structure()), ": ", asCell()->structure()->classInfo()->className,
-                ", ", IndexingTypeDump(asCell()->structure()->indexingTypeIncludingHistory()), ")");
+            out.print(" (", *asCell()->structure(), ")");
         }
     } else if (isTrue())
         out.print("True");
index 8c49a26..d086019 100644 (file)
@@ -996,6 +996,43 @@ bool Structure::prototypeChainMayInterceptStoreTo(VM& vm, PropertyName propertyN
     }
 }
 
+void Structure::dump(PrintStream& out) const
+{
+    out.print(RawPointer(this), ":[", classInfo()->className, ", {");
+    
+    Vector<Structure*, 8> structures;
+    Structure* structure;
+    PropertyTable* table;
+    
+    const_cast<Structure*>(this)->findStructuresAndMapForMaterialization(
+        structures, structure, table);
+    
+    CommaPrinter comma;
+    
+    if (table) {
+        PropertyTable::iterator iter = table->begin();
+        PropertyTable::iterator end = table->end();
+        for (; iter != end; ++iter)
+            out.print(comma, iter->key, ":", static_cast<int>(iter->offset));
+        
+        structure->m_lock.unlock();
+    }
+    
+    for (unsigned i = structures.size(); i--;) {
+        Structure* structure = structures[i];
+        if (!structure->m_nameInPrevious)
+            continue;
+        out.print(comma, structure->m_nameInPrevious.get(), ":", static_cast<int>(structure->m_offset));
+    }
+    
+    out.print("}, ", IndexingTypeDump(indexingType()));
+    
+    if (m_prototype.get().isCell())
+        out.print(", Proto:", RawPointer(m_prototype.get().asCell()));
+    
+    out.print("]");
+}
+
 #if DO_PROPERTYMAP_CONSTENCY_CHECK
 
 void PropertyTable::checkConsistency()
index d4e347e..03170f7 100644 (file)
@@ -43,6 +43,7 @@
 #include "Weak.h"
 #include <wtf/CompilationThread.h>
 #include <wtf/PassRefPtr.h>
+#include <wtf/PrintStream.h>
 #include <wtf/RefCounted.h>
 #include <wtf/text/StringImpl.h>
 
@@ -355,7 +356,9 @@ public:
     {
         return m_transitionWatchpointSet;
     }
-        
+    
+    void dump(PrintStream&) const;
+    
     static JS_EXPORTDATA const ClassInfo s_info;
 
 private: