OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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 #include "src/code-stub-assembler.h" | 5 #include "src/code-stub-assembler.h" |
6 | 6 |
7 namespace v8 { | 7 namespace v8 { |
8 namespace internal { | 8 namespace internal { |
9 | 9 |
10 typedef compiler::Node Node; | 10 typedef compiler::Node Node; |
11 typedef CodeStubAssembler::ParameterMode ParameterMode; | 11 typedef CodeStubAssembler::ParameterMode ParameterMode; |
12 typedef compiler::CodeAssemblerState CodeAssemblerState; | 12 typedef compiler::CodeAssemblerState CodeAssemblerState; |
13 | 13 |
14 class PromiseBuiltinsAssembler : public CodeStubAssembler { | 14 class PromiseBuiltinsAssembler : public CodeStubAssembler { |
15 public: | 15 public: |
16 explicit PromiseBuiltinsAssembler(CodeAssemblerState* state) | 16 explicit PromiseBuiltinsAssembler(CodeAssemblerState* state) |
17 : CodeStubAssembler(state) {} | 17 : CodeStubAssembler(state) {} |
18 | 18 |
19 // These allocate and initialize a promise with pending state and | 19 // These allocate and initialize a promise with pending state and |
20 // undefined fields. | 20 // undefined fields. |
21 // | 21 // |
22 // This uses undefined as the parent promise for the promise init | 22 // This uses undefined as the parent promise for the promise init |
23 // hook. | 23 // hook. |
24 Node* AllocateAndInitJSPromise(Node* context); | 24 Node* AllocateAndInitJSPromise(Node* context); |
25 // This uses the given parent as the parent promise for the promise | 25 // This uses the given parent as the parent promise for the promise |
26 // init hook. | 26 // init hook. |
27 Node* AllocateAndInitJSPromise(Node* context, Node* parent); | 27 Node* AllocateAndInitJSPromise(Node* context, Node* parent); |
28 | 28 |
| 29 // Allocate and initialize a Promise with pending state and undefined fields, |
| 30 // without invoking Promise Hooks. This is suitable for internal Promises |
| 31 // not exposed to JS code. |
| 32 Node* AllocateAndInitInternalJSPromise(Node* context); |
| 33 |
29 // This allocates and initializes a promise with the given state and | 34 // This allocates and initializes a promise with the given state and |
30 // fields. | 35 // fields. |
31 Node* AllocateAndSetJSPromise(Node* context, Node* status, Node* result); | 36 Node* AllocateAndSetJSPromise(Node* context, Node* status, Node* result); |
32 | 37 |
33 Node* AllocatePromiseResolveThenableJobInfo(Node* result, Node* then, | 38 Node* AllocatePromiseResolveThenableJobInfo(Node* result, Node* then, |
34 Node* resolve, Node* reject, | 39 Node* resolve, Node* reject, |
35 Node* context); | 40 Node* context); |
36 | 41 |
37 Node* ThrowIfNotJSReceiver(Node* context, Node* value, | 42 Node* ThrowIfNotJSReceiver(Node* context, Node* value, |
38 MessageTemplate::Template msg_template, | 43 MessageTemplate::Template msg_template, |
(...skipping 11 matching lines...) Expand all Loading... |
50 | 55 |
51 Node* InternalPromiseThen(Node* context, Node* promise, Node* on_resolve, | 56 Node* InternalPromiseThen(Node* context, Node* promise, Node* on_resolve, |
52 Node* on_reject); | 57 Node* on_reject); |
53 | 58 |
54 Node* InternalPerformPromiseThen(Node* context, Node* promise, | 59 Node* InternalPerformPromiseThen(Node* context, Node* promise, |
55 Node* on_resolve, Node* on_reject, | 60 Node* on_resolve, Node* on_reject, |
56 Node* deferred_promise, | 61 Node* deferred_promise, |
57 Node* deferred_on_resolve, | 62 Node* deferred_on_resolve, |
58 Node* deferred_on_reject); | 63 Node* deferred_on_reject); |
59 | 64 |
| 65 void FastPerformPromiseThen(Node* context, Node* promise, |
| 66 Node* on_resolve = nullptr, |
| 67 Node* on_reject = nullptr, |
| 68 Node* result_promise = nullptr); |
| 69 |
60 void InternalResolvePromise(Node* context, Node* promise, Node* result); | 70 void InternalResolvePromise(Node* context, Node* promise, Node* result); |
61 | 71 |
62 void BranchIfFastPath(Node* context, Node* promise, Label* if_isunmodified, | 72 void BranchIfFastPath(Node* context, Node* promise, Label* if_isunmodified, |
63 Label* if_ismodified); | 73 Label* if_ismodified); |
64 | 74 |
65 void BranchIfFastPath(Node* native_context, Node* promise_fun, Node* promise, | 75 void BranchIfFastPath(Node* native_context, Node* promise_fun, Node* promise, |
66 Label* if_isunmodified, Label* if_ismodified); | 76 Label* if_isunmodified, Label* if_ismodified); |
67 | 77 |
68 Node* CreatePromiseContext(Node* native_context, int slots); | 78 Node* CreatePromiseContext(Node* native_context, int slots); |
69 Node* CreatePromiseResolvingFunctionsContext(Node* promise, Node* debug_event, | 79 Node* CreatePromiseResolvingFunctionsContext(Node* promise, Node* debug_event, |
(...skipping 13 matching lines...) Expand all Loading... |
83 | 93 |
84 protected: | 94 protected: |
85 void PromiseInit(Node* promise); | 95 void PromiseInit(Node* promise); |
86 | 96 |
87 private: | 97 private: |
88 Node* AllocateJSPromise(Node* context); | 98 Node* AllocateJSPromise(Node* context); |
89 }; | 99 }; |
90 | 100 |
91 } // namespace internal | 101 } // namespace internal |
92 } // namespace v8 | 102 } // namespace v8 |
OLD | NEW |