| 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 #else | 115 #else |
| 116 #define CODE_STUB_LIST_MIPS(V) | 116 #define CODE_STUB_LIST_MIPS(V) |
| 117 #endif | 117 #endif |
| 118 | 118 |
| 119 // Combined list of code stubs. | 119 // Combined list of code stubs. |
| 120 #define CODE_STUB_LIST(V) \ | 120 #define CODE_STUB_LIST(V) \ |
| 121 CODE_STUB_LIST_ALL_PLATFORMS(V) \ | 121 CODE_STUB_LIST_ALL_PLATFORMS(V) \ |
| 122 CODE_STUB_LIST_ARM(V) \ | 122 CODE_STUB_LIST_ARM(V) \ |
| 123 CODE_STUB_LIST_MIPS(V) | 123 CODE_STUB_LIST_MIPS(V) |
| 124 | 124 |
| 125 // Mode to overwrite BinaryExpression values. | |
| 126 enum OverwriteMode { NO_OVERWRITE, OVERWRITE_LEFT, OVERWRITE_RIGHT }; | |
| 127 | |
| 128 // Stub is base classes of all stubs. | 125 // Stub is base classes of all stubs. |
| 129 class CodeStub BASE_EMBEDDED { | 126 class CodeStub BASE_EMBEDDED { |
| 130 public: | 127 public: |
| 131 enum Major { | 128 enum Major { |
| 132 #define DEF_ENUM(name) name, | 129 #define DEF_ENUM(name) name, |
| 133 CODE_STUB_LIST(DEF_ENUM) | 130 CODE_STUB_LIST(DEF_ENUM) |
| 134 #undef DEF_ENUM | 131 #undef DEF_ENUM |
| 135 NoCache, // marker for stubs that do custom caching | 132 NoCache, // marker for stubs that do custom caching |
| 136 NUMBER_OF_IDS | 133 NUMBER_OF_IDS |
| 137 }; | 134 }; |
| (...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 971 | 968 |
| 972 virtual Handle<Code> GenerateCode(Isolate* isolate); | 969 virtual Handle<Code> GenerateCode(Isolate* isolate); |
| 973 | 970 |
| 974 private: | 971 private: |
| 975 virtual CodeStub::Major MajorKey() { return KeyedLoadField; } | 972 virtual CodeStub::Major MajorKey() { return KeyedLoadField; } |
| 976 }; | 973 }; |
| 977 | 974 |
| 978 | 975 |
| 979 class BinaryOpStub: public PlatformCodeStub { | 976 class BinaryOpStub: public PlatformCodeStub { |
| 980 public: | 977 public: |
| 981 BinaryOpStub(Token::Value op, OverwriteMode mode) | 978 explicit BinaryOpStub(Token::Value op) |
| 982 : op_(op), | 979 : op_(op), |
| 983 mode_(mode), | |
| 984 platform_specific_bit_(false), | 980 platform_specific_bit_(false), |
| 985 left_type_(BinaryOpIC::UNINITIALIZED), | 981 left_type_(BinaryOpIC::UNINITIALIZED), |
| 986 right_type_(BinaryOpIC::UNINITIALIZED), | 982 right_type_(BinaryOpIC::UNINITIALIZED), |
| 987 result_type_(BinaryOpIC::UNINITIALIZED), | 983 result_type_(BinaryOpIC::UNINITIALIZED), |
| 988 encoded_right_arg_(false, encode_arg_value(1)) { | 984 encoded_right_arg_(false, encode_arg_value(1)) { |
| 989 Initialize(); | 985 Initialize(); |
| 990 ASSERT(OpBits::is_valid(Token::NUM_TOKENS)); | 986 ASSERT(OpBits::is_valid(Token::NUM_TOKENS)); |
| 991 } | 987 } |
| 992 | 988 |
| 993 BinaryOpStub( | 989 BinaryOpStub( |
| 994 int key, | 990 int key, |
| 995 BinaryOpIC::TypeInfo left_type, | 991 BinaryOpIC::TypeInfo left_type, |
| 996 BinaryOpIC::TypeInfo right_type, | 992 BinaryOpIC::TypeInfo right_type, |
| 997 BinaryOpIC::TypeInfo result_type, | 993 BinaryOpIC::TypeInfo result_type, |
| 998 Maybe<int32_t> fixed_right_arg) | 994 Maybe<int32_t> fixed_right_arg) |
| 999 : op_(OpBits::decode(key)), | 995 : op_(OpBits::decode(key)), |
| 1000 mode_(ModeBits::decode(key)), | |
| 1001 platform_specific_bit_(PlatformSpecificBits::decode(key)), | 996 platform_specific_bit_(PlatformSpecificBits::decode(key)), |
| 1002 left_type_(left_type), | 997 left_type_(left_type), |
| 1003 right_type_(right_type), | 998 right_type_(right_type), |
| 1004 result_type_(result_type), | 999 result_type_(result_type), |
| 1005 encoded_right_arg_(fixed_right_arg.has_value, | 1000 encoded_right_arg_(fixed_right_arg.has_value, |
| 1006 encode_arg_value(fixed_right_arg.value)) { } | 1001 encode_arg_value(fixed_right_arg.value)) { } |
| 1007 | 1002 |
| 1008 static void decode_types_from_minor_key(int minor_key, | 1003 static void decode_types_from_minor_key(int minor_key, |
| 1009 BinaryOpIC::TypeInfo* left_type, | 1004 BinaryOpIC::TypeInfo* left_type, |
| 1010 BinaryOpIC::TypeInfo* right_type, | 1005 BinaryOpIC::TypeInfo* right_type, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1037 FixedRightArgValueBits::is_valid(WhichPowerOf2(value)); | 1032 FixedRightArgValueBits::is_valid(WhichPowerOf2(value)); |
| 1038 } | 1033 } |
| 1039 | 1034 |
| 1040 enum SmiCodeGenerateHeapNumberResults { | 1035 enum SmiCodeGenerateHeapNumberResults { |
| 1041 ALLOW_HEAPNUMBER_RESULTS, | 1036 ALLOW_HEAPNUMBER_RESULTS, |
| 1042 NO_HEAPNUMBER_RESULTS | 1037 NO_HEAPNUMBER_RESULTS |
| 1043 }; | 1038 }; |
| 1044 | 1039 |
| 1045 private: | 1040 private: |
| 1046 Token::Value op_; | 1041 Token::Value op_; |
| 1047 OverwriteMode mode_; | |
| 1048 bool platform_specific_bit_; // Indicates SSE3 on IA32. | 1042 bool platform_specific_bit_; // Indicates SSE3 on IA32. |
| 1049 | 1043 |
| 1050 // Operand type information determined at runtime. | 1044 // Operand type information determined at runtime. |
| 1051 BinaryOpIC::TypeInfo left_type_; | 1045 BinaryOpIC::TypeInfo left_type_; |
| 1052 BinaryOpIC::TypeInfo right_type_; | 1046 BinaryOpIC::TypeInfo right_type_; |
| 1053 BinaryOpIC::TypeInfo result_type_; | 1047 BinaryOpIC::TypeInfo result_type_; |
| 1054 | 1048 |
| 1055 Maybe<int> encoded_right_arg_; | 1049 Maybe<int> encoded_right_arg_; |
| 1056 | 1050 |
| 1057 static int encode_arg_value(int32_t value) { | 1051 static int encode_arg_value(int32_t value) { |
| 1058 ASSERT(can_encode_arg_value(value)); | 1052 ASSERT(can_encode_arg_value(value)); |
| 1059 return WhichPowerOf2(value); | 1053 return WhichPowerOf2(value); |
| 1060 } | 1054 } |
| 1061 | 1055 |
| 1062 static int32_t decode_arg_value(int value) { | 1056 static int32_t decode_arg_value(int value) { |
| 1063 return 1 << value; | 1057 return 1 << value; |
| 1064 } | 1058 } |
| 1065 | 1059 |
| 1066 virtual void PrintName(StringStream* stream); | 1060 virtual void PrintName(StringStream* stream); |
| 1067 | 1061 |
| 1068 // Minor key encoding in all 25 bits FFFFFHTTTRRRLLLPOOOOOOOMM. | 1062 // Minor key encoding in all 25 bits FFFFFHTTTRRRLLLPOOOOOOOMM. |
| 1069 // Note: We actually do not need 7 bits for the operation, just 4 bits to | 1063 // Note: We actually do not need 7 bits for the operation, just 4 bits to |
| 1070 // encode ADD, SUB, MUL, DIV, MOD, BIT_OR, BIT_AND, BIT_XOR, SAR, SHL, SHR. | 1064 // encode ADD, SUB, MUL, DIV, MOD, BIT_OR, BIT_AND, BIT_XOR, SAR, SHL, SHR. |
| 1071 class ModeBits: public BitField<OverwriteMode, 0, 2> {}; | |
| 1072 class OpBits: public BitField<Token::Value, 2, 7> {}; | 1065 class OpBits: public BitField<Token::Value, 2, 7> {}; |
| 1073 class PlatformSpecificBits: public BitField<bool, 9, 1> {}; | 1066 class PlatformSpecificBits: public BitField<bool, 9, 1> {}; |
| 1074 class LeftTypeBits: public BitField<BinaryOpIC::TypeInfo, 10, 3> {}; | 1067 class LeftTypeBits: public BitField<BinaryOpIC::TypeInfo, 10, 3> {}; |
| 1075 class RightTypeBits: public BitField<BinaryOpIC::TypeInfo, 13, 3> {}; | 1068 class RightTypeBits: public BitField<BinaryOpIC::TypeInfo, 13, 3> {}; |
| 1076 class ResultTypeBits: public BitField<BinaryOpIC::TypeInfo, 16, 3> {}; | 1069 class ResultTypeBits: public BitField<BinaryOpIC::TypeInfo, 16, 3> {}; |
| 1077 class HasFixedRightArgBits: public BitField<bool, 19, 1> {}; | 1070 class HasFixedRightArgBits: public BitField<bool, 19, 1> {}; |
| 1078 class FixedRightArgValueBits: public BitField<int, 20, 5> {}; | 1071 class FixedRightArgValueBits: public BitField<int, 20, 5> {}; |
| 1079 | 1072 |
| 1080 Major MajorKey() { return BinaryOp; } | 1073 Major MajorKey() { return BinaryOp; } |
| 1081 int MinorKey() { | 1074 int MinorKey() { |
| 1082 return OpBits::encode(op_) | 1075 return OpBits::encode(op_) |
| 1083 | ModeBits::encode(mode_) | |
| 1084 | PlatformSpecificBits::encode(platform_specific_bit_) | 1076 | PlatformSpecificBits::encode(platform_specific_bit_) |
| 1085 | LeftTypeBits::encode(left_type_) | 1077 | LeftTypeBits::encode(left_type_) |
| 1086 | RightTypeBits::encode(right_type_) | 1078 | RightTypeBits::encode(right_type_) |
| 1087 | ResultTypeBits::encode(result_type_) | 1079 | ResultTypeBits::encode(result_type_) |
| 1088 | HasFixedRightArgBits::encode(encoded_right_arg_.has_value) | 1080 | HasFixedRightArgBits::encode(encoded_right_arg_.has_value) |
| 1089 | FixedRightArgValueBits::encode(encoded_right_arg_.value); | 1081 | FixedRightArgValueBits::encode(encoded_right_arg_.value); |
| 1090 } | 1082 } |
| 1091 | 1083 |
| 1092 | 1084 |
| 1093 // Platform-independent implementation. | 1085 // Platform-independent implementation. |
| (...skipping 1206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2300 int MinorKey() { return 0; } | 2292 int MinorKey() { return 0; } |
| 2301 | 2293 |
| 2302 void Generate(MacroAssembler* masm); | 2294 void Generate(MacroAssembler* masm); |
| 2303 | 2295 |
| 2304 DISALLOW_COPY_AND_ASSIGN(ProfileEntryHookStub); | 2296 DISALLOW_COPY_AND_ASSIGN(ProfileEntryHookStub); |
| 2305 }; | 2297 }; |
| 2306 | 2298 |
| 2307 } } // namespace v8::internal | 2299 } } // namespace v8::internal |
| 2308 | 2300 |
| 2309 #endif // V8_CODE_STUBS_H_ | 2301 #endif // V8_CODE_STUBS_H_ |
| OLD | NEW |