Commit 9eb320ad authored by gsathya's avatar gsathya Committed by Commit bot

Promises: Make debug calls only when debugging

Previously, certain calls to DebugPushPromise and DebugPopPromise
happened always, without any check to see if we were in a debugging
environment. This patch adds a conditional check before making these
debug calls to make sure they aren't called when not needed.

Before the patch, running --prof over the bluebird benchmarks,
brings up these unprotected debug calls --
ticks    cpp   total   name
16    6.7%    2.0%  v8::internal::Runtime_DebugPushPromise(int, v8::internal::Object**, v8::internal::Isolate*)
7    2.9%    0.9%  v8::internal::Runtime_DebugPopPromise(int, v8::internal::Object**, v8::internal::Isolate*)

This patch removes the above calls and provides a 4% improvement (with
a 2% variance over 10 runs) in the bluebird benchmark.

Review-Url: https://codereview.chromium.org/1985293002
Cr-Commit-Position: refs/heads/master@{#36451}
parent bb8b2b9b
......@@ -83,14 +83,14 @@ var GlobalPromise = function Promise(resolver) {
var promise = PromiseInit(%_NewObject(GlobalPromise, new.target));
var callbacks = CreateResolvingFunctions(promise);
var debug_is_active = DEBUG_IS_ACTIVE;
try {
%DebugPushPromise(promise, Promise);
if (debug_is_active) %DebugPushPromise(promise, Promise);
resolver(callbacks.resolve, callbacks.reject);
} catch (e) {
%_Call(callbacks.reject, UNDEFINED, e);
} finally {
%DebugPopPromise();
if (debug_is_active) %DebugPopPromise();
}
return promise;
......@@ -127,14 +127,15 @@ function PromiseDone(promise, status, value, promiseQueue) {
}
function PromiseHandle(value, handler, deferred) {
var debug_is_active = DEBUG_IS_ACTIVE;
try {
%DebugPushPromise(deferred.promise, PromiseHandle);
if (debug_is_active) %DebugPushPromise(deferred.promise, PromiseHandle);
var result = handler(value);
deferred.resolve(result);
} catch (exception) {
try { deferred.reject(exception); } catch (e) { }
} finally {
%DebugPopPromise();
if (debug_is_active) %DebugPopPromise();
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment