JSC should have more logging in structure-related code
authorfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 19 Nov 2012 02:55:14 +0000 (02:55 +0000)
committerfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 19 Nov 2012 02:55:14 +0000 (02:55 +0000)
https://bugs.webkit.org/show_bug.cgi?id=102630

Reviewed by Simon Fraser.

- JSValue::description() now tells you if something is a structure, and if so,
  what kind of structure it is.

- Jettisoning logic now tells you why things are being jettisoned.

- It's now possible to turn off GC-triggered jettisoning entirely.

* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::finalizeUnconditionally):
(JSC::CodeBlock::reoptimize):
(JSC::ProgramCodeBlock::jettison):
(JSC::EvalCodeBlock::jettison):
(JSC::FunctionCodeBlock::jettison):
* bytecode/CodeBlock.h:
(JSC::CodeBlock::shouldImmediatelyAssumeLivenessDuringScan):
* runtime/JSValue.cpp:
(JSC::JSValue::description):
* runtime/Options.h:
(JSC):

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

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/bytecode/CodeBlock.cpp
Source/JavaScriptCore/bytecode/CodeBlock.h
Source/JavaScriptCore/runtime/JSValue.cpp
Source/JavaScriptCore/runtime/Options.h

index f63cd9f..e9d2ada 100644 (file)
@@ -1,5 +1,32 @@
 2012-11-18  Filip Pizlo  <fpizlo@apple.com>
 
+        JSC should have more logging in structure-related code
+        https://bugs.webkit.org/show_bug.cgi?id=102630
+
+        Reviewed by Simon Fraser.
+
+        - JSValue::description() now tells you if something is a structure, and if so,
+          what kind of structure it is.
+        
+        - Jettisoning logic now tells you why things are being jettisoned.
+        
+        - It's now possible to turn off GC-triggered jettisoning entirely.
+
+        * bytecode/CodeBlock.cpp:
+        (JSC::CodeBlock::finalizeUnconditionally):
+        (JSC::CodeBlock::reoptimize):
+        (JSC::ProgramCodeBlock::jettison):
+        (JSC::EvalCodeBlock::jettison):
+        (JSC::FunctionCodeBlock::jettison):
+        * bytecode/CodeBlock.h:
+        (JSC::CodeBlock::shouldImmediatelyAssumeLivenessDuringScan):
+        * runtime/JSValue.cpp:
+        (JSC::JSValue::description):
+        * runtime/Options.h:
+        (JSC):
+
+2012-11-18  Filip Pizlo  <fpizlo@apple.com>
+
         DFG constant folding phase should say 'changed = true' whenever it changes the graph
         https://bugs.webkit.org/show_bug.cgi?id=102550
 
index 8f7c183..49cd5e9 100644 (file)
@@ -32,6 +32,7 @@
 
 #include "BytecodeGenerator.h"
 #include "DFGCapabilities.h"
+#include "DFGCommon.h"
 #include "DFGNode.h"
 #include "DFGRepatch.h"
 #include "Debugger.h"
@@ -2193,6 +2194,27 @@ void CodeBlock::finalizeUnconditionally()
         // optimizing.
         alternative()->optimizeAfterWarmUp();
         
+        if (DFG::shouldShowDisassembly()) {
+            dataLog("DFG CodeBlock %p will be jettisoned because of the following dead references:\n", this);
+            for (unsigned i = 0; i < m_dfgData->transitions.size(); ++i) {
+                WeakReferenceTransition& transition = m_dfgData->transitions[i];
+                JSCell* origin = transition.m_codeOrigin.get();
+                JSCell* from = transition.m_from.get();
+                JSCell* to = transition.m_to.get();
+                if ((!origin || Heap::isMarked(origin)) && Heap::isMarked(from))
+                    continue;
+                dataLog("    Transition under %s, ", JSValue(origin).description());
+                dataLog("%s -> ", JSValue(from).description());
+                dataLog("%s.\n", JSValue(to).description());
+            }
+            for (unsigned i = 0; i < m_dfgData->weakReferences.size(); ++i) {
+                JSCell* weak = m_dfgData->weakReferences[i].get();
+                if (Heap::isMarked(weak))
+                    continue;
+                dataLog("    Weak reference %s.\n", JSValue(weak).description());
+            }
+        }
+        
         jettison();
         return;
     }
