Bug 1546727: Make DebuggerFrame_maybeDecrementFrameScriptStepModeCount a method of DebuggerFrame. r=jorendorff
authorJim Blandy <jimb@mozilla.com>
Wed, 08 May 2019 07:06:40 +0000
changeset 532542 9224b5e39c2e1e8132929a7be64a71c9531ddd2f
parent 532541 ab450513a15615bc3dd1ddf2db999424dc7531d6
child 532543 7f94111df77a31b17dfe6dbfc0793150f93f898f
push id11270
push userrgurzau@mozilla.com
push dateWed, 15 May 2019 15:07:19 +0000
treeherdermozilla-beta@571bc76da583 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
bugs1546727
milestone68.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 1546727: Make DebuggerFrame_maybeDecrementFrameScriptStepModeCount a method of DebuggerFrame. r=jorendorff This function probably predates the existence of the DebuggerFrame class, and was never moved in. Depends on D28783 Differential Revision: https://phabricator.services.mozilla.com/D28784
js/src/vm/Debugger.cpp
js/src/vm/Debugger.h
--- a/js/src/vm/Debugger.cpp
+++ b/js/src/vm/Debugger.cpp
@@ -927,19 +927,16 @@ ResumeMode Debugger::slowPathOnResumeFra
         }
       }
     }
   }
 
   return slowPathOnEnterFrame(cx, frame);
 }
 
