Bug 1271650 - DebuggerFrame::referent should be a static method. r=jimb
authorEddy Bruel <ejpbruel@mozilla.com>
Wed, 20 Jul 2016 13:44:13 +0200
changeset 331114 904a6eb36f1ba6d8d1d79f445f25d6eeef021688
parent 331113 1e55eeb2395e3255816a94f4f50f4e291c7394d8
child 331115 bdbb5822afe1851c0df23d33a591b4001e221831
push id9858
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 14:37:10 +0000
treeherdermozilla-aurora@203106ef6cb6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimb
bugs1271650
milestone50.0a1
Bug 1271650 - DebuggerFrame::referent should be a static method. r=jimb
js/src/vm/Debugger-inl.h
js/src/vm/Debugger.cpp
js/src/vm/Debugger.h
--- a/js/src/vm/Debugger-inl.h
+++ b/js/src/vm/Debugger-inl.h
@@ -81,27 +81,16 @@ js::Debugger::onNewWasmInstance(JSContex
 
 inline js::Debugger*
 js::DebuggerEnvironment::owner() const
 {
     JSObject* dbgobj = &getReservedSlot(OWNER_SLOT).toObject();
     return Debugger::fromJSObject(dbgobj);
 }
 
-inline js::AbstractFramePtr
-js::DebuggerFrame::referent() const
-{
-    AbstractFramePtr frame = AbstractFramePtr::FromRaw(getPrivate());
-    if (frame.isScriptFrameIterData()) {
-        ScriptFrameIter iter(*(ScriptFrameIter::Data*)(frame.raw()));
-        frame = iter.abstractFramePtr();
-    }
-    return frame;
-}
-
 inline js::Debugger*
 js::DebuggerFrame::owner() const
 {
     JSObject* dbgobj = &getReservedSlot(OWNER_SLOT).toObject();
     return Debugger::fromJSObject(dbgobj);
 }
 
 inline js::Debugger*
--- a/js/src/vm/Debugger.cpp
+++ b/js/src/vm/Debugger.cpp
@@ -7073,17 +7073,17 @@ DebuggerFrame::create(JSContext* cx, Han
 
   return &frame;
 }
 
 /* static */ bool
 DebuggerFrame::getCallee(JSContext* cx, Handle<DebuggerFrame*> frame,
                          MutableHandle<DebuggerObject*> result)
 {
-    AbstractFramePtr referent = frame->referent();
+    AbstractFramePtr referent = DebuggerFrame::getReferent(frame);
     if (!referent.isFunctionFrame()) {
         result.set(nullptr);
         return true;
     }
 
     Debugger* dbg = frame->owner();
 
     RootedObject callee(cx, referent.callee());
@@ -7158,19 +7158,30 @@ DebuggerFrame::getEnvironment(JSContext*
         if (!env)
             return false;
     }
 
     return dbg->wrapEnvironment(cx, env, result);
 }
 
 /* static */ bool
-DebuggerFrame::isGenerator() const
-{
-    return referent().script()->isGenerator();
+DebuggerFrame::getIsGenerator(Handle<DebuggerFrame*> frame)
+{
+    return DebuggerFrame::getReferent(frame).script()->isGenerator();
+}
+
+/* static */ AbstractFramePtr
+DebuggerFrame::getReferent(Handle<DebuggerFrame*> frame)
+{
+    AbstractFramePtr referent = AbstractFramePtr::FromRaw(frame->getPrivate());
+    if (referent.isScriptFrameIterData()) {
+        ScriptFrameIter iter(*(ScriptFrameIter::Data*)(referent.raw()));
+        referent = iter.abstractFramePtr();
+    }
+    return referent;
 }
 
 /* static */ bool
 DebuggerFrame::getScriptFrameIter(JSContext* cx, Handle<DebuggerFrame*> frame,
                                   Maybe<ScriptFrameIter>& result)
 {
     AbstractFramePtr referent = AbstractFramePtr::FromRaw(frame->getPrivate());
     if (referent.isScriptFrameIterData()) {
@@ -7383,17 +7394,17 @@ DebuggerFrame::calleeGetter(JSContext* c
     return true;
 }
 
 /* static */ bool
 DebuggerFrame::generatorGetter(JSContext* cx, unsigned argc, Value* vp)
 {
     THIS_DEBUGGER_FRAME(cx, argc, vp, "get callee", args, frame);
 
-    args.rval().setBoolean(frame->isGenerator());
+    args.rval().setBoolean(DebuggerFrame::getIsGenerator(frame));
     return true;
 }
 
 /* static */ bool
 DebuggerFrame::constructingGetter(JSContext* cx, unsigned argc, Value* vp)
 {
     THIS_DEBUGGER_FRAME(cx, argc, vp, "get callee", args, frame);
 
--- a/js/src/vm/Debugger.h
+++ b/js/src/vm/Debugger.h
@@ -1148,36 +1148,35 @@ class DebuggerFrame : public NativeObjec
                                     bool checkLive);
 
     static MOZ_MUST_USE bool getCallee(JSContext* cx, Handle<DebuggerFrame*> frame,
                                        MutableHandle<DebuggerObject*> result);
     static MOZ_MUST_USE bool getIsConstructing(JSContext* cx, Handle<DebuggerFrame*> frame,
                                                bool& result);
     static MOZ_MUST_USE bool getEnvironment(JSContext* cx, Handle<DebuggerFrame*> frame,
                                             MutableHandle<DebuggerEnvironment*> result);
-
-    bool isGenerator() const;
+    static bool getIsGenerator(Handle<DebuggerFrame*> frame);
 
   private:
     static const ClassOps classOps_;
 
     static const JSPropertySpec properties_[];
     static const JSFunctionSpec methods_[];
 
+    static AbstractFramePtr getReferent(Handle<DebuggerFrame*> frame);
     static MOZ_MUST_USE bool getScriptFrameIter(JSContext* cx, Handle<DebuggerFrame*> frame,
                                                 mozilla::Maybe<ScriptFrameIter>& result);
 
     static MOZ_MUST_USE bool construct(JSContext* cx, unsigned argc, Value* vp);
 
     static MOZ_MUST_USE bool calleeGetter(JSContext* cx, unsigned argc, Value* vp);
     static MOZ_MUST_USE bool constructingGetter(JSContext* cx, unsigned argc, Value* vp);
     static MOZ_MUST_USE bool environmentGetter(JSContext* cx, unsigned argc, Value* vp);
     static MOZ_MUST_USE bool generatorGetter(JSContext* cx, unsigned argc, Value* vp);
 
-    AbstractFramePtr referent() const;
     Debugger* owner() const;
 };
 
 class DebuggerObject : public NativeObject
 {
   public:
     static const Class class_;