Bug 1368736 - Mark BaselineFrame as debuggee frame in HandleDebugTrap if the breakpoint is on JSOP_DEBUGAFTERYIELD. r=shu
authorJan de Mooij <jdemooij@mozilla.com>
Tue, 06 Jun 2017 15:06:55 +0200
changeset 410692 ee3c032059e517cf3d25b80c835dc45e2711b504
parent 410691 9c6ee0bd191b7ff7195870b0674d4574b2851b9f
child 410693 5df249f4aee1e3b33de2f4822d47b49839eb922a
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersshu
bugs1368736
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1368736 - Mark BaselineFrame as debuggee frame in HandleDebugTrap if the breakpoint is on JSOP_DEBUGAFTERYIELD. r=shu
js/src/jit-test/tests/debug/bug1368736.js
js/src/jit/VMFunctions.cpp
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/debug/bug1368736.js
@@ -0,0 +1,18 @@
+g = newGlobal();
+hits = 0;
+Debugger(g).onDebuggerStatement = function(frame) {
+    // Set a breakpoint at the JSOP_DEBUGAFTERYIELD op.
+    frame.script.setBreakpoint(71, {hit: function() { hits++; }});
+}
+g.eval(`
+function* range() {
+    debugger;
+    for (var i = 0; i < 3; i++) {
+        yield i;
+    }
+}
+var iter = range();
+for (var i = 0; i < 3; i++)
+    assertEq(iter.next().value, i);
+`);
+assertEq(hits, 2);
--- a/js/src/jit/VMFunctions.cpp
+++ b/js/src/jit/VMFunctions.cpp
@@ -1055,16 +1055,24 @@ InitRestParameter(JSContext* cx, uint32_
 bool
 HandleDebugTrap(JSContext* cx, BaselineFrame* frame, uint8_t* retAddr, bool* mustReturn)
 {
     *mustReturn = false;
 
     RootedScript script(cx, frame->script());
     jsbytecode* pc = script->baselineScript()->icEntryFromReturnAddress(retAddr).pc(script);
 
+    if (*pc == JSOP_DEBUGAFTERYIELD) {
+        // JSOP_DEBUGAFTERYIELD will set the frame's debuggee flag, but if we
+        // set a breakpoint there we have to do it now.
+        MOZ_ASSERT(!frame->isDebuggee());
+        if (!DebugAfterYield(cx, frame))
+            return false;
+    }
+
     MOZ_ASSERT(frame->isDebuggee());
     MOZ_ASSERT(script->stepModeEnabled() || script->hasBreakpointsAt(pc));
 
     RootedValue rval(cx);
     JSTrapStatus status = JSTRAP_CONTINUE;
 
     if (script->stepModeEnabled())
         status = Debugger::onSingleStep(cx, &rval);