| 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 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 NO_GENERIC_BINARY_FLAGS = 0, | 649 NO_GENERIC_BINARY_FLAGS = 0, |
| 650 NO_SMI_CODE_IN_STUB = 1 << 0 // Omit smi code in stub. | 650 NO_SMI_CODE_IN_STUB = 1 << 0 // Omit smi code in stub. |
| 651 }; | 651 }; |
| 652 | 652 |
| 653 | 653 |
| 654 class GenericBinaryOpStub: public CodeStub { | 654 class GenericBinaryOpStub: public CodeStub { |
| 655 public: | 655 public: |
| 656 GenericBinaryOpStub(Token::Value op, | 656 GenericBinaryOpStub(Token::Value op, |
| 657 OverwriteMode mode, | 657 OverwriteMode mode, |
| 658 GenericBinaryFlags flags, | 658 GenericBinaryFlags flags, |
| 659 bool only_numbers = false) | 659 NumberInfo::Type operands_type = NumberInfo::kUnknown) |
| 660 : op_(op), | 660 : op_(op), |
| 661 mode_(mode), | 661 mode_(mode), |
| 662 flags_(flags), | 662 flags_(flags), |
| 663 args_in_registers_(false), | 663 args_in_registers_(false), |
| 664 args_reversed_(false), | 664 args_reversed_(false), |
| 665 name_(NULL), | 665 name_(NULL), |
| 666 only_numbers_in_stub_(only_numbers) { | 666 operands_type_(operands_type) { |
| 667 use_sse3_ = CpuFeatures::IsSupported(SSE3); | 667 use_sse3_ = CpuFeatures::IsSupported(SSE3); |
| 668 ASSERT(OpBits::is_valid(Token::NUM_TOKENS)); | 668 ASSERT(OpBits::is_valid(Token::NUM_TOKENS)); |
| 669 } | 669 } |
| 670 | 670 |
| 671 // Generate code to call the stub with the supplied arguments. This will add | 671 // Generate code to call the stub with the supplied arguments. This will add |
| 672 // code at the call site to prepare arguments either in registers or on the | 672 // code at the call site to prepare arguments either in registers or on the |
| 673 // stack together with the actual call. | 673 // stack together with the actual call. |
| 674 void GenerateCall(MacroAssembler* masm, Register left, Register right); | 674 void GenerateCall(MacroAssembler* masm, Register left, Register right); |
| 675 void GenerateCall(MacroAssembler* masm, Register left, Smi* right); | 675 void GenerateCall(MacroAssembler* masm, Register left, Smi* right); |
| 676 void GenerateCall(MacroAssembler* masm, Smi* left, Register right); | 676 void GenerateCall(MacroAssembler* masm, Smi* left, Register right); |
| 677 | 677 |
| 678 Result GenerateCall(MacroAssembler* masm, | 678 Result GenerateCall(MacroAssembler* masm, |
| 679 VirtualFrame* frame, | 679 VirtualFrame* frame, |
| 680 Result* left, | 680 Result* left, |
| 681 Result* right); | 681 Result* right); |
| 682 | 682 |
| 683 private: | 683 private: |
| 684 Token::Value op_; | 684 Token::Value op_; |
| 685 OverwriteMode mode_; | 685 OverwriteMode mode_; |
| 686 GenericBinaryFlags flags_; | 686 GenericBinaryFlags flags_; |
| 687 bool args_in_registers_; // Arguments passed in registers not on the stack. | 687 bool args_in_registers_; // Arguments passed in registers not on the stack. |
| 688 bool args_reversed_; // Left and right argument are swapped. | 688 bool args_reversed_; // Left and right argument are swapped. |
| 689 bool use_sse3_; | 689 bool use_sse3_; |
| 690 char* name_; | 690 char* name_; |
| 691 bool only_numbers_in_stub_; | 691 NumberInfo::Type operands_type_; |
| 692 | 692 |
| 693 const char* GetName(); | 693 const char* GetName(); |
| 694 | 694 |
| 695 #ifdef DEBUG | 695 #ifdef DEBUG |
| 696 void Print() { | 696 void Print() { |
| 697 PrintF("GenericBinaryOpStub %d (op %s), " | 697 PrintF("GenericBinaryOpStub %d (op %s), " |
| 698 "(mode %d, flags %d, registers %d, reversed %d, only_numbers %d)\n", | 698 "(mode %d, flags %d, registers %d, reversed %d, only_numbers %s)\n", |
| 699 MinorKey(), | 699 MinorKey(), |
| 700 Token::String(op_), | 700 Token::String(op_), |
| 701 static_cast<int>(mode_), | 701 static_cast<int>(mode_), |
| 702 static_cast<int>(flags_), | 702 static_cast<int>(flags_), |
| 703 static_cast<int>(args_in_registers_), | 703 static_cast<int>(args_in_registers_), |
| 704 static_cast<int>(args_reversed_), | 704 static_cast<int>(args_reversed_), |
| 705 static_cast<int>(only_numbers_in_stub_)); | 705 NumberInfo::ToString(operands_type_)); |
| 706 } | 706 } |
| 707 #endif | 707 #endif |
| 708 | 708 |
| 709 // Minor key encoding in 16 bits NFRASOOOOOOOOOMM. | 709 // Minor key encoding in 16 bits NNNFRASOOOOOOOMM. |
| 710 class ModeBits: public BitField<OverwriteMode, 0, 2> {}; | 710 class ModeBits: public BitField<OverwriteMode, 0, 2> {}; |
| 711 class OpBits: public BitField<Token::Value, 2, 9> {}; | 711 class OpBits: public BitField<Token::Value, 2, 7> {}; |
| 712 class SSE3Bits: public BitField<bool, 11, 1> {}; | 712 class SSE3Bits: public BitField<bool, 9, 1> {}; |
| 713 class ArgsInRegistersBits: public BitField<bool, 12, 1> {}; | 713 class ArgsInRegistersBits: public BitField<bool, 10, 1> {}; |
| 714 class ArgsReversedBits: public BitField<bool, 13, 1> {}; | 714 class ArgsReversedBits: public BitField<bool, 11, 1> {}; |
| 715 class FlagBits: public BitField<GenericBinaryFlags, 14, 1> {}; | 715 class FlagBits: public BitField<GenericBinaryFlags, 12, 1> {}; |
| 716 class OnlyNumberBits: public BitField<bool, 15, 1> {}; | 716 class NumberInfoBits: public BitField<NumberInfo::Type, 13, 3> {}; |
| 717 | 717 |
| 718 Major MajorKey() { return GenericBinaryOp; } | 718 Major MajorKey() { return GenericBinaryOp; } |
| 719 int MinorKey() { | 719 int MinorKey() { |
| 720 // Encode the parameters in a unique 16 bit value. | 720 // Encode the parameters in a unique 16 bit value. |
| 721 return OpBits::encode(op_) | 721 return OpBits::encode(op_) |
| 722 | ModeBits::encode(mode_) | 722 | ModeBits::encode(mode_) |
| 723 | FlagBits::encode(flags_) | 723 | FlagBits::encode(flags_) |
| 724 | SSE3Bits::encode(use_sse3_) | 724 | SSE3Bits::encode(use_sse3_) |
| 725 | ArgsInRegistersBits::encode(args_in_registers_) | 725 | ArgsInRegistersBits::encode(args_in_registers_) |
| 726 | ArgsReversedBits::encode(args_reversed_) | 726 | ArgsReversedBits::encode(args_reversed_) |
| 727 | OnlyNumberBits::encode(only_numbers_in_stub_); | 727 | NumberInfoBits::encode(operands_type_); |
| 728 } | 728 } |
| 729 | 729 |
| 730 void Generate(MacroAssembler* masm); | 730 void Generate(MacroAssembler* masm); |
| 731 void GenerateSmiCode(MacroAssembler* masm, Label* slow); | 731 void GenerateSmiCode(MacroAssembler* masm, Label* slow); |
| 732 void GenerateLoadArguments(MacroAssembler* masm); | 732 void GenerateLoadArguments(MacroAssembler* masm); |
| 733 void GenerateReturn(MacroAssembler* masm); | 733 void GenerateReturn(MacroAssembler* masm); |
| 734 | 734 |
| 735 bool ArgsInRegistersSupported() { | 735 bool ArgsInRegistersSupported() { |
| 736 return (op_ == Token::ADD) || (op_ == Token::SUB) | 736 return (op_ == Token::ADD) || (op_ == Token::SUB) |
| 737 || (op_ == Token::MUL) || (op_ == Token::DIV); | 737 || (op_ == Token::MUL) || (op_ == Token::DIV); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 825 Major MajorKey() { return StringCompare; } | 825 Major MajorKey() { return StringCompare; } |
| 826 int MinorKey() { return 0; } | 826 int MinorKey() { return 0; } |
| 827 | 827 |
| 828 void Generate(MacroAssembler* masm); | 828 void Generate(MacroAssembler* masm); |
| 829 }; | 829 }; |
| 830 | 830 |
| 831 | 831 |
| 832 } } // namespace v8::internal | 832 } } // namespace v8::internal |
| 833 | 833 |
| 834 #endif // V8_X64_CODEGEN_X64_H_ | 834 #endif // V8_X64_CODEGEN_X64_H_ |
| OLD | NEW |