Title: [138276] trunk
Revision
138276
Author
[email protected]
Date
2012-12-20 11:14:39 -0800 (Thu, 20 Dec 2012)

Log Message

DFG speculation checks that take JumpList should consolidate OSRExits
https://bugs.webkit.org/show_bug.cgi?id=105401

Reviewed by Oliver Hunt.

Source/_javascript_Core: 

Change OSRExitCompilationInfo to always contain a JumpList, and change JumpList
to be more compact. This way, a speculationCheck that takes a JumpList only has
to emit one OSRExit structure, and one OSRExit landing pad.
        
The downside is that we get less precise information about *where* we exited
from. So, this also includes changes to the profiler to be more relaxed about
what an ExitSite is.

* assembler/AbstractMacroAssembler.h:
(JumpList):
* dfg/DFGJITCompiler.cpp:
(JSC::DFG::JITCompiler::linkOSRExits):
(JSC::DFG::JITCompiler::link):
* dfg/DFGJITCompiler.h:
(DFG):
(JSC::DFG::JITCompiler::appendExitInfo):
(JITCompiler):
* dfg/DFGOSRExitCompilationInfo.h:
(OSRExitCompilationInfo):
* dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::speculationCheck):
(JSC::DFG::SpeculativeJIT::speculationWatchpoint):
(JSC::DFG::SpeculativeJIT::forwardSpeculationCheck):
* profiler/ProfilerCompilation.cpp:
(JSC::Profiler::Compilation::addOSRExitSite):
* profiler/ProfilerCompilation.h:
(Compilation):
* profiler/ProfilerOSRExitSite.cpp:
(JSC::Profiler::OSRExitSite::toJS):
* profiler/ProfilerOSRExitSite.h:
(JSC::Profiler::OSRExitSite::OSRExitSite):
(JSC::Profiler::OSRExitSite::codeAddress):
(OSRExitSite):

Tools: 

Update the profiler to understand that an OSR exit may have multiple
candidate exit sites.

* Scripts/display-profiler-output:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (138275 => 138276)


--- trunk/Source/_javascript_Core/ChangeLog	2012-12-20 19:00:08 UTC (rev 138275)
+++ trunk/Source/_javascript_Core/ChangeLog	2012-12-20 19:14:39 UTC (rev 138276)
@@ -1,3 +1,44 @@
+2012-12-19  Filip Pizlo  <[email protected]>
+
+        DFG speculation checks that take JumpList should consolidate OSRExits
+        https://bugs.webkit.org/show_bug.cgi?id=105401
+
+        Reviewed by Oliver Hunt.
+
+        Change OSRExitCompilationInfo to always contain a JumpList, and change JumpList
+        to be more compact. This way, a speculationCheck that takes a JumpList only has
+        to emit one OSRExit structure, and one OSRExit landing pad.
+        
+        The downside is that we get less precise information about *where* we exited
+        from. So, this also includes changes to the profiler to be more relaxed about
+        what an ExitSite is.
+
+        * assembler/AbstractMacroAssembler.h:
+        (JumpList):
+        * dfg/DFGJITCompiler.cpp:
+        (JSC::DFG::JITCompiler::linkOSRExits):
+        (JSC::DFG::JITCompiler::link):
+        * dfg/DFGJITCompiler.h:
+        (DFG):
+        (JSC::DFG::JITCompiler::appendExitInfo):
+        (JITCompiler):
+        * dfg/DFGOSRExitCompilationInfo.h:
+        (OSRExitCompilationInfo):
+        * dfg/DFGSpeculativeJIT.cpp:
+        (JSC::DFG::SpeculativeJIT::speculationCheck):
+        (JSC::DFG::SpeculativeJIT::speculationWatchpoint):
+        (JSC::DFG::SpeculativeJIT::forwardSpeculationCheck):
+        * profiler/ProfilerCompilation.cpp:
+        (JSC::Profiler::Compilation::addOSRExitSite):
+        * profiler/ProfilerCompilation.h:
+        (Compilation):
+        * profiler/ProfilerOSRExitSite.cpp:
+        (JSC::Profiler::OSRExitSite::toJS):
+        * profiler/ProfilerOSRExitSite.h:
+        (JSC::Profiler::OSRExitSite::OSRExitSite):
+        (JSC::Profiler::OSRExitSite::codeAddress):
+        (OSRExitSite):
+
 2012-12-19  Oliver Hunt  <[email protected]>
 
         Fix some incorrect tests in testapi.c

Modified: trunk/Source/_javascript_Core/assembler/AbstractMacroAssembler.h (138275 => 138276)


