Bug 911216 - Part 18: Only capture Promise allocation and resolution stacks if async stacks are enabled or the Promise's compartment is debugged. r=efaust,f=fitzgen
authorTill Schneidereit <till@tillschneidereit.net>
Thu, 26 May 2016 16:13:47 +0200
changeset 338192 8d3730e7d1f0fb096bfe93d11afd2691e9fe1453
parent 338191 0a1f4ee953d0e4e8959cb9a75e4b58a6cc3d08df
child 338193 b87905133eafb182539e8ea332ad19ab9548e8ee
push id6249
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 13:59:36 +0000
treeherdermozilla-beta@bad9d4f5bf7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersefaust
bugs911216
milestone49.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 911216 - Part 18: Only capture Promise allocation and resolution stacks if async stacks are enabled or the Promise's compartment is debugged. r=efaust,f=fitzgen
js/src/builtin/Promise.cpp
--- a/js/src/builtin/Promise.cpp
+++ b/js/src/builtin/Promise.cpp
@@ -127,18 +127,20 @@ PromiseObject::create(JSContext* cx, Han
         // Step 7.
         promise->setFixedSlot(PROMISE_IS_HANDLED_SLOT,
                               Int32Value(PROMISE_IS_HANDLED_STATE_UNHANDLED));
 
         // Store an allocation stack so we can later figure out what the
         // control flow was for some unexpected results. Frightfully expensive,
         // but oh well.
         RootedObject stack(cx);
-        if (!JS::CaptureCurrentStack(cx, &stack, 0))
-            return nullptr;
+        if (cx->runtime()->options().asyncStack() || cx->compartment()->isDebuggee()) {
+            if (!JS::CaptureCurrentStack(cx, &stack, 0))
+                return nullptr;
+        }
         promise->setFixedSlot(PROMISE_ALLOCATION_SITE_SLOT, ObjectOrNullValue(stack));
         promise->setFixedSlot(PROMISE_ALLOCATION_TIME_SLOT, Now());
     }
 
     RootedValue promiseVal(cx, ObjectValue(*promise));
     if (wrappedProto && !cx->compartment()->wrap(cx, &promiseVal))
         return nullptr;
 
@@ -407,19 +409,21 @@ PromiseObject::reject(JSContext* cx, Han
     RootedValue dummy(cx);
     return Call(cx, funVal, UndefinedHandleValue, args, &dummy);
 }
 
 void PromiseObject::onSettled(JSContext* cx)
 {
     Rooted<PromiseObject*> promise(cx, this);
     RootedObject stack(cx);
-    if (!JS::CaptureCurrentStack(cx, &stack, 0)) {
-        cx->clearPendingException();
-        return;
+    if (cx->runtime()->options().asyncStack() || cx->compartment()->isDebuggee()) {
+        if (!JS::CaptureCurrentStack(cx, &stack, 0)) {
+            cx->clearPendingException();
+            return;
+        }
     }
     promise->setFixedSlot(PROMISE_RESOLUTION_SITE_SLOT, ObjectOrNullValue(stack));
     promise->setFixedSlot(PROMISE_RESOLUTION_TIME_SLOT, Now());
 
     if (promise->state() == JS::PromiseState::Rejected &&
         promise->getFixedSlot(PROMISE_IS_HANDLED_SLOT).toInt32() !=
             PROMISE_IS_HANDLED_STATE_HANDLED)
     {