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

Side by Side Diff: src/js/promise.js

Issue 2314903004: [promises] Move PromiseResolveThenableJob to c++ (Closed)
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « src/isolate.cc ('k') | src/objects.h » ('j') | src/objects.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 (function(global, utils, extrasUtils) { 5 (function(global, utils, extrasUtils) {
6 6
7 "use strict"; 7 "use strict";
8 8
9 %CheckIsBootstrapping(); 9 %CheckIsBootstrapping();
10 10
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 %PromiseRevokeReject(resolution); 272 %PromiseRevokeReject(resolution);
273 } 273 }
274 // Don't cause a debug event as this case is forwarding a rejection 274 // Don't cause a debug event as this case is forwarding a rejection
275 RejectPromise(promise, thenableValue, false); 275 RejectPromise(promise, thenableValue, false);
276 SET_PRIVATE(resolution, promiseHasHandlerSymbol, true); 276 SET_PRIVATE(resolution, promiseHasHandlerSymbol, true);
277 return; 277 return;
278 } 278 }
279 } 279 }
280 280
281 if (IS_CALLABLE(then)) { 281 if (IS_CALLABLE(then)) {
282 // PromiseResolveThenableJob 282 var callbacks = CreateResolvingFunctions(promise, false);
283 var id; 283 %EnqueuePromiseResolveThenableJob(
284 var name = "PromiseResolveThenableJob"; 284 promise, resolution, then, callbacks.resolve, callbacks.reject);
285 var instrumenting = DEBUG_IS_ACTIVE;
286 %EnqueueMicrotask(function() {
287 if (instrumenting) {
288 %DebugAsyncTaskEvent({ type: "willHandle", id: id, name: name });
289 }
290 // These resolving functions simply forward the exception, so
291 // don't create a new debugEvent.
292 var callbacks = CreateResolvingFunctions(promise, false);
293 try {
294 %_Call(then, resolution, callbacks.resolve, callbacks.reject);
295 } catch (e) {
296 %_Call(callbacks.reject, UNDEFINED, e);
297 }
298 if (instrumenting) {
299 %DebugAsyncTaskEvent({ type: "didHandle", id: id, name: name });
300 }
301 });
302 if (instrumenting) {
303 id = ++lastMicrotaskId;
304 %DebugAsyncTaskEvent({ type: "enqueue", id: id, name: name });
305 }
306 return; 285 return;
307 } 286 }
308 } 287 }
309 FulfillPromise(promise, kFulfilled, resolution, promiseFulfillReactionsSymbol) ; 288 FulfillPromise(promise, kFulfilled, resolution, promiseFulfillReactionsSymbol) ;
310 } 289 }
311 290
312 // ES#sec-rejectpromise 291 // ES#sec-rejectpromise
313 // RejectPromise ( promise, reason ) 292 // RejectPromise ( promise, reason )
314 function RejectPromise(promise, reason, debugEvent) { 293 function RejectPromise(promise, reason, debugEvent) {
315 // Check promise status to confirm that this reject has an effect. 294 // Check promise status to confirm that this reject has an effect.
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 "then", PromiseThen, 582 "then", PromiseThen,
604 "catch", PromiseCatch 583 "catch", PromiseCatch
605 ]); 584 ]);
606 585
607 %InstallToContext([ 586 %InstallToContext([
608 "promise_catch", PromiseCatch, 587 "promise_catch", PromiseCatch,
609 "promise_create", PromiseCreate, 588 "promise_create", PromiseCreate,
610 "promise_has_user_defined_reject_handler", PromiseHasUserDefinedRejectHandler, 589 "promise_has_user_defined_reject_handler", PromiseHasUserDefinedRejectHandler,
611 "promise_reject", DoRejectPromise, 590 "promise_reject", DoRejectPromise,
612 "promise_resolve", ResolvePromise, 591 "promise_resolve", ResolvePromise,
613 "promise_then", PromiseThen, 592 "promise_then", PromiseThen
614 ]); 593 ]);
615 594
616 // This allows extras to create promises quickly without building extra 595 // This allows extras to create promises quickly without building extra
617 // resolve/reject closures, and allows them to later resolve and reject any 596 // resolve/reject closures, and allows them to later resolve and reject any
618 // promise without having to hold on to those closures forever. 597 // promise without having to hold on to those closures forever.
619 utils.InstallFunctions(extrasUtils, 0, [ 598 utils.InstallFunctions(extrasUtils, 0, [
620 "createPromise", PromiseCreate, 599 "createPromise", PromiseCreate,
621 "resolvePromise", ResolvePromise, 600 "resolvePromise", ResolvePromise,
622 "rejectPromise", DoRejectPromise 601 "rejectPromise", DoRejectPromise
623 ]); 602 ]);
624 603
625 utils.Export(function(to) { 604 utils.Export(function(to) {
626 to.PromiseCastResolved = PromiseCastResolved; 605 to.PromiseCastResolved = PromiseCastResolved;
627 to.PromiseThen = PromiseThen; 606 to.PromiseThen = PromiseThen;
628 607
629 to.GlobalPromise = GlobalPromise; 608 to.GlobalPromise = GlobalPromise;
630 to.NewPromiseCapability = NewPromiseCapability; 609 to.NewPromiseCapability = NewPromiseCapability;
631 to.PerformPromiseThen = PerformPromiseThen; 610 to.PerformPromiseThen = PerformPromiseThen;
632 to.RejectPromise = RejectPromise; 611 to.RejectPromise = RejectPromise;
633 }); 612 });
634 613
635 }) 614 })
OLDNEW
« no previous file with comments | « src/isolate.cc ('k') | src/objects.h » ('j') | src/objects.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698