OLD | NEW |
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 1728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1739 } | 1739 } |
1740 | 1740 |
1741 // SuspendGenerator <generator> | 1741 // SuspendGenerator <generator> |
1742 // | 1742 // |
1743 // Exports the register file and stores it into the generator. Also stores the | 1743 // Exports the register file and stores it into the generator. Also stores the |
1744 // current context and the state given in the accumulator into the generator. | 1744 // current context and the state given in the accumulator into the generator. |
1745 void Interpreter::DoSuspendGenerator(InterpreterAssembler* assembler) { | 1745 void Interpreter::DoSuspendGenerator(InterpreterAssembler* assembler) { |
1746 Node* generator_reg = __ BytecodeOperandReg(0); | 1746 Node* generator_reg = __ BytecodeOperandReg(0); |
1747 Node* generator = __ LoadRegister(generator_reg); | 1747 Node* generator = __ LoadRegister(generator_reg); |
1748 | 1748 |
1749 Node* array = __ ExportRegisterFile(); | 1749 Node* array = |
| 1750 __ LoadObjectField(generator, JSGeneratorObject::kOperandStackOffset); |
1750 Node* context = __ GetContext(); | 1751 Node* context = __ GetContext(); |
1751 Node* state = __ GetAccumulator(); | 1752 Node* state = __ GetAccumulator(); |
1752 | 1753 |
1753 __ StoreObjectField(generator, JSGeneratorObject::kOperandStackOffset, array); | 1754 __ ExportRegisterFile(array); |
1754 __ StoreObjectField(generator, JSGeneratorObject::kContextOffset, context); | 1755 __ StoreObjectField(generator, JSGeneratorObject::kContextOffset, context); |
1755 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, state); | 1756 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, state); |
1756 | 1757 |
1757 __ Dispatch(); | 1758 __ Dispatch(); |
1758 } | 1759 } |
1759 | 1760 |
1760 // ResumeGenerator <generator> | 1761 // ResumeGenerator <generator> |
1761 // | 1762 // |
1762 // Imports the register file stored in the generator. Also loads the | 1763 // Imports the register file stored in the generator. Also loads the |
1763 // generator's state and stores it in the accumulator, before overwriting it | 1764 // generator's state and stores it in the accumulator, before overwriting it |
1764 // with kGeneratorExecuting. | 1765 // with kGeneratorExecuting. |
1765 void Interpreter::DoResumeGenerator(InterpreterAssembler* assembler) { | 1766 void Interpreter::DoResumeGenerator(InterpreterAssembler* assembler) { |
1766 Node* generator_reg = __ BytecodeOperandReg(0); | 1767 Node* generator_reg = __ BytecodeOperandReg(0); |
1767 Node* generator = __ LoadRegister(generator_reg); | 1768 Node* generator = __ LoadRegister(generator_reg); |
1768 | 1769 |
1769 __ ImportRegisterFile( | 1770 __ ImportRegisterFile( |
1770 __ LoadObjectField(generator, JSGeneratorObject::kOperandStackOffset)); | 1771 __ LoadObjectField(generator, JSGeneratorObject::kOperandStackOffset)); |
1771 __ StoreObjectField(generator, JSGeneratorObject::kOperandStackOffset, | |
1772 __ HeapConstant(isolate_->factory()->empty_fixed_array())); | |
1773 | 1772 |
1774 Node* old_state = | 1773 Node* old_state = |
1775 __ LoadObjectField(generator, JSGeneratorObject::kContinuationOffset); | 1774 __ LoadObjectField(generator, JSGeneratorObject::kContinuationOffset); |
1776 Node* new_state = __ Int32Constant(JSGeneratorObject::kGeneratorExecuting); | 1775 Node* new_state = __ Int32Constant(JSGeneratorObject::kGeneratorExecuting); |
1777 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, | 1776 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, |
1778 __ SmiTag(new_state)); | 1777 __ SmiTag(new_state)); |
1779 __ SetAccumulator(old_state); | 1778 __ SetAccumulator(old_state); |
1780 | 1779 |
1781 __ Dispatch(); | 1780 __ Dispatch(); |
1782 } | 1781 } |
1783 | 1782 |
1784 } // namespace interpreter | 1783 } // namespace interpreter |
1785 } // namespace internal | 1784 } // namespace internal |
1786 } // namespace v8 | 1785 } // namespace v8 |
OLD | NEW |