builtins-async-gen.h 2.37 KB
Newer Older
1 2 3 4
// 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.

5 6
#ifndef V8_BUILTINS_BUILTINS_ASYNC_GEN_H_
#define V8_BUILTINS_BUILTINS_ASYNC_GEN_H_
7

8
#include "src/builtins/builtins-promise-gen.h"
9 10 11 12 13 14

namespace v8 {
namespace internal {

class AsyncBuiltinsAssembler : public PromiseBuiltinsAssembler {
 public:
15
  explicit AsyncBuiltinsAssembler(compiler::CodeAssemblerState* state)
16 17 18
      : PromiseBuiltinsAssembler(state) {}

 protected:
19
  // Perform steps to resume generator after `value` is resolved.
20 21 22
  // `on_reject` is the SharedFunctioninfo instance used to create the reject
  // closure. `on_resolve` is the SharedFunctioninfo instance used to create the
  // resolve closure. Returns the Promise-wrapped `value`.
23 24 25
  TNode<Object> Await(TNode<Context> context,
                      TNode<JSGeneratorObject> generator, TNode<Object> value,
                      TNode<JSPromise> outer_promise,
26 27
                      TNode<SharedFunctionInfo> on_resolve_sfi,
                      TNode<SharedFunctionInfo> on_reject_sfi,
28 29 30 31
                      TNode<Oddball> is_predicted_as_caught);
  TNode<Object> Await(TNode<Context> context,
                      TNode<JSGeneratorObject> generator, TNode<Object> value,
                      TNode<JSPromise> outer_promise,
32 33
                      TNode<SharedFunctionInfo> on_resolve_sfi,
                      TNode<SharedFunctionInfo> on_reject_sfi,
34
                      bool is_predicted_as_caught) {
35 36
    return Await(context, generator, value, outer_promise, on_resolve_sfi,
                 on_reject_sfi, BooleanConstant(is_predicted_as_caught));
37
  }
38 39 40

  // Return a new built-in function object as defined in
  // Async Iterator Value Unwrap Functions
41
  TNode<JSFunction> CreateUnwrapClosure(TNode<NativeContext> native_context,
42
                                        TNode<Oddball> done);
43 44

 private:
45 46 47
  void InitializeNativeClosure(TNode<Context> context,
                               TNode<NativeContext> native_context,
                               TNode<HeapObject> function,
48
                               TNode<SharedFunctionInfo> shared_info);
49
  TNode<Context> AllocateAsyncIteratorValueUnwrapContext(
50
      TNode<NativeContext> native_context, TNode<Oddball> done);
51 52 53 54 55
};

}  // namespace internal
}  // namespace v8

56
#endif  // V8_BUILTINS_BUILTINS_ASYNC_GEN_H_