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 1774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1785 void Interpreter::DoNop(InterpreterAssembler* assembler) { __ Dispatch(); } | 1785 void Interpreter::DoNop(InterpreterAssembler* assembler) { __ Dispatch(); } |
1786 | 1786 |
1787 // SuspendGenerator <generator> | 1787 // SuspendGenerator <generator> |
1788 // | 1788 // |
1789 // Exports the register file and stores it into the generator. Also stores the | 1789 // Exports the register file and stores it into the generator. Also stores the |
1790 // current context and the state given in the accumulator into the generator. | 1790 // current context and the state given in the accumulator into the generator. |
1791 void Interpreter::DoSuspendGenerator(InterpreterAssembler* assembler) { | 1791 void Interpreter::DoSuspendGenerator(InterpreterAssembler* assembler) { |
1792 Node* generator_reg = __ BytecodeOperandReg(0); | 1792 Node* generator_reg = __ BytecodeOperandReg(0); |
1793 Node* generator = __ LoadRegister(generator_reg); | 1793 Node* generator = __ LoadRegister(generator_reg); |
1794 | 1794 |
| 1795 Label if_stepping(assembler, Label::kDeferred), ok(assembler); |
| 1796 Node* step_action_address = __ ExternalConstant( |
| 1797 ExternalReference::debug_last_step_action_address(isolate_)); |
| 1798 Node* step_action = __ Load(MachineType::Int8(), step_action_address); |
| 1799 STATIC_ASSERT(StepIn > StepNext); |
| 1800 STATIC_ASSERT(StepFrame > StepNext); |
| 1801 STATIC_ASSERT(LastStepAction == StepFrame); |
| 1802 Node* step_next = __ Int32Constant(StepNext); |
| 1803 __ BranchIfInt32LessThanOrEqual(step_next, step_action, &if_stepping, &ok); |
| 1804 __ Bind(&ok); |
| 1805 |
1795 Node* array = | 1806 Node* array = |
1796 __ LoadObjectField(generator, JSGeneratorObject::kOperandStackOffset); | 1807 __ LoadObjectField(generator, JSGeneratorObject::kOperandStackOffset); |
1797 Node* context = __ GetContext(); | 1808 Node* context = __ GetContext(); |
1798 Node* state = __ GetAccumulator(); | 1809 Node* state = __ GetAccumulator(); |
1799 | 1810 |
1800 __ ExportRegisterFile(array); | 1811 __ ExportRegisterFile(array); |
1801 __ StoreObjectField(generator, JSGeneratorObject::kContextOffset, context); | 1812 __ StoreObjectField(generator, JSGeneratorObject::kContextOffset, context); |
1802 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, state); | 1813 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, state); |
1803 | 1814 |
1804 __ Dispatch(); | 1815 __ Dispatch(); |
| 1816 |
| 1817 __ Bind(&if_stepping); |
| 1818 { |
| 1819 Node* context = __ GetContext(); |
| 1820 __ CallRuntime(Runtime::kDebugRecordAsyncFunction, context, generator); |
| 1821 __ Goto(&ok); |
| 1822 } |
1805 } | 1823 } |
1806 | 1824 |
1807 // ResumeGenerator <generator> | 1825 // ResumeGenerator <generator> |
1808 // | 1826 // |
1809 // Imports the register file stored in the generator. Also loads the | 1827 // Imports the register file stored in the generator. Also loads the |
1810 // generator's state and stores it in the accumulator, before overwriting it | 1828 // generator's state and stores it in the accumulator, before overwriting it |
1811 // with kGeneratorExecuting. | 1829 // with kGeneratorExecuting. |
1812 void Interpreter::DoResumeGenerator(InterpreterAssembler* assembler) { | 1830 void Interpreter::DoResumeGenerator(InterpreterAssembler* assembler) { |
1813 Node* generator_reg = __ BytecodeOperandReg(0); | 1831 Node* generator_reg = __ BytecodeOperandReg(0); |
1814 Node* generator = __ LoadRegister(generator_reg); | 1832 Node* generator = __ LoadRegister(generator_reg); |
1815 | 1833 |
1816 __ ImportRegisterFile( | 1834 __ ImportRegisterFile( |
1817 __ LoadObjectField(generator, JSGeneratorObject::kOperandStackOffset)); | 1835 __ LoadObjectField(generator, JSGeneratorObject::kOperandStackOffset)); |
1818 | 1836 |
1819 Node* old_state = | 1837 Node* old_state = |
1820 __ LoadObjectField(generator, JSGeneratorObject::kContinuationOffset); | 1838 __ LoadObjectField(generator, JSGeneratorObject::kContinuationOffset); |
1821 Node* new_state = __ Int32Constant(JSGeneratorObject::kGeneratorExecuting); | 1839 Node* new_state = __ Int32Constant(JSGeneratorObject::kGeneratorExecuting); |
1822 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, | 1840 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, |
1823 __ SmiTag(new_state)); | 1841 __ SmiTag(new_state)); |
1824 __ SetAccumulator(old_state); | 1842 __ SetAccumulator(old_state); |
1825 | 1843 |
1826 __ Dispatch(); | 1844 __ Dispatch(); |
1827 } | 1845 } |
1828 | 1846 |
1829 } // namespace interpreter | 1847 } // namespace interpreter |
1830 } // namespace internal | 1848 } // namespace internal |
1831 } // namespace v8 | 1849 } // namespace v8 |
OLD | NEW |