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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 = __ CallRuntime(function_id, 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 void Interpreter::DoCompareOp(Token::Value op, | |
286 compiler::InterpreterAssembler* assembler) { | |
287 // TODO(oth): placeholder until compare path fixed. | |
288 // The accumulator should be set to true on success (or false otherwise) | |
289 // by the comparisons so it can be used for conditional jumps. | |
290 DoLdaTrue(assembler); | |
291 } | |
292 | |
293 | |
285 // Add <src> | 294 // Add <src> |
286 // | 295 // |
287 // Add register <src> to accumulator. | 296 // Add register <src> to accumulator. |
288 void Interpreter::DoAdd(compiler::InterpreterAssembler* assembler) { | 297 void Interpreter::DoAdd(compiler::InterpreterAssembler* assembler) { |
289 DoBinaryOp(Runtime::kAdd, assembler); | 298 DoBinaryOp(Runtime::kAdd, assembler); |
290 } | 299 } |
291 | 300 |
292 | 301 |
293 // Sub <src> | 302 // Sub <src> |
294 // | 303 // |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
331 Node* function = __ LoadRegister(function_reg); | 340 Node* function = __ LoadRegister(function_reg); |
332 Node* receiver_reg = __ BytecodeOperandReg(1); | 341 Node* receiver_reg = __ BytecodeOperandReg(1); |
333 Node* first_arg = __ RegisterLocation(receiver_reg); | 342 Node* first_arg = __ RegisterLocation(receiver_reg); |
334 Node* args_count = __ BytecodeOperandCount(2); | 343 Node* args_count = __ BytecodeOperandCount(2); |
335 Node* result = __ CallJS(function, first_arg, args_count); | 344 Node* result = __ CallJS(function, first_arg, args_count); |
336 __ SetAccumulator(result); | 345 __ SetAccumulator(result); |
337 __ Dispatch(); | 346 __ Dispatch(); |
338 } | 347 } |
339 | 348 |
340 | 349 |
350 // TestEqual <src> | |
351 // | |
352 // Test if register equals the accumulator. | |
rmcilroy
2015/09/18 10:42:24
nit (for all comments) - /s/Test if register/Test
oth
2015/09/23 10:46:56
Done.
| |
353 void Interpreter::DoTestEqual(compiler::InterpreterAssembler* assembler) { | |
354 DoCompareOp(Token::Value::EQ, assembler); | |
355 } | |
356 | |
357 | |
358 // TestNotEqual <src> | |
359 // | |
360 // Test if register not equal to the accumulator. | |
361 void Interpreter::DoTestNotEqual(compiler::InterpreterAssembler* assembler) { | |
362 DoCompareOp(Token::Value::NE, assembler); | |
363 } | |
364 | |
365 | |
366 // TestEqualStrict <src> | |
367 // | |
368 // Test if register strictly equal to the accumulator. | |
rmcilroy
2015/09/18 10:42:24
/s/strictly/is strictly (and below)
oth
2015/09/23 10:46:56
Done.
| |
369 void Interpreter::DoTestEqualStrict(compiler::InterpreterAssembler* assembler) { | |
370 DoCompareOp(Token::Value::EQ_STRICT, assembler); | |
371 } | |
372 | |
373 | |
374 // TestNotEqualStrict <src> | |
375 // | |
376 // Test if register not strictly equal to the accumulator. | |
377 void Interpreter::DoTestNotEqualStrict( | |
378 compiler::InterpreterAssembler* assembler) { | |
379 DoCompareOp(Token::Value::NE_STRICT, assembler); | |
380 } | |
381 | |
382 | |
383 // TestLessThan <src> | |
384 // | |
385 // Test if register is less than the accumulator. | |
386 void Interpreter::DoTestLessThan(compiler::InterpreterAssembler* assembler) { | |
387 DoCompareOp(Token::Value::LT, assembler); | |
388 } | |
389 | |
390 | |
391 // TestGreaterThan <src> | |
392 // | |
393 // Test if register is greater than the accumulator. | |
394 void Interpreter::DoTestGreaterThan(compiler::InterpreterAssembler* assembler) { | |
395 DoCompareOp(Token::Value::GT, assembler); | |
396 } | |
397 | |
398 | |
399 // TestLessThanEqual <src> | |
400 // | |
401 // Test if register is less than or equal to the accumulator. | |
402 void Interpreter::DoTestLessThanEqual( | |
403 compiler::InterpreterAssembler* assembler) { | |
404 DoCompareOp(Token::Value::LTE, assembler); | |
405 } | |
406 | |
407 | |
408 // TestGreaterThanEqual <src> | |
409 // | |
410 // Test if register is greater than or equal to the accumulator. | |
411 void Interpreter::DoTestGreaterThanEqual( | |
412 compiler::InterpreterAssembler* assembler) { | |
413 DoCompareOp(Token::Value::GTE, assembler); | |
414 } | |
415 | |
416 | |
417 // TestIn <src> | |
418 // | |
419 // Test if register is in the collection referenced by the accumulator. | |
420 void Interpreter::DoTestIn(compiler::InterpreterAssembler* assembler) { | |
421 DoCompareOp(Token::Value::IN, assembler); | |
422 } | |
423 | |
424 | |
425 // TestInstanceOf <src> | |
426 // | |
427 // Test if object referenced by register is an an instance of type referenced | |
428 // by the accumulator. | |
429 void Interpreter::DoTestInstanceOf(compiler::InterpreterAssembler* assembler) { | |
430 DoCompareOp(Token::Value::INSTANCEOF, assembler); | |
431 } | |
432 | |
433 | |
434 // JumpSmi8 <imm8> | |
435 // | |
436 // Jump by number of bytes represented by an immediate operand. | |
437 void Interpreter::DoJumpSmi8(compiler::InterpreterAssembler* assembler) { | |
438 Node* int_value = __ BytecodeOperandImm8(0); | |
rmcilroy
2015/09/18 10:42:24
nit - /s/int_value/jump_delta (and below)
oth
2015/09/23 10:46:56
Done. s/int_value/relative_jump/ to match code fur
| |
439 __ Jump(int_value); | |
440 } | |
441 | |
442 | |
443 // JumpConstant <idx> | |
444 // | |
445 // Jump by number of bytes in the Smi in the |idx| entry in the constant pool. | |
446 void Interpreter::DoJumpConstant(compiler::InterpreterAssembler* assembler) { | |
447 Node* index = __ BytecodeOperandIdx(0); | |
448 Node* constant = __ LoadConstantPoolEntry(index); | |
449 Node* int_value = __ SmiUntag(constant); | |
450 __ Jump(int_value); | |
451 } | |
452 | |
453 | |
454 // JumpIfTrueSmi8 <imm8> | |
455 // | |
456 // Jump by number of bytes represented by an immediate operand if the | |
457 // accumulator contains true. | |
458 void Interpreter::DoJumpIfTrueSmi8(compiler::InterpreterAssembler* assembler) { | |
459 Node* accumulator = __ GetAccumulator(); | |
460 Node* relative_jump = __ BytecodeOperandImm8(0); | |
461 Node* boolean_value = __ BooleanConstant(true); | |
462 __ JumpIfEqual(accumulator, boolean_value, relative_jump); | |
463 } | |
464 | |
465 | |
466 // JumpIfTrueConstant <idx> | |
467 // | |
468 // Jump by number of bytes in the Smi in the |idx| entry in the constant pool | |
469 // if the accumulator contains true. | |
470 void Interpreter::DoJumpIfTrueConstant( | |
471 compiler::InterpreterAssembler* assembler) { | |
472 Node* accumulator = __ GetAccumulator(); | |
473 Node* index = __ BytecodeOperandIdx(0); | |
474 Node* constant = __ LoadConstantPoolEntry(index); | |
475 Node* relative_jump = __ SmiUntag(constant); | |
476 Node* boolean_value = __ BooleanConstant(true); | |
477 __ JumpIfEqual(accumulator, boolean_value, relative_jump); | |
478 } | |
479 | |
480 | |
481 // JumpIfFalseSmi8 <imm8> | |
482 // | |
483 // Jump by number of bytes represented by an immediate operand if the | |
484 // accumulator contains false. | |
485 void Interpreter::DoJumpIfFalseSmi8(compiler::InterpreterAssembler* assembler) { | |
486 Node* accumulator = __ GetAccumulator(); | |
487 Node* relative_jump = __ BytecodeOperandImm8(0); | |
488 Node* boolean_value = __ BooleanConstant(false); | |
489 __ JumpIfEqual(accumulator, boolean_value, relative_jump); | |
490 } | |
491 | |
492 | |
493 // JumpIfFalseConstant <idx> | |
494 // | |
495 // Jump by number of bytes in the Smi in the |idx| entry in the constant pool | |
496 // if the accumulator contains false. | |
497 void Interpreter::DoJumpIfFalseConstant( | |
498 compiler::InterpreterAssembler* assembler) { | |
499 Node* accumulator = __ GetAccumulator(); | |
500 Node* index = __ BytecodeOperandIdx(0); | |
501 Node* constant = __ LoadConstantPoolEntry(index); | |
502 Node* relative_jump = __ SmiUntag(constant); | |
503 Node* boolean_value = __ BooleanConstant(false); | |
504 __ JumpIfEqual(accumulator, boolean_value, relative_jump); | |
505 } | |
506 | |
507 | |
341 // Return | 508 // Return |
342 // | 509 // |
343 // Return the value in register 0. | 510 // Return the value in register 0. |
344 void Interpreter::DoReturn(compiler::InterpreterAssembler* assembler) { | 511 void Interpreter::DoReturn(compiler::InterpreterAssembler* assembler) { |
345 __ Return(); | 512 __ Return(); |
346 } | 513 } |
347 | 514 |
348 | 515 |
349 } // namespace interpreter | 516 } // namespace interpreter |
350 } // namespace internal | 517 } // namespace internal |
351 } // namespace v8 | 518 } // namespace v8 |
OLD | NEW |