OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "src/builtins/builtins-promise.h" |
| 6 |
| 7 namespace v8 { |
| 8 namespace internal { |
| 9 |
| 10 class AsyncBuiltinsAssembler : public PromiseBuiltinsAssembler { |
| 11 public: |
| 12 explicit AsyncBuiltinsAssembler(CodeAssemblerState* state) |
| 13 : PromiseBuiltinsAssembler(state) {} |
| 14 |
| 15 // Async Generator: |
| 16 void AsyncGeneratorResumeNext(Node* context, Node* generator, |
| 17 Node* continuation); |
| 18 void AsyncGeneratorResumeNext(Node* context, Node* generator) { |
| 19 Node* continuation = |
| 20 LoadObjectField(generator, JSAsyncGeneratorObject::kContinuationOffset); |
| 21 AsyncGeneratorResumeNext(context, generator, continuation); |
| 22 } |
| 23 |
| 24 Node* TakeFirstAsyncGeneratorRequestFromQueue(Node* generator); |
| 25 void AddAsyncGeneratorRequestToQueue(Node* generator, Node* request); |
| 26 |
| 27 Node* AllocateAsyncGeneratorRequest( |
| 28 JSAsyncGeneratorObject::ResumeMode resume_mode, Node* resume_value, |
| 29 Node* promise); |
| 30 |
| 31 // Async Iterator |
| 32 Node* AllocateAsyncIteratorValueUnwrapContext(Node* native_context, |
| 33 Node* done); |
| 34 |
| 35 protected: |
| 36 // Async Generator shared |
| 37 void AsyncGeneratorEnqueue(Node* context, Node* generator, Node* value, |
| 38 JSAsyncGeneratorObject::ResumeMode resume_mode, |
| 39 const char* method_name); |
| 40 |
| 41 void AsyncGeneratorAwaitResumeClosure( |
| 42 Node* context, Node* value, |
| 43 JSAsyncGeneratorObject::ResumeMode resume_mode); |
| 44 |
| 45 typedef std::function<Node*(Node*)> NodeGenerator1; |
| 46 |
| 47 // Perform steps to resume generator after `value` is resolved. |
| 48 // `on_reject_context_index` is an index into the Native Context, which should |
| 49 // point to a SharedFunctioninfo instance used to create the closure. The |
| 50 // value following the reject index should be a similar value for the resolve |
| 51 // closure. Returns the Promise-wrapped `value`. |
| 52 Node* Await(Node* context, Node* generator, Node* value, Node* outer_promise, |
| 53 const NodeGenerator1& create_closure_context, |
| 54 int on_resolve_context_index, int on_reject_context_index, |
| 55 bool is_catchable); |
| 56 |
| 57 // Shared implementation of the catchable and uncatchable variations of Await |
| 58 // for AsyncGenerators. |
| 59 void AsyncGeneratorAwait(bool is_catchable); |
| 60 |
| 61 private: |
| 62 // Async Generator private |
| 63 void AsyncGeneratorResumeNextStep(Node* context, Node* generator, Node* req, |
| 64 Node* continuation); |
| 65 }; |
| 66 |
| 67 } // namespace internal |
| 68 } // namespace v8 |
OLD | NEW |