| 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/compiler.h" | 7 #include "src/compiler.h" |
| 8 #include "src/compiler/interpreter-assembler.h" | 8 #include "src/compiler/interpreter-assembler.h" |
| 9 #include "src/factory.h" | 9 #include "src/factory.h" |
| 10 #include "src/interpreter/bytecode-generator.h" | 10 #include "src/interpreter/bytecode-generator.h" |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 // | 176 // |
| 177 // Store accumulator to register <dst>. | 177 // Store accumulator to register <dst>. |
| 178 void Interpreter::DoStar(compiler::InterpreterAssembler* assembler) { | 178 void Interpreter::DoStar(compiler::InterpreterAssembler* assembler) { |
| 179 Node* reg_index = __ BytecodeOperandReg(0); | 179 Node* reg_index = __ BytecodeOperandReg(0); |
| 180 Node* accumulator = __ GetAccumulator(); | 180 Node* accumulator = __ GetAccumulator(); |
| 181 __ StoreRegister(accumulator, reg_index); | 181 __ StoreRegister(accumulator, reg_index); |
| 182 __ Dispatch(); | 182 __ Dispatch(); |
| 183 } | 183 } |
| 184 | 184 |
| 185 | 185 |
| 186 void Interpreter::DoBinaryOp(Builtins::JavaScript binop_builtin, | 186 void Interpreter::DoBinaryOp(int builtin_context_index, |
| 187 compiler::InterpreterAssembler* assembler) { | 187 compiler::InterpreterAssembler* assembler) { |
| 188 // TODO(rmcilroy): Call ICs which back-patch bytecode with type specialized | 188 // TODO(rmcilroy): Call ICs which back-patch bytecode with type specialized |
| 189 // operations, instead of calling builtins directly. | 189 // operations, instead of calling builtins directly. |
| 190 Node* reg_index = __ BytecodeOperandReg(0); | 190 Node* reg_index = __ BytecodeOperandReg(0); |
| 191 Node* lhs = __ LoadRegister(reg_index); | 191 Node* lhs = __ LoadRegister(reg_index); |
| 192 Node* rhs = __ GetAccumulator(); | 192 Node* rhs = __ GetAccumulator(); |
| 193 Node* result = __ CallJSBuiltin(binop_builtin, lhs, rhs); | 193 Node* result = __ CallJSBuiltin(builtin_context_index, lhs, rhs); |
| 194 __ SetAccumulator(result); | 194 __ SetAccumulator(result); |
| 195 __ Dispatch(); | 195 __ Dispatch(); |
| 196 } | 196 } |
| 197 | 197 |
| 198 | 198 |
| 199 // Add <src> | 199 // Add <src> |
| 200 // | 200 // |
| 201 // Add register <src> to accumulator. | 201 // Add register <src> to accumulator. |
| 202 void Interpreter::DoAdd(compiler::InterpreterAssembler* assembler) { | 202 void Interpreter::DoAdd(compiler::InterpreterAssembler* assembler) { |
| 203 DoBinaryOp(Builtins::ADD, assembler); | 203 DoBinaryOp(Context::ADD_BUILTIN_INDEX, assembler); |
| 204 } | 204 } |
| 205 | 205 |
| 206 | 206 |
| 207 // Sub <src> | 207 // Sub <src> |
| 208 // | 208 // |
| 209 // Subtract register <src> from accumulator. | 209 // Subtract register <src> from accumulator. |
| 210 void Interpreter::DoSub(compiler::InterpreterAssembler* assembler) { | 210 void Interpreter::DoSub(compiler::InterpreterAssembler* assembler) { |
| 211 DoBinaryOp(Builtins::SUB, assembler); | 211 DoBinaryOp(Context::SUB_BUILTIN_INDEX, assembler); |
| 212 } | 212 } |
| 213 | 213 |
| 214 | 214 |
| 215 // Mul <src> | 215 // Mul <src> |
| 216 // | 216 // |
| 217 // Multiply accumulator by register <src>. | 217 // Multiply accumulator by register <src>. |
| 218 void Interpreter::DoMul(compiler::InterpreterAssembler* assembler) { | 218 void Interpreter::DoMul(compiler::InterpreterAssembler* assembler) { |
| 219 DoBinaryOp(Builtins::MUL, assembler); | 219 DoBinaryOp(Context::MUL_BUILTIN_INDEX, assembler); |
| 220 } | 220 } |
| 221 | 221 |
| 222 | 222 |
| 223 // Div <src> | 223 // Div <src> |
| 224 // | 224 // |
| 225 // Divide register <src> by accumulator. | 225 // Divide register <src> by accumulator. |
| 226 void Interpreter::DoDiv(compiler::InterpreterAssembler* assembler) { | 226 void Interpreter::DoDiv(compiler::InterpreterAssembler* assembler) { |
| 227 DoBinaryOp(Builtins::DIV, assembler); | 227 DoBinaryOp(Context::DIV_BUILTIN_INDEX, assembler); |
| 228 } | 228 } |
| 229 | 229 |
| 230 | 230 |
| 231 // Mod <src> | 231 // Mod <src> |
| 232 // | 232 // |
| 233 // Modulo register <src> by accumulator. | 233 // Modulo register <src> by accumulator. |
| 234 void Interpreter::DoMod(compiler::InterpreterAssembler* assembler) { | 234 void Interpreter::DoMod(compiler::InterpreterAssembler* assembler) { |
| 235 DoBinaryOp(Builtins::MOD, assembler); | 235 DoBinaryOp(Context::MOD_BUILTIN_INDEX, assembler); |
| 236 } | 236 } |
| 237 | 237 |
| 238 | 238 |
| 239 // Return | 239 // Return |
| 240 // | 240 // |
| 241 // Return the value in register 0. | 241 // Return the value in register 0. |
| 242 void Interpreter::DoReturn(compiler::InterpreterAssembler* assembler) { | 242 void Interpreter::DoReturn(compiler::InterpreterAssembler* assembler) { |
| 243 __ Return(); | 243 __ Return(); |
| 244 } | 244 } |
| 245 | 245 |
| 246 | 246 |
| 247 } // namespace interpreter | 247 } // namespace interpreter |
| 248 } // namespace internal | 248 } // namespace internal |
| 249 } // namespace v8 | 249 } // namespace v8 |
| OLD | NEW |