--- trunk/Source/_javascript_Core/assembler/AbstractMacroAssembler.h	2012-12-20 19:00:08 UTC (rev 138275)
+++ trunk/Source/_javascript_Core/assembler/AbstractMacroAssembler.h	2012-12-20 19:14:39 UTC (rev 138276)
@@ -592,7 +592,7 @@
         friend class LinkBuffer;
 
     public:
-        typedef Vector<Jump, 16> JumpVector;
+        typedef Vector<Jump, 2> JumpVector;
         
         JumpList() { }
         

Modified: trunk/Source/_javascript_Core/dfg/DFGJITCompiler.cpp (138275 => 138276)


--- trunk/Source/_javascript_Core/dfg/DFGJITCompiler.cpp	2012-12-20 19:00:08 UTC (rev 138275)
+++ trunk/Source/_javascript_Core/dfg/DFGJITCompiler.cpp	2012-12-20 19:14:39 UTC (rev 138276)
@@ -55,19 +55,23 @@
     if (m_graph.m_compilation) {
         for (unsigned i = 0; i < codeBlock()->numberOfOSRExits(); ++i) {
             OSRExit& exit = codeBlock()->osrExit(i);
-            if (exit.m_watchpointIndex == std::numeric_limits<unsigned>::max())
-                m_exitSiteLabels.append(m_exitCompilationInfo[i].failureJump().label());
-            else
-                m_exitSiteLabels.append(codeBlock()->watchpoint(exit.m_watchpointIndex).sourceLabel());
+            Vector<Label> labels;
+            if (exit.m_watchpointIndex == std::numeric_limits<unsigned>::max()) {
+                OSRExitCompilationInfo& info = m_exitCompilationInfo[i];
+                for (unsigned j = 0; j < info.m_failureJumps.jumps().size(); ++j)
+                    labels.append(info.m_failureJumps.jumps()[j].label());
+            } else
+                labels.append(codeBlock()->watchpoint(exit.m_watchpointIndex).sourceLabel());
+            m_exitSiteLabels.append(labels);
         }
     }
     
     for (unsigned i = 0; i < codeBlock()->numberOfOSRExits(); ++i) {
         OSRExit& exit = codeBlock()->osrExit(i);
-        Jump& failureJump = m_exitCompilationInfo[i].failureJump();
-        ASSERT(!failureJump.isSet() == (exit.m_watchpointIndex != std::numeric_limits<unsigned>::max()));
+        JumpList& failureJumps = m_exitCompilationInfo[i].m_failureJumps;
+        ASSERT(failureJumps.empty() == (exit.m_watchpointIndex != std::numeric_limits<unsigned>::max()));
         if (exit.m_watchpointIndex == std::numeric_limits<unsigned>::max())
-            failureJump.link(this);
+            failureJumps.link(this);
         else
             codeBlock()->watchpoint(exit.m_watchpointIndex).setDestination(label());
         jitAssertHasValidCallFrame();
@@ -221,8 +225,11 @@
     if (m_graph.m_compilation) {
         ASSERT(m_exitSiteLabels.size() == codeBlock()->numberOfOSRExits());
         for (unsigned i = 0; i < m_exitSiteLabels.size(); ++i) {
-            m_graph.m_compilation->addOSRExitSite(
-                linkBuffer.locationOf(m_exitSiteLabels[i]).executableAddress());
+            Vector<Label>& labels = m_exitSiteLabels[i];
+            Vector<const void*> addresses;
+            for (unsigned j = 0; j < labels.size(); ++j)
+                addresses.append(linkBuffer.locationOf(labels[j]).executableAddress());
+            m_graph.m_compilation->addOSRExitSite(addresses);
         }
     } else
         ASSERT(!m_exitSiteLabels.size());

Modified: trunk/Source/_javascript_Core/dfg/DFGJITCompiler.h (138275 => 138276)


--- trunk/Source/_javascript_Core/dfg/DFGJITCompiler.h	2012-12-20 19:00:08 UTC (rev 138275)
+++ trunk/Source/_javascript_Core/dfg/DFGJITCompiler.h	2012-12-20 19:14:39 UTC (rev 138276)
@@ -51,6 +51,7 @@
 
 class JITCodeGenerator;
 class NodeToRegisterMap;
+class OSRExitJumpPlaceholder;
 class SlowPathGenerator;
 class SpeculativeJIT;
 class SpeculationRecovery;
@@ -344,7 +345,12 @@
     SpeculatedType getSpeculation(NodeIndex nodeIndex) { return getSpeculation(graph()[nodeIndex]); }
     SpeculatedType getSpeculation(Edge nodeUse) { return getSpeculation(nodeUse.index()); }
 
-    void appendExitJump(MacroAssembler::Jump jumpToFail) { m_exitCompilationInfo.append(OSRExitCompilationInfo(jumpToFail)); }
+    void appendExitInfo(MacroAssembler::JumpList jumpsToFail = MacroAssembler::JumpList())
+    {
+        OSRExitCompilationInfo info;
+        info.m_failureJumps = jumpsToFail;
+        m_exitCompilationInfo.append(info);
+    }
 
 #if USE(JSVALUE32_64)
     void* addressOfDoubleConstant(NodeIndex nodeIndex)
@@ -423,6 +429,8 @@
     }
 
 private:
