Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: src/runtime/runtime-generator.cc

Issue 1957393004: Allow Turbofan optimization of Ignition generators (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/runtime/runtime-utils.h" 5 #include "src/runtime/runtime-utils.h"
6 6
7 #include "src/arguments.h" 7 #include "src/arguments.h"
8 #include "src/factory.h" 8 #include "src/factory.h"
9 #include "src/frames-inl.h" 9 #include "src/frames-inl.h"
10 #include "src/objects-inl.h" 10 #include "src/objects-inl.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 // Returns resume mode of generator activation. 122 // Returns resume mode of generator activation.
123 RUNTIME_FUNCTION(Runtime_GeneratorGetResumeMode) { 123 RUNTIME_FUNCTION(Runtime_GeneratorGetResumeMode) {
124 HandleScope scope(isolate); 124 HandleScope scope(isolate);
125 DCHECK(args.length() == 1); 125 DCHECK(args.length() == 1);
126 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0); 126 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0);
127 127
128 return Smi::FromInt(generator->resume_mode()); 128 return Smi::FromInt(generator->resume_mode());
129 } 129 }
130 130
131 131
132 // Returns generator continuation as a PC offset, or the magic -1 or 0 values. 132 RUNTIME_FUNCTION(Runtime_GeneratorSetContext) {
133 HandleScope scope(isolate);
134 DCHECK(args.length() == 1);
135 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0);
136
137 generator->set_context(isolate->context());
138 return isolate->heap()->undefined_value();
139 }
140
141
133 RUNTIME_FUNCTION(Runtime_GeneratorGetContinuation) { 142 RUNTIME_FUNCTION(Runtime_GeneratorGetContinuation) {
134 HandleScope scope(isolate); 143 HandleScope scope(isolate);
135 DCHECK(args.length() == 1); 144 DCHECK(args.length() == 1);
136 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0); 145 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0);
137 146
138 return Smi::FromInt(generator->continuation()); 147 return Smi::FromInt(generator->continuation());
139 } 148 }
140 149
141 150
151 RUNTIME_FUNCTION(Runtime_GeneratorSetContinuation) {
152 HandleScope scope(isolate);
153 DCHECK(args.length() == 2);
154 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0);
155 CONVERT_ARG_HANDLE_CHECKED(Smi, continuation, 1);
Benedikt Meurer 2016/05/10 10:32:08 Use CONVERT_SMI_ARG_CHECKED here.
neis 2016/05/10 11:32:06 Done.
156
157 generator->set_continuation(continuation->value());
158 return isolate->heap()->undefined_value();
159 }
160
161
162 RUNTIME_FUNCTION(Runtime_GeneratorReadRegister) {
163 HandleScope scope(isolate);
164 DCHECK(args.length() == 2);
165 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0);
166 CONVERT_ARG_HANDLE_CHECKED(Smi, index, 1);
Benedikt Meurer 2016/05/10 10:32:08 Use CONVERT_SMI_ARG_CHECKED here.
neis 2016/05/10 11:32:06 Done.
167
168 DCHECK(FLAG_ignition && FLAG_ignition_generators);
169 DCHECK(generator->function()->shared()->HasBytecodeArray());
170
171 return generator->operand_stack()->get(index->value());
172 }
173
174
175 RUNTIME_FUNCTION(Runtime_GeneratorWriteRegister) {
176 HandleScope scope(isolate);
177 DCHECK(args.length() == 3);
178 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0);
179 CONVERT_ARG_HANDLE_CHECKED(Smi, index, 1);
Benedikt Meurer 2016/05/10 10:32:08 Use CONVERT_SMI_ARG_CHECKED here.
neis 2016/05/10 11:32:06 Done.
180 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
181
182 DCHECK(FLAG_ignition && FLAG_ignition_generators);
183 DCHECK(generator->function()->shared()->HasBytecodeArray());
184
185 generator->operand_stack()->set(index->value(), *value);
186 return isolate->heap()->undefined_value();
187 }
188
189
142 RUNTIME_FUNCTION(Runtime_GeneratorGetSourcePosition) { 190 RUNTIME_FUNCTION(Runtime_GeneratorGetSourcePosition) {
143 HandleScope scope(isolate); 191 HandleScope scope(isolate);
144 DCHECK(args.length() == 1); 192 DCHECK(args.length() == 1);
145 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0); 193 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0);
146 194
147 if (generator->is_suspended()) { 195 if (generator->is_suspended()) {
148 Handle<Code> code(generator->function()->code(), isolate); 196 Handle<Code> code(generator->function()->code(), isolate);
149 int offset = generator->continuation(); 197 int offset = generator->continuation();
150 RUNTIME_ASSERT(0 <= offset && offset < code->instruction_size()); 198 RUNTIME_ASSERT(0 <= offset && offset < code->instruction_size());
151 return Smi::FromInt(code->SourcePosition(offset)); 199 return Smi::FromInt(code->SourcePosition(offset));
152 } 200 }
153 201
154 return isolate->heap()->undefined_value(); 202 return isolate->heap()->undefined_value();
155 } 203 }
156 204
157 } // namespace internal 205 } // namespace internal
158 } // namespace v8 206 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698