| 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 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 // Right Shifts register <src> by the count specified in the accumulator. | 501 // Right Shifts register <src> by the count specified in the accumulator. |
| 502 // Result is zero-filled. The accumulator and register <src> are converted to | 502 // Result is zero-filled. The accumulator and register <src> are converted to |
| 503 // uint32 before the operation 5 lsb bits from the accumulator are used as | 503 // uint32 before the operation 5 lsb bits from the accumulator are used as |
| 504 // count i.e. <src> << (accumulator & 0x1F). | 504 // count i.e. <src> << (accumulator & 0x1F). |
| 505 void Interpreter::DoShiftRightLogical( | 505 void Interpreter::DoShiftRightLogical( |
| 506 compiler::InterpreterAssembler* assembler) { | 506 compiler::InterpreterAssembler* assembler) { |
| 507 DoBinaryOp(Runtime::kShiftRightLogical, assembler); | 507 DoBinaryOp(Runtime::kShiftRightLogical, assembler); |
| 508 } | 508 } |
| 509 | 509 |
| 510 | 510 |
| 511 void Interpreter::DoCountOp(Runtime::FunctionId function_id, |
| 512 compiler::InterpreterAssembler* assembler) { |
| 513 Node* value = __ GetAccumulator(); |
| 514 Node* one = __ NumberConstant(1); |
| 515 Node* result = __ CallRuntime(function_id, value, one); |
| 516 __ SetAccumulator(result); |
| 517 __ Dispatch(); |
| 518 } |
| 519 |
| 520 |
| 521 // Inc |
| 522 // |
| 523 // Increments value in the accumulator by one. |
| 524 void Interpreter::DoInc(compiler::InterpreterAssembler* assembler) { |
| 525 DoCountOp(Runtime::kAdd, assembler); |
| 526 } |
| 527 |
| 528 |
| 529 // Dec |
| 530 // |
| 531 // Decrements value in the accumulator by one. |
| 532 void Interpreter::DoDec(compiler::InterpreterAssembler* assembler) { |
| 533 DoCountOp(Runtime::kSubtract, assembler); |
| 534 } |
| 535 |
| 536 |
| 511 // LogicalNot | 537 // LogicalNot |
| 512 // | 538 // |
| 513 // Perform logical-not on the accumulator, first casting the | 539 // Perform logical-not on the accumulator, first casting the |
| 514 // accumulator to a boolean value if required. | 540 // accumulator to a boolean value if required. |
| 515 void Interpreter::DoLogicalNot(compiler::InterpreterAssembler* assembler) { | 541 void Interpreter::DoLogicalNot(compiler::InterpreterAssembler* assembler) { |
| 516 Node* accumulator = __ GetAccumulator(); | 542 Node* accumulator = __ GetAccumulator(); |
| 517 Node* result = __ CallRuntime(Runtime::kInterpreterLogicalNot, accumulator); | 543 Node* result = __ CallRuntime(Runtime::kInterpreterLogicalNot, accumulator); |
| 518 __ SetAccumulator(result); | 544 __ SetAccumulator(result); |
| 519 __ Dispatch(); | 545 __ Dispatch(); |
| 520 } | 546 } |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 686 // | 712 // |
| 687 // Cast the object referenced by the accumulator to a name. | 713 // Cast the object referenced by the accumulator to a name. |
| 688 void Interpreter::DoToName(compiler::InterpreterAssembler* assembler) { | 714 void Interpreter::DoToName(compiler::InterpreterAssembler* assembler) { |
| 689 Node* accumulator = __ GetAccumulator(); | 715 Node* accumulator = __ GetAccumulator(); |
| 690 Node* result = __ CallRuntime(Runtime::kToName, accumulator); | 716 Node* result = __ CallRuntime(Runtime::kToName, accumulator); |
| 691 __ SetAccumulator(result); | 717 __ SetAccumulator(result); |
| 692 __ Dispatch(); | 718 __ Dispatch(); |
| 693 } | 719 } |
| 694 | 720 |
| 695 | 721 |
| 722 // ToNumber |
| 723 // |
| 724 // Cast the object referenced by the accumulator to a number. |
| 725 void Interpreter::DoToNumber(compiler::InterpreterAssembler* assembler) { |
| 726 Node* accumulator = __ GetAccumulator(); |
| 727 Node* result = __ CallRuntime(Runtime::kToNumber, accumulator); |
| 728 __ SetAccumulator(result); |
| 729 __ Dispatch(); |
| 730 } |
| 731 |
| 732 |
| 696 // Jump <imm8> | 733 // Jump <imm8> |
| 697 // | 734 // |
| 698 // Jump by number of bytes represented by the immediate operand |imm8|. | 735 // Jump by number of bytes represented by the immediate operand |imm8|. |
| 699 void Interpreter::DoJump(compiler::InterpreterAssembler* assembler) { | 736 void Interpreter::DoJump(compiler::InterpreterAssembler* assembler) { |
| 700 Node* relative_jump = __ BytecodeOperandImm8(0); | 737 Node* relative_jump = __ BytecodeOperandImm8(0); |
| 701 __ Jump(relative_jump); | 738 __ Jump(relative_jump); |
| 702 } | 739 } |
| 703 | 740 |
| 704 | 741 |
| 705 // JumpConstant <idx> | 742 // JumpConstant <idx> |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 891 // | 928 // |
| 892 // Return the value in the accumulator. | 929 // Return the value in the accumulator. |
| 893 void Interpreter::DoReturn(compiler::InterpreterAssembler* assembler) { | 930 void Interpreter::DoReturn(compiler::InterpreterAssembler* assembler) { |
| 894 __ Return(); | 931 __ Return(); |
| 895 } | 932 } |
| 896 | 933 |
| 897 | 934 |
| 898 } // namespace interpreter | 935 } // namespace interpreter |
| 899 } // namespace internal | 936 } // namespace internal |
| 900 } // namespace v8 | 937 } // namespace v8 |
| OLD | NEW |