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

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

Issue 1904933002: Introduce bytecodes for assisting generator suspend and resume. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Nix Created 4 years, 8 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-assembler.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 8
9 #include "src/ast/prettyprinter.h" 9 #include "src/ast/prettyprinter.h"
10 #include "src/code-factory.h" 10 #include "src/code-factory.h"
(...skipping 1667 matching lines...) Expand 10 before | Expand all | Expand 10 after
1678 __ DispatchWide(OperandScale::kQuadruple); 1678 __ DispatchWide(OperandScale::kQuadruple);
1679 } 1679 }
1680 1680
1681 // Illegal 1681 // Illegal
1682 // 1682 //
1683 // An invalid bytecode aborting execution if dispatched. 1683 // An invalid bytecode aborting execution if dispatched.
1684 void Interpreter::DoIllegal(InterpreterAssembler* assembler) { 1684 void Interpreter::DoIllegal(InterpreterAssembler* assembler) {
1685 __ Abort(kInvalidBytecode); 1685 __ Abort(kInvalidBytecode);
1686 } 1686 }
1687 1687
1688 // SuspendGenerator <generator>
1689 //
1690 // Exports the register file and stores it into the generator. Also stores the
1691 // current context and the state given in the accumulator into the generator.
1692 void Interpreter::DoSuspendGenerator(InterpreterAssembler* assembler) {
1693 Node* generator_reg = __ BytecodeOperandReg(0);
1694 Node* generator = __ LoadRegister(generator_reg);
1695
1696 Node* array = __ ExportRegisterFile();
1697 Node* context = __ GetContext();
1698 Node* state = __ GetAccumulator();
1699
1700 __ StoreObjectField(generator, JSGeneratorObject::kOperandStackOffset, array);
1701 __ StoreObjectField(generator, JSGeneratorObject::kContextOffset, context);
1702 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, state);
1703
1704 __ Dispatch();
1705 }
1706
1707 // ResumeGenerator <generator>
1708 //
1709 // Imports the register file stored in the generator. Also loads the
1710 // generator's state and stores it in the accumulator, before overwriting it
1711 // with kGeneratorExecuting.
1712 void Interpreter::DoResumeGenerator(InterpreterAssembler* assembler) {
1713 Node* generator_reg = __ BytecodeOperandReg(0);
1714 Node* generator = __ LoadRegister(generator_reg);
1715
1716 __ ImportRegisterFile(
1717 __ LoadObjectField(generator, JSGeneratorObject::kOperandStackOffset));
1718 __ StoreObjectField(generator, JSGeneratorObject::kOperandStackOffset,
1719 __ HeapConstant(isolate_->factory()->empty_fixed_array()));
1720
1721 Node* old_state =
1722 __ LoadObjectField(generator, JSGeneratorObject::kContinuationOffset);
1723 Node* new_state = __ Int32Constant(JSGeneratorObject::kGeneratorExecuting);
1724 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset,
1725 __ SmiTag(new_state));
1726 __ SetAccumulator(old_state);
1727
1728 __ Dispatch();
1729 }
1730
1688 } // namespace interpreter 1731 } // namespace interpreter
1689 } // namespace internal 1732 } // namespace internal
1690 } // namespace v8 1733 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/bytecodes.h ('k') | src/interpreter/interpreter-assembler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698