Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(874)

Side by Side Diff: src/builtins/builtins-promise.cc

Issue 2578173004: [promisehook] Fire init hook for promise subclass (Closed)
Patch Set: add regression test Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 654 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 665
666 Node* const executor_map = LoadMap(executor); 666 Node* const executor_map = LoadMap(executor);
667 GotoUnless(IsCallableMap(executor_map), &if_notcallable); 667 GotoUnless(IsCallableMap(executor_map), &if_notcallable);
668 668
669 Node* const native_context = LoadNativeContext(context); 669 Node* const native_context = LoadNativeContext(context);
670 Node* const promise_fun = 670 Node* const promise_fun =
671 LoadContextElement(native_context, Context::PROMISE_FUNCTION_INDEX); 671 LoadContextElement(native_context, Context::PROMISE_FUNCTION_INDEX);
672 Node* const is_debug_active = IsDebugActive(); 672 Node* const is_debug_active = IsDebugActive();
673 Label if_targetisnotmodified(this), 673 Label if_targetisnotmodified(this),
674 if_targetismodified(this, Label::kDeferred), run_executor(this), 674 if_targetismodified(this, Label::kDeferred), run_executor(this),
675 debug_push(this, Label::kDeferred), init(this); 675 debug_push(this), init(this);
676 676
677 Branch(WordEqual(promise_fun, new_target), &if_targetisnotmodified, 677 Branch(WordEqual(promise_fun, new_target), &if_targetisnotmodified,
678 &if_targetismodified); 678 &if_targetismodified);
679 679
680 Variable var_result(this, MachineRepresentation::kTagged), 680 Variable var_result(this, MachineRepresentation::kTagged),
681 var_reject_call(this, MachineRepresentation::kTagged), 681 var_reject_call(this, MachineRepresentation::kTagged),
682 var_reason(this, MachineRepresentation::kTagged); 682 var_reason(this, MachineRepresentation::kTagged);
683 683
684 Bind(&if_targetisnotmodified); 684 Bind(&if_targetisnotmodified);
685 { 685 {
686 Node* const instance = AllocateJSPromise(context); 686 Node* const instance = AllocateJSPromise(context);
687 var_result.Bind(instance); 687 var_result.Bind(instance);
688 GotoUnless(IsPromiseHookEnabled(), &init);
689 CallRuntime(Runtime::kPromiseHookInit, context, instance,
690 UndefinedConstant());
691 Goto(&init); 688 Goto(&init);
692 } 689 }
693 690
694 Bind(&if_targetismodified); 691 Bind(&if_targetismodified);
695 { 692 {
696 Callable fast_new_object_stub = CodeFactory::FastNewObject(isolate); 693 Callable fast_new_object_stub = CodeFactory::FastNewObject(isolate);
697 Node* const instance = 694 Node* const instance =
698 CallStub(fast_new_object_stub, context, promise_fun, new_target); 695 CallStub(fast_new_object_stub, context, promise_fun, new_target);
699 696
700 var_result.Bind(instance); 697 var_result.Bind(instance);
701 Goto(&init); 698 Goto(&init);
702 } 699 }
703 700
704 Bind(&init); 701 Bind(&init);
705 { 702 {
706 PromiseInit(var_result.value()); 703 PromiseInit(var_result.value());
707 Branch(is_debug_active, &debug_push, &run_executor); 704 GotoUnless(IsPromiseHookEnabled(), &debug_push);
705 CallRuntime(Runtime::kPromiseHookInit, context, var_result.value(),
706 UndefinedConstant());
707 Goto(&debug_push);
708 } 708 }
709 709
710 Bind(&debug_push); 710 Bind(&debug_push);
711 { 711 {
712 GotoUnless(is_debug_active, &run_executor);
712 CallRuntime(Runtime::kDebugPushPromise, context, var_result.value()); 713 CallRuntime(Runtime::kDebugPushPromise, context, var_result.value());
713 Goto(&run_executor); 714 Goto(&run_executor);
714 } 715 }
715 716
716 Bind(&run_executor); 717 Bind(&run_executor);
717 { 718 {
718 Label out(this), if_rejectpromise(this), debug_pop(this, Label::kDeferred); 719 Label out(this), if_rejectpromise(this), debug_pop(this, Label::kDeferred);
719 720
720 Node *resolve, *reject; 721 Node *resolve, *reject;
721 std::tie(resolve, reject) = CreatePromiseResolvingFunctions( 722 std::tie(resolve, reject) = CreatePromiseResolvingFunctions(
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
1030 CallStub(getproperty_callable, context, promise, then_str); 1031 CallStub(getproperty_callable, context, promise, then_str);
1031 Callable call_callable = CodeFactory::Call(isolate); 1032 Callable call_callable = CodeFactory::Call(isolate);
1032 Node* const result = 1033 Node* const result =
1033 CallJS(call_callable, context, then, promise, on_resolve, on_reject); 1034 CallJS(call_callable, context, then, promise, on_resolve, on_reject);
1034 Return(result); 1035 Return(result);
1035 } 1036 }
1036 } 1037 }
1037 1038
1038 } // namespace internal 1039 } // namespace internal
1039 } // namespace v8 1040 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698