| 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 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 void Interpreter::DoKeyedStoreICStrict( | 342 void Interpreter::DoKeyedStoreICStrict( |
| 343 compiler::InterpreterAssembler* assembler) { | 343 compiler::InterpreterAssembler* assembler) { |
| 344 Callable ic = | 344 Callable ic = |
| 345 CodeFactory::KeyedStoreICInOptimizedCode(isolate_, STRICT, UNINITIALIZED); | 345 CodeFactory::KeyedStoreICInOptimizedCode(isolate_, STRICT, UNINITIALIZED); |
| 346 DoPropertyStoreIC(ic, assembler); | 346 DoPropertyStoreIC(ic, assembler); |
| 347 } | 347 } |
| 348 | 348 |
| 349 | 349 |
| 350 // KeyedStoreICGeneric <object> <key> | 350 // KeyedStoreICGeneric <object> <key> |
| 351 // | 351 // |
| 352 // Calls the generic KeyStoreIC for <object> and the key <key> with the value in | 352 // Calls the generic KeyedStoreIC for <object> and the key <key> with the value |
| 353 // the accumulator. | 353 // in the accumulator. |
| 354 void Interpreter::DoKeyedStoreICGeneric( | 354 void Interpreter::DoKeyedStoreICGeneric( |
| 355 compiler::InterpreterAssembler* assembler) { | 355 compiler::InterpreterAssembler* assembler) { |
| 356 Callable ic = | 356 Callable ic = |
| 357 CodeFactory::KeyedStoreICInOptimizedCode(isolate_, SLOPPY, MEGAMORPHIC); | 357 CodeFactory::KeyedStoreICInOptimizedCode(isolate_, SLOPPY, MEGAMORPHIC); |
| 358 Node* code_target = __ HeapConstant(ic.code()); | 358 Node* code_target = __ HeapConstant(ic.code()); |
| 359 Node* object_reg_index = __ BytecodeOperandReg8(0); | 359 Node* object_reg_index = __ BytecodeOperandReg8(0); |
| 360 Node* object = __ LoadRegister(object_reg_index); | 360 Node* object = __ LoadRegister(object_reg_index); |
| 361 Node* name_reg_index = __ BytecodeOperandReg8(1); | 361 Node* name_reg_index = __ BytecodeOperandReg8(1); |
| 362 Node* name = __ LoadRegister(name_reg_index); | 362 Node* name = __ LoadRegister(name_reg_index); |
| 363 Node* value = __ GetAccumulator(); | 363 Node* value = __ GetAccumulator(); |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 // | 649 // |
| 650 // Cast the object referenced by the accumulator to a boolean. | 650 // Cast the object referenced by the accumulator to a boolean. |
| 651 void Interpreter::DoToBoolean(compiler::InterpreterAssembler* assembler) { | 651 void Interpreter::DoToBoolean(compiler::InterpreterAssembler* assembler) { |
| 652 Node* accumulator = __ GetAccumulator(); | 652 Node* accumulator = __ GetAccumulator(); |
| 653 Node* result = __ CallRuntime(Runtime::kInterpreterToBoolean, accumulator); | 653 Node* result = __ CallRuntime(Runtime::kInterpreterToBoolean, accumulator); |
| 654 __ SetAccumulator(result); | 654 __ SetAccumulator(result); |
| 655 __ Dispatch(); | 655 __ Dispatch(); |
| 656 } | 656 } |
| 657 | 657 |
| 658 | 658 |
| 659 // ToName |
| 660 // |
| 661 // Cast the object referenced by the accumulator to a name. |
| 662 void Interpreter::DoToName(compiler::InterpreterAssembler* assembler) { |
| 663 Node* accumulator = __ GetAccumulator(); |
| 664 Node* result = __ CallRuntime(Runtime::kToName, accumulator); |
| 665 __ SetAccumulator(result); |
| 666 __ Dispatch(); |
| 667 } |
| 668 |
| 669 |
| 659 // Jump <imm8> | 670 // Jump <imm8> |
| 660 // | 671 // |
| 661 // Jump by number of bytes represented by the immediate operand |imm8|. | 672 // Jump by number of bytes represented by the immediate operand |imm8|. |
| 662 void Interpreter::DoJump(compiler::InterpreterAssembler* assembler) { | 673 void Interpreter::DoJump(compiler::InterpreterAssembler* assembler) { |
| 663 Node* relative_jump = __ BytecodeOperandImm8(0); | 674 Node* relative_jump = __ BytecodeOperandImm8(0); |
| 664 __ Jump(relative_jump); | 675 __ Jump(relative_jump); |
| 665 } | 676 } |
| 666 | 677 |
| 667 | 678 |
| 668 // JumpConstant <idx> | 679 // JumpConstant <idx> |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 compiler::InterpreterAssembler* assembler) { | 734 compiler::InterpreterAssembler* assembler) { |
| 724 Node* accumulator = __ GetAccumulator(); | 735 Node* accumulator = __ GetAccumulator(); |
| 725 Node* index = __ BytecodeOperandIdx8(0); | 736 Node* index = __ BytecodeOperandIdx8(0); |
| 726 Node* constant = __ LoadConstantPoolEntry(index); | 737 Node* constant = __ LoadConstantPoolEntry(index); |
| 727 Node* relative_jump = __ SmiUntag(constant); | 738 Node* relative_jump = __ SmiUntag(constant); |
| 728 Node* false_value = __ BooleanConstant(false); | 739 Node* false_value = __ BooleanConstant(false); |
| 729 __ JumpIfWordEqual(accumulator, false_value, relative_jump); | 740 __ JumpIfWordEqual(accumulator, false_value, relative_jump); |
| 730 } | 741 } |
| 731 | 742 |
| 732 | 743 |
| 733 // CreateArrayLiteral <idx> <flags> | 744 void Interpreter::DoCreateLiteral(Runtime::FunctionId function_id, |
| 734 // | 745 compiler::InterpreterAssembler* assembler) { |
| 735 // Creates an array literal for literal index <idx> with flags <flags> and | |
| 736 // constant elements in the accumulator. | |
| 737 void Interpreter::DoCreateArrayLiteral( | |
| 738 compiler::InterpreterAssembler* assembler) { | |
| 739 Node* constant_elements = __ GetAccumulator(); | 746 Node* constant_elements = __ GetAccumulator(); |
| 740 Node* literal_index_raw = __ BytecodeOperandIdx8(0); | 747 Node* literal_index_raw = __ BytecodeOperandIdx8(0); |
| 741 Node* literal_index = __ SmiTag(literal_index_raw); | 748 Node* literal_index = __ SmiTag(literal_index_raw); |
| 742 Node* flags_raw = __ BytecodeOperandImm8(1); | 749 Node* flags_raw = __ BytecodeOperandImm8(1); |
| 743 Node* flags = __ SmiTag(flags_raw); | 750 Node* flags = __ SmiTag(flags_raw); |
| 744 Node* closure = __ LoadRegister(Register::function_closure()); | 751 Node* closure = __ LoadRegister(Register::function_closure()); |
| 745 Node* literals_array = | 752 Node* literals_array = |
| 746 __ LoadObjectField(closure, JSFunction::kLiteralsOffset); | 753 __ LoadObjectField(closure, JSFunction::kLiteralsOffset); |
| 747 Node* result = __ CallRuntime(Runtime::kCreateArrayLiteral, literals_array, | 754 Node* result = __ CallRuntime(function_id, literals_array, literal_index, |
| 748 literal_index, constant_elements, flags); | 755 constant_elements, flags); |
| 749 __ SetAccumulator(result); | 756 __ SetAccumulator(result); |
| 750 __ Dispatch(); | 757 __ Dispatch(); |
| 751 } | 758 } |
| 752 | 759 |
| 753 | 760 |
| 761 // CreateArrayLiteral <idx> <flags> |
| 762 // |
| 763 // Creates an array literal for literal index <idx> with flags <flags> and |
| 764 // constant elements in the accumulator. |
| 765 void Interpreter::DoCreateArrayLiteral( |
| 766 compiler::InterpreterAssembler* assembler) { |
| 767 DoCreateLiteral(Runtime::kCreateArrayLiteral, assembler); |
| 768 } |
| 769 |
| 770 |
| 771 // CreateObjectLiteral <idx> <flags> |
| 772 // |
| 773 // Creates an object literal for literal index <idx> with flags <flags> and |
| 774 // constant elements in the accumulator. |
| 775 void Interpreter::DoCreateObjectLiteral( |
| 776 compiler::InterpreterAssembler* assembler) { |
| 777 DoCreateLiteral(Runtime::kCreateObjectLiteral, assembler); |
| 778 } |
| 779 |
| 780 |
| 754 // CreateClosure <tenured> | 781 // CreateClosure <tenured> |
| 755 // | 782 // |
| 756 // Creates a new closure for SharedFunctionInfo in the accumulator with the | 783 // Creates a new closure for SharedFunctionInfo in the accumulator with the |
| 757 // PretenureFlag <tenured>. | 784 // PretenureFlag <tenured>. |
| 758 void Interpreter::DoCreateClosure(compiler::InterpreterAssembler* assembler) { | 785 void Interpreter::DoCreateClosure(compiler::InterpreterAssembler* assembler) { |
| 759 // TODO(rmcilroy): Possibly call FastNewClosureStub when possible instead of | 786 // TODO(rmcilroy): Possibly call FastNewClosureStub when possible instead of |
| 760 // calling into the runtime. | 787 // calling into the runtime. |
| 761 Node* shared = __ GetAccumulator(); | 788 Node* shared = __ GetAccumulator(); |
| 762 Node* tenured_raw = __ BytecodeOperandImm8(0); | 789 Node* tenured_raw = __ BytecodeOperandImm8(0); |
| 763 Node* tenured = __ SmiTag(tenured_raw); | 790 Node* tenured = __ SmiTag(tenured_raw); |
| 764 Node* result = | 791 Node* result = |
| 765 __ CallRuntime(Runtime::kInterpreterNewClosure, shared, tenured); | 792 __ CallRuntime(Runtime::kInterpreterNewClosure, shared, tenured); |
| 766 __ SetAccumulator(result); | 793 __ SetAccumulator(result); |
| 767 __ Dispatch(); | 794 __ Dispatch(); |
| 768 } | 795 } |
| 769 | 796 |
| 770 | 797 |
| 771 // Return | 798 // Return |
| 772 // | 799 // |
| 773 // Return the value in the accumulator. | 800 // Return the value in the accumulator. |
| 774 void Interpreter::DoReturn(compiler::InterpreterAssembler* assembler) { | 801 void Interpreter::DoReturn(compiler::InterpreterAssembler* assembler) { |
| 775 __ Return(); | 802 __ Return(); |
| 776 } | 803 } |
| 777 | 804 |
| 778 | 805 |
| 779 } // namespace interpreter | 806 } // namespace interpreter |
| 780 } // namespace internal | 807 } // namespace internal |
| 781 } // namespace v8 | 808 } // namespace v8 |
| OLD | NEW |