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/builtins/builtins-promise.h" | 5 #include "src/builtins/builtins-promise.h" |
6 #include "src/builtins/builtins-constructor.h" | 6 #include "src/builtins/builtins-constructor.h" |
7 #include "src/builtins/builtins-utils.h" | 7 #include "src/builtins/builtins-utils.h" |
8 #include "src/builtins/builtins.h" | 8 #include "src/builtins/builtins.h" |
9 #include "src/code-factory.h" | 9 #include "src/code-factory.h" |
10 #include "src/code-stub-assembler.h" | 10 #include "src/code-stub-assembler.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 Node* PromiseBuiltinsAssembler::AllocateAndInitJSPromise(Node* context) { | 35 Node* PromiseBuiltinsAssembler::AllocateAndInitJSPromise(Node* context) { |
36 return AllocateAndInitJSPromise(context, UndefinedConstant()); | 36 return AllocateAndInitJSPromise(context, UndefinedConstant()); |
37 } | 37 } |
38 | 38 |
39 Node* PromiseBuiltinsAssembler::AllocateAndInitJSPromise(Node* context, | 39 Node* PromiseBuiltinsAssembler::AllocateAndInitJSPromise(Node* context, |
40 Node* parent) { | 40 Node* parent) { |
41 Node* const instance = AllocateJSPromise(context); | 41 Node* const instance = AllocateJSPromise(context); |
42 PromiseInit(instance); | 42 PromiseInit(instance); |
43 | 43 |
44 Label out(this); | 44 Label out(this); |
45 GotoUnless(IsPromiseHookEnabled(), &out); | 45 GotoUnless(IsPromiseHookEnabledOrDebugIsActive(), &out); |
46 CallRuntime(Runtime::kPromiseHookInit, context, instance, parent); | 46 CallRuntime(Runtime::kPromiseHookInit, context, instance, parent); |
47 Goto(&out); | 47 Goto(&out); |
48 | 48 |
49 Bind(&out); | 49 Bind(&out); |
50 return instance; | 50 return instance; |
51 } | 51 } |
52 | 52 |
53 Node* PromiseBuiltinsAssembler::AllocateAndSetJSPromise(Node* context, | 53 Node* PromiseBuiltinsAssembler::AllocateAndSetJSPromise(Node* context, |
54 Node* status, | 54 Node* status, |
55 Node* result) { | 55 Node* result) { |
56 CSA_ASSERT(this, TaggedIsSmi(status)); | 56 CSA_ASSERT(this, TaggedIsSmi(status)); |
57 | 57 |
58 Node* const instance = AllocateJSPromise(context); | 58 Node* const instance = AllocateJSPromise(context); |
59 | 59 |
60 StoreObjectFieldNoWriteBarrier(instance, JSPromise::kStatusOffset, status); | 60 StoreObjectFieldNoWriteBarrier(instance, JSPromise::kStatusOffset, status); |
61 StoreObjectFieldNoWriteBarrier(instance, JSPromise::kResultOffset, result); | 61 StoreObjectFieldNoWriteBarrier(instance, JSPromise::kResultOffset, result); |
62 StoreObjectFieldNoWriteBarrier(instance, JSPromise::kFlagsOffset, | 62 StoreObjectFieldNoWriteBarrier(instance, JSPromise::kFlagsOffset, |
63 SmiConstant(0)); | 63 SmiConstant(0)); |
64 | 64 |
65 Label out(this); | 65 Label out(this); |
66 GotoUnless(IsPromiseHookEnabled(), &out); | 66 GotoUnless(IsPromiseHookEnabledOrDebugIsActive(), &out); |
67 CallRuntime(Runtime::kPromiseHookInit, context, instance, | 67 CallRuntime(Runtime::kPromiseHookInit, context, instance, |
68 UndefinedConstant()); | 68 UndefinedConstant()); |
69 Goto(&out); | 69 Goto(&out); |
70 | 70 |
71 Bind(&out); | 71 Bind(&out); |
72 return instance; | 72 return instance; |
73 } | 73 } |
74 | 74 |
75 std::pair<Node*, Node*> | 75 std::pair<Node*, Node*> |
76 PromiseBuiltinsAssembler::CreatePromiseResolvingFunctions( | 76 PromiseBuiltinsAssembler::CreatePromiseResolvingFunctions( |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 capability, JSPromiseCapability::kPromiseOffset, promise); | 127 capability, JSPromiseCapability::kPromiseOffset, promise); |
128 | 128 |
129 Node* resolve = nullptr; | 129 Node* resolve = nullptr; |
130 Node* reject = nullptr; | 130 Node* reject = nullptr; |
131 | 131 |
132 std::tie(resolve, reject) = | 132 std::tie(resolve, reject) = |
133 CreatePromiseResolvingFunctions(promise, debug_event, native_context); | 133 CreatePromiseResolvingFunctions(promise, debug_event, native_context); |
134 StoreObjectField(capability, JSPromiseCapability::kResolveOffset, resolve); | 134 StoreObjectField(capability, JSPromiseCapability::kResolveOffset, resolve); |
135 StoreObjectField(capability, JSPromiseCapability::kRejectOffset, reject); | 135 StoreObjectField(capability, JSPromiseCapability::kRejectOffset, reject); |
136 | 136 |
137 GotoUnless(IsPromiseHookEnabled(), &out); | 137 GotoUnless(IsPromiseHookEnabledOrDebugIsActive(), &out); |
138 CallRuntime(Runtime::kPromiseHookInit, context, promise, | 138 CallRuntime(Runtime::kPromiseHookInit, context, promise, |
139 UndefinedConstant()); | 139 UndefinedConstant()); |
140 Goto(&out); | 140 Goto(&out); |
141 } | 141 } |
142 | 142 |
143 Bind(&if_custom_promise); | 143 Bind(&if_custom_promise); |
144 { | 144 { |
145 Label if_notcallable(this, Label::kDeferred); | 145 Label if_notcallable(this, Label::kDeferred); |
146 Node* executor_context = | 146 Node* executor_context = |
147 CreatePromiseGetCapabilitiesExecutorContext(capability, native_context); | 147 CreatePromiseGetCapabilitiesExecutorContext(capability, native_context); |
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1067 } | 1067 } |
1068 | 1068 |
1069 Bind(&if_targetismodified); | 1069 Bind(&if_targetismodified); |
1070 { | 1070 { |
1071 ConstructorBuiltinsAssembler constructor_assembler(this->state()); | 1071 ConstructorBuiltinsAssembler constructor_assembler(this->state()); |
1072 Node* const instance = constructor_assembler.EmitFastNewObject( | 1072 Node* const instance = constructor_assembler.EmitFastNewObject( |
1073 context, promise_fun, new_target); | 1073 context, promise_fun, new_target); |
1074 PromiseInit(instance); | 1074 PromiseInit(instance); |
1075 var_result.Bind(instance); | 1075 var_result.Bind(instance); |
1076 | 1076 |
1077 GotoUnless(IsPromiseHookEnabled(), &debug_push); | 1077 GotoUnless(IsPromiseHookEnabledOrDebugIsActive(), &debug_push); |
1078 CallRuntime(Runtime::kPromiseHookInit, context, instance, | 1078 CallRuntime(Runtime::kPromiseHookInit, context, instance, |
1079 UndefinedConstant()); | 1079 UndefinedConstant()); |
1080 Goto(&debug_push); | 1080 Goto(&debug_push); |
1081 } | 1081 } |
1082 | 1082 |
1083 Bind(&debug_push); | 1083 Bind(&debug_push); |
1084 { | 1084 { |
1085 GotoUnless(is_debug_active, &run_executor); | 1085 GotoUnless(is_debug_active, &run_executor); |
1086 CallRuntime(Runtime::kDebugPushPromise, context, var_result.value()); | 1086 CallRuntime(Runtime::kDebugPushPromise, context, var_result.value()); |
1087 Goto(&run_executor); | 1087 Goto(&run_executor); |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1537 Node* const reason = Parameter(2); | 1537 Node* const reason = Parameter(2); |
1538 Node* const debug_event = Parameter(3); | 1538 Node* const debug_event = Parameter(3); |
1539 Node* const context = Parameter(6); | 1539 Node* const context = Parameter(6); |
1540 | 1540 |
1541 InternalPromiseReject(context, promise, reason, debug_event); | 1541 InternalPromiseReject(context, promise, reason, debug_event); |
1542 Return(UndefinedConstant()); | 1542 Return(UndefinedConstant()); |
1543 } | 1543 } |
1544 | 1544 |
1545 } // namespace internal | 1545 } // namespace internal |
1546 } // namespace v8 | 1546 } // namespace v8 |
OLD | NEW |