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

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

Issue 1404783002: Debugger: allow stepping into resolver from Promise constructor. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 2 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/js/macros.py ('k') | src/runtime/runtime.h » ('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 (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 16 matching lines...) Expand all
27 // Status values: 0 = pending, +1 = resolved, -1 = rejected 27 // Status values: 0 = pending, +1 = resolved, -1 = rejected
28 var lastMicrotaskId = 0; 28 var lastMicrotaskId = 0;
29 29
30 var GlobalPromise = function Promise(resolver) { 30 var GlobalPromise = function Promise(resolver) {
31 if (resolver === promiseRawSymbol) return; 31 if (resolver === promiseRawSymbol) return;
32 if (!%_IsConstructCall()) throw MakeTypeError(kNotAPromise, this); 32 if (!%_IsConstructCall()) throw MakeTypeError(kNotAPromise, this);
33 if (!IS_CALLABLE(resolver)) 33 if (!IS_CALLABLE(resolver))
34 throw MakeTypeError(kResolverNotAFunction, resolver); 34 throw MakeTypeError(kResolverNotAFunction, resolver);
35 var promise = PromiseInit(this); 35 var promise = PromiseInit(this);
36 try { 36 try {
37 %DebugPushPromise(promise, Promise); 37 %DebugPushPromise(promise, Promise, resolver);
38 resolver(function(x) { PromiseResolve(promise, x) }, 38 resolver(function(x) { PromiseResolve(promise, x) },
39 function(r) { PromiseReject(promise, r) }); 39 function(r) { PromiseReject(promise, r) });
40 } catch (e) { 40 } catch (e) {
41 PromiseReject(promise, e); 41 PromiseReject(promise, e);
42 } finally { 42 } finally {
43 %DebugPopPromise(); 43 %DebugPopPromise();
44 } 44 }
45 } 45 }
46 46
47 // Core functionality. 47 // Core functionality.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 deferred.reject(r); 93 deferred.reject(r);
94 } 94 }
95 return deferred.promise; 95 return deferred.promise;
96 } 96 }
97 } 97 }
98 return x; 98 return x;
99 } 99 }
100 100
101 function PromiseHandle(value, handler, deferred) { 101 function PromiseHandle(value, handler, deferred) {
102 try { 102 try {
103 %DebugPushPromise(deferred.promise, PromiseHandle); 103 %DebugPushPromise(deferred.promise, PromiseHandle, handler);
104 DEBUG_PREPARE_STEP_IN_IF_STEPPING(handler);
105 var result = handler(value); 104 var result = handler(value);
106 if (result === deferred.promise) 105 if (result === deferred.promise)
107 throw MakeTypeError(kPromiseCyclic, result); 106 throw MakeTypeError(kPromiseCyclic, result);
108 else if (IsPromise(result)) 107 else if (IsPromise(result))
109 %_CallFunction(result, deferred.resolve, deferred.reject, PromiseChain); 108 %_CallFunction(result, deferred.resolve, deferred.reject, PromiseChain);
110 else 109 else
111 deferred.resolve(result); 110 deferred.resolve(result);
112 } catch (exception) { 111 } catch (exception) {
113 try { deferred.reject(exception); } catch (e) { } 112 try { deferred.reject(exception); } catch (e) { }
114 } finally { 113 } finally {
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 // This allows extras to create promises quickly without building extra 393 // This allows extras to create promises quickly without building extra
395 // resolve/reject closures, and allows them to later resolve and reject any 394 // resolve/reject closures, and allows them to later resolve and reject any
396 // promise without having to hold on to those closures forever. 395 // promise without having to hold on to those closures forever.
397 utils.InstallFunctions(extrasUtils, 0, [ 396 utils.InstallFunctions(extrasUtils, 0, [
398 "createPromise", PromiseCreate, 397 "createPromise", PromiseCreate,
399 "resolvePromise", PromiseResolve, 398 "resolvePromise", PromiseResolve,
400 "rejectPromise", PromiseReject 399 "rejectPromise", PromiseReject
401 ]); 400 ]);
402 401
403 }) 402 })
OLDNEW
« no previous file with comments | « src/js/macros.py ('k') | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698