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

Side by Side Diff: src/promise.js

Issue 734163002: Allow stepping into Promise handlers. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years, 1 month 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/debug.cc ('k') | test/mjsunit/es6/debug-stepin-promises.js » ('j') | no next file with comments »
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 "use strict"; 5 "use strict";
6 6
7 // This file relies on the fact that the following declaration has been made 7 // This file relies on the fact that the following declaration has been made
8 // in runtime.js: 8 // in runtime.js:
9 // var $Object = global.Object 9 // var $Object = global.Object
10 // var $WeakMap = global.WeakMap 10 // var $WeakMap = global.WeakMap
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 } 96 }
97 return deferred.promise; 97 return deferred.promise;
98 } 98 }
99 } 99 }
100 return x; 100 return x;
101 } 101 }
102 102
103 function PromiseHandle(value, handler, deferred) { 103 function PromiseHandle(value, handler, deferred) {
104 try { 104 try {
105 %DebugPushPromise(deferred.promise); 105 %DebugPushPromise(deferred.promise);
106 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(handler);
107 if (stepping) %DebugPrepareStepInIfStepping(handler);
106 var result = handler(value); 108 var result = handler(value);
107 if (result === deferred.promise) 109 if (result === deferred.promise)
108 throw MakeTypeError('promise_cyclic', [result]); 110 throw MakeTypeError('promise_cyclic', [result]);
109 else if (IsPromise(result)) 111 else if (IsPromise(result))
110 %_CallFunction(result, deferred.resolve, deferred.reject, PromiseChain); 112 %_CallFunction(result, deferred.resolve, deferred.reject, PromiseChain);
111 else 113 else
112 deferred.resolve(result); 114 deferred.resolve(result);
113 } catch (exception) { 115 } catch (exception) {
114 try { deferred.reject(exception); } catch (e) { } 116 try { deferred.reject(exception); } catch (e) { }
115 } finally { 117 } finally {
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 onResolve = IS_SPEC_FUNCTION(onResolve) ? onResolve 265 onResolve = IS_SPEC_FUNCTION(onResolve) ? onResolve
264 : PromiseIdResolveHandler; 266 : PromiseIdResolveHandler;
265 onReject = IS_SPEC_FUNCTION(onReject) ? onReject 267 onReject = IS_SPEC_FUNCTION(onReject) ? onReject
266 : PromiseIdRejectHandler; 268 : PromiseIdRejectHandler;
267 var that = this; 269 var that = this;
268 var constructor = this.constructor; 270 var constructor = this.constructor;
269 return %_CallFunction( 271 return %_CallFunction(
270 this, 272 this,
271 function(x) { 273 function(x) {
272 x = PromiseCoerce(constructor, x); 274 x = PromiseCoerce(constructor, x);
273 return x === that ? onReject(MakeTypeError('promise_cyclic', [x])) : 275 if (x === that) {
274 IsPromise(x) ? x.then(onResolve, onReject) : onResolve(x); 276 if (DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(onReject)) {
Yang 2014/11/17 19:41:02 This conditional is used in a lot of places now. D
277 %DebugPrepareStepInIfStepping(onReject);
278 }
279 return onReject(MakeTypeError('promise_cyclic', [x]));
280 } else if (IsPromise(x)) {
281 return x.then(onResolve, onReject);
282 } else {
283 if (DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(onResolve)) {
284 %DebugPrepareStepInIfStepping(onResolve);
285 }
286 return onResolve(x);
287 }
275 }, 288 },
276 onReject, 289 onReject,
277 PromiseChain 290 PromiseChain
278 ); 291 );
279 } 292 }
280 293
281 // Combinators. 294 // Combinators.
282 295
283 function PromiseCast(x) { 296 function PromiseCast(x) {
284 // TODO(rossberg): cannot do better until we support @@create. 297 // TODO(rossberg): cannot do better until we support @@create.
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 "race", PromiseOne, 388 "race", PromiseOne,
376 "resolve", PromiseCast 389 "resolve", PromiseCast
377 ]); 390 ]);
378 InstallFunctions($Promise.prototype, DONT_ENUM, [ 391 InstallFunctions($Promise.prototype, DONT_ENUM, [
379 "chain", PromiseChain, 392 "chain", PromiseChain,
380 "then", PromiseThen, 393 "then", PromiseThen,
381 "catch", PromiseCatch 394 "catch", PromiseCatch
382 ]); 395 ]);
383 396
384 })(); 397 })();
OLDNEW
« no previous file with comments | « src/debug.cc ('k') | test/mjsunit/es6/debug-stepin-promises.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698