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

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

Issue 2578923002: [inspector] async stacks for Promise.then calls... (Closed)
Patch Set: avoid calling functions 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 | src/debug/debug.h » ('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-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 776 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 Node* reject = nullptr; 787 Node* reject = nullptr;
788 std::tie(resolve, reject) = CreatePromiseResolvingFunctions( 788 std::tie(resolve, reject) = CreatePromiseResolvingFunctions(
789 promise, FalseConstant(), native_context); 789 promise, FalseConstant(), native_context);
790 790
791 Node* const info = AllocatePromiseResolveThenableJobInfo( 791 Node* const info = AllocatePromiseResolveThenableJobInfo(
792 result, var_then.value(), resolve, reject, context); 792 result, var_then.value(), resolve, reject, context);
793 793
794 Label enqueue(this); 794 Label enqueue(this);
795 GotoUnless(IsDebugActive(), &enqueue); 795 GotoUnless(IsDebugActive(), &enqueue);
796 796
797 Node* const debug_id = CallRuntime(Runtime::kDebugNextMicrotaskId, context); 797 Node* const debug_id =
798 CallRuntime(Runtime::kDebugNextAsyncTaskId, context, promise);
798 Node* const debug_name = SmiConstant(kDebugPromiseResolveThenableJob); 799 Node* const debug_name = SmiConstant(kDebugPromiseResolveThenableJob);
799 CallRuntime(Runtime::kDebugAsyncTaskEvent, context,
800 SmiConstant(kDebugEnqueue), debug_id, debug_name);
801 800
802 StoreObjectField(info, PromiseResolveThenableJobInfo::kDebugIdOffset, 801 StoreObjectField(info, PromiseResolveThenableJobInfo::kDebugIdOffset,
803 debug_id); 802 debug_id);
804 StoreObjectField(info, PromiseResolveThenableJobInfo::kDebugNameOffset, 803 StoreObjectField(info, PromiseResolveThenableJobInfo::kDebugNameOffset,
805 debug_name); 804 debug_name);
806 805
807 GotoIf(TaggedIsSmi(result), &enqueue); 806 GotoIf(TaggedIsSmi(result), &enqueue);
808 GotoUnless(HasInstanceType(result, JS_PROMISE_TYPE), &enqueue); 807 GotoUnless(HasInstanceType(result, JS_PROMISE_TYPE), &enqueue);
809 808
810 // Mark the dependency of the new promise on the resolution 809 // Mark the dependency of the new promise on the resolution
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 TrueConstant()); 847 TrueConstant());
849 Goto(&out); 848 Goto(&out);
850 } 849 }
851 850
852 Bind(&out); 851 Bind(&out);
853 } 852 }
854 853
855 void PromiseBuiltinsAssembler::PromiseFulfill( 854 void PromiseBuiltinsAssembler::PromiseFulfill(
856 Node* context, Node* promise, Node* result, 855 Node* context, Node* promise, Node* result,
857 v8::Promise::PromiseState status) { 856 v8::Promise::PromiseState status) {
858 Label do_promisereset(this); 857 Label do_promisereset(this), debug_async_event_enqueue_recurring(this);
859 858
860 Node* const status_smi = SmiConstant(static_cast<int>(status)); 859 Node* const status_smi = SmiConstant(static_cast<int>(status));
861 Node* const deferred_promise = 860 Node* const deferred_promise =
862 LoadObjectField(promise, JSPromise::kDeferredPromiseOffset); 861 LoadObjectField(promise, JSPromise::kDeferredPromiseOffset);
863 862
864 GotoIf(IsUndefined(deferred_promise), &do_promisereset); 863 GotoIf(IsUndefined(deferred_promise), &debug_async_event_enqueue_recurring);
865 864
866 Node* const tasks = 865 Node* const tasks =
867 status == v8::Promise::kFulfilled 866 status == v8::Promise::kFulfilled
868 ? LoadObjectField(promise, JSPromise::kFulfillReactionsOffset) 867 ? LoadObjectField(promise, JSPromise::kFulfillReactionsOffset)
869 : LoadObjectField(promise, JSPromise::kRejectReactionsOffset); 868 : LoadObjectField(promise, JSPromise::kRejectReactionsOffset);
870 869
871 Node* const deferred_on_resolve = 870 Node* const deferred_on_resolve =
872 LoadObjectField(promise, JSPromise::kDeferredOnResolveOffset); 871 LoadObjectField(promise, JSPromise::kDeferredOnResolveOffset);
873 Node* const deferred_on_reject = 872 Node* const deferred_on_reject =
874 LoadObjectField(promise, JSPromise::kDeferredOnRejectOffset); 873 LoadObjectField(promise, JSPromise::kDeferredOnRejectOffset);
875 874
876 Node* const info = AllocatePromiseReactionJobInfo( 875 Node* const info = AllocatePromiseReactionJobInfo(
877 promise, result, tasks, deferred_promise, deferred_on_resolve, 876 promise, result, tasks, deferred_promise, deferred_on_resolve,
878 deferred_on_reject, context); 877 deferred_on_reject, context);
878
879 CallRuntime(Runtime::kEnqueuePromiseReactionJob, context, info, status_smi); 879 CallRuntime(Runtime::kEnqueuePromiseReactionJob, context, info, status_smi);
880 Goto(&do_promisereset); 880 Goto(&debug_async_event_enqueue_recurring);
881
882 Bind(&debug_async_event_enqueue_recurring);
883 {
884 GotoUnless(IsDebugActive(), &do_promisereset);
885 CallRuntime(Runtime::kDebugAsyncEventEnqueueRecurring, context, promise,
886 status_smi);
887 Goto(&do_promisereset);
888 }
881 889
882 Bind(&do_promisereset); 890 Bind(&do_promisereset);
883 { 891 {
884 StoreObjectField(promise, JSPromise::kStatusOffset, status_smi); 892 StoreObjectField(promise, JSPromise::kStatusOffset, status_smi);
885 StoreObjectField(promise, JSPromise::kResultOffset, result); 893 StoreObjectField(promise, JSPromise::kResultOffset, result);
886 StoreObjectFieldRoot(promise, JSPromise::kDeferredPromiseOffset, 894 StoreObjectFieldRoot(promise, JSPromise::kDeferredPromiseOffset,
887 Heap::kUndefinedValueRootIndex); 895 Heap::kUndefinedValueRootIndex);
888 StoreObjectFieldRoot(promise, JSPromise::kDeferredOnResolveOffset, 896 StoreObjectFieldRoot(promise, JSPromise::kDeferredOnResolveOffset,
889 Heap::kUndefinedValueRootIndex); 897 Heap::kUndefinedValueRootIndex);
890 StoreObjectFieldRoot(promise, JSPromise::kDeferredOnRejectOffset, 898 StoreObjectFieldRoot(promise, JSPromise::kDeferredOnRejectOffset,
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
1441 1449
1442 // 5. Return promiseCapability.[[Promise]]. 1450 // 5. Return promiseCapability.[[Promise]].
1443 Node* const promise = 1451 Node* const promise =
1444 LoadObjectField(capability, JSPromiseCapability::kPromiseOffset); 1452 LoadObjectField(capability, JSPromiseCapability::kPromiseOffset);
1445 Return(promise); 1453 Return(promise);
1446 } 1454 }
1447 } 1455 }
1448 1456
1449 } // namespace internal 1457 } // namespace internal
1450 } // namespace v8 1458 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/debug/debug.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698