Bug 1501666 - Fix bug in elaborate assertion that counts step hooks. r=jimb
☠☠ backed out by 2f0e92d76c4e ☠ ☠
authorJason Orendorff <jorendorff@mozilla.com>
Fri, 30 Nov 2018 01:23:39 +0000
changeset 448890 12525933eb9e4b77aed03ef536aac18a36f81278
parent 448889 2e6cbbc4c53e3c0cc762b8c716d5e6370a11bd17
child 448891 b096dc953832f7601d34625144d19c1bb43c9f7a
push id35129
push usernerli@mozilla.com
push dateFri, 30 Nov 2018 09:34:14 +0000
treeherdermozilla-central@c5b713000513 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimb
bugs1501666
milestone65.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 1501666 - Fix bug in elaborate assertion that counts step hooks. r=jimb Differential Revision: https://phabricator.services.mozilla.com/D12493
js/src/jit-test/tests/debug/bug1501666.js
js/src/vm/Debugger.cpp
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/debug/bug1501666.js
@@ -0,0 +1,16 @@
+async function gg() {
+    await 3;
+    await 3;
+}
+gg();
+gg();
+var g = newGlobal();
+g.parent = this;
+g.eval(`
+    var dbg = Debugger(parent);
+    dbg.onEnterFrame = function(frame) {
+        frame.onStep = function() {};
+    };
+`);
+
+drainJobQueue();
--- a/js/src/vm/Debugger.cpp
+++ b/js/src/vm/Debugger.cpp
@@ -2371,22 +2371,37 @@ Debugger::onSingleStep(JSContext* cx, Mu
         uint32_t stepperCount = 0;
         JSScript* trappingScript = iter.script();
         GlobalObject* global = cx->global();
         if (GlobalObject::DebuggerVector* debuggers = global->getDebuggers()) {
             for (auto p = debuggers->begin(); p != debuggers->end(); p++) {
                 Debugger* dbg = *p;
                 for (FrameMap::Range r = dbg->frames.all(); !r.empty(); r.popFront()) {
                     AbstractFramePtr frame = r.front().key();
-                    NativeObject* frameobj = r.front().value();
+                    NativeObject* frameObj = r.front().value();
                     if (frame.isWasmDebugFrame()) {
                         continue;
                     }
                     if (frame.script() == trappingScript &&
-                        !frameobj->getReservedSlot(JSSLOT_DEBUGFRAME_ONSTEP_HANDLER).isUndefined())
+                        !frameObj->getReservedSlot(JSSLOT_DEBUGFRAME_ONSTEP_HANDLER).isUndefined())
+                    {
+                        stepperCount++;
+                    }
+                }
+
+                // Also count hooks set on suspended generator frames.
+                for (GeneratorWeakMap::Range r = dbg->generatorFrames.all(); !r.empty(); r.popFront()) {
+                    GeneratorObject& genObj = r.front().key()->as<GeneratorObject>();
+                    DebuggerFrame& frameObj = r.front().value()->as<DebuggerFrame>();
+
+                    // Running frames were already counted in dbg->frames loop.
+                    if (!genObj.isRunning() &&
+                        !genObj.callee().isInterpretedLazy() &&
+                        genObj.callee().nonLazyScript() == trappingScript &&
+                        !frameObj.getReservedSlot(JSSLOT_DEBUGFRAME_ONSTEP_HANDLER).isUndefined())
                     {
                         stepperCount++;
                     }
                 }
             }
         }
         MOZ_ASSERT(stepperCount == trappingScript->stepModeCount());
     }