+    friend class OSRExitJumpPlaceholder;
+    
     // Internal implementation to compile.
     void compileEntry();
     void compileBody(SpeculativeJIT&);
@@ -464,7 +472,7 @@
     Vector<PropertyAccessRecord, 4> m_propertyAccesses;
     Vector<JSCallRecord, 4> m_jsCalls;
     Vector<OSRExitCompilationInfo> m_exitCompilationInfo;
-    Vector<Label> m_exitSiteLabels;
+    Vector<Vector<Label> > m_exitSiteLabels;
     unsigned m_currentCodeOriginIndex;
 };
 

Modified: trunk/Source/_javascript_Core/dfg/DFGOSRExitCompilationInfo.h (138275 => 138276)


--- trunk/Source/_javascript_Core/dfg/DFGOSRExitCompilationInfo.h	2012-12-20 19:00:08 UTC (rev 138275)
+++ trunk/Source/_javascript_Core/dfg/DFGOSRExitCompilationInfo.h	2012-12-20 19:14:39 UTC (rev 138276)
@@ -36,17 +36,8 @@
 
 namespace JSC { namespace DFG {
 
-class OSRExitCompilationInfo {
-public:
-    OSRExitCompilationInfo(MacroAssembler::Jump failureJump)
-        : m_failureJump(failureJump)
-    {
-    }
-
-    MacroAssembler::Jump& failureJump() { return m_failureJump; }
-
-private:
-    MacroAssembler::Jump m_failureJump;
+struct OSRExitCompilationInfo {
+    MacroAssembler::JumpList m_failureJumps;
 };
 
 } } // namespace JSC::DFG

Modified: trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp (138275 => 138276)


--- trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp	2012-12-20 19:00:08 UTC (rev 138275)
+++ trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp	2012-12-20 19:14:39 UTC (rev 138276)
@@ -109,7 +109,7 @@
     if (!m_compileOkay)
         return;
     ASSERT(at(m_compileIndex).canExit() || m_isCheckingArgumentTypes);
-    m_jit.appendExitJump(jumpToFail);
+    m_jit.appendExitInfo(jumpToFail);
     m_jit.codeBlock()->appendOSRExit(OSRExit(kind, jsValueSource, m_jit.graph().methodOfGettingAValueProfileFor(nodeIndex), this, m_stream->size()));
 }
 
@@ -121,10 +121,11 @@
 
 void SpeculativeJIT::speculationCheck(ExitKind kind, JSValueSource jsValueSource, NodeIndex nodeIndex, const MacroAssembler::JumpList& jumpsToFail)
 {
+    if (!m_compileOkay)
+        return;
     ASSERT(at(m_compileIndex).canExit() || m_isCheckingArgumentTypes);
-    Vector<MacroAssembler::Jump, 16> jumpVector = jumpsToFail.jumps();
-    for (unsigned i = 0; i < jumpVector.size(); ++i)
-        speculationCheck(kind, jsValueSource, nodeIndex, jumpVector[i]);
+    m_jit.appendExitInfo(jumpsToFail);
+    m_jit.codeBlock()->appendOSRExit(OSRExit(kind, jsValueSource, m_jit.graph().methodOfGettingAValueProfileFor(nodeIndex), this, m_stream->size()));
 }
 
 void SpeculativeJIT::speculationCheck(ExitKind kind, JSValueSource jsValueSource, Edge nodeUse, const MacroAssembler::JumpList& jumpsToFail)
@@ -139,7 +140,7 @@
         return;
     ASSERT(at(m_compileIndex).canExit() || m_isCheckingArgumentTypes);
     m_jit.codeBlock()->appendSpeculationRecovery(recovery);
