Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(112)

Unified Diff: src/js/promise.js

Issue 2406343002: [promises] Move PromiseReactionJob to c++ (Closed)
Patch Set: fix promisedebugeventscope Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/isolate.cc ('k') | src/objects.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/js/promise.js
diff --git a/src/js/promise.js b/src/js/promise.js
index 86be06018ce7230dd54a9d7179db9dbd5fa365fa..b9f1d123094c1eb79d4e2ce5a1ddd50889e4942e 100644
--- a/src/js/promise.js
+++ b/src/js/promise.js
@@ -190,22 +190,8 @@ function PromiseHandle(value, handler, deferred) {
}
function PromiseEnqueue(value, tasks, deferreds, status) {
- var id, name, instrumenting = DEBUG_IS_ACTIVE;
- %EnqueueMicrotask(function() {
- if (instrumenting) {
- %DebugAsyncTaskEvent({ type: "willHandle", id: id, name: name });
- }
- if (IS_ARRAY(tasks)) {
- for (var i = 0; i < tasks.length; i += 2) {
- PromiseHandle(value, tasks[i], tasks[i + 1]);
- }
- } else {
- PromiseHandle(value, tasks, deferreds);
- }
- if (instrumenting) {
- %DebugAsyncTaskEvent({ type: "didHandle", id: id, name: name });
- }
- });
+ var id, name, beforeDebug, afterDebug, instrumenting = DEBUG_IS_ACTIVE;
+
if (instrumenting) {
// In an async function, reuse the existing stack related to the outer
// Promise. Otherwise, e.g. in a direct call to then, save a new stack.
@@ -225,7 +211,12 @@ function PromiseEnqueue(value, tasks, deferreds, status) {
name = status === kFulfilled ? "Promise.resolve" : "Promise.reject";
%DebugAsyncTaskEvent({ type: "enqueue", id: id, name: name });
}
+
+ beforeDebug = { type: "willHandle", id: id, name: name };
+ afterDebug = { type: "didHandle", id: id, name: name };
}
+
+ %EnqueuePromiseReactionJob(value, tasks, deferreds, beforeDebug, afterDebug);
}
function PromiseAttachCallbacks(promise, deferred, onResolve, onReject) {
@@ -703,7 +694,8 @@ utils.InstallFunctions(GlobalPromise.prototype, DONT_ENUM, [
"promise_has_user_defined_reject_handler", PromiseHasUserDefinedRejectHandler,
"promise_reject", DoRejectPromise,
"promise_resolve", ResolvePromise,
- "promise_then", PromiseThen
+ "promise_then", PromiseThen,
+ "promise_handle", PromiseHandle
]);
// This allows extras to create promises quickly without building extra
« no previous file with comments | « src/isolate.cc ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698