OLD | NEW |
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 21 matching lines...) Expand all Loading... |
32 | 32 |
33 utils.Import(function(from) { | 33 utils.Import(function(from) { |
34 ObjectHasOwnProperty = from.ObjectHasOwnProperty; | 34 ObjectHasOwnProperty = from.ObjectHasOwnProperty; |
35 SpeciesConstructor = from.SpeciesConstructor; | 35 SpeciesConstructor = from.SpeciesConstructor; |
36 }); | 36 }); |
37 | 37 |
38 // ------------------------------------------------------------------- | 38 // ------------------------------------------------------------------- |
39 | 39 |
40 // Core functionality. | 40 // Core functionality. |
41 | 41 |
42 function PromiseDebugGetInfo(deferreds, status) { | 42 function PromiseDebugGetInfo(deferreds, status, id) { |
43 var id, name, instrumenting = DEBUG_IS_ACTIVE; | 43 var name, instrumenting = DEBUG_IS_ACTIVE; |
44 | |
45 if (instrumenting) { | 44 if (instrumenting) { |
46 // In an async function, reuse the existing stack related to the outer | 45 // In an async function, reuse the existing stack related to the outer |
47 // Promise. Otherwise, e.g. in a direct call to then, save a new stack. | 46 // Promise. Otherwise, e.g. in a direct call to then, save a new stack. |
48 // Promises with multiple reactions with one or more of them being async | 47 // Promises with multiple reactions with one or more of them being async |
49 // functions will not get a good stack trace, as async functions require | 48 // functions will not get a good stack trace, as async functions require |
50 // different stacks from direct Promise use, but we save and restore a | 49 // different stacks from direct Promise use, but we save and restore a |
51 // stack once for all reactions. TODO(littledan): Improve this case. | 50 // stack once for all reactions. TODO(littledan): Improve this case. |
52 if (!IS_UNDEFINED(deferreds) && | 51 if (!IS_UNDEFINED(deferreds) && |
53 HAS_PRIVATE(deferreds.promise, promiseHandledBySymbol) && | 52 HAS_PRIVATE(deferreds.promise, promiseHandledBySymbol) && |
54 HAS_PRIVATE(GET_PRIVATE(deferreds.promise, promiseHandledBySymbol), | 53 HAS_PRIVATE(GET_PRIVATE(deferreds.promise, promiseHandledBySymbol), |
55 promiseAsyncStackIDSymbol)) { | 54 promiseAsyncStackIDSymbol)) { |
56 id = GET_PRIVATE(GET_PRIVATE(deferreds.promise, promiseHandledBySymbol), | 55 id = GET_PRIVATE(GET_PRIVATE(deferreds.promise, promiseHandledBySymbol), |
57 promiseAsyncStackIDSymbol); | 56 promiseAsyncStackIDSymbol); |
58 name = "async function"; | 57 name = "async function"; |
59 } else { | 58 } else { |
60 id = %DebugNextMicrotaskId(); | |
61 name = status === kFulfilled ? "Promise.resolve" : "Promise.reject"; | 59 name = status === kFulfilled ? "Promise.resolve" : "Promise.reject"; |
62 %DebugAsyncTaskEvent("enqueue", id, name); | |
63 } | 60 } |
64 } | 61 } |
65 return [id, name]; | 62 return [id, name]; |
66 } | 63 } |
67 | 64 |
68 function PromiseIdResolveHandler(x) { return x; } | 65 function PromiseIdResolveHandler(x) { return x; } |
69 function PromiseIdRejectHandler(r) { %_ReThrow(r); } | 66 function PromiseIdRejectHandler(r) { %_ReThrow(r); } |
70 SET_PRIVATE(PromiseIdRejectHandler, promiseForwardingHandlerSymbol, true); | 67 SET_PRIVATE(PromiseIdRejectHandler, promiseForwardingHandlerSymbol, true); |
71 | 68 |
72 // ------------------------------------------------------------------- | 69 // ------------------------------------------------------------------- |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 | 384 |
388 utils.Export(function(to) { | 385 utils.Export(function(to) { |
389 to.PromiseCreate = PromiseCreate; | 386 to.PromiseCreate = PromiseCreate; |
390 to.PromiseThen = PromiseThen; | 387 to.PromiseThen = PromiseThen; |
391 | 388 |
392 to.CreateInternalPromiseCapability = CreateInternalPromiseCapability; | 389 to.CreateInternalPromiseCapability = CreateInternalPromiseCapability; |
393 to.RejectPromise = RejectPromise; | 390 to.RejectPromise = RejectPromise; |
394 }); | 391 }); |
395 | 392 |
396 }) | 393 }) |
OLD | NEW |