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 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
744 Node* closure = __ LoadRegister(Register::function_closure()); | 744 Node* closure = __ LoadRegister(Register::function_closure()); |
745 Node* literals_array = | 745 Node* literals_array = |
746 __ LoadObjectField(closure, JSFunction::kLiteralsOffset); | 746 __ LoadObjectField(closure, JSFunction::kLiteralsOffset); |
747 Node* result = __ CallRuntime(Runtime::kCreateArrayLiteral, literals_array, | 747 Node* result = __ CallRuntime(Runtime::kCreateArrayLiteral, literals_array, |
748 literal_index, constant_elements, flags); | 748 literal_index, constant_elements, flags); |
749 __ SetAccumulator(result); | 749 __ SetAccumulator(result); |
750 __ Dispatch(); | 750 __ Dispatch(); |
751 } | 751 } |
752 | 752 |
753 | 753 |
754 // JumpIfToBooleanTrue <imm8> | |
rmcilroy
2015/10/14 14:32:44
nit - move these to be below DoJumpIfFalseConstant
mythria
2015/10/14 14:59:55
Done.
| |
755 // | |
756 // Jump by number of bytes represented by an immediate operand if the object | |
757 // referenced by the accumulator is true when the object is cast to boolean. | |
758 void Interpreter::DoJumpIfToBooleanTrue( | |
759 compiler::InterpreterAssembler* assembler) { | |
760 Node* accumulator = __ GetAccumulator(); | |
761 Node* relative_jump = __ BytecodeOperandImm8(0); | |
762 Node* to_boolean_value = | |
763 __ CallRuntime(Runtime::kInterpreterToBoolean, accumulator); | |
764 Node* true_value = __ BooleanConstant(true); | |
765 __ JumpIfWordEqual(to_boolean_value, true_value, relative_jump); | |
766 } | |
767 | |
768 | |
769 // JumpIfToBooleanTrueConstant <idx> | |
770 // | |
771 // Jump by number of bytes in the Smi in the |idx| entry in the constant pool | |
772 // if the object referenced by the accumulator is true when the object is cast | |
773 // to boolean. | |
774 void Interpreter::DoJumpIfToBooleanTrueConstant( | |
775 compiler::InterpreterAssembler* assembler) { | |
776 Node* accumulator = __ GetAccumulator(); | |
777 Node* to_boolean_value = | |
778 __ CallRuntime(Runtime::kInterpreterToBoolean, accumulator); | |
779 Node* index = __ BytecodeOperandIdx8(0); | |
780 Node* constant = __ LoadConstantPoolEntry(index); | |
781 Node* relative_jump = __ SmiUntag(constant); | |
782 Node* true_value = __ BooleanConstant(true); | |
783 __ JumpIfWordEqual(to_boolean_value, true_value, relative_jump); | |
784 } | |
785 | |
786 | |
787 // JumpIfToBooleanFalse <imm8> | |
788 // | |
789 // Jump by number of bytes represented by an immediate operand if the object | |
790 // referenced by the accumulator is false when the object is cast to boolean. | |
791 void Interpreter::DoJumpIfToBooleanFalse( | |
792 compiler::InterpreterAssembler* assembler) { | |
793 Node* accumulator = __ GetAccumulator(); | |
794 Node* relative_jump = __ BytecodeOperandImm8(0); | |
795 Node* to_boolean_value = | |
796 __ CallRuntime(Runtime::kInterpreterToBoolean, accumulator); | |
797 Node* false_value = __ BooleanConstant(false); | |
798 __ JumpIfWordEqual(to_boolean_value, false_value, relative_jump); | |
799 } | |
800 | |
801 | |
802 // JumpIfToBooleanFalseConstant <idx> | |
803 // | |
804 // Jump by number of bytes in the Smi in the |idx| entry in the constant pool | |
805 // if the object referenced by the accumulator is false when the object is cast | |
806 // to boolean. | |
807 void Interpreter::DoJumpIfToBooleanFalseConstant( | |
808 compiler::InterpreterAssembler* assembler) { | |
809 Node* accumulator = __ GetAccumulator(); | |
810 Node* to_boolean_value = | |
811 __ CallRuntime(Runtime::kInterpreterToBoolean, accumulator); | |
812 Node* index = __ BytecodeOperandIdx8(0); | |
813 Node* constant = __ LoadConstantPoolEntry(index); | |
814 Node* relative_jump = __ SmiUntag(constant); | |
815 Node* false_value = __ BooleanConstant(false); | |
816 __ JumpIfWordEqual(to_boolean_value, false_value, relative_jump); | |
817 } | |
818 | |
819 | |
754 // CreateClosure <tenured> | 820 // CreateClosure <tenured> |
755 // | 821 // |
756 // Creates a new closure for SharedFunctionInfo in the accumulator with the | 822 // Creates a new closure for SharedFunctionInfo in the accumulator with the |
757 // PretenureFlag <tenured>. | 823 // PretenureFlag <tenured>. |
758 void Interpreter::DoCreateClosure(compiler::InterpreterAssembler* assembler) { | 824 void Interpreter::DoCreateClosure(compiler::InterpreterAssembler* assembler) { |
759 // TODO(rmcilroy): Possibly call FastNewClosureStub when possible instead of | 825 // TODO(rmcilroy): Possibly call FastNewClosureStub when possible instead of |
760 // calling into the runtime. | 826 // calling into the runtime. |
761 Node* shared = __ GetAccumulator(); | 827 Node* shared = __ GetAccumulator(); |
762 Node* tenured_raw = __ BytecodeOperandImm8(0); | 828 Node* tenured_raw = __ BytecodeOperandImm8(0); |
763 Node* tenured = __ SmiTag(tenured_raw); | 829 Node* tenured = __ SmiTag(tenured_raw); |
764 Node* result = | 830 Node* result = |
765 __ CallRuntime(Runtime::kInterpreterNewClosure, shared, tenured); | 831 __ CallRuntime(Runtime::kInterpreterNewClosure, shared, tenured); |
766 __ SetAccumulator(result); | 832 __ SetAccumulator(result); |
767 __ Dispatch(); | 833 __ Dispatch(); |
768 } | 834 } |
769 | 835 |
770 | 836 |
771 // Return | 837 // Return |
772 // | 838 // |
773 // Return the value in the accumulator. | 839 // Return the value in the accumulator. |
774 void Interpreter::DoReturn(compiler::InterpreterAssembler* assembler) { | 840 void Interpreter::DoReturn(compiler::InterpreterAssembler* assembler) { |
775 __ Return(); | 841 __ Return(); |
776 } | 842 } |
777 | 843 |
778 | 844 |
779 } // namespace interpreter | 845 } // namespace interpreter |
780 } // namespace internal | 846 } // namespace internal |
781 } // namespace v8 | 847 } // namespace v8 |
OLD | NEW |