Bug 1278562 - Implement a C++ interface for DebuggerObject.promiseTimeToResolution. r=jimb
authorEddy Bruel <ejpbruel@mozilla.com
Fri, 02 Sep 2016 13:24:10 +0200
changeset 312406 de45e910de91b18ed189a0bdbcb7c9b68aeb39b3
parent 312405 9c01cff2648aaa98a9ae4d72581b2933af74ac48
child 312407 fc4928fc74e5add861fb00c40ee40ba5386c82d3
push id20447
push userkwierso@gmail.com
push dateFri, 02 Sep 2016 20:36:44 +0000
treeherderfx-team@969397f22187 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimb
bugs1278562
milestone51.0a1
Bug 1278562 - Implement a C++ interface for DebuggerObject.promiseTimeToResolution. r=jimb
js/src/vm/Debugger.cpp
js/src/vm/Debugger.h
--- a/js/src/vm/Debugger.cpp
+++ b/js/src/vm/Debugger.cpp
@@ -8700,24 +8700,27 @@ DebuggerObject::promiseLifetimeGetter(JS
 
     args.rval().setNumber(object->promiseLifetime());
     return true;
 }
 
 /* static */ bool
 DebuggerObject::promiseTimeToResolutionGetter(JSContext* cx, unsigned argc, Value* vp)
 {
-    THIS_DEBUGOBJECT_PROMISE(cx, argc, vp, "get promiseTimeToResolution", args, refobj);
-
-    if (promise->state() == JS::PromiseState::Pending) {
+    THIS_DEBUGOBJECT(cx, argc, vp, "get promiseTimeToResolution", args, object);
+
+    if (!DebuggerObject::requirePromise(cx, object))
+        return false;
+
+    if (object->promiseState() == JS::PromiseState::Pending) {
         JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_DEBUG_PROMISE_NOT_RESOLVED);
         return false;
     }
 
-    args.rval().setNumber(promise->timeToResolution());
+    args.rval().setNumber(object->promiseTimeToResolution());
     return true;
 }
 
 /* static */ bool
 DebuggerObject::promiseAllocationSiteGetter(JSContext* cx, unsigned argc, Value* vp)
 {
     THIS_DEBUGOBJECT_PROMISE(cx, argc, vp, "get promiseAllocationSite", args, refobj);
 
@@ -9419,16 +9422,24 @@ DebuggerObject::promiseState() const
 }
 
 double
 DebuggerObject::promiseLifetime() const
 {
     return promise()->lifetime();
 }
 
+double
+DebuggerObject::promiseTimeToResolution() const
+{
+    MOZ_ASSERT(promiseState() != JS::PromiseState::Pending);
+
+    return promise()->timeToResolution();
+}
+
 /* static */ bool
 DebuggerObject::getParameterNames(JSContext* cx, HandleDebuggerObject object,
                                   MutableHandle<StringVector> result)
 {
     MOZ_ASSERT(object->isDebuggeeFunction());
 
     RootedFunction referent(cx, &object->referent()->as<JSFunction>());
 
--- a/js/src/vm/Debugger.h
+++ b/js/src/vm/Debugger.h
@@ -1315,16 +1315,17 @@ class DebuggerObject : public NativeObje
 #ifdef SPIDERMONKEY_PROMISE
     bool isPromise() const;
 #endif // SPIDERMONKEY_PROMISE
     JSAtom* name() const;
     JSAtom* displayName() const;
 #ifdef SPIDERMONKEY_PROMISE
     JS::PromiseState promiseState() const;
     double promiseLifetime() const;
+    double promiseTimeToResolution() const;
 #endif // SPIDERMONKEY_PROMISE
 
   private:
     enum {
         OWNER_SLOT
     };
 
     static const unsigned RESERVED_SLOTS = 1;