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 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 NumberInfo::Type operands_type = NumberInfo::kUnknown) |
663 : op_(op), | 663 : op_(op), |
664 mode_(mode), | 664 mode_(mode), |
665 flags_(flags), | 665 flags_(flags), |
666 args_in_registers_(false), | 666 args_in_registers_(false), |
667 args_reversed_(false), | 667 args_reversed_(false), |
668 name_(NULL), | 668 name_(NULL), |
669 only_numbers_in_stub_(only_numbers) { | 669 operands_type_(operands_type) { |
670 use_sse3_ = CpuFeatures::IsSupported(SSE3); | 670 use_sse3_ = CpuFeatures::IsSupported(SSE3); |
671 ASSERT(OpBits::is_valid(Token::NUM_TOKENS)); | 671 ASSERT(OpBits::is_valid(Token::NUM_TOKENS)); |
672 } | 672 } |
673 | 673 |
674 // 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 |
675 // 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 |
676 // stack together with the actual call. | 676 // stack together with the actual call. |
677 void GenerateCall(MacroAssembler* masm, Register left, Register right); | 677 void GenerateCall(MacroAssembler* masm, Register left, Register right); |
678 void GenerateCall(MacroAssembler* masm, Register left, Smi* right); | 678 void GenerateCall(MacroAssembler* masm, Register left, Smi* right); |
679 void GenerateCall(MacroAssembler* masm, Smi* left, Register right); | 679 void GenerateCall(MacroAssembler* masm, Smi* left, Register right); |
680 | 680 |
681 Result GenerateCall(MacroAssembler* masm, | 681 Result GenerateCall(MacroAssembler* masm, |
682 VirtualFrame* frame, | 682 VirtualFrame* frame, |
683 Result* left, | 683 Result* left, |
684 Result* right); | 684 Result* right); |
685 | 685 |
686 private: | 686 private: |
687 Token::Value op_; | 687 Token::Value op_; |
688 OverwriteMode mode_; | 688 OverwriteMode mode_; |
689 GenericBinaryFlags flags_; | 689 GenericBinaryFlags flags_; |
690 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. |
691 bool args_reversed_; // Left and right argument are swapped. | 691 bool args_reversed_; // Left and right argument are swapped. |
692 bool use_sse3_; | 692 bool use_sse3_; |
693 char* name_; | 693 char* name_; |
694 bool only_numbers_in_stub_; // Arguments are only numbers. | 694 NumberInfo::Type operands_type_; // Number type information of operands. |
695 | 695 |
696 const char* GetName(); | 696 const char* GetName(); |
697 | 697 |
698 #ifdef DEBUG | 698 #ifdef DEBUG |
699 void Print() { | 699 void Print() { |
700 PrintF("GenericBinaryOpStub %d (op %s), " | 700 PrintF("GenericBinaryOpStub %d (op %s), " |
701 "(mode %d, flags %d, registers %d, reversed %d, only_numbers %d)\n", | 701 "(mode %d, flags %d, registers %d, reversed %d, number_info %s)\n", |
702 MinorKey(), | 702 MinorKey(), |
703 Token::String(op_), | 703 Token::String(op_), |
704 static_cast<int>(mode_), | 704 static_cast<int>(mode_), |
705 static_cast<int>(flags_), | 705 static_cast<int>(flags_), |
706 static_cast<int>(args_in_registers_), | 706 static_cast<int>(args_in_registers_), |
707 static_cast<int>(args_reversed_), | 707 static_cast<int>(args_reversed_), |
708 static_cast<int>(only_numbers_in_stub_)); | 708 NumberInfo::ToString(operands_type_)); |
709 } | 709 } |
710 #endif | 710 #endif |
711 | 711 |
712 // Minor key encoding in 16 bits NFRASOOOOOOOOOMM. | 712 // Minor key encoding in 16 bits NNNFRASOOOOOOOMM. |
713 class ModeBits: public BitField<OverwriteMode, 0, 2> {}; | 713 class ModeBits: public BitField<OverwriteMode, 0, 2> {}; |
714 class OpBits: public BitField<Token::Value, 2, 9> {}; | 714 class OpBits: public BitField<Token::Value, 2, 7> {}; |
715 class SSE3Bits: public BitField<bool, 11, 1> {}; | 715 class SSE3Bits: public BitField<bool, 9, 1> {}; |
716 class ArgsInRegistersBits: public BitField<bool, 12, 1> {}; | 716 class ArgsInRegistersBits: public BitField<bool, 10, 1> {}; |
717 class ArgsReversedBits: public BitField<bool, 13, 1> {}; | 717 class ArgsReversedBits: public BitField<bool, 11, 1> {}; |
718 class FlagBits: public BitField<GenericBinaryFlags, 14, 1> {}; | 718 class FlagBits: public BitField<GenericBinaryFlags, 12, 1> {}; |
719 class OnlyNumbersBits: public BitField<bool, 15, 1> {}; | 719 class NumberInfoBits: public BitField<NumberInfo::Type, 13, 3> {}; |
720 | 720 |
721 Major MajorKey() { return GenericBinaryOp; } | 721 Major MajorKey() { return GenericBinaryOp; } |
722 int MinorKey() { | 722 int MinorKey() { |
723 // Encode the parameters in a unique 16 bit value. | 723 // Encode the parameters in a unique 16 bit value. |
724 return OpBits::encode(op_) | 724 return OpBits::encode(op_) |
725 | ModeBits::encode(mode_) | 725 | ModeBits::encode(mode_) |
726 | FlagBits::encode(flags_) | 726 | FlagBits::encode(flags_) |
727 | SSE3Bits::encode(use_sse3_) | 727 | SSE3Bits::encode(use_sse3_) |
728 | ArgsInRegistersBits::encode(args_in_registers_) | 728 | ArgsInRegistersBits::encode(args_in_registers_) |
729 | ArgsReversedBits::encode(args_reversed_) | 729 | ArgsReversedBits::encode(args_reversed_) |
730 | OnlyNumbersBits::encode(only_numbers_in_stub_); | 730 | NumberInfoBits::encode(operands_type_); |
731 } | 731 } |
732 | 732 |
733 void Generate(MacroAssembler* masm); | 733 void Generate(MacroAssembler* masm); |
734 void GenerateSmiCode(MacroAssembler* masm, Label* slow); | 734 void GenerateSmiCode(MacroAssembler* masm, Label* slow); |
735 void GenerateLoadArguments(MacroAssembler* masm); | 735 void GenerateLoadArguments(MacroAssembler* masm); |
736 void GenerateReturn(MacroAssembler* masm); | 736 void GenerateReturn(MacroAssembler* masm); |
737 void GenerateHeapResultAllocation(MacroAssembler* masm, Label* alloc_failure); | 737 void GenerateHeapResultAllocation(MacroAssembler* masm, Label* alloc_failure); |
738 | 738 |
739 bool ArgsInRegistersSupported() { | 739 bool ArgsInRegistersSupported() { |
740 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... |
856 Major MajorKey() { return StringCompare; } | 856 Major MajorKey() { return StringCompare; } |
857 int MinorKey() { return 0; } | 857 int MinorKey() { return 0; } |
858 | 858 |
859 void Generate(MacroAssembler* masm); | 859 void Generate(MacroAssembler* masm); |
860 }; | 860 }; |
861 | 861 |
862 | 862 |
863 } } // namespace v8::internal | 863 } } // namespace v8::internal |
864 | 864 |
865 #endif // V8_IA32_CODEGEN_IA32_H_ | 865 #endif // V8_IA32_CODEGEN_IA32_H_ |
OLD | NEW |