builtins-async-gen.h 2.4 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
#include "src/objects/js-generator.h"
10 11 12 13 14 15

namespace v8 {
namespace internal {

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

 protected:
20
  // Perform steps to resume generator after `value` is resolved.
21 22 23
  // `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`.
24 25 26
  TNode<Object> Await(TNode<Context> context,
                      TNode<JSGeneratorObject> generator, TNode<Object> value,
                      TNode<JSPromise> outer_promise,
27 28
                      TNode<SharedFunctionInfo> on_resolve_sfi,
                      TNode<SharedFunctionInfo> on_reject_sfi,
29 30 31 32
                      TNode<Oddball> is_predicted_as_caught);
  TNode<Object> Await(TNode<Context> context,
                      TNode<JSGeneratorObject> generator, TNode<Object> value,
                      TNode<JSPromise> outer_promise,
33 34
                      TNode<SharedFunctionInfo> on_resolve_sfi,
                      TNode<SharedFunctionInfo> on_reject_sfi,
35
                      bool is_predicted_as_caught) {
36 37
    return Await(context, generator, value, outer_promise, on_resolve_sfi,
                 on_reject_sfi, BooleanConstant(is_predicted_as_caught));
38
  }
39 40 41

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

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

}  // namespace internal
}  // namespace v8

57
#endif  // V8_BUILTINS_BUILTINS_ASYNC_GEN_H_