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

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

Issue 2314903004: [promises] Move PromiseResolveThenableJob to c++ (Closed)
Patch Set: dont create handles if not in debug 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
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 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 %PromiseRevokeReject(resolution); 276 %PromiseRevokeReject(resolution);
277 } 277 }
278 // Don't cause a debug event as this case is forwarding a rejection 278 // Don't cause a debug event as this case is forwarding a rejection
279 RejectPromise(promise, thenableValue, false); 279 RejectPromise(promise, thenableValue, false);
280 SET_PRIVATE(resolution, promiseHasHandlerSymbol, true); 280 SET_PRIVATE(resolution, promiseHasHandlerSymbol, true);
281 return; 281 return;
282 } 282 }
283 } 283 }
284 284
285 if (IS_CALLABLE(then)) { 285 if (IS_CALLABLE(then)) {
286 // PromiseResolveThenableJob 286 var callbacks = CreateResolvingFunctions(promise, false);
287 var id; 287 var id, before_debug_event, after_debug_event;
288 var name = "PromiseResolveThenableJob"; 288 if (DEBUG_IS_ACTIVE) {
289 var instrumenting = DEBUG_IS_ACTIVE;
290 %EnqueueMicrotask(function() {
291 if (instrumenting) {
292 %DebugAsyncTaskEvent({ type: "willHandle", id: id, name: name });
293 }
294 // These resolving functions simply forward the exception, so
295 // don't create a new debugEvent.
296 var callbacks = CreateResolvingFunctions(promise, false);
297 try {
298 %_Call(then, resolution, callbacks.resolve, callbacks.reject);
299 } catch (e) {
300 %_Call(callbacks.reject, UNDEFINED, e);
301 }
302 if (instrumenting) {
303 %DebugAsyncTaskEvent({ type: "didHandle", id: id, name: name });
304 }
305 });
306 if (instrumenting) {
307 id = ++lastMicrotaskId; 289 id = ++lastMicrotaskId;
308 %DebugAsyncTaskEvent({ type: "enqueue", id: id, name: name }); 290 before_debug_event = {
291 type: "willHandle",
292 id: id,
293 name: "PromiseResolveThenableJob"
294 };
295 after_debug_event = {
296 type: "didHandle",
297 id: id,
298 name: "PromiseResolveThenableJob"
299 };
300 %DebugAsyncTaskEvent({
301 type: "enqueue",
302 id: id,
303 name: "PromiseResolveThenableJob"
304 });
309 } 305 }
306 %EnqueuePromiseResolveThenableJob(
307 resolution, then, callbacks.resolve, callbacks.reject,
308 before_debug_event, after_debug_event);
310 return; 309 return;
311 } 310 }
312 } 311 }
313 FulfillPromise(promise, kFulfilled, resolution, promiseFulfillReactionsSymbol) ; 312 FulfillPromise(promise, kFulfilled, resolution, promiseFulfillReactionsSymbol) ;
314 } 313 }
315 314
316 // ES#sec-rejectpromise 315 // ES#sec-rejectpromise
317 // RejectPromise ( promise, reason ) 316 // RejectPromise ( promise, reason )
318 function RejectPromise(promise, reason, debugEvent) { 317 function RejectPromise(promise, reason, debugEvent) {
319 // Check promise status to confirm that this reject has an effect. 318 // Check promise status to confirm that this reject has an effect.
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 "then", PromiseThen, 605 "then", PromiseThen,
607 "catch", PromiseCatch 606 "catch", PromiseCatch
608 ]); 607 ]);
609 608
610 %InstallToContext([ 609 %InstallToContext([
611 "promise_catch", PromiseCatch, 610 "promise_catch", PromiseCatch,
612 "promise_create", PromiseCreate, 611 "promise_create", PromiseCreate,
613 "promise_has_user_defined_reject_handler", PromiseHasUserDefinedRejectHandler, 612 "promise_has_user_defined_reject_handler", PromiseHasUserDefinedRejectHandler,
614 "promise_reject", DoRejectPromise, 613 "promise_reject", DoRejectPromise,
615 "promise_resolve", ResolvePromise, 614 "promise_resolve", ResolvePromise,
616 "promise_then", PromiseThen, 615 "promise_then", PromiseThen
617 ]); 616 ]);
618 617
619 // This allows extras to create promises quickly without building extra 618 // This allows extras to create promises quickly without building extra
620 // resolve/reject closures, and allows them to later resolve and reject any 619 // resolve/reject closures, and allows them to later resolve and reject any
621 // promise without having to hold on to those closures forever. 620 // promise without having to hold on to those closures forever.
622 utils.InstallFunctions(extrasUtils, 0, [ 621 utils.InstallFunctions(extrasUtils, 0, [
623 "createPromise", PromiseCreate, 622 "createPromise", PromiseCreate,
624 "resolvePromise", ResolvePromise, 623 "resolvePromise", ResolvePromise,
625 "rejectPromise", DoRejectPromise 624 "rejectPromise", DoRejectPromise
626 ]); 625 ]);
627 626
628 utils.Export(function(to) { 627 utils.Export(function(to) {
629 to.IsPromise = IsPromise; 628 to.IsPromise = IsPromise;
630 to.PromiseCreate = PromiseCreate; 629 to.PromiseCreate = PromiseCreate;
631 to.PromiseThen = PromiseThen; 630 to.PromiseThen = PromiseThen;
632 631
633 to.GlobalPromise = GlobalPromise; 632 to.GlobalPromise = GlobalPromise;
634 to.NewPromiseCapability = NewPromiseCapability; 633 to.NewPromiseCapability = NewPromiseCapability;
635 to.PerformPromiseThen = PerformPromiseThen; 634 to.PerformPromiseThen = PerformPromiseThen;
636 to.ResolvePromise = ResolvePromise; 635 to.ResolvePromise = ResolvePromise;
637 to.RejectPromise = RejectPromise; 636 to.RejectPromise = RejectPromise;
638 }); 637 });
639 638
640 }) 639 })
OLDNEW
« src/isolate.cc ('K') | « src/isolate.cc ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698