OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
878 | 878 |
879 | 879 |
880 class BinaryOpStub: public PlatformCodeStub { | 880 class BinaryOpStub: public PlatformCodeStub { |
881 public: | 881 public: |
882 BinaryOpStub(Token::Value op, OverwriteMode mode) | 882 BinaryOpStub(Token::Value op, OverwriteMode mode) |
883 : op_(op), | 883 : op_(op), |
884 mode_(mode), | 884 mode_(mode), |
885 platform_specific_bit_(false), | 885 platform_specific_bit_(false), |
886 left_type_(BinaryOpIC::UNINITIALIZED), | 886 left_type_(BinaryOpIC::UNINITIALIZED), |
887 right_type_(BinaryOpIC::UNINITIALIZED), | 887 right_type_(BinaryOpIC::UNINITIALIZED), |
888 result_type_(BinaryOpIC::UNINITIALIZED) { | 888 result_type_(BinaryOpIC::UNINITIALIZED), |
| 889 has_fixed_right_arg_(false), |
| 890 encoded_right_arg_(encode_arg_value(1)) { |
889 Initialize(); | 891 Initialize(); |
890 ASSERT(OpBits::is_valid(Token::NUM_TOKENS)); | 892 ASSERT(OpBits::is_valid(Token::NUM_TOKENS)); |
891 } | 893 } |
892 | 894 |
893 BinaryOpStub( | 895 BinaryOpStub( |
894 int key, | 896 int key, |
895 BinaryOpIC::TypeInfo left_type, | 897 BinaryOpIC::TypeInfo left_type, |
896 BinaryOpIC::TypeInfo right_type, | 898 BinaryOpIC::TypeInfo right_type, |
897 BinaryOpIC::TypeInfo result_type = BinaryOpIC::UNINITIALIZED) | 899 BinaryOpIC::TypeInfo result_type, |
| 900 bool has_fixed_right_arg, |
| 901 int32_t fixed_right_arg_value) |
898 : op_(OpBits::decode(key)), | 902 : op_(OpBits::decode(key)), |
899 mode_(ModeBits::decode(key)), | 903 mode_(ModeBits::decode(key)), |
900 platform_specific_bit_(PlatformSpecificBits::decode(key)), | 904 platform_specific_bit_(PlatformSpecificBits::decode(key)), |
901 left_type_(left_type), | 905 left_type_(left_type), |
902 right_type_(right_type), | 906 right_type_(right_type), |
903 result_type_(result_type) { } | 907 result_type_(result_type), |
| 908 has_fixed_right_arg_(has_fixed_right_arg), |
| 909 encoded_right_arg_(encode_arg_value(fixed_right_arg_value)) { } |
904 | 910 |
905 static void decode_types_from_minor_key(int minor_key, | 911 static void decode_types_from_minor_key(int minor_key, |
906 BinaryOpIC::TypeInfo* left_type, | 912 BinaryOpIC::TypeInfo* left_type, |
907 BinaryOpIC::TypeInfo* right_type, | 913 BinaryOpIC::TypeInfo* right_type, |
908 BinaryOpIC::TypeInfo* result_type) { | 914 BinaryOpIC::TypeInfo* result_type) { |
909 *left_type = | 915 *left_type = |
910 static_cast<BinaryOpIC::TypeInfo>(LeftTypeBits::decode(minor_key)); | 916 static_cast<BinaryOpIC::TypeInfo>(LeftTypeBits::decode(minor_key)); |
911 *right_type = | 917 *right_type = |
912 static_cast<BinaryOpIC::TypeInfo>(RightTypeBits::decode(minor_key)); | 918 static_cast<BinaryOpIC::TypeInfo>(RightTypeBits::decode(minor_key)); |
913 *result_type = | 919 *result_type = |
914 static_cast<BinaryOpIC::TypeInfo>(ResultTypeBits::decode(minor_key)); | 920 static_cast<BinaryOpIC::TypeInfo>(ResultTypeBits::decode(minor_key)); |
915 } | 921 } |
916 | 922 |
917 static Token::Value decode_op_from_minor_key(int minor_key) { | 923 static Token::Value decode_op_from_minor_key(int minor_key) { |
918 return static_cast<Token::Value>(OpBits::decode(minor_key)); | 924 return static_cast<Token::Value>(OpBits::decode(minor_key)); |
919 } | 925 } |
920 | 926 |
| 927 static bool decode_has_fixed_right_arg_from_minor_key(int minor_key) { |
| 928 return HasFixedRightArgBits::decode(minor_key); |
| 929 } |
| 930 |
| 931 static int decode_fixed_right_arg_value_from_minor_key(int minor_key) { |
| 932 return decode_arg_value(FixedRightArgValueBits::decode(minor_key)); |
| 933 } |
| 934 |
| 935 int fixed_right_arg_value() const { |
| 936 return decode_arg_value(encoded_right_arg_); |
| 937 } |
| 938 |
| 939 static bool can_encode_arg_value(int32_t value) { |
| 940 return value > 0 && |
| 941 IsPowerOf2(value) && |
| 942 FixedRightArgValueBits::is_valid(WhichPowerOf2(value)); |
| 943 } |
| 944 |
921 enum SmiCodeGenerateHeapNumberResults { | 945 enum SmiCodeGenerateHeapNumberResults { |
922 ALLOW_HEAPNUMBER_RESULTS, | 946 ALLOW_HEAPNUMBER_RESULTS, |
923 NO_HEAPNUMBER_RESULTS | 947 NO_HEAPNUMBER_RESULTS |
924 }; | 948 }; |
925 | 949 |
926 private: | 950 private: |
927 Token::Value op_; | 951 Token::Value op_; |
928 OverwriteMode mode_; | 952 OverwriteMode mode_; |
929 bool platform_specific_bit_; // Indicates SSE3 on IA32. | 953 bool platform_specific_bit_; // Indicates SSE3 on IA32. |
930 | 954 |
931 // Operand type information determined at runtime. | 955 // Operand type information determined at runtime. |
932 BinaryOpIC::TypeInfo left_type_; | 956 BinaryOpIC::TypeInfo left_type_; |
933 BinaryOpIC::TypeInfo right_type_; | 957 BinaryOpIC::TypeInfo right_type_; |
934 BinaryOpIC::TypeInfo result_type_; | 958 BinaryOpIC::TypeInfo result_type_; |
935 | 959 |
| 960 bool has_fixed_right_arg_; |
| 961 int encoded_right_arg_; |
| 962 |
| 963 static int encode_arg_value(int32_t value) { |
| 964 ASSERT(can_encode_arg_value(value)); |
| 965 return WhichPowerOf2(value); |
| 966 } |
| 967 |
| 968 static int32_t decode_arg_value(int value) { |
| 969 return 1 << value; |
| 970 } |
| 971 |
936 virtual void PrintName(StringStream* stream); | 972 virtual void PrintName(StringStream* stream); |
937 | 973 |
938 // Minor key encoding in 19 bits TTTRRRLLLSOOOOOOOMM. | 974 // Minor key encoding in all 25 bits FFFFFHTTTRRRLLLPOOOOOOOMM. |
| 975 // Note: We actually do not need 7 bits for the operation, just 4 bits to |
| 976 // encode ADD, SUB, MUL, DIV, MOD, BIT_OR, BIT_AND, BIT_XOR, SAR, SHL, SHR. |
939 class ModeBits: public BitField<OverwriteMode, 0, 2> {}; | 977 class ModeBits: public BitField<OverwriteMode, 0, 2> {}; |
940 class OpBits: public BitField<Token::Value, 2, 7> {}; | 978 class OpBits: public BitField<Token::Value, 2, 7> {}; |
941 class PlatformSpecificBits: public BitField<bool, 9, 1> {}; | 979 class PlatformSpecificBits: public BitField<bool, 9, 1> {}; |
942 class LeftTypeBits: public BitField<BinaryOpIC::TypeInfo, 10, 3> {}; | 980 class LeftTypeBits: public BitField<BinaryOpIC::TypeInfo, 10, 3> {}; |
943 class RightTypeBits: public BitField<BinaryOpIC::TypeInfo, 13, 3> {}; | 981 class RightTypeBits: public BitField<BinaryOpIC::TypeInfo, 13, 3> {}; |
944 class ResultTypeBits: public BitField<BinaryOpIC::TypeInfo, 16, 3> {}; | 982 class ResultTypeBits: public BitField<BinaryOpIC::TypeInfo, 16, 3> {}; |
| 983 class HasFixedRightArgBits: public BitField<bool, 19, 1> {}; |
| 984 class FixedRightArgValueBits: public BitField<int, 20, 5> {}; |
945 | 985 |
946 Major MajorKey() { return BinaryOp; } | 986 Major MajorKey() { return BinaryOp; } |
947 int MinorKey() { | 987 int MinorKey() { |
948 return OpBits::encode(op_) | 988 return OpBits::encode(op_) |
949 | ModeBits::encode(mode_) | 989 | ModeBits::encode(mode_) |
950 | PlatformSpecificBits::encode(platform_specific_bit_) | 990 | PlatformSpecificBits::encode(platform_specific_bit_) |
951 | LeftTypeBits::encode(left_type_) | 991 | LeftTypeBits::encode(left_type_) |
952 | RightTypeBits::encode(right_type_) | 992 | RightTypeBits::encode(right_type_) |
953 | ResultTypeBits::encode(result_type_); | 993 | ResultTypeBits::encode(result_type_) |
| 994 | HasFixedRightArgBits::encode(has_fixed_right_arg_) |
| 995 | FixedRightArgValueBits::encode(encoded_right_arg_); |
954 } | 996 } |
955 | 997 |
956 | 998 |
957 // Platform-independent implementation. | 999 // Platform-independent implementation. |
958 void Generate(MacroAssembler* masm); | 1000 void Generate(MacroAssembler* masm); |
959 void GenerateCallRuntime(MacroAssembler* masm); | 1001 void GenerateCallRuntime(MacroAssembler* masm); |
960 | 1002 |
961 // Platform-independent signature, platform-specific implementation. | 1003 // Platform-independent signature, platform-specific implementation. |
962 void Initialize(); | 1004 void Initialize(); |
963 void GenerateAddStrings(MacroAssembler* masm); | 1005 void GenerateAddStrings(MacroAssembler* masm); |
(...skipping 1031 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1995 | 2037 |
1996 // The current function entry hook. | 2038 // The current function entry hook. |
1997 static FunctionEntryHook entry_hook_; | 2039 static FunctionEntryHook entry_hook_; |
1998 | 2040 |
1999 DISALLOW_COPY_AND_ASSIGN(ProfileEntryHookStub); | 2041 DISALLOW_COPY_AND_ASSIGN(ProfileEntryHookStub); |
2000 }; | 2042 }; |
2001 | 2043 |
2002 } } // namespace v8::internal | 2044 } } // namespace v8::internal |
2003 | 2045 |
2004 #endif // V8_CODE_STUBS_H_ | 2046 #endif // V8_CODE_STUBS_H_ |
OLD | NEW |