| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #ifndef V8_X64_CODEGEN_X64_H_ | 28 #ifndef V8_X64_CODEGEN_X64_H_ |
| 29 #define V8_X64_CODEGEN_X64_H_ | 29 #define V8_X64_CODEGEN_X64_H_ |
| 30 | 30 |
| 31 #include "ic-inl.h" |
| 32 |
| 31 namespace v8 { | 33 namespace v8 { |
| 32 namespace internal { | 34 namespace internal { |
| 33 | 35 |
| 34 // Forward declarations | 36 // Forward declarations |
| 35 class CompilationInfo; | 37 class CompilationInfo; |
| 36 class DeferredCode; | 38 class DeferredCode; |
| 37 class RegisterAllocator; | 39 class RegisterAllocator; |
| 38 class RegisterFile; | 40 class RegisterFile; |
| 39 | 41 |
| 40 enum InitState { CONST_INIT, NOT_CONST_INIT }; | 42 enum InitState { CONST_INIT, NOT_CONST_INIT }; |
| (...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 public: | 666 public: |
| 665 GenericBinaryOpStub(Token::Value op, | 667 GenericBinaryOpStub(Token::Value op, |
| 666 OverwriteMode mode, | 668 OverwriteMode mode, |
| 667 GenericBinaryFlags flags, | 669 GenericBinaryFlags flags, |
| 668 NumberInfo operands_type = NumberInfo::Unknown()) | 670 NumberInfo operands_type = NumberInfo::Unknown()) |
| 669 : op_(op), | 671 : op_(op), |
| 670 mode_(mode), | 672 mode_(mode), |
| 671 flags_(flags), | 673 flags_(flags), |
| 672 args_in_registers_(false), | 674 args_in_registers_(false), |
| 673 args_reversed_(false), | 675 args_reversed_(false), |
| 674 name_(NULL), | 676 static_operands_type_(operands_type), |
| 675 operands_type_(operands_type) { | 677 runtime_operands_type_(BinaryOpIC::DEFAULT), |
| 678 name_(NULL) { |
| 676 use_sse3_ = CpuFeatures::IsSupported(SSE3); | 679 use_sse3_ = CpuFeatures::IsSupported(SSE3); |
| 677 ASSERT(OpBits::is_valid(Token::NUM_TOKENS)); | 680 ASSERT(OpBits::is_valid(Token::NUM_TOKENS)); |
| 678 } | 681 } |
| 679 | 682 |
| 683 GenericBinaryOpStub(int key, BinaryOpIC::TypeInfo type_info) |
| 684 : op_(OpBits::decode(key)), |
| 685 mode_(ModeBits::decode(key)), |
| 686 flags_(FlagBits::decode(key)), |
| 687 args_in_registers_(ArgsInRegistersBits::decode(key)), |
| 688 args_reversed_(ArgsReversedBits::decode(key)), |
| 689 use_sse3_(SSE3Bits::decode(key)), |
| 690 static_operands_type_(NumberInfo::ExpandedRepresentation( |
| 691 StaticTypeInfoBits::decode(key))), |
| 692 runtime_operands_type_(type_info), |
| 693 name_(NULL) { |
| 694 } |
| 695 |
| 680 // Generate code to call the stub with the supplied arguments. This will add | 696 // Generate code to call the stub with the supplied arguments. This will add |
| 681 // code at the call site to prepare arguments either in registers or on the | 697 // code at the call site to prepare arguments either in registers or on the |
| 682 // stack together with the actual call. | 698 // stack together with the actual call. |
| 683 void GenerateCall(MacroAssembler* masm, Register left, Register right); | 699 void GenerateCall(MacroAssembler* masm, Register left, Register right); |
| 684 void GenerateCall(MacroAssembler* masm, Register left, Smi* right); | 700 void GenerateCall(MacroAssembler* masm, Register left, Smi* right); |
| 685 void GenerateCall(MacroAssembler* masm, Smi* left, Register right); | 701 void GenerateCall(MacroAssembler* masm, Smi* left, Register right); |
| 686 | 702 |
| 687 Result GenerateCall(MacroAssembler* masm, | 703 Result GenerateCall(MacroAssembler* masm, |
| 688 VirtualFrame* frame, | 704 VirtualFrame* frame, |
| 689 Result* left, | 705 Result* left, |
| 690 Result* right); | 706 Result* right); |
| 691 | 707 |
| 692 private: | 708 private: |
| 693 Token::Value op_; | 709 Token::Value op_; |
| 694 OverwriteMode mode_; | 710 OverwriteMode mode_; |
| 695 GenericBinaryFlags flags_; | 711 GenericBinaryFlags flags_; |
| 696 bool args_in_registers_; // Arguments passed in registers not on the stack. | 712 bool args_in_registers_; // Arguments passed in registers not on the stack. |
| 697 bool args_reversed_; // Left and right argument are swapped. | 713 bool args_reversed_; // Left and right argument are swapped. |
| 698 bool use_sse3_; | 714 bool use_sse3_; |
| 715 |
| 716 // Number type information of operands, determined by code generator. |
| 717 NumberInfo static_operands_type_; |
| 718 |
| 719 // Operand type information determined at runtime. |
| 720 BinaryOpIC::TypeInfo runtime_operands_type_; |
| 721 |
| 699 char* name_; | 722 char* name_; |
| 700 NumberInfo operands_type_; | |
| 701 | 723 |
| 702 const char* GetName(); | 724 const char* GetName(); |
| 703 | 725 |
| 704 #ifdef DEBUG | 726 #ifdef DEBUG |
| 705 void Print() { | 727 void Print() { |
| 706 PrintF("GenericBinaryOpStub %d (op %s), " | 728 PrintF("GenericBinaryOpStub %d (op %s), " |
| 707 "(mode %d, flags %d, registers %d, reversed %d, only_numbers %s)\n", | 729 "(mode %d, flags %d, registers %d, reversed %d, only_numbers %s)\n", |
| 708 MinorKey(), | 730 MinorKey(), |
| 709 Token::String(op_), | 731 Token::String(op_), |
| 710 static_cast<int>(mode_), | 732 static_cast<int>(mode_), |
| 711 static_cast<int>(flags_), | 733 static_cast<int>(flags_), |
| 712 static_cast<int>(args_in_registers_), | 734 static_cast<int>(args_in_registers_), |
| 713 static_cast<int>(args_reversed_), | 735 static_cast<int>(args_reversed_), |
| 714 operands_type_.ToString()); | 736 static_operands_type_.ToString()); |
| 715 } | 737 } |
| 716 #endif | 738 #endif |
| 717 | 739 |
| 718 // Minor key encoding in 16 bits NNNFRASOOOOOOOMM. | 740 // Minor key encoding in 18 bits TTNNNFRASOOOOOOOMM. |
| 719 class ModeBits: public BitField<OverwriteMode, 0, 2> {}; | 741 class ModeBits: public BitField<OverwriteMode, 0, 2> {}; |
| 720 class OpBits: public BitField<Token::Value, 2, 7> {}; | 742 class OpBits: public BitField<Token::Value, 2, 7> {}; |
| 721 class SSE3Bits: public BitField<bool, 9, 1> {}; | 743 class SSE3Bits: public BitField<bool, 9, 1> {}; |
| 722 class ArgsInRegistersBits: public BitField<bool, 10, 1> {}; | 744 class ArgsInRegistersBits: public BitField<bool, 10, 1> {}; |
| 723 class ArgsReversedBits: public BitField<bool, 11, 1> {}; | 745 class ArgsReversedBits: public BitField<bool, 11, 1> {}; |
| 724 class FlagBits: public BitField<GenericBinaryFlags, 12, 1> {}; | 746 class FlagBits: public BitField<GenericBinaryFlags, 12, 1> {}; |
| 725 class NumberInfoBits: public BitField<int, 13, 3> {}; | 747 class StaticTypeInfoBits: public BitField<int, 13, 3> {}; |
| 748 class RuntimeTypeInfoBits: public BitField<BinaryOpIC::TypeInfo, 16, 2> {}; |
| 726 | 749 |
| 727 Major MajorKey() { return GenericBinaryOp; } | 750 Major MajorKey() { return GenericBinaryOp; } |
| 728 int MinorKey() { | 751 int MinorKey() { |
| 729 // Encode the parameters in a unique 16 bit value. | 752 // Encode the parameters in a unique 18 bit value. |
| 730 return OpBits::encode(op_) | 753 return OpBits::encode(op_) |
| 731 | ModeBits::encode(mode_) | 754 | ModeBits::encode(mode_) |
| 732 | FlagBits::encode(flags_) | 755 | FlagBits::encode(flags_) |
| 733 | SSE3Bits::encode(use_sse3_) | 756 | SSE3Bits::encode(use_sse3_) |
| 734 | ArgsInRegistersBits::encode(args_in_registers_) | 757 | ArgsInRegistersBits::encode(args_in_registers_) |
| 735 | ArgsReversedBits::encode(args_reversed_) | 758 | ArgsReversedBits::encode(args_reversed_) |
| 736 | NumberInfoBits::encode(operands_type_.ThreeBitRepresentation()); | 759 | StaticTypeInfoBits::encode( |
| 760 static_operands_type_.ThreeBitRepresentation()) |
| 761 | RuntimeTypeInfoBits::encode(runtime_operands_type_); |
| 737 } | 762 } |
| 738 | 763 |
| 739 void Generate(MacroAssembler* masm); | 764 void Generate(MacroAssembler* masm); |
| 740 void GenerateSmiCode(MacroAssembler* masm, Label* slow); | 765 void GenerateSmiCode(MacroAssembler* masm, Label* slow); |
| 741 void GenerateLoadArguments(MacroAssembler* masm); | 766 void GenerateLoadArguments(MacroAssembler* masm); |
| 742 void GenerateReturn(MacroAssembler* masm); | 767 void GenerateReturn(MacroAssembler* masm); |
| 768 void GenerateRegisterArgsPush(MacroAssembler* masm); |
| 769 void GenerateTypeTransition(MacroAssembler* masm); |
| 743 | 770 |
| 744 bool ArgsInRegistersSupported() { | 771 bool ArgsInRegistersSupported() { |
| 745 return (op_ == Token::ADD) || (op_ == Token::SUB) | 772 return (op_ == Token::ADD) || (op_ == Token::SUB) |
| 746 || (op_ == Token::MUL) || (op_ == Token::DIV); | 773 || (op_ == Token::MUL) || (op_ == Token::DIV); |
| 747 } | 774 } |
| 748 bool IsOperationCommutative() { | 775 bool IsOperationCommutative() { |
| 749 return (op_ == Token::ADD) || (op_ == Token::MUL); | 776 return (op_ == Token::ADD) || (op_ == Token::MUL); |
| 750 } | 777 } |
| 751 | 778 |
| 752 void SetArgsInRegisters() { args_in_registers_ = true; } | 779 void SetArgsInRegisters() { args_in_registers_ = true; } |
| 753 void SetArgsReversed() { args_reversed_ = true; } | 780 void SetArgsReversed() { args_reversed_ = true; } |
| 754 bool HasSmiCodeInStub() { return (flags_ & NO_SMI_CODE_IN_STUB) == 0; } | 781 bool HasSmiCodeInStub() { return (flags_ & NO_SMI_CODE_IN_STUB) == 0; } |
| 755 bool HasArgsInRegisters() { return args_in_registers_; } | 782 bool HasArgsInRegisters() { return args_in_registers_; } |
| 756 bool HasArgsReversed() { return args_reversed_; } | 783 bool HasArgsReversed() { return args_reversed_; } |
| 784 |
| 785 bool ShouldGenerateSmiCode() { |
| 786 return HasSmiCodeInStub() && |
| 787 runtime_operands_type_ != BinaryOpIC::HEAP_NUMBERS && |
| 788 runtime_operands_type_ != BinaryOpIC::STRINGS; |
| 789 } |
| 790 |
| 791 bool ShouldGenerateFPCode() { |
| 792 return runtime_operands_type_ != BinaryOpIC::STRINGS; |
| 793 } |
| 794 |
| 795 virtual int GetCodeKind() { return Code::BINARY_OP_IC; } |
| 796 |
| 797 virtual InlineCacheState GetICState() { |
| 798 return BinaryOpIC::ToState(runtime_operands_type_); |
| 799 } |
| 757 }; | 800 }; |
| 758 | 801 |
| 759 | 802 |
| 760 class StringStubBase: public CodeStub { | 803 class StringStubBase: public CodeStub { |
| 761 public: | 804 public: |
| 762 // Generate code for copying characters using a simple loop. This should only | 805 // Generate code for copying characters using a simple loop. This should only |
| 763 // be used in places where the number of characters is small and the | 806 // be used in places where the number of characters is small and the |
| 764 // additional setup and checking in GenerateCopyCharactersREP adds too much | 807 // additional setup and checking in GenerateCopyCharactersREP adds too much |
| 765 // overhead. Copying of overlapping regions is not supported. | 808 // overhead. Copying of overlapping regions is not supported. |
| 766 void GenerateCopyCharacters(MacroAssembler* masm, | 809 void GenerateCopyCharacters(MacroAssembler* masm, |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 861 Major MajorKey() { return StringCompare; } | 904 Major MajorKey() { return StringCompare; } |
| 862 int MinorKey() { return 0; } | 905 int MinorKey() { return 0; } |
| 863 | 906 |
| 864 void Generate(MacroAssembler* masm); | 907 void Generate(MacroAssembler* masm); |
| 865 }; | 908 }; |
| 866 | 909 |
| 867 | 910 |
| 868 } } // namespace v8::internal | 911 } } // namespace v8::internal |
| 869 | 912 |
| 870 #endif // V8_X64_CODEGEN_X64_H_ | 913 #endif // V8_X64_CODEGEN_X64_H_ |
| OLD | NEW |