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