-    m_jit.appendExitJump(jumpToFail);
+    m_jit.appendExitInfo(jumpToFail);
     m_jit.codeBlock()->appendOSRExit(OSRExit(kind, jsValueSource, m_jit.graph().methodOfGettingAValueProfileFor(nodeIndex), this, m_stream->size(), m_jit.codeBlock()->numberOfSpeculationRecoveries()));
 }
 
@@ -161,7 +162,7 @@
     if (!m_compileOkay)
         return 0;
     ASSERT(at(m_compileIndex).canExit() || m_isCheckingArgumentTypes);
-    m_jit.appendExitJump(JITCompiler::Jump());
+    m_jit.appendExitInfo(JITCompiler::JumpList());
     OSRExit& exit = m_jit.codeBlock()->osrExit(
         m_jit.codeBlock()->appendOSRExit(
             OSRExit(kind, jsValueSource,
@@ -270,9 +271,8 @@
 void SpeculativeJIT::forwardSpeculationCheck(ExitKind kind, JSValueSource jsValueSource, NodeIndex nodeIndex, const MacroAssembler::JumpList& jumpsToFail, const ValueRecovery& valueRecovery)
 {
     ASSERT(at(m_compileIndex).canExit() || m_isCheckingArgumentTypes);
-    Vector<MacroAssembler::Jump, 16> jumpVector = jumpsToFail.jumps();
-    for (unsigned i = 0; i < jumpVector.size(); ++i)
-        forwardSpeculationCheck(kind, jsValueSource, nodeIndex, jumpVector[i], valueRecovery);
+    speculationCheck(kind, jsValueSource, nodeIndex, jumpsToFail);
+    convertLastOSRExitToForward(valueRecovery);
 }
 
 void SpeculativeJIT::speculationCheck(ExitKind kind, JSValueSource jsValueSource, NodeIndex nodeIndex, MacroAssembler::Jump jumpToFail, SpeculationDirection direction)

Modified: trunk/Source/_javascript_Core/profiler/ProfilerCompilation.cpp (138275 => 138276)


--- trunk/Source/_javascript_Core/profiler/ProfilerCompilation.cpp	2012-12-20 19:00:08 UTC (rev 138275)
+++ trunk/Source/_javascript_Core/profiler/ProfilerCompilation.cpp	2012-12-20 19:14:39 UTC (rev 138276)
@@ -74,9 +74,9 @@
     return result;
 }
 
-void Compilation::addOSRExitSite(const void* codeAddress)
+void Compilation::addOSRExitSite(const Vector<const void*>& codeAddresses)
 {
-    m_osrExitSites.append(OSRExitSite(codeAddress));
+    m_osrExitSites.append(OSRExitSite(codeAddresses));
 }
 
 OSRExit* Compilation::addOSRExit(unsigned id, const OriginStack& originStack, ExitKind exitKind, bool isWatchpoint)

Modified: trunk/Source/_javascript_Core/profiler/ProfilerCompilation.h (138275 => 138276)


--- trunk/Source/_javascript_Core/profiler/ProfilerCompilation.h	2012-12-20 19:00:08 UTC (rev 138275)
+++ trunk/Source/_javascript_Core/profiler/ProfilerCompilation.h	2012-12-20 19:14:39 UTC (rev 138276)
@@ -60,7 +60,7 @@
     
     void addDescription(const CompiledBytecode&);
     ExecutionCounter* executionCounterFor(const OriginStack&);
-    void addOSRExitSite(const void* codeAddress);
+    void addOSRExitSite(const Vector<const void*>& codeAddresses);
     OSRExit* addOSRExit(unsigned id, const OriginStack&, ExitKind, bool isWatchpoint);
     
     JSValue toJS(ExecState*) const;

Modified: trunk/Source/_javascript_Core/profiler/ProfilerOSRExitSite.cpp (138275 => 138276)


--- trunk/Source/_javascript_Core/profiler/ProfilerOSRExitSite.cpp	2012-12-20 19:00:08 UTC (rev 138275)
+++ trunk/Source/_javascript_Core/profiler/ProfilerOSRExitSite.cpp	2012-12-20 19:14:39 UTC (rev 138276)
@@ -26,6 +26,7 @@
 #include "config.h"
 #include "ProfilerOSRExitSite.h"
 
+#include "JSGlobalObject.h"
 #include "JSScope.h"
 #include "JSString.h"
 #include <wtf/StringPrintStream.h>
@@ -34,7 +35,10 @@
 
 JSValue OSRExitSite::toJS(ExecState* exec) const
 {
-    return jsString(exec, toString(RawPointer(m_codeAddress)));
+    JSArray* result = constructEmptyArray(exec, 0);
+    for (unsigned i = 0; i < m_codeAddresses.size(); ++i)
+        result->putDirectIndex(exec, i, jsString(exec, toString(RawPointer(m_codeAddresses[i]))));
+    return result;
 }
 
 } } // namespace JSC::Profiler

