| 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/code-factory.h" | 7 #include "src/code-factory.h" |
| 8 #include "src/compiler.h" | 8 #include "src/compiler.h" |
| 9 #include "src/compiler/interpreter-assembler.h" | 9 #include "src/compiler/interpreter-assembler.h" |
| 10 #include "src/factory.h" | 10 #include "src/factory.h" |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 // | 262 // |
| 263 // Calls the KeyStoreIC at FeedBackVector slot <slot> for <object> and the key | 263 // Calls the KeyStoreIC at FeedBackVector slot <slot> for <object> and the key |
| 264 // <key> with the value in the accumulator. | 264 // <key> with the value in the accumulator. |
| 265 void Interpreter::DoKeyedStoreIC(compiler::InterpreterAssembler* assembler) { | 265 void Interpreter::DoKeyedStoreIC(compiler::InterpreterAssembler* assembler) { |
| 266 Callable ic = | 266 Callable ic = |
| 267 CodeFactory::KeyedStoreICInOptimizedCode(isolate_, SLOPPY, UNINITIALIZED); | 267 CodeFactory::KeyedStoreICInOptimizedCode(isolate_, SLOPPY, UNINITIALIZED); |
| 268 DoPropertyStoreIC(ic, assembler); | 268 DoPropertyStoreIC(ic, assembler); |
| 269 } | 269 } |
| 270 | 270 |
| 271 | 271 |
| 272 void Interpreter::DoBinaryOp(int builtin_context_index, | 272 void Interpreter::DoBinaryOp(Runtime::FunctionId function_id, |
| 273 compiler::InterpreterAssembler* assembler) { | 273 compiler::InterpreterAssembler* assembler) { |
| 274 // TODO(rmcilroy): Call ICs which back-patch bytecode with type specialized | 274 // TODO(rmcilroy): Call ICs which back-patch bytecode with type specialized |
| 275 // operations, instead of calling builtins directly. | 275 // operations, instead of calling builtins directly. |
| 276 Node* reg_index = __ BytecodeOperandReg(0); | 276 Node* reg_index = __ BytecodeOperandReg(0); |
| 277 Node* lhs = __ LoadRegister(reg_index); | 277 Node* lhs = __ LoadRegister(reg_index); |
| 278 Node* rhs = __ GetAccumulator(); | 278 Node* rhs = __ GetAccumulator(); |
| 279 Node* result = __ CallJSBuiltin(builtin_context_index, lhs, rhs); | 279 Node* result = __ CallRuntime(function_id, lhs, rhs); |
| 280 __ SetAccumulator(result); | 280 __ SetAccumulator(result); |
| 281 __ Dispatch(); | 281 __ Dispatch(); |
| 282 } | 282 } |
| 283 | 283 |
| 284 | 284 |
| 285 // Add <src> | 285 // Add <src> |
| 286 // | 286 // |
| 287 // Add register <src> to accumulator. | 287 // Add register <src> to accumulator. |
| 288 void Interpreter::DoAdd(compiler::InterpreterAssembler* assembler) { | 288 void Interpreter::DoAdd(compiler::InterpreterAssembler* assembler) { |
| 289 DoBinaryOp(Context::ADD_BUILTIN_INDEX, assembler); | 289 DoBinaryOp(Runtime::kAdd, assembler); |
| 290 } | 290 } |
| 291 | 291 |
| 292 | 292 |
| 293 // Sub <src> | 293 // Sub <src> |
| 294 // | 294 // |
| 295 // Subtract register <src> from accumulator. | 295 // Subtract register <src> from accumulator. |
| 296 void Interpreter::DoSub(compiler::InterpreterAssembler* assembler) { | 296 void Interpreter::DoSub(compiler::InterpreterAssembler* assembler) { |
| 297 DoBinaryOp(Context::SUB_BUILTIN_INDEX, assembler); | 297 DoBinaryOp(Runtime::kSubtract, assembler); |
| 298 } | 298 } |
| 299 | 299 |
| 300 | 300 |
| 301 // Mul <src> | 301 // Mul <src> |
| 302 // | 302 // |
| 303 // Multiply accumulator by register <src>. | 303 // Multiply accumulator by register <src>. |
| 304 void Interpreter::DoMul(compiler::InterpreterAssembler* assembler) { | 304 void Interpreter::DoMul(compiler::InterpreterAssembler* assembler) { |
| 305 DoBinaryOp(Context::MUL_BUILTIN_INDEX, assembler); | 305 DoBinaryOp(Runtime::kMultiply, assembler); |
| 306 } | 306 } |
| 307 | 307 |
| 308 | 308 |
| 309 // Div <src> | 309 // Div <src> |
| 310 // | 310 // |
| 311 // Divide register <src> by accumulator. | 311 // Divide register <src> by accumulator. |
| 312 void Interpreter::DoDiv(compiler::InterpreterAssembler* assembler) { | 312 void Interpreter::DoDiv(compiler::InterpreterAssembler* assembler) { |
| 313 DoBinaryOp(Context::DIV_BUILTIN_INDEX, assembler); | 313 DoBinaryOp(Runtime::kDivide, assembler); |
| 314 } | 314 } |
| 315 | 315 |
| 316 | 316 |
| 317 // Mod <src> | 317 // Mod <src> |
| 318 // | 318 // |
| 319 // Modulo register <src> by accumulator. | 319 // Modulo register <src> by accumulator. |
| 320 void Interpreter::DoMod(compiler::InterpreterAssembler* assembler) { | 320 void Interpreter::DoMod(compiler::InterpreterAssembler* assembler) { |
| 321 DoBinaryOp(Context::MOD_BUILTIN_INDEX, assembler); | 321 DoBinaryOp(Runtime::kModulus, assembler); |
| 322 } | 322 } |
| 323 | 323 |
| 324 | 324 |
| 325 // Return | 325 // Return |
| 326 // | 326 // |
| 327 // Return the value in register 0. | 327 // Return the value in register 0. |
| 328 void Interpreter::DoReturn(compiler::InterpreterAssembler* assembler) { | 328 void Interpreter::DoReturn(compiler::InterpreterAssembler* assembler) { |
| 329 __ Return(); | 329 __ Return(); |
| 330 } | 330 } |
| 331 | 331 |
| 332 | 332 |
| 333 } // namespace interpreter | 333 } // namespace interpreter |
| 334 } // namespace internal | 334 } // namespace internal |
| 335 } // namespace v8 | 335 } // namespace v8 |
| OLD | NEW |