Bug 1115844 - Fix Baseline to emit a nop for JSOP_DEBUGLEAVEBLOCK to temporarily work around a pc lookup bug. r=shu, a=sledru
authorJan de Mooij <jdemooij@mozilla.com>
Fri, 09 Jan 2015 10:09:21 +0100
changeset 242917 54a53a093110
parent 242916 d1b7588f273b
child 242918 73c3918b169f
push id4341
push userryanvm@gmail.com
push date2015-01-20 15:33 +0000
treeherdermozilla-beta@595835cd60a0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersshu, sledru
bugs1115844
milestone36.0
Bug 1115844 - Fix Baseline to emit a nop for JSOP_DEBUGLEAVEBLOCK to temporarily work around a pc lookup bug. r=shu, a=sledru
js/src/jit-test/tests/baseline/bug1115844.js
js/src/jit/BaselineCompiler.cpp
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/baseline/bug1115844.js
@@ -0,0 +1,6 @@
+function f() {
+    let(x) yield x;
+}
+var g = f();
+g.next();
+g.close();
--- a/js/src/jit/BaselineCompiler.cpp
+++ b/js/src/jit/BaselineCompiler.cpp
@@ -2949,33 +2949,48 @@ BaselineCompiler::emit_JSOP_PUSHBLOCKSCO
 }
 
 typedef bool (*PopBlockScopeFn)(JSContext *, BaselineFrame *);
 static const VMFunction PopBlockScopeInfo = FunctionInfo<PopBlockScopeFn>(jit::PopBlockScope);
 
 bool
 BaselineCompiler::emit_JSOP_POPBLOCKSCOPE()
 {
+#ifdef DEBUG
+    // The static block scope ends right before this op. Assert we generated
+    // JIT code for the previous op, so that pcForNativeOffset does not
+    // incorrectly return this pc instead of the previous one and confuse
+    // ScopeIter::settle. TODO: remove this when bug 1118826 lands.
+    PCMappingEntry &prevEntry = pcMappingEntries_[pcMappingEntries_.length() - 2];
+    PCMappingEntry &curEntry = pcMappingEntries_[pcMappingEntries_.length() - 1];
+    MOZ_ASSERT(curEntry.pcOffset == script->pcToOffset(pc));
+    MOZ_ASSERT(curEntry.nativeOffset > prevEntry.nativeOffset);
+#endif
+
     // Call a stub to pop the block from the block chain.
     prepareVMCall();
 
     masm.loadBaselineFramePtr(BaselineFrameReg, R0.scratchReg());
     pushArg(R0.scratchReg());
 
     return callVM(PopBlockScopeInfo);
 }
 
 typedef bool (*DebugLeaveBlockFn)(JSContext *, BaselineFrame *, jsbytecode *);
 static const VMFunction DebugLeaveBlockInfo = FunctionInfo<DebugLeaveBlockFn>(jit::DebugLeaveBlock);
 
 bool
 BaselineCompiler::emit_JSOP_DEBUGLEAVEBLOCK()
 {
-    if (!compileDebugInstrumentation_)
+    if (!compileDebugInstrumentation_) {
+        // See the comment in emit_JSOP_POPBLOCKSCOPE.
+        if (*GetNextPc(pc) == JSOP_POPBLOCKSCOPE)
+            masm.nop();
         return true;
+    }
 
     prepareVMCall();
     masm.loadBaselineFramePtr(BaselineFrameReg, R0.scratchReg());
     pushArg(ImmPtr(pc));
     pushArg(R0.scratchReg());
 
     return callVM(DebugLeaveBlockInfo);
 }