Bug 1546727: Make DebuggerFrame_requireLive and DebuggerFrame_checkThis member functions of DebuggerFrame. r=jorendorff
authorJim Blandy <jimb@mozilla.com>
Wed, 08 May 2019 07:06:42 +0000
changeset 532544 b4e7d290701a7db413bc912d12c6597ede43b728
parent 532543 7f94111df77a31b17dfe6dbfc0793150f93f898f
child 532545 f8b9b7dcd147413285007736cbb2ba51e79ca30d
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_requireLive and DebuggerFrame_checkThis member functions of DebuggerFrame. r=jorendorff These function probably predate the existence of the DebuggerFrame class, and were never moved in. Depends on D28784 Differential Revision: https://phabricator.services.mozilla.com/D28785
js/src/vm/Debugger.cpp
js/src/vm/Debugger.h
--- a/js/src/vm/Debugger.cpp
+++ b/js/src/vm/Debugger.cpp
@@ -9528,19 +9528,18 @@ void DebuggerFrame::setOnPopHandler(OnPo
   if (prior && prior != handler) {
     prior->drop();
   }
 
   setReservedSlot(ONPOP_HANDLER_SLOT,
                   handler ? PrivateValue(handler) : UndefinedValue());
 }
 
-static bool DebuggerFrame_requireLive(JSContext* cx,
-                                      HandleDebuggerFrame frame) {
-  if (!frame->isLive()) {
+bool DebuggerFrame::requireLive(JSContext* cx) {
+  if (!isLive()) {
     JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr,
                               JSMSG_DEBUG_NOT_LIVE, "Debugger.Frame");
     return false;
   }
 
   return true;
 }
 
@@ -9618,64 +9617,63 @@ void DebuggerFrame::trace(JSTracer* trc,
     onStepHandler->trace(trc);
   }
   OnPopHandler* onPopHandler = obj->as<DebuggerFrame>().onPopHandler();
   if (onPopHandler) {
     onPopHandler->trace(trc);
   }
 }
 
-static DebuggerFrame* DebuggerFrame_checkThis(JSContext* cx,
-                                              const CallArgs& args,
-                                              const char* fnname,
-                                              bool checkLive) {
+/* static */
+DebuggerFrame* DebuggerFrame::checkThis(JSContext* cx, const CallArgs& args,
+                                        const char* fnname, bool checkLive) {
   JSObject* thisobj = NonNullObject(cx, args.thisv());
   if (!thisobj) {
     return nullptr;
   }
-  if (thisobj->getClass() != &DebuggerFrame::class_) {
+  if (thisobj->getClass() != &class_) {
     JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr,
                               JSMSG_INCOMPATIBLE_PROTO, "Debugger.Frame",
                               fnname, thisobj->getClass()->name);
     return nullptr;
   }
 
   RootedDebuggerFrame frame(cx, &thisobj->as<DebuggerFrame>());
 
   // Forbid Debugger.Frame.prototype, which is of class DebuggerFrame::class_
   // but isn't really a working Debugger.Frame object. The prototype object
   // is distinguished by having a nullptr private value. Also, forbid popped
   // frames.
   if (!frame->getPrivate() &&
-      frame->getReservedSlot(DebuggerFrame::OWNER_SLOT).isUndefined()) {
+      frame->getReservedSlot(OWNER_SLOT).isUndefined()) {
     JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr,
                               JSMSG_INCOMPATIBLE_PROTO, "Debugger.Frame",
                               fnname, "prototype object");
     return nullptr;
   }
 
   if (checkLive) {
-    if (!DebuggerFrame_requireLive(cx, frame)) {
+    if (!frame->requireLive(cx)) {
       return nullptr;
     }
   }
 
   return frame;
 }
 
 /*
  * Methods can use THIS_DEBUGGER_FRAME to check that `this` is a Debugger.Frame
  * object and get it in a local Rooted.
  *
  * Methods that need the AbstractFramePtr should use THIS_FRAME.
  */
-#define THIS_DEBUGGER_FRAME(cx, argc, vp, fnname, args, frame)                \
-  CallArgs args = CallArgsFromVp(argc, vp);                                   \
-  RootedDebuggerFrame frame(cx,                                               \
-                            DebuggerFrame_checkThis(cx, args, fnname, true)); \
+#define THIS_DEBUGGER_FRAME(cx, argc, vp, fnname, args, frame)                 \
+  CallArgs args = CallArgsFromVp(argc, vp);                                    \
+  RootedDebuggerFrame frame(cx,                                                \
+                            DebuggerFrame::checkThis(cx, args, fnname, true)); \
   if (!frame) return false;
 
 #define THIS_FRAME(cx, argc, vp, fnname, args, thisobj, iter, frame) \
   THIS_DEBUGGER_FRAME(cx, argc, vp, fnname, args, thisobj);          \
   FrameIter iter(*thisobj->frameIterData());                         \
   AbstractFramePtr frame = iter.abstractFramePtr()
 
 /* static */
@@ -9969,18 +9967,17 @@ bool DebuggerFrame::offsetGetter(JSConte
 
   args.rval().setNumber(double(result));
   return true;
 }
 
 /* static */
 bool DebuggerFrame::liveGetter(JSContext* cx, unsigned argc, Value* vp) {
   CallArgs args = CallArgsFromVp(argc, vp);
-  RootedDebuggerFrame frame(
-      cx, DebuggerFrame_checkThis(cx, args, "get live", false));
+  RootedDebuggerFrame frame(cx, checkThis(cx, args, "get live", false));
   if (!frame) {
     return false;
   }
 
   args.rval().setBoolean(frame->isLive());
   return true;
 }
 
--- a/js/src/vm/Debugger.h
+++ b/js/src/vm/Debugger.h
@@ -1484,16 +1484,22 @@ class DebuggerFrame : public NativeObjec
   static MOZ_MUST_USE bool eval(JSContext* cx, HandleDebuggerFrame frame,
                                 mozilla::Range<const char16_t> chars,
                                 HandleObject bindings,
                                 const EvalOptions& options,
                                 ResumeMode& resumeMode,
                                 MutableHandleValue value,
                                 MutableHandleSavedFrame exnStack);
 
+  MOZ_MUST_USE bool requireLive(JSContext* cx);
+  static MOZ_MUST_USE DebuggerFrame* checkThis(JSContext* cx,
+                                               const CallArgs& args,
+                                               const char* fnname,
+                                               bool checkLive);
+
   bool isLive() const;
   OnStepHandler* onStepHandler() const;
   OnPopHandler* onPopHandler() const;
   void setOnPopHandler(OnPopHandler* handler);
 
   /*
    * Called after a generator/async frame is resumed, before exposing this
    * Debugger.Frame object to any hooks.