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

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

Issue 2161263003: [debug] use catch prediction flag for promise rejections. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 5 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 } 81 }
82 if (IS_UNDEFINED(new.target)) throw MakeTypeError(kNotAPromise, this); 82 if (IS_UNDEFINED(new.target)) throw MakeTypeError(kNotAPromise, this);
83 if (!IS_CALLABLE(executor)) { 83 if (!IS_CALLABLE(executor)) {
84 throw MakeTypeError(kResolverNotAFunction, executor); 84 throw MakeTypeError(kResolverNotAFunction, executor);
85 } 85 }
86 86
87 var promise = PromiseInit(%_NewObject(GlobalPromise, new.target)); 87 var promise = PromiseInit(%_NewObject(GlobalPromise, new.target));
88 var callbacks = CreateResolvingFunctions(promise); 88 var callbacks = CreateResolvingFunctions(promise);
89 var debug_is_active = DEBUG_IS_ACTIVE; 89 var debug_is_active = DEBUG_IS_ACTIVE;
90 try { 90 try {
91 if (debug_is_active) %DebugPushPromise(promise, Promise); 91 if (debug_is_active) %DebugPushPromise(promise);
92 executor(callbacks.resolve, callbacks.reject); 92 executor(callbacks.resolve, callbacks.reject);
93 } catch (e) { 93 } %catch (e) { // Natives syntax to mark this catch block.
94 %_Call(callbacks.reject, UNDEFINED, e); 94 %_Call(callbacks.reject, UNDEFINED, e);
95 } finally { 95 } finally {
96 if (debug_is_active) %DebugPopPromise(); 96 if (debug_is_active) %DebugPopPromise();
97 } 97 }
98 98
99 return promise; 99 return promise;
100 } 100 }
101 101
102 // Core functionality. 102 // Core functionality.
103 103
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 var deferreds = GET_PRIVATE(promise, promiseDeferredReactionsSymbol); 150 var deferreds = GET_PRIVATE(promise, promiseDeferredReactionsSymbol);
151 PromiseEnqueue(value, tasks, deferreds, status); 151 PromiseEnqueue(value, tasks, deferreds, status);
152 } 152 }
153 PromiseSet(promise, status, value); 153 PromiseSet(promise, status, value);
154 } 154 }
155 } 155 }
156 156
157 function PromiseHandle(value, handler, deferred) { 157 function PromiseHandle(value, handler, deferred) {
158 var debug_is_active = DEBUG_IS_ACTIVE; 158 var debug_is_active = DEBUG_IS_ACTIVE;
159 try { 159 try {
160 if (debug_is_active) %DebugPushPromise(deferred.promise, PromiseHandle); 160 if (debug_is_active) %DebugPushPromise(deferred.promise);
161 var result = handler(value); 161 var result = handler(value);
162 deferred.resolve(result); 162 deferred.resolve(result);
163 } catch (exception) { 163 } %catch (exception) { // Natives syntax to mark this catch block.
164 try { deferred.reject(exception); } catch (e) { } 164 try { deferred.reject(exception); } catch (e) { }
165 } finally { 165 } finally {
166 if (debug_is_active) %DebugPopPromise(); 166 if (debug_is_active) %DebugPopPromise();
167 } 167 }
168 } 168 }
169 169
170 function PromiseEnqueue(value, tasks, deferreds, status) { 170 function PromiseEnqueue(value, tasks, deferreds, status) {
171 var id, name, instrumenting = DEBUG_IS_ACTIVE; 171 var id, name, instrumenting = DEBUG_IS_ACTIVE;
172 %EnqueueMicrotask(function() { 172 %EnqueueMicrotask(function() {
173 if (instrumenting) { 173 if (instrumenting) {
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 to.PromiseChain = PromiseChain; 619 to.PromiseChain = PromiseChain;
620 to.PromiseDefer = PromiseDefer; 620 to.PromiseDefer = PromiseDefer;
621 to.PromiseAccept = PromiseAccept; 621 to.PromiseAccept = PromiseAccept;
622 622
623 to.PromiseCreateRejected = PromiseCreateRejected; 623 to.PromiseCreateRejected = PromiseCreateRejected;
624 to.PromiseCreateResolved = PromiseCreateResolved; 624 to.PromiseCreateResolved = PromiseCreateResolved;
625 to.PromiseThen = PromiseThen; 625 to.PromiseThen = PromiseThen;
626 }); 626 });
627 627
628 }) 628 })
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698