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-constructor.h" |
5 #include "src/builtins/builtins-promise.h" | 6 #include "src/builtins/builtins-promise.h" |
6 #include "src/builtins/builtins-constructor.h" | 7 #include "src/builtins/builtins-utils-gen.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" |
11 #include "src/objects-inl.h" | 11 #include "src/objects-inl.h" |
12 | 12 |
13 namespace v8 { | 13 namespace v8 { |
14 namespace internal { | 14 namespace internal { |
15 | 15 |
| 16 using compiler::Node; |
| 17 |
16 Node* PromiseBuiltinsAssembler::AllocateJSPromise(Node* context) { | 18 Node* PromiseBuiltinsAssembler::AllocateJSPromise(Node* context) { |
17 Node* const native_context = LoadNativeContext(context); | 19 Node* const native_context = LoadNativeContext(context); |
18 Node* const promise_fun = | 20 Node* const promise_fun = |
19 LoadContextElement(native_context, Context::PROMISE_FUNCTION_INDEX); | 21 LoadContextElement(native_context, Context::PROMISE_FUNCTION_INDEX); |
20 Node* const initial_map = | 22 Node* const initial_map = |
21 LoadObjectField(promise_fun, JSFunction::kPrototypeOrInitialMapOffset); | 23 LoadObjectField(promise_fun, JSFunction::kPrototypeOrInitialMapOffset); |
22 Node* const instance = AllocateJSObjectFromMap(initial_map); | 24 Node* const instance = AllocateJSObjectFromMap(initial_map); |
23 return instance; | 25 return instance; |
24 } | 26 } |
25 | 27 |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 Node* const result = InternalPerformPromiseThen( | 405 Node* const result = InternalPerformPromiseThen( |
404 context, promise, on_resolve, on_reject, var_deferred_promise.value(), | 406 context, promise, on_resolve, on_reject, var_deferred_promise.value(), |
405 var_deferred_on_resolve.value(), var_deferred_on_reject.value()); | 407 var_deferred_on_resolve.value(), var_deferred_on_reject.value()); |
406 return result; | 408 return result; |
407 } | 409 } |
408 | 410 |
409 Node* PromiseBuiltinsAssembler::InternalPerformPromiseThen( | 411 Node* PromiseBuiltinsAssembler::InternalPerformPromiseThen( |
410 Node* context, Node* promise, Node* on_resolve, Node* on_reject, | 412 Node* context, Node* promise, Node* on_resolve, Node* on_reject, |
411 Node* deferred_promise, Node* deferred_on_resolve, | 413 Node* deferred_promise, Node* deferred_on_resolve, |
412 Node* deferred_on_reject) { | 414 Node* deferred_on_reject) { |
413 | |
414 Variable var_on_resolve(this, MachineRepresentation::kTagged), | 415 Variable var_on_resolve(this, MachineRepresentation::kTagged), |
415 var_on_reject(this, MachineRepresentation::kTagged); | 416 var_on_reject(this, MachineRepresentation::kTagged); |
416 | 417 |
417 var_on_resolve.Bind(on_resolve); | 418 var_on_resolve.Bind(on_resolve); |
418 var_on_reject.Bind(on_reject); | 419 var_on_reject.Bind(on_reject); |
419 | 420 |
420 Label out(this), if_onresolvenotcallable(this), onrejectcheck(this), | 421 Label out(this), if_onresolvenotcallable(this), onrejectcheck(this), |
421 append_callbacks(this); | 422 append_callbacks(this); |
422 GotoIf(TaggedIsSmi(on_resolve), &if_onresolvenotcallable); | 423 GotoIf(TaggedIsSmi(on_resolve), &if_onresolvenotcallable); |
423 | 424 |
(...skipping 1329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1753 // 5. Return ? Invoke(promise, "then", « thenFinally, catchFinally »). | 1754 // 5. Return ? Invoke(promise, "then", « thenFinally, catchFinally »). |
1754 Node* const result = | 1755 Node* const result = |
1755 CallJS(call_callable, context, then, promise, var_then_finally.value(), | 1756 CallJS(call_callable, context, then, promise, var_then_finally.value(), |
1756 var_catch_finally.value()); | 1757 var_catch_finally.value()); |
1757 Return(result); | 1758 Return(result); |
1758 } | 1759 } |
1759 } | 1760 } |
1760 | 1761 |
1761 } // namespace internal | 1762 } // namespace internal |
1762 } // namespace v8 | 1763 } // namespace v8 |
OLD | NEW |