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

Unified Diff: src/builtins/builtins-async.h

Issue 2622833002: WIP [esnext] implement async iteration proposal (Closed)
Patch Set: Fix minor parsing bug, add some local test262 tests 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
Index: src/builtins/builtins-async.h
diff --git a/src/builtins/builtins-async.h b/src/builtins/builtins-async.h
new file mode 100644
index 0000000000000000000000000000000000000000..56a438fa04d24cb6daabf7d72e04a32872767b24
--- /dev/null
+++ b/src/builtins/builtins-async.h
@@ -0,0 +1,67 @@
+// Copyright 2016 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"
+
+namespace v8 {
+namespace internal {
+
+class AsyncBuiltinsAssembler : public PromiseBuiltinsAssembler {
Dan Ehrenberg 2017/01/13 19:41:09 I'm a little surprised by this inheritance, and do
caitp 2017/01/13 20:11:52 Would that make CSA methods private, or just Promi
caitp 2017/01/17 19:23:11 This causes problems for the TF_BUILTIN pattern, i
+ public:
+ explicit AsyncBuiltinsAssembler(CodeAssemblerState* state)
+ : PromiseBuiltinsAssembler(state) {}
+
+ // Async Generator:
+ void AsyncGeneratorResumeNext(Node* context, Node* generator,
+ Node* continuation);
+ void AsyncGeneratorResumeNext(Node* context, Node* generator) {
+ Node* continuation =
+ LoadObjectField(generator, JSAsyncGeneratorObject::kContinuationOffset);
+ AsyncGeneratorResumeNext(context, generator, continuation);
+ }
+
+ Node* TakeFirstAsyncGeneratorRequestFromQueue(Node* generator);
+ void AddAsyncGeneratorRequestToQueue(Node* generator, Node* request);
+
+ Node* AllocateAsyncGeneratorRequest(
+ JSAsyncGeneratorObject::ResumeMode resume_mode, Node* resume_value,
+ Node* promise);
+
+ // Async Iterator
+ Node* AllocateAsyncIteratorValueUnwrapContext(Node* native_context,
+ Node* promise, Node* done);
+
+ protected:
+ // Async Generator shared
+ void AsyncGeneratorEnqueue(Node* context, Node* generator, Node* value,
+ JSAsyncGeneratorObject::ResumeMode resume_mode,
+ const char* method_name);
+
+ void AsyncGeneratorAwaitResumeClosure(
+ Node* context, Node* value,
+ JSAsyncGeneratorObject::ResumeMode resume_mode);
+
+ typedef std::function<Node*(Node*)> NodeGenerator1;
+
+ // Perform steps to resume generator after `value` is resolved.
+ // `on_reject_context_index` is an index into the Native Context, which should
+ // point to a SharedFunctioninfo instance used to create the closure. The
+ // value following the reject index should be a similar value for the resolve
+ // closure. Returns the Promise-wrapped `value`.
+ Node* Await(Node* context, Node* generator, Node* value, Node* outer_promise,
+ const NodeGenerator1& create_closure_context,
+ int on_reject_context_index, bool is_catchable);
+
+ // Shared implementation of the catchable and uncatchable variations of Await
+ // for AsyncGenerators.
+ void AsyncGeneratorAwait(bool is_catchable);
+
+ private:
+ // Async Generator private
+ void AsyncGeneratorResumeNextStep(Node* context, Node* generator, Node* req,
+ Node* continuation, Label* exit_loop);
+};
+
+} // namespace internal
+} // namespace v8

Powered by Google App Engine
This is Rietveld 408576698