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 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "src/ast/prettyprinter.h" | 10 #include "src/ast/prettyprinter.h" |
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
743 // PopContext <context> | 743 // PopContext <context> |
744 // | 744 // |
745 // Pops the current context and sets <context> as the new context. | 745 // Pops the current context and sets <context> as the new context. |
746 void Interpreter::DoPopContext(InterpreterAssembler* assembler) { | 746 void Interpreter::DoPopContext(InterpreterAssembler* assembler) { |
747 Node* reg_index = __ BytecodeOperandReg(0); | 747 Node* reg_index = __ BytecodeOperandReg(0); |
748 Node* context = __ LoadRegister(reg_index); | 748 Node* context = __ LoadRegister(reg_index); |
749 __ SetContext(context); | 749 __ SetContext(context); |
750 __ Dispatch(); | 750 __ Dispatch(); |
751 } | 751 } |
752 | 752 |
| 753 // TODO(mythria): Remove this function once all BinaryOps record type feedback. |
753 template <class Generator> | 754 template <class Generator> |
754 void Interpreter::DoBinaryOp(InterpreterAssembler* assembler) { | 755 void Interpreter::DoBinaryOp(InterpreterAssembler* assembler) { |
755 Node* reg_index = __ BytecodeOperandReg(0); | 756 Node* reg_index = __ BytecodeOperandReg(0); |
756 Node* lhs = __ LoadRegister(reg_index); | 757 Node* lhs = __ LoadRegister(reg_index); |
757 Node* rhs = __ GetAccumulator(); | 758 Node* rhs = __ GetAccumulator(); |
758 Node* context = __ GetContext(); | 759 Node* context = __ GetContext(); |
759 Node* result = Generator::Generate(assembler, lhs, rhs, context); | 760 Node* result = Generator::Generate(assembler, lhs, rhs, context); |
760 __ SetAccumulator(result); | 761 __ SetAccumulator(result); |
761 __ Dispatch(); | 762 __ Dispatch(); |
762 } | 763 } |
763 | 764 |
| 765 template <class Generator> |
| 766 void Interpreter::DoBinaryOpWithFeedback(InterpreterAssembler* assembler) { |
| 767 Node* reg_index = __ BytecodeOperandReg(0); |
| 768 Node* lhs = __ LoadRegister(reg_index); |
| 769 Node* rhs = __ GetAccumulator(); |
| 770 Node* context = __ GetContext(); |
| 771 Node* slot_index = __ BytecodeOperandIdx(1); |
| 772 Node* type_feedback_vector = __ LoadTypeFeedbackVector(); |
| 773 Node* result = Generator::Generate(assembler, lhs, rhs, context, |
| 774 type_feedback_vector, slot_index); |
| 775 __ SetAccumulator(result); |
| 776 __ Dispatch(); |
| 777 } |
| 778 |
764 // Add <src> | 779 // Add <src> |
765 // | 780 // |
766 // Add register <src> to accumulator. | 781 // Add register <src> to accumulator. |
767 void Interpreter::DoAdd(InterpreterAssembler* assembler) { | 782 void Interpreter::DoAdd(InterpreterAssembler* assembler) { |
768 DoBinaryOp<AddStub>(assembler); | 783 DoBinaryOp<AddStub>(assembler); |
769 } | 784 } |
770 | 785 |
771 // Sub <src> | 786 // Sub <src> |
772 // | 787 // |
773 // Subtract register <src> from accumulator. | 788 // Subtract register <src> from accumulator. |
774 void Interpreter::DoSub(InterpreterAssembler* assembler) { | 789 void Interpreter::DoSub(InterpreterAssembler* assembler) { |
775 DoBinaryOp<SubtractStub>(assembler); | 790 DoBinaryOpWithFeedback<SubtractWithFeedbackStub>(assembler); |
776 } | 791 } |
777 | 792 |
778 // Mul <src> | 793 // Mul <src> |
779 // | 794 // |
780 // Multiply accumulator by register <src>. | 795 // Multiply accumulator by register <src>. |
781 void Interpreter::DoMul(InterpreterAssembler* assembler) { | 796 void Interpreter::DoMul(InterpreterAssembler* assembler) { |
782 DoBinaryOp<MultiplyStub>(assembler); | 797 DoBinaryOp<MultiplyStub>(assembler); |
783 } | 798 } |
784 | 799 |
785 // Div <src> | 800 // Div <src> |
(...skipping 1365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2151 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, | 2166 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, |
2152 __ SmiTag(new_state)); | 2167 __ SmiTag(new_state)); |
2153 __ SetAccumulator(old_state); | 2168 __ SetAccumulator(old_state); |
2154 | 2169 |
2155 __ Dispatch(); | 2170 __ Dispatch(); |
2156 } | 2171 } |
2157 | 2172 |
2158 } // namespace interpreter | 2173 } // namespace interpreter |
2159 } // namespace internal | 2174 } // namespace internal |
2160 } // namespace v8 | 2175 } // namespace v8 |
OLD | NEW |