| 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-utils.h" | 6 #include "src/builtins/builtins-utils.h" |
| 7 #include "src/builtins/builtins.h" | 7 #include "src/builtins/builtins.h" |
| 8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
| 9 #include "src/code-stub-assembler.h" | 9 #include "src/code-stub-assembler.h" |
| 10 #include "src/promise-utils.h" | 10 #include "src/promise-utils.h" |
| (...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 | 605 |
| 606 Node* const executor_map = LoadMap(executor); | 606 Node* const executor_map = LoadMap(executor); |
| 607 GotoUnless(IsCallableMap(executor_map), &if_notcallable); | 607 GotoUnless(IsCallableMap(executor_map), &if_notcallable); |
| 608 | 608 |
| 609 Node* const native_context = LoadNativeContext(context); | 609 Node* const native_context = LoadNativeContext(context); |
| 610 Node* const promise_fun = | 610 Node* const promise_fun = |
| 611 LoadContextElement(native_context, Context::PROMISE_FUNCTION_INDEX); | 611 LoadContextElement(native_context, Context::PROMISE_FUNCTION_INDEX); |
| 612 Node* const is_debug_active = IsDebugActive(); | 612 Node* const is_debug_active = IsDebugActive(); |
| 613 Label if_targetisnotmodified(this), | 613 Label if_targetisnotmodified(this), |
| 614 if_targetismodified(this, Label::kDeferred), run_executor(this), | 614 if_targetismodified(this, Label::kDeferred), run_executor(this), |
| 615 debug_push(this, Label::kDeferred), init(this); | 615 debug_push(this), init(this); |
| 616 | 616 |
| 617 Branch(WordEqual(promise_fun, new_target), &if_targetisnotmodified, | 617 Branch(WordEqual(promise_fun, new_target), &if_targetisnotmodified, |
| 618 &if_targetismodified); | 618 &if_targetismodified); |
| 619 | 619 |
| 620 Variable var_result(this, MachineRepresentation::kTagged), | 620 Variable var_result(this, MachineRepresentation::kTagged), |
| 621 var_reject_call(this, MachineRepresentation::kTagged), | 621 var_reject_call(this, MachineRepresentation::kTagged), |
| 622 var_reason(this, MachineRepresentation::kTagged); | 622 var_reason(this, MachineRepresentation::kTagged); |
| 623 | 623 |
| 624 Bind(&if_targetisnotmodified); | 624 Bind(&if_targetisnotmodified); |
| 625 { | 625 { |
| 626 Node* const instance = AllocateJSPromise(context); | 626 Node* const instance = AllocateJSPromise(context); |
| 627 var_result.Bind(instance); | 627 var_result.Bind(instance); |
| 628 GotoUnless(IsPromiseHookEnabled(), &init); | |
| 629 CallRuntime(Runtime::kPromiseHookInit, context, instance, | |
| 630 UndefinedConstant()); | |
| 631 Goto(&init); | 628 Goto(&init); |
| 632 } | 629 } |
| 633 | 630 |
| 634 Bind(&if_targetismodified); | 631 Bind(&if_targetismodified); |
| 635 { | 632 { |
| 636 Callable fast_new_object_stub = CodeFactory::FastNewObject(isolate); | 633 Callable fast_new_object_stub = CodeFactory::FastNewObject(isolate); |
| 637 Node* const instance = | 634 Node* const instance = |
| 638 CallStub(fast_new_object_stub, context, promise_fun, new_target); | 635 CallStub(fast_new_object_stub, context, promise_fun, new_target); |
| 639 | 636 |
| 640 var_result.Bind(instance); | 637 var_result.Bind(instance); |
| 641 Goto(&init); | 638 Goto(&init); |
| 642 } | 639 } |
| 643 | 640 |
| 644 Bind(&init); | 641 Bind(&init); |
| 645 { | 642 { |
| 646 PromiseInit(var_result.value()); | 643 PromiseInit(var_result.value()); |
| 647 Branch(is_debug_active, &debug_push, &run_executor); | 644 GotoUnless(IsPromiseHookEnabled(), &debug_push); |
| 645 CallRuntime(Runtime::kPromiseHookInit, context, var_result.value(), |
| 646 UndefinedConstant()); |
| 647 Goto(&debug_push); |
| 648 } | 648 } |
| 649 | 649 |
| 650 Bind(&debug_push); | 650 Bind(&debug_push); |
| 651 { | 651 { |
| 652 GotoUnless(is_debug_active, &run_executor); |
| 652 CallRuntime(Runtime::kDebugPushPromise, context, var_result.value()); | 653 CallRuntime(Runtime::kDebugPushPromise, context, var_result.value()); |
| 653 Goto(&run_executor); | 654 Goto(&run_executor); |
| 654 } | 655 } |
| 655 | 656 |
| 656 Bind(&run_executor); | 657 Bind(&run_executor); |
| 657 { | 658 { |
| 658 Label out(this), if_rejectpromise(this), debug_pop(this, Label::kDeferred); | 659 Label out(this), if_rejectpromise(this), debug_pop(this, Label::kDeferred); |
| 659 | 660 |
| 660 Node *resolve, *reject; | 661 Node *resolve, *reject; |
| 661 std::tie(resolve, reject) = CreatePromiseResolvingFunctions( | 662 std::tie(resolve, reject) = CreatePromiseResolvingFunctions( |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 986 CallRuntime(Runtime::kDebugPopPromise, context); | 987 CallRuntime(Runtime::kDebugPopPromise, context); |
| 987 Goto(&out); | 988 Goto(&out); |
| 988 | 989 |
| 989 Bind(&out); | 990 Bind(&out); |
| 990 Return(UndefinedConstant()); | 991 Return(UndefinedConstant()); |
| 991 } | 992 } |
| 992 } | 993 } |
| 993 | 994 |
| 994 } // namespace internal | 995 } // namespace internal |
| 995 } // namespace v8 | 996 } // namespace v8 |
| OLD | NEW |