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

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

Issue 2643023002: [async-await] Move remaining async-await code to TF (Closed)
Patch Set: Fix set_handled_hint logic in Await 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 | « src/builtins/builtins-async.h ('k') | src/builtins/builtins-async-function.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-async.h" 5 #include "src/builtins/builtins-async.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/frames-inl.h" 10 #include "src/frames-inl.h"
11 11
12 namespace v8 { 12 namespace v8 {
13 namespace internal { 13 namespace internal {
14 14
15 Node* AsyncBuiltinsAssembler::Await( 15 Node* AsyncBuiltinsAssembler::Await(
16 Node* context, Node* generator, Node* value, Node* outer_promise, 16 Node* context, Node* generator, Node* value, Node* outer_promise,
17 const NodeGenerator1& create_closure_context, int on_resolve_context_index, 17 const NodeGenerator1& create_closure_context, int on_resolve_context_index,
18 int on_reject_context_index, bool is_catchable) { 18 int on_reject_context_index, bool is_predicted_as_caught) {
19 // Let promiseCapability be ! NewPromiseCapability(%Promise%). 19 // Let promiseCapability be ! NewPromiseCapability(%Promise%).
20 Node* const wrapped_value = AllocateAndInitJSPromise(context); 20 Node* const wrapped_value = AllocateAndInitJSPromise(context);
21 21
22 // Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). 22 // Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »).
23 InternalResolvePromise(context, wrapped_value, value); 23 InternalResolvePromise(context, wrapped_value, value);
24 24
25 Node* const native_context = LoadNativeContext(context); 25 Node* const native_context = LoadNativeContext(context);
26 26
27 Node* const closure_context = create_closure_context(native_context); 27 Node* const closure_context = create_closure_context(native_context);
28 Node* const map = LoadContextElement( 28 Node* const map = LoadContextElement(
(...skipping 19 matching lines...) Expand all
48 AllocateAndInitJSPromise(context, wrapped_value); 48 AllocateAndInitJSPromise(context, wrapped_value);
49 49
50 // The Promise will be thrown away and not handled, but it shouldn't trigger 50 // The Promise will be thrown away and not handled, but it shouldn't trigger
51 // unhandled reject events as its work is done 51 // unhandled reject events as its work is done
52 PromiseSetHasHandler(throwaway_promise); 52 PromiseSetHasHandler(throwaway_promise);
53 53
54 Label do_perform_promise_then(this); 54 Label do_perform_promise_then(this);
55 GotoUnless(IsDebugActive(), &do_perform_promise_then); 55 GotoUnless(IsDebugActive(), &do_perform_promise_then);
56 { 56 {
57 Label common(this); 57 Label common(this);
58 GotoIf(TaggedIsSmi(value), &common);
58 GotoUnless(HasInstanceType(value, JS_PROMISE_TYPE), &common); 59 GotoUnless(HasInstanceType(value, JS_PROMISE_TYPE), &common);
59 { 60 {
60 // Mark the reject handler callback to be a forwarding edge, rather 61 // Mark the reject handler callback to be a forwarding edge, rather
61 // than a meaningful catch handler 62 // than a meaningful catch handler
62 Node* const key = 63 Node* const key =
63 HeapConstant(factory()->promise_forwarding_handler_symbol()); 64 HeapConstant(factory()->promise_forwarding_handler_symbol());
64 CallRuntime(Runtime::kSetProperty, on_reject, key, TrueConstant(), 65 CallRuntime(Runtime::kSetProperty, context, on_reject, key,
65 SmiConstant(STRICT)); 66 TrueConstant(), SmiConstant(STRICT));
66 67
67 if (!is_catchable) { 68 if (is_predicted_as_caught) PromiseSetHandledHint(value);
jgruber 2017/01/20 14:00:27 Note the inverted logic and the changed flag.
68 PromiseSetHasHandler(value);
69 }
70 } 69 }
71 70
72 Goto(&common); 71 Goto(&common);
73 Bind(&common); 72 Bind(&common);
74 // Mark the dependency to outer Promise in case the throwaway Promise is 73 // Mark the dependency to outer Promise in case the throwaway Promise is
75 // found on the Promise stack 74 // found on the Promise stack
76 CSA_SLOW_ASSERT(this, HasInstanceType(outer_promise, JS_PROMISE_TYPE)); 75 CSA_SLOW_ASSERT(this, HasInstanceType(outer_promise, JS_PROMISE_TYPE));
77 76
78 Node* const key = HeapConstant(factory()->promise_handled_by_symbol()); 77 Node* const key = HeapConstant(factory()->promise_handled_by_symbol());
79 CallRuntime(Runtime::kSetProperty, throwaway_promise, key, outer_promise, 78 CallRuntime(Runtime::kSetProperty, context, throwaway_promise, key,
80 SmiConstant(STRICT)); 79 outer_promise, SmiConstant(STRICT));
81 } 80 }
82 81
83 Goto(&do_perform_promise_then); 82 Goto(&do_perform_promise_then);
84 Bind(&do_perform_promise_then); 83 Bind(&do_perform_promise_then);
85 InternalPerformPromiseThen(context, wrapped_value, on_resolve, on_reject, 84 InternalPerformPromiseThen(context, wrapped_value, on_resolve, on_reject,
86 throwaway_promise, UndefinedConstant(), 85 throwaway_promise, UndefinedConstant(),
87 UndefinedConstant()); 86 UndefinedConstant());
88 87
89 return wrapped_value; 88 return wrapped_value;
90 } 89 }
91 90
92 } // namespace internal 91 } // namespace internal
93 } // namespace v8 92 } // namespace v8
OLDNEW
« no previous file with comments | « src/builtins/builtins-async.h ('k') | src/builtins/builtins-async-function.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698