Modified: trunk/Source/_javascript_Core/profiler/ProfilerOSRExitSite.h (138275 => 138276)


--- trunk/Source/_javascript_Core/profiler/ProfilerOSRExitSite.h	2012-12-20 19:00:08 UTC (rev 138275)
+++ trunk/Source/_javascript_Core/profiler/ProfilerOSRExitSite.h	2012-12-20 19:14:39 UTC (rev 138276)
@@ -27,22 +27,23 @@
 #define ProfilerOSRExitSite_h
 
 #include "JSValue.h"
+#include <wtf/Vector.h>
 
 namespace JSC { namespace Profiler {
 
 class OSRExitSite {
 public:
-    explicit OSRExitSite(const void* codeAddress)
-        : m_codeAddress(codeAddress)
+    explicit OSRExitSite(const Vector<const void*>& codeAddresses)
+        : m_codeAddresses(codeAddresses)
     {
     }
     
-    const void* codeAddress() const { return m_codeAddress; }
+    const Vector<const void*>& codeAddress() const { return m_codeAddresses; }
     
     JSValue toJS(ExecState*) const;
 
 private:
-    const void* m_codeAddress;
+    Vector<const void*> m_codeAddresses;
 };
 
 } } // namespace JSC::Profiler

Modified: trunk/Tools/ChangeLog (138275 => 138276)


--- trunk/Tools/ChangeLog	2012-12-20 19:00:08 UTC (rev 138275)
+++ trunk/Tools/ChangeLog	2012-12-20 19:14:39 UTC (rev 138276)
@@ -1,3 +1,15 @@
+2012-12-19  Filip Pizlo  <[email protected]>
+
+        DFG speculation checks that take JumpList should consolidate OSRExits
+        https://bugs.webkit.org/show_bug.cgi?id=105401
+
+        Reviewed by Oliver Hunt.
+
+        Update the profiler to understand that an OSR exit may have multiple
+        candidate exit sites.
+
+        * Scripts/display-profiler-output:
+
 2012-12-20  Eric Seidel  <[email protected]>
 
         EWSes do not need to dump build/test logs when things pass

Modified: trunk/Tools/Scripts/display-profiler-output (138275 => 138276)


--- trunk/Tools/Scripts/display-profiler-output	2012-12-20 19:00:08 UTC (rev 138275)
+++ trunk/Tools/Scripts/display-profiler-output	2012-12-20 19:14:39 UTC (rev 138276)
@@ -308,12 +308,12 @@
 end
 
 class OSRExit
-    attr_reader :compilation, :origin, :codeAddress, :exitKind, :isWatchpoint, :count
+    attr_reader :compilation, :origin, :codeAddresses, :exitKind, :isWatchpoint, :count
     
-    def initialize(compilation, origin, codeAddress, exitKind, isWatchpoint, count)
+    def initialize(compilation, origin, codeAddresses, exitKind, isWatchpoint, count)
         @compilation = compilation
         @origin = origin
-        @codeAddress = codeAddress
+        @codeAddresses = codeAddresses
         @exitKind = exitKind
         @isWatchpoint = isWatchpoint
         @count = count
@@ -358,10 +358,16 @@
         json["osrExits"].each {
             | subJson |
             osrExit = OSRExit.new(self, originStackFromJSON(subJson["origin"]),
-                                  json["osrExitSites"][subJson["id"]].hex, subJson["exitKind"],
-                                  subJson["isWatchpoint"], subJson["count"])
-            osrExits[osrExit.codeAddress] = [] unless osrExits[osrExit.codeAddress]
-            osrExits[osrExit.codeAddress] << osrExit
+                                  json["osrExitSites"][subJson["id"]].map {
+                                      | value |
+                                      value.hex
+                                  }, subJson["exitKind"], subJson["isWatchpoint"],
+                                  subJson["count"])
+            osrExit.codeAddresses.each {
+                | codeAddress |
+                osrExits[codeAddress] = [] unless osrExits[codeAddress]
+                osrExits[codeAddress] << osrExit
+            }
             osrExit.origin[-1].osrExits << osrExit
         }
         @profiledBytecodes = []
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to