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

Side by Side Diff: src/interpreter/interpreter.cc

Issue 2622833002: WIP [esnext] implement async iteration proposal (Closed)
Patch Set: simplify AsyncIteratorValueUnwrap Created 3 years, 11 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
« no previous file with comments | « src/interpreter/bytecodes.h ('k') | src/interpreter/interpreter-intrinsics.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/interpreter/interpreter.h" 5 #include "src/interpreter/interpreter.h"
6 6
7 #include <fstream> 7 #include <fstream>
8 #include <memory> 8 #include <memory>
9 9
10 #include "src/ast/prettyprinter.h" 10 #include "src/ast/prettyprinter.h"
(...skipping 3224 matching lines...) Expand 10 before | Expand all | Expand 10 after
3235 __ Dispatch(); 3235 __ Dispatch();
3236 3236
3237 __ Bind(&if_stepping); 3237 __ Bind(&if_stepping);
3238 { 3238 {
3239 Node* context = __ GetContext(); 3239 Node* context = __ GetContext();
3240 __ CallRuntime(Runtime::kDebugRecordGenerator, context, generator); 3240 __ CallRuntime(Runtime::kDebugRecordGenerator, context, generator);
3241 __ Goto(&ok); 3241 __ Goto(&ok);
3242 } 3242 }
3243 } 3243 }
3244 3244
3245 // AwaitGenerator <generator>
3246 //
3247 // Like SuspendGenerator, exports the register file and stores it into the
3248 // generator, along with current context, the continuation state. The current
3249 // bytecode offset is stored in the [await_input] field to prevent clobbering
3250 // the sent value.
3251 void Interpreter::DoAwaitGenerator(InterpreterAssembler* assembler) {
3252 Node* generator_reg = __ BytecodeOperandReg(0);
3253 Node* generator = __ LoadRegister(generator_reg);
3254
3255 Label if_stepping(assembler, Label::kDeferred), ok(assembler);
3256 Node* step_action_address = __ ExternalConstant(
3257 ExternalReference::debug_last_step_action_address(isolate_));
3258 Node* step_action = __ Load(MachineType::Int8(), step_action_address);
3259 STATIC_ASSERT(StepIn > StepNext);
3260 STATIC_ASSERT(StepFrame > StepNext);
3261 STATIC_ASSERT(LastStepAction == StepFrame);
3262 Node* step_next = __ Int32Constant(StepNext);
3263 __ Branch(__ Int32LessThanOrEqual(step_next, step_action), &if_stepping, &ok);
3264 __ Bind(&ok);
3265
3266 Node* array =
3267 __ LoadObjectField(generator, JSGeneratorObject::kRegisterFileOffset);
3268 Node* context = __ GetContext();
3269 Node* state = __ GetAccumulator();
3270
3271 __ ExportRegisterFile(array);
3272 __ StoreObjectField(generator, JSGeneratorObject::kContextOffset, context);
3273 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, state);
3274
3275 Node* offset = __ SmiTag(__ BytecodeOffset());
3276 __ StoreObjectField(generator, JSAsyncGeneratorObject::kAwaitInputOffset,
3277 offset);
3278
3279 __ Dispatch();
3280
3281 __ Bind(&if_stepping);
3282 {
3283 Node* context = __ GetContext();
3284 __ CallRuntime(Runtime::kDebugRecordGenerator, context, generator);
3285 __ Goto(&ok);
3286 }
3287 }
3288
3245 // ResumeGenerator <generator> 3289 // ResumeGenerator <generator>
3246 // 3290 //
3247 // Imports the register file stored in the generator. Also loads the 3291 // Imports the register file stored in the generator. Also loads the
3248 // generator's state and stores it in the accumulator, before overwriting it 3292 // generator's state and stores it in the accumulator, before overwriting it
3249 // with kGeneratorExecuting. 3293 // with kGeneratorExecuting.
3250 void Interpreter::DoResumeGenerator(InterpreterAssembler* assembler) { 3294 void Interpreter::DoResumeGenerator(InterpreterAssembler* assembler) {
3251 Node* generator_reg = __ BytecodeOperandReg(0); 3295 Node* generator_reg = __ BytecodeOperandReg(0);
3252 Node* generator = __ LoadRegister(generator_reg); 3296 Node* generator = __ LoadRegister(generator_reg);
3253 3297
3254 __ ImportRegisterFile( 3298 __ ImportRegisterFile(
3255 __ LoadObjectField(generator, JSGeneratorObject::kRegisterFileOffset)); 3299 __ LoadObjectField(generator, JSGeneratorObject::kRegisterFileOffset));
3256 3300
3257 Node* old_state = 3301 Node* old_state =
3258 __ LoadObjectField(generator, JSGeneratorObject::kContinuationOffset); 3302 __ LoadObjectField(generator, JSGeneratorObject::kContinuationOffset);
3259 Node* new_state = __ Int32Constant(JSGeneratorObject::kGeneratorExecuting); 3303 Node* new_state = __ Int32Constant(JSGeneratorObject::kGeneratorExecuting);
3260 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, 3304 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset,
3261 __ SmiTag(new_state)); 3305 __ SmiTag(new_state));
3262 __ SetAccumulator(old_state); 3306 __ SetAccumulator(old_state);
3263 3307
3264 __ Dispatch(); 3308 __ Dispatch();
3265 } 3309 }
3266 3310
3267 } // namespace interpreter 3311 } // namespace interpreter
3268 } // namespace internal 3312 } // namespace internal
3269 } // namespace v8 3313 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/bytecodes.h ('k') | src/interpreter/interpreter-intrinsics.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698