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 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 return IsSetWord(SmiUntag(flags), 1 << JSPromise::kHasHandlerBit); | 264 return IsSetWord(SmiUntag(flags), 1 << JSPromise::kHasHandlerBit); |
265 } | 265 } |
266 | 266 |
267 void PromiseBuiltinsAssembler::PromiseSetHasHandler(Node* promise) { | 267 void PromiseBuiltinsAssembler::PromiseSetHasHandler(Node* promise) { |
268 Node* const flags = LoadObjectField(promise, JSPromise::kFlagsOffset); | 268 Node* const flags = LoadObjectField(promise, JSPromise::kFlagsOffset); |
269 Node* const new_flags = | 269 Node* const new_flags = |
270 SmiOr(flags, SmiConstant(1 << JSPromise::kHasHandlerBit)); | 270 SmiOr(flags, SmiConstant(1 << JSPromise::kHasHandlerBit)); |
271 StoreObjectFieldNoWriteBarrier(promise, JSPromise::kFlagsOffset, new_flags); | 271 StoreObjectFieldNoWriteBarrier(promise, JSPromise::kFlagsOffset, new_flags); |
272 } | 272 } |
273 | 273 |
| 274 void PromiseBuiltinsAssembler::PromiseSetHandledHint(Node* promise) { |
| 275 Node* const flags = LoadObjectField(promise, JSPromise::kFlagsOffset); |
| 276 Node* const new_flags = |
| 277 SmiOr(flags, SmiConstant(1 << JSPromise::kHandledHintBit)); |
| 278 StoreObjectFieldNoWriteBarrier(promise, JSPromise::kFlagsOffset, new_flags); |
| 279 } |
| 280 |
274 Node* PromiseBuiltinsAssembler::SpeciesConstructor(Node* context, Node* object, | 281 Node* PromiseBuiltinsAssembler::SpeciesConstructor(Node* context, Node* object, |
275 Node* default_constructor) { | 282 Node* default_constructor) { |
276 Isolate* isolate = this->isolate(); | 283 Isolate* isolate = this->isolate(); |
277 Variable var_result(this, MachineRepresentation::kTagged); | 284 Variable var_result(this, MachineRepresentation::kTagged); |
278 var_result.Bind(default_constructor); | 285 var_result.Bind(default_constructor); |
279 | 286 |
280 // 2. Let C be ? Get(O, "constructor"). | 287 // 2. Let C be ? Get(O, "constructor"). |
281 Node* const constructor_str = | 288 Node* const constructor_str = |
282 HeapConstant(isolate->factory()->constructor_string()); | 289 HeapConstant(isolate->factory()->constructor_string()); |
283 Callable getproperty_callable = CodeFactory::GetProperty(isolate); | 290 Callable getproperty_callable = CodeFactory::GetProperty(isolate); |
(...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1152 GotoIf(TaggedIsSmi(maybe_promise), &if_notpromise); | 1159 GotoIf(TaggedIsSmi(maybe_promise), &if_notpromise); |
1153 | 1160 |
1154 Node* const result = | 1161 Node* const result = |
1155 SelectBooleanConstant(HasInstanceType(maybe_promise, JS_PROMISE_TYPE)); | 1162 SelectBooleanConstant(HasInstanceType(maybe_promise, JS_PROMISE_TYPE)); |
1156 Return(result); | 1163 Return(result); |
1157 | 1164 |
1158 Bind(&if_notpromise); | 1165 Bind(&if_notpromise); |
1159 Return(FalseConstant()); | 1166 Return(FalseConstant()); |
1160 } | 1167 } |
1161 | 1168 |
1162 TF_BUILTIN(PerformPromiseThen, PromiseBuiltinsAssembler) { | |
1163 Node* const promise = Parameter(1); | |
1164 Node* const on_resolve = Parameter(2); | |
1165 Node* const on_reject = Parameter(3); | |
1166 Node* const deferred_promise = Parameter(4); | |
1167 Node* const context = Parameter(7); | |
1168 | |
1169 // No deferred_on_resolve/deferred_on_reject because this is just an | |
1170 // internal promise created by async-await. | |
1171 Node* const result = InternalPerformPromiseThen( | |
1172 context, promise, on_resolve, on_reject, deferred_promise, | |
1173 UndefinedConstant(), UndefinedConstant()); | |
1174 | |
1175 // TODO(gsathya): This is unused, but value is returned according to spec. | |
1176 Return(result); | |
1177 } | |
1178 | |
1179 // ES#sec-promise.prototype.then | 1169 // ES#sec-promise.prototype.then |
1180 // Promise.prototype.catch ( onFulfilled, onRejected ) | 1170 // Promise.prototype.catch ( onFulfilled, onRejected ) |
1181 TF_BUILTIN(PromiseThen, PromiseBuiltinsAssembler) { | 1171 TF_BUILTIN(PromiseThen, PromiseBuiltinsAssembler) { |
1182 // 1. Let promise be the this value. | 1172 // 1. Let promise be the this value. |
1183 Node* const promise = Parameter(0); | 1173 Node* const promise = Parameter(0); |
1184 Node* const on_resolve = Parameter(1); | 1174 Node* const on_resolve = Parameter(1); |
1185 Node* const on_reject = Parameter(2); | 1175 Node* const on_reject = Parameter(2); |
1186 Node* const context = Parameter(5); | 1176 Node* const context = Parameter(5); |
1187 | 1177 |
1188 Node* const result = | 1178 Node* const result = |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1547 Node* const reason = Parameter(2); | 1537 Node* const reason = Parameter(2); |
1548 Node* const debug_event = Parameter(3); | 1538 Node* const debug_event = Parameter(3); |
1549 Node* const context = Parameter(6); | 1539 Node* const context = Parameter(6); |
1550 | 1540 |
1551 InternalPromiseReject(context, promise, reason, debug_event); | 1541 InternalPromiseReject(context, promise, reason, debug_event); |
1552 Return(UndefinedConstant()); | 1542 Return(UndefinedConstant()); |
1553 } | 1543 } |
1554 | 1544 |
1555 } // namespace internal | 1545 } // namespace internal |
1556 } // namespace v8 | 1546 } // namespace v8 |
OLD | NEW |