Title: [201622] trunk/Source/_javascript_Core
Revision
201622
Author
[email protected]
Date
2016-06-02 15:18:27 -0700 (Thu, 02 Jun 2016)

Log Message

Teach bytecode liveness about the debugger
https://bugs.webkit.org/show_bug.cgi?id=158288

Reviewed by Filip Pizlo.

There was a bug where we wouldn't always keep the scope register
on the stack when the debugger is enabled. The debugger always assumes
it can read from the scope. The bug happened in OSR exit from the FTL.
The FTL uses bytecode liveness for OSR exit. Bytecode liveness proved
that the scope register was dead, so the FTL OSR exit wrote `undefined`
into the scope's stack slot when OSR exiting to the baseline.

To fix this, I taught bytecode liveness' computeUsesForBytecodeOffset() that the
scope is used by every instruction except op_enter. This causes the
scope to be live-in at every instruction except op_enter.

* bytecode/BytecodeLivenessAnalysis.cpp:
(JSC::blockContainsBytecodeOffset):
(JSC::addAlwaysLiveLocals):
(JSC::findBasicBlockForBytecodeOffset):
(JSC::stepOverInstruction):
(JSC::computeLocalLivenessForBytecodeOffset):
(JSC::BytecodeLivenessAnalysis::runLivenessFixpoint):
* bytecode/UnlinkedCodeBlock.cpp:
(JSC::UnlinkedCodeBlock::UnlinkedCodeBlock):
* tests/stress/shadow-chicken-reading-from-scope-after-ftl-osr-exit-bytecode-liveness.js: Added.
(foo):
(catch):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (201621 => 201622)


--- trunk/Source/_javascript_Core/ChangeLog	2016-06-02 22:15:08 UTC (rev 201621)
+++ trunk/Source/_javascript_Core/ChangeLog	2016-06-02 22:18:27 UTC (rev 201622)
@@ -1,3 +1,34 @@
+2016-06-02  Saam Barati  <[email protected]>
+
+        Teach bytecode liveness about the debugger
+        https://bugs.webkit.org/show_bug.cgi?id=158288
+
+        Reviewed by Filip Pizlo.
+
+        There was a bug where we wouldn't always keep the scope register
+        on the stack when the debugger is enabled. The debugger always assumes
+        it can read from the scope. The bug happened in OSR exit from the FTL.
+        The FTL uses bytecode liveness for OSR exit. Bytecode liveness proved
+        that the scope register was dead, so the FTL OSR exit wrote `undefined`
+        into the scope's stack slot when OSR exiting to the baseline.
+
+        To fix this, I taught bytecode liveness' computeUsesForBytecodeOffset() that the
+        scope is used by every instruction except op_enter. This causes the
+        scope to be live-in at every instruction except op_enter.
+
+        * bytecode/BytecodeLivenessAnalysis.cpp:
+        (JSC::blockContainsBytecodeOffset):
+        (JSC::addAlwaysLiveLocals):
+        (JSC::findBasicBlockForBytecodeOffset):
+        (JSC::stepOverInstruction):
+        (JSC::computeLocalLivenessForBytecodeOffset):
+        (JSC::BytecodeLivenessAnalysis::runLivenessFixpoint):
+        * bytecode/UnlinkedCodeBlock.cpp:
+        (JSC::UnlinkedCodeBlock::UnlinkedCodeBlock):
+        * tests/stress/shadow-chicken-reading-from-scope-after-ftl-osr-exit-bytecode-liveness.js: Added.
+        (foo):
+        (catch):
+
 2016-06-02  Michael Saboff  <[email protected]>
 
         REGRESSION(r200694): %ThrowTypeError% is not unique

Modified: trunk/Source/_javascript_Core/bytecode/BytecodeUseDef.h (201621 => 201622)


--- trunk/Source/_javascript_Core/bytecode/BytecodeUseDef.h	2016-06-02 22:15:08 UTC (rev 201621)
+++ trunk/Source/_javascript_Core/bytecode/BytecodeUseDef.h	2016-06-02 22:18:27 UTC (rev 201622)
@@ -38,6 +38,10 @@
     Instruction* instructionsBegin = codeBlock->instructions().begin();
     Instruction* instruction = &instructionsBegin[bytecodeOffset];
     OpcodeID opcodeID = interpreter->getOpcodeID(instruction->u.opcode);
+
+    if (opcodeID != op_enter && codeBlock->wasCompiledWithDebuggingOpcodes() && codeBlock->scopeRegister().isValid())
+        functor(codeBlock, instruction, opcodeID, codeBlock->scopeRegister().offset());
+
     switch (opcodeID) {
     // No uses.
     case op_new_regexp:

Modified: trunk/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.cpp (201621 => 201622)


--- trunk/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.cpp	2016-06-02 22:15:08 UTC (rev 201621)
+++ trunk/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.cpp	2016-06-02 22:18:27 UTC (rev 201622)
@@ -68,7 +68,7 @@
     , m_evalContextType(static_cast<unsigned>(info.evalContextType()))
     , m_isArrowFunctionContext(info.isArrowFunctionContext())
     , m_isClassContext(info.isClassContext())
-    , m_wasCompiledWithDebuggingOpcodes(debuggerMode == DebuggerMode::DebuggerOn)
+    , m_wasCompiledWithDebuggingOpcodes(debuggerMode == DebuggerMode::DebuggerOn || Options::forceDebuggerBytecodeGeneration())
     , m_firstLine(0)
     , m_lineCount(0)
     , m_endColumn(UINT_MAX)

Added: trunk/Source/_javascript_Core/tests/stress/shadow-chicken-reading-from-scope-after-ftl-osr-exit-bytecode-liveness.js (0 => 201622)


--- trunk/Source/_javascript_Core/tests/stress/shadow-chicken-reading-from-scope-after-ftl-osr-exit-bytecode-liveness.js	                        (rev 0)
+++ trunk/Source/_javascript_Core/tests/stress/shadow-chicken-reading-from-scope-after-ftl-osr-exit-bytecode-liveness.js	2016-06-02 22:18:27 UTC (rev 201622)
@@ -0,0 +1,17 @@
+//@ runMiscNoCJITTest("--forceDebuggerBytecodeGeneration=true", "--alwaysUseShadowChicken=true")
+
+"use strict";
+
+function foo(b) {
+    if (b)
+        throw "foo";
+    return b;
+}
+noInline(foo);
+
+for (let i = 0; i < 10000; i++)
+    foo(false);
+
+try {
+    foo(true);
+} catch(e) { }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to