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

Unified Diff: src/builtins/builtins-async-function.cc

Issue 2638073002: [async-await] Move PromiseCreate and PromiseRelease to TF (Closed)
Patch Set: Move to builtins-async-function.cc and address comment 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/builtins/builtins.h ('k') | src/js/async-await.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/builtins/builtins-async-function.cc
diff --git a/src/builtins/builtins-async-function.cc b/src/builtins/builtins-async-function.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a03c976ef0e5fc1fa40460ba85123672af7151f7
--- /dev/null
+++ b/src/builtins/builtins-async-function.cc
@@ -0,0 +1,68 @@
+// Copyright 2017 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "src/builtins/builtins-promise.h"
+#include "src/builtins/builtins-utils.h"
+#include "src/builtins/builtins.h"
+#include "src/code-stub-assembler.h"
+
+namespace v8 {
+namespace internal {
+
+typedef compiler::Node Node;
+typedef CodeStubAssembler::ParameterMode ParameterMode;
+typedef compiler::CodeAssemblerState CodeAssemblerState;
+
+class AsyncFunctionBuiltinsAssembler : public PromiseBuiltinsAssembler {
+ public:
+ explicit AsyncFunctionBuiltinsAssembler(CodeAssemblerState* state)
+ : PromiseBuiltinsAssembler(state) {}
+};
+
+TF_BUILTIN(AsyncFunctionPromiseCreate, AsyncFunctionBuiltinsAssembler) {
+ CSA_ASSERT_JS_ARGC_EQ(this, 0);
+ Node* const context = Parameter(3);
+
+ Node* const promise = AllocateAndInitJSPromise(context);
+
+ Label if_is_debug_active(this, Label::kDeferred);
+ GotoIf(IsDebugActive(), &if_is_debug_active);
+
+ // Early exit if debug is not active.
+ Return(promise);
+
+ Bind(&if_is_debug_active);
+ {
+ // Push the Promise under construction in an async function on
+ // the catch prediction stack to handle exceptions thrown before
+ // the first await.
+ // Assign ID and create a recurring task to save stack for future
+ // resumptions from await.
+ CallRuntime(Runtime::kDebugAsyncFunctionPromiseCreated, context, promise);
+ Return(promise);
+ }
+}
+
+TF_BUILTIN(AsyncFunctionPromiseRelease, AsyncFunctionBuiltinsAssembler) {
+ CSA_ASSERT_JS_ARGC_EQ(this, 1);
+ Node* const promise = Parameter(1);
+ Node* const context = Parameter(4);
+
+ Label if_is_debug_active(this, Label::kDeferred);
+ GotoIf(IsDebugActive(), &if_is_debug_active);
+
+ // Early exit if debug is not active.
+ Return(UndefinedConstant());
+
+ Bind(&if_is_debug_active);
+ {
+ // Pop the Promise under construction in an async function on
+ // from catch prediction stack.
+ CallRuntime(Runtime::kDebugPopPromise, context);
+ Return(promise);
+ }
+}
+
+} // namespace internal
+} // namespace v8
« no previous file with comments | « src/builtins/builtins.h ('k') | src/js/async-await.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698