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

Unified Diff: src/js/promise.js

Issue 2314903004: [promises] Move PromiseResolveThenableJob to c++ (Closed)
Patch Set: rebase Created 4 years, 3 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 a7ba69e491968211d5d61cc4ba96300f0a48f09e..7d192371caeb08499fd201f6cba9cc3262c82fa8 100644
--- a/src/js/promise.js
+++ b/src/js/promise.js
@@ -284,34 +284,34 @@ function ResolvePromise(promise, resolution) {
}
if (IS_CALLABLE(then)) {
- // PromiseResolveThenableJob
- var id;
- var name = "PromiseResolveThenableJob";
+ var callbacks = CreateResolvingFunctions(promise, false);
+ var id, before_debug_event, after_debug_event;
var instrumenting = DEBUG_IS_ACTIVE;
- if (instrumenting && IsPromise(resolution)) {
- // Mark the dependency of the new promise on the resolution
- SET_PRIVATE(resolution, promiseHandledBySymbol, promise);
- }
- %EnqueueMicrotask(function() {
- if (instrumenting) {
- %DebugAsyncTaskEvent({ type: "willHandle", id: id, name: name });
- }
- // These resolving functions simply forward the exception, so
- // don't create a new debugEvent.
- var callbacks = CreateResolvingFunctions(promise, false);
- try {
- %_Call(then, resolution, callbacks.resolve, callbacks.reject);
- } catch (e) {
- %_Call(callbacks.reject, UNDEFINED, e);
- }
- if (instrumenting) {
- %DebugAsyncTaskEvent({ type: "didHandle", id: id, name: name });
- }
- });
if (instrumenting) {
+ if (IsPromise(resolution)) {
+ // Mark the dependency of the new promise on the resolution
+ SET_PRIVATE(resolution, promiseHandledBySymbol, promise);
+ }
id = ++lastMicrotaskId;
- %DebugAsyncTaskEvent({ type: "enqueue", id: id, name: name });
+ before_debug_event = {
+ type: "willHandle",
+ id: id,
+ name: "PromiseResolveThenableJob"
+ };
+ after_debug_event = {
+ type: "didHandle",
+ id: id,
+ name: "PromiseResolveThenableJob"
+ };
+ %DebugAsyncTaskEvent({
+ type: "enqueue",
+ id: id,
+ name: "PromiseResolveThenableJob"
+ });
}
+ %EnqueuePromiseResolveThenableJob(
+ resolution, then, callbacks.resolve, callbacks.reject,
+ before_debug_event, after_debug_event);
return;
}
}
@@ -655,7 +655,7 @@ 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
]);
// 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