• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef V8_BUILTINS_BUILTINS_ASYNC_GEN_H_
6 #define V8_BUILTINS_BUILTINS_ASYNC_GEN_H_
7 
8 #include "src/builtins/builtins-promise-gen.h"
9 
10 namespace v8 {
11 namespace internal {
12 
13 class AsyncBuiltinsAssembler : public PromiseBuiltinsAssembler {
14  public:
AsyncBuiltinsAssembler(compiler::CodeAssemblerState * state)15   explicit AsyncBuiltinsAssembler(compiler::CodeAssemblerState* state)
16       : PromiseBuiltinsAssembler(state) {}
17 
18  protected:
19   // Perform steps to resume generator after `value` is resolved.
20   // `on_reject` is the SharedFunctioninfo instance used to create the reject
21   // closure. `on_resolve` is the SharedFunctioninfo instance used to create the
22   // resolve closure. Returns the Promise-wrapped `value`.
23   TNode<Object> Await(TNode<Context> context,
24                       TNode<JSGeneratorObject> generator, TNode<Object> value,
25                       TNode<JSPromise> outer_promise,
26                       TNode<SharedFunctionInfo> on_resolve_sfi,
27                       TNode<SharedFunctionInfo> on_reject_sfi,
28                       TNode<Oddball> is_predicted_as_caught);
Await(TNode<Context> context,TNode<JSGeneratorObject> generator,TNode<Object> value,TNode<JSPromise> outer_promise,TNode<SharedFunctionInfo> on_resolve_sfi,TNode<SharedFunctionInfo> on_reject_sfi,bool is_predicted_as_caught)29   TNode<Object> Await(TNode<Context> context,
30                       TNode<JSGeneratorObject> generator, TNode<Object> value,
31                       TNode<JSPromise> outer_promise,
32                       TNode<SharedFunctionInfo> on_resolve_sfi,
33                       TNode<SharedFunctionInfo> on_reject_sfi,
34                       bool is_predicted_as_caught) {
35     return Await(context, generator, value, outer_promise, on_resolve_sfi,
36                  on_reject_sfi, BooleanConstant(is_predicted_as_caught));
37   }
38 
39   // Return a new built-in function object as defined in
40   // Async Iterator Value Unwrap Functions
41   TNode<JSFunction> CreateUnwrapClosure(TNode<NativeContext> native_context,
42                                         TNode<Oddball> done);
43 
44  private:
45   void InitializeNativeClosure(TNode<Context> context,
46                                TNode<NativeContext> native_context,
47                                TNode<HeapObject> function,
48                                TNode<SharedFunctionInfo> shared_info);
49   TNode<Context> AllocateAsyncIteratorValueUnwrapContext(
50       TNode<NativeContext> native_context, TNode<Oddball> done);
51 };
52 
53 }  // namespace internal
54 }  // namespace v8
55 
56 #endif  // V8_BUILTINS_BUILTINS_ASYNC_GEN_H_
57