@@ -2668,6 +2690,8 @@ void CodeBlock::reoptimize()
     ASSERT(replacement() != this);
     ASSERT(replacement()->alternative() == this);
     replacement()->tallyFrequentExitSites();
+    if (DFG::shouldShowDisassembly())
+        dataLog("DFG CodeBlock %p will be jettisoned due to reoptimization of %p.\n", replacement(), this);
     replacement()->jettison();
     countReoptimization();
     optimizeAfterWarmUp();
@@ -2733,6 +2757,8 @@ void ProgramCodeBlock::jettison()
 {
     ASSERT(JITCode::isOptimizingJIT(getJITType()));
     ASSERT(this == replacement());
+    if (DFG::shouldShowDisassembly())
+        dataLog("Jettisoning DFG CodeBlock %p.\n", this);
     static_cast<ProgramExecutable*>(ownerExecutable())->jettisonOptimizedCode(*globalData());
 }
 
@@ -2740,6 +2766,8 @@ void EvalCodeBlock::jettison()
 {
     ASSERT(JITCode::isOptimizingJIT(getJITType()));
     ASSERT(this == replacement());
+    if (DFG::shouldShowDisassembly())
+        dataLog("Jettisoning DFG CodeBlock %p.\n", this);
     static_cast<EvalExecutable*>(ownerExecutable())->jettisonOptimizedCode(*globalData());
 }
 
@@ -2747,6 +2775,8 @@ void FunctionCodeBlock::jettison()
 {
     ASSERT(JITCode::isOptimizingJIT(getJITType()));
     ASSERT(this == replacement());
+    if (DFG::shouldShowDisassembly())
+        dataLog("Jettisoning DFG CodeBlock %p.\n", this);
     static_cast<FunctionExecutable*>(ownerExecutable())->jettisonOptimizedCodeFor(*globalData(), m_isConstructor ? CodeForConstruct : CodeForCall);
 }
 
index 0199935..c841ec3 100644 (file)
@@ -1239,6 +1239,9 @@ namespace JSC {
             // allow them to continue to execute soundly.
             if (m_dfgData->mayBeExecuting)
                 return true;
+            
+            if (Options::forceDFGCodeBlockLiveness())
+                return true;
 
             return false;
         }
index 8f245f9..d925373 100644 (file)
@@ -214,10 +214,18 @@ char* JSValue::description() const
         snprintf(description, size, "Double: %08x:%08x, %lf", u.asTwoInt32s[1], u.asTwoInt32s[0], asDouble());
 #endif
     } else if (isCell()) {
-        snprintf(
-            description, size, "Cell: %p -> %p (%p: %s, %s)",
-            asCell(), isObject() ? asObject(*this)->butterfly() : 0, asCell()->structure(), asCell()->structure()->classInfo()->className,
-            indexingTypeToString(asCell()->structure()->indexingTypeIncludingHistory()));
+        if (asCell()->inherits(&Structure::s_info)) {
+            Structure* structure = jsCast<Structure*>(asCell());
+            snprintf(
+                description, size, "Structure: %p: %s, %s",
+                structure, structure->classInfo()->className,
+                indexingTypeToString(structure->indexingTypeIncludingHistory()));
+        } else {
+            snprintf(
+                description, size, "Cell: %p -> %p (%p: %s, %s)",
+                asCell(), isObject() ? asObject(*this)->butterfly() : 0, asCell()->structure(), asCell()->structure()->classInfo()->className,
+                indexingTypeToString(asCell()->structure()->indexingTypeIncludingHistory()));
+        }
     } else if (isTrue())
         snprintf(description, size, "True");
     else if (isFalse())
index d6d8c66..99a5f85 100644 (file)
@@ -66,6 +66,8 @@ namespace JSC {
     v(bool, useDFGJIT, true) \
     v(bool, useRegExpJIT, true) \
     \
+    v(bool, forceDFGCodeBlockLiveness, false) \
+    \
     /* showDisassembly implies showDFGDisassembly. */ \
     v(bool, showDisassembly, false) \
     v(bool, showDFGDisassembly, false) \