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