-static void DebuggerFrame_maybeDecrementFrameScriptStepModeCount(
-    FreeOp* fop, AbstractFramePtr frame, NativeObject* frameobj);
-
 /*
  * RAII class to mark a generator as "running" temporarily while running
  * debugger code.
  *
  * When Debugger::slowPathOnLeaveFrame is called for a frame that is yielding
  * or awaiting, its generator is in the "suspended" state. Letting script
  * observe this state, with the generator on stack yet also reenterable, would
  * be bad, so we mark it running while we fire events.
@@ -4492,18 +4489,17 @@ void Debugger::removeDebuggeeGlobal(Free
   // This is a bug, since it's observable and contrary to the spec. One
   // possible fix would be to put such objects into a compartment-wide bag
   // which slowPathOnLeaveFrame would have to examine.
   for (FrameMap::Enum e(frames); !e.empty(); e.popFront()) {
     AbstractFramePtr frame = e.front().key();
     DebuggerFrame* frameobj = e.front().value();
     if (frame.hasGlobal(global)) {
       frameobj->freeFrameIterData(fop);
-      DebuggerFrame_maybeDecrementFrameScriptStepModeCount(fop, frame,
-                                                           frameobj);
+      frameobj->maybeDecrementFrameScriptStepModeCount(fop, frame);
       e.removeFront();
     }
   }
 
   // Clear this global's generators from generatorFrames as well.
   //
   // This method can be called either from script (dbg.removeDebuggee) or
   // from an awkward time during GC sweeping. In the latter case, skip this
@@ -7778,17 +7774,17 @@ bool Debugger::replaceFrameGuts(JSContex
       // removeFromDebuggerFramesOnExit and removeToDebuggerFramesOnExit
       // must both run for the same reason given above.
       //
       // The difference is that the current frameobj is no longer in its
       // Debugger's frame map, so it will not be cleaned up by neither
       // lambda. Manually clean it up here.
       FreeOp* fop = cx->runtime()->defaultFreeOp();
       frameobj->freeFrameIterData(fop);
-      DebuggerFrame_maybeDecrementFrameScriptStepModeCount(fop, to, frameobj);
+      frameobj->maybeDecrementFrameScriptStepModeCount(fop, to);
 
       ReportOutOfMemory(cx);
       return false;
     }
   }
 
   // All frames successfuly replaced, cancel the rollback.
   removeToDebuggerFramesOnExit.release();
@@ -7807,18 +7803,17 @@ bool Debugger::inFrameMaps(AbstractFrame
 /* static */
 void Debugger::removeFromFrameMapsAndClearBreakpointsIn(JSContext* cx,
                                                         AbstractFramePtr frame,
                                                         bool suspending) {
   forEachDebuggerFrame(frame, [&](DebuggerFrame* frameobj) {
     FreeOp* fop = cx->runtime()->defaultFreeOp();
     frameobj->freeFrameIterData(fop);
     if (!suspending) {
-      DebuggerFrame_maybeDecrementFrameScriptStepModeCount(fop, frame,
-                                                           frameobj);
+      frameobj->maybeDecrementFrameScriptStepModeCount(fop, frame);
     }
 
     Debugger* dbg = Debugger::fromChildJSObject(frameobj);
     dbg->frames.remove(frame);
 
     if (!suspending && frame.isGeneratorFrame()) {
       // Terminally exiting a generator.
       auto* genObj = GetGeneratorObjectForFrame(cx, frame);
@@ -9581,21 +9576,20 @@ bool DebuggerFrame::requireScriptReferen
 
 void DebuggerFrame::freeFrameIterData(FreeOp* fop) {
   if (FrameIter::Data* data = frameIterData()) {
     fop->delete_(data);
     setPrivate(nullptr);
   }
 }
 
-static void DebuggerFrame_maybeDecrementFrameScriptStepModeCount(
-    FreeOp* fop, AbstractFramePtr frame, NativeObject* frameobj) {
+void DebuggerFrame::maybeDecrementFrameScriptStepModeCount(
+    FreeOp* fop, AbstractFramePtr frame) {
   // If this frame has an onStep handler, decrement the script's count.
-  if (frameobj->getReservedSlot(DebuggerFrame::ONSTEP_HANDLER_SLOT)
-          .isUndefined()) {
+  if (getReservedSlot(ONSTEP_HANDLER_SLOT).isUndefined()) {
     return;
   }
   if (frame.isWasmDebugFrame()) {
     wasm::Instance* instance = frame.wasmInstance();
     instance->debug().decrementStepModeCount(
         fop, frame.asWasmDebugFrame()->funcIndex());
   } else {
     frame.script()->decrementStepModeCount(fop);
--- a/js/src/vm/Debugger.h
+++ b/js/src/vm/Debugger.h
@@ -1450,17 +1450,16 @@ class DebuggerFrame : public NativeObjec
 
   static void trace(JSTracer* trc, JSObject* obj);
 
   static NativeObject* initClass(JSContext* cx, HandleObject dbgCtor,
                                  Handle<GlobalObject*> global);
   static DebuggerFrame* create(JSContext* cx, HandleObject proto,
                                const FrameIter& iter,
                                HandleNativeObject debugger);
-  void freeFrameIterData(FreeOp* fop);
 
   static MOZ_MUST_USE bool getArguments(JSContext* cx,
                                         HandleDebuggerFrame frame,
                                         MutableHandleDebuggerArguments result);
   static MOZ_MUST_USE bool getCallee(JSContext* cx, HandleDebuggerFrame frame,
                                      MutableHandleDebuggerObject result);
   static MOZ_MUST_USE bool getIsConstructing(JSContext* cx,
                                              HandleDebuggerFrame frame,
@@ -1548,16 +1547,19 @@ class DebuggerFrame : public NativeObjec
   static MOZ_MUST_USE bool evalMethod(JSContext* cx, unsigned argc, Value* vp);
   static MOZ_MUST_USE bool evalWithBindingsMethod(JSContext* cx, unsigned argc,
                                                   Value* vp);
 
   Debugger* owner() const;
 
  public:
   FrameIter::Data* frameIterData() const;
+  void freeFrameIterData(FreeOp* fop);
+  void maybeDecrementFrameScriptStepModeCount(FreeOp* fop,
+                                              AbstractFramePtr frame);
 };
 
 class DebuggerObject : public NativeObject {
  public:
   static const Class class_;
 
   static NativeObject* initClass(JSContext* cx, Handle<GlobalObject*> global,
                                  HandleObject debugCtor);