| 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 "src/ast/prettyprinter.h" | 7 #include "src/ast/prettyprinter.h" |
| 8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
| 9 #include "src/compiler.h" | 9 #include "src/compiler.h" |
| 10 #include "src/factory.h" | 10 #include "src/factory.h" |
| (...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 // PopContext <context> | 737 // PopContext <context> |
| 738 // | 738 // |
| 739 // Pops the current context and sets <context> as the new context. | 739 // Pops the current context and sets <context> as the new context. |
| 740 void Interpreter::DoPopContext(InterpreterAssembler* assembler) { | 740 void Interpreter::DoPopContext(InterpreterAssembler* assembler) { |
| 741 Node* reg_index = __ BytecodeOperandReg(0); | 741 Node* reg_index = __ BytecodeOperandReg(0); |
| 742 Node* context = __ LoadRegister(reg_index); | 742 Node* context = __ LoadRegister(reg_index); |
| 743 __ SetContext(context); | 743 __ SetContext(context); |
| 744 __ Dispatch(); | 744 __ Dispatch(); |
| 745 } | 745 } |
| 746 | 746 |
| 747 void Interpreter::DoBinaryOp(Callable callable, |
| 748 InterpreterAssembler* assembler) { |
| 749 // TODO(bmeurer): Collect definition side type feedback for various |
| 750 // binary operations. |
| 751 Node* target = __ HeapConstant(callable.code()); |
| 752 Node* reg_index = __ BytecodeOperandReg(0); |
| 753 Node* lhs = __ LoadRegister(reg_index); |
| 754 Node* rhs = __ GetAccumulator(); |
| 755 Node* context = __ GetContext(); |
| 756 Node* result = __ CallStub(callable.descriptor(), target, context, lhs, rhs); |
| 757 __ SetAccumulator(result); |
| 758 __ Dispatch(); |
| 759 } |
| 760 |
| 747 void Interpreter::DoBinaryOp(Runtime::FunctionId function_id, | 761 void Interpreter::DoBinaryOp(Runtime::FunctionId function_id, |
| 748 InterpreterAssembler* assembler) { | 762 InterpreterAssembler* assembler) { |
| 749 // TODO(rmcilroy): Call ICs which back-patch bytecode with type specialized | 763 // TODO(rmcilroy): Call ICs which back-patch bytecode with type specialized |
| 750 // operations, instead of calling builtins directly. | 764 // operations, instead of calling builtins directly. |
| 751 Node* reg_index = __ BytecodeOperandReg(0); | 765 Node* reg_index = __ BytecodeOperandReg(0); |
| 752 Node* lhs = __ LoadRegister(reg_index); | 766 Node* lhs = __ LoadRegister(reg_index); |
| 753 Node* rhs = __ GetAccumulator(); | 767 Node* rhs = __ GetAccumulator(); |
| 754 Node* context = __ GetContext(); | 768 Node* context = __ GetContext(); |
| 755 Node* result = __ CallRuntime(function_id, context, lhs, rhs); | 769 Node* result = __ CallRuntime(function_id, context, lhs, rhs); |
| 756 __ SetAccumulator(result); | 770 __ SetAccumulator(result); |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1167 // Test if the value in the <src> register is not equal to the accumulator. | 1181 // Test if the value in the <src> register is not equal to the accumulator. |
| 1168 void Interpreter::DoTestNotEqual(InterpreterAssembler* assembler) { | 1182 void Interpreter::DoTestNotEqual(InterpreterAssembler* assembler) { |
| 1169 DoBinaryOp(Runtime::kNotEqual, assembler); | 1183 DoBinaryOp(Runtime::kNotEqual, assembler); |
| 1170 } | 1184 } |
| 1171 | 1185 |
| 1172 | 1186 |
| 1173 // TestEqualStrict <src> | 1187 // TestEqualStrict <src> |
| 1174 // | 1188 // |
| 1175 // Test if the value in the <src> register is strictly equal to the accumulator. | 1189 // Test if the value in the <src> register is strictly equal to the accumulator. |
| 1176 void Interpreter::DoTestEqualStrict(InterpreterAssembler* assembler) { | 1190 void Interpreter::DoTestEqualStrict(InterpreterAssembler* assembler) { |
| 1177 DoBinaryOp(Runtime::kStrictEqual, assembler); | 1191 DoBinaryOp(CodeFactory::StrictEqual(isolate_), assembler); |
| 1178 } | 1192 } |
| 1179 | 1193 |
| 1180 | 1194 |
| 1181 // TestNotEqualStrict <src> | 1195 // TestNotEqualStrict <src> |
| 1182 // | 1196 // |
| 1183 // Test if the value in the <src> register is not strictly equal to the | 1197 // Test if the value in the <src> register is not strictly equal to the |
| 1184 // accumulator. | 1198 // accumulator. |
| 1185 void Interpreter::DoTestNotEqualStrict(InterpreterAssembler* assembler) { | 1199 void Interpreter::DoTestNotEqualStrict(InterpreterAssembler* assembler) { |
| 1186 DoBinaryOp(Runtime::kStrictNotEqual, assembler); | 1200 DoBinaryOp(Runtime::kStrictNotEqual, assembler); |
| 1187 } | 1201 } |
| (...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1899 Node* index = __ LoadRegister(index_reg); | 1913 Node* index = __ LoadRegister(index_reg); |
| 1900 Node* one = __ SmiConstant(Smi::FromInt(1)); | 1914 Node* one = __ SmiConstant(Smi::FromInt(1)); |
| 1901 Node* result = __ SmiAdd(index, one); | 1915 Node* result = __ SmiAdd(index, one); |
| 1902 __ SetAccumulator(result); | 1916 __ SetAccumulator(result); |
| 1903 __ Dispatch(); | 1917 __ Dispatch(); |
| 1904 } | 1918 } |
| 1905 | 1919 |
| 1906 } // namespace interpreter | 1920 } // namespace interpreter |
| 1907 } // namespace internal | 1921 } // namespace internal |
| 1908 } // namespace v8 | 1922 } // namespace v8 |
| OLD | NEW |