v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
runtime-generator.cc
Go to the documentation of this file.
1// Copyright 2014 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/heap/factory.h"
6#include "src/heap/heap-inl.h"
8
9namespace v8 {
10namespace internal {
11
12RUNTIME_FUNCTION(Runtime_AsyncFunctionAwait) {
13 // Runtime call is implemented in InterpreterIntrinsics and lowered in
14 // JSIntrinsicLowering
16}
17
18RUNTIME_FUNCTION(Runtime_AsyncFunctionEnter) {
19 // Runtime call is implemented in InterpreterIntrinsics and lowered in
20 // JSIntrinsicLowering
22}
23
24RUNTIME_FUNCTION(Runtime_AsyncFunctionReject) {
25 // Runtime call is implemented in InterpreterIntrinsics and lowered in
26 // JSIntrinsicLowering
28}
29
30RUNTIME_FUNCTION(Runtime_AsyncFunctionResolve) {
31 // Runtime call is implemented in InterpreterIntrinsics and lowered in
32 // JSIntrinsicLowering
34}
35
36RUNTIME_FUNCTION(Runtime_CreateJSGeneratorObject) {
37 HandleScope scope(isolate);
38 DCHECK_EQ(2, args.length());
41 CHECK_IMPLIES(IsAsyncFunction(function->shared()->kind()),
42 IsAsyncGeneratorFunction(function->shared()->kind()));
43 CHECK(IsResumableFunction(function->shared()->kind()));
44
45 // Underlying function needs to have bytecode available.
46 DCHECK(function->shared()->HasBytecodeArray());
47 int length;
48 {
49 // TODO(40931165): load bytecode array from function's dispatch table entry
50 // when available instead of shared function info.
51 Tagged<BytecodeArray> bytecode =
52 function->shared()->GetBytecodeArray(isolate);
53
54 length = bytecode->parameter_count_without_receiver() +
55 bytecode->register_count();
56 }
57 DirectHandle<FixedArray> parameters_and_registers =
58 isolate->factory()->NewFixedArray(length);
59
61 isolate->factory()->NewJSGeneratorObject(function);
63 Tagged<JSGeneratorObject> raw_generator = *generator;
64 raw_generator->set_function(*function);
65 raw_generator->set_context(isolate->context());
66 raw_generator->set_receiver(*receiver);
67 raw_generator->set_parameters_and_registers(*parameters_and_registers);
68 raw_generator->set_resume_mode(JSGeneratorObject::ResumeMode::kNext);
69 raw_generator->set_continuation(JSGeneratorObject::kGeneratorExecuting);
70 if (IsJSAsyncGeneratorObject(*raw_generator)) {
71 Cast<JSAsyncGeneratorObject>(raw_generator)->set_is_awaiting(0);
72 }
73 return raw_generator;
74}
75
76RUNTIME_FUNCTION(Runtime_GeneratorClose) {
77 // Runtime call is implemented in InterpreterIntrinsics and lowered in
78 // JSIntrinsicLowering
80}
81
82RUNTIME_FUNCTION(Runtime_GeneratorGetFunction) {
83 HandleScope scope(isolate);
84 DCHECK_EQ(1, args.length());
86
87 return generator->function();
88}
89
90RUNTIME_FUNCTION(Runtime_AsyncGeneratorAwait) {
91 // Runtime call is implemented in InterpreterIntrinsics and lowered in
92 // JSIntrinsicLowering
94}
95
96RUNTIME_FUNCTION(Runtime_AsyncGeneratorResolve) {
97 // Runtime call is implemented in InterpreterIntrinsics and lowered in
98 // JSIntrinsicLowering
100}
101
102RUNTIME_FUNCTION(Runtime_AsyncGeneratorReject) {
103 // Runtime call is implemented in InterpreterIntrinsics and lowered in
104 // JSIntrinsicLowering
105 UNREACHABLE();
106}
107
108RUNTIME_FUNCTION(Runtime_AsyncGeneratorYieldWithAwait) {
109 // Runtime call is implemented in InterpreterIntrinsics and lowered in
110 // JSIntrinsicLowering
111 UNREACHABLE();
112}
113
114RUNTIME_FUNCTION(Runtime_GeneratorGetResumeMode) {
115 // Runtime call is implemented in InterpreterIntrinsics and lowered in
116 // JSIntrinsicLowering
117 UNREACHABLE();
118}
119
120} // namespace internal
121} // namespace v8
static const int kGeneratorExecuting
#define RUNTIME_FUNCTION(Name)
Definition arguments.h:162
base::Vector< const DirectHandle< Object > > args
Definition execution.cc:74
TNode< Object > receiver
bool IsResumableFunction(FunctionKind kind)
bool IsAsyncFunction(FunctionKind kind)
bool IsAsyncGeneratorFunction(FunctionKind kind)
Tagged< To > Cast(Tagged< From > value, const v8::SourceLocation &loc=INIT_SOURCE_LOCATION_IN_DEBUG)
Definition casting.h:150
#define CHECK_IMPLIES(lhs, rhs)
#define CHECK(condition)
Definition logging.h:124
#define DCHECK(condition)
Definition logging.h:482
#define DCHECK_EQ(v1, v2)
Definition logging.h:485