| 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 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1117 Token::Value op_; | 1117 Token::Value op_; |
| 1118 CompareIC::State left_; | 1118 CompareIC::State left_; |
| 1119 CompareIC::State right_; | 1119 CompareIC::State right_; |
| 1120 CompareIC::State state_; | 1120 CompareIC::State state_; |
| 1121 Handle<Map> known_map_; | 1121 Handle<Map> known_map_; |
| 1122 }; | 1122 }; |
| 1123 | 1123 |
| 1124 | 1124 |
| 1125 class CompareNilICStub : public HydrogenCodeStub { | 1125 class CompareNilICStub : public HydrogenCodeStub { |
| 1126 public: | 1126 public: |
| 1127 enum Type { | 1127 enum CompareNilType { |
| 1128 UNDEFINED, | 1128 UNDEFINED, |
| 1129 NULL_TYPE, | 1129 NULL_TYPE, |
| 1130 MONOMORPHIC_MAP, | 1130 MONOMORPHIC_MAP, |
| 1131 UNDETECTABLE, | 1131 UNDETECTABLE, |
| 1132 GENERIC, |
| 1132 NUMBER_OF_TYPES | 1133 NUMBER_OF_TYPES |
| 1133 }; | 1134 }; |
| 1134 | 1135 |
| 1135 class Types : public EnumSet<Type, byte> { | 1136 class State : public EnumSet<CompareNilType, byte> { |
| 1136 public: | 1137 public: |
| 1137 Types() : EnumSet<Type, byte>(0) { } | 1138 State() : EnumSet<CompareNilType, byte>(0) { } |
| 1138 explicit Types(byte bits) : EnumSet<Type, byte>(bits) { } | 1139 explicit State(byte bits) : EnumSet<CompareNilType, byte>(bits) { } |
| 1139 | 1140 |
| 1140 static Types FullCompare() { | 1141 static State Generic() { |
| 1141 Types set; | 1142 State set; |
| 1142 set.Add(UNDEFINED); | 1143 set.Add(UNDEFINED); |
| 1143 set.Add(NULL_TYPE); | 1144 set.Add(NULL_TYPE); |
| 1144 set.Add(UNDETECTABLE); | 1145 set.Add(UNDETECTABLE); |
| 1146 set.Add(GENERIC); |
| 1145 return set; | 1147 return set; |
| 1146 } | 1148 } |
| 1147 | 1149 |
| 1148 void Print(StringStream* stream) const; | 1150 void Print(StringStream* stream) const; |
| 1149 void TraceTransition(Types to) const; | 1151 void TraceTransition(State to) const; |
| 1150 }; | 1152 }; |
| 1151 | 1153 |
| 1154 static Handle<Type> StateToType( |
| 1155 Isolate* isolate, State state, Handle<Map> map = Handle<Map>()); |
| 1156 |
| 1152 // At most 6 different types can be distinguished, because the Code object | 1157 // At most 6 different types can be distinguished, because the Code object |
| 1153 // only has room for a single byte to hold a set and there are two more | 1158 // only has room for a single byte to hold a set and there are two more |
| 1154 // boolean flags we need to store. :-P | 1159 // boolean flags we need to store. :-P |
| 1155 STATIC_ASSERT(NUMBER_OF_TYPES <= 6); | 1160 STATIC_ASSERT(NUMBER_OF_TYPES <= 6); |
| 1156 | 1161 |
| 1157 CompareNilICStub(NilValue nil, Types types = Types()) | 1162 CompareNilICStub(NilValue nil, State state = State()) |
| 1158 : types_(types) { | 1163 : nil_value_(nil), state_(state) { |
| 1159 nil_value_ = nil; | |
| 1160 } | 1164 } |
| 1161 | 1165 |
| 1162 CompareNilICStub(Code::ExtraICState ic_state, | 1166 CompareNilICStub(Code::ExtraICState ic_state, |
| 1163 InitializationState init_state = INITIALIZED) | 1167 InitializationState init_state = INITIALIZED) |
| 1164 : HydrogenCodeStub(init_state) { | 1168 : HydrogenCodeStub(init_state) { |
| 1165 nil_value_ = NilValueField::decode(ic_state); | 1169 nil_value_ = NilValueField::decode(ic_state); |
| 1166 types_ = Types(ExtractTypesFromExtraICState(ic_state)); | 1170 state_ = State(ExtractTypesFromExtraICState(ic_state)); |
| 1167 } | 1171 } |
| 1168 | 1172 |
| 1169 static Handle<Code> GetUninitialized(Isolate* isolate, | 1173 static Handle<Code> GetUninitialized(Isolate* isolate, |
| 1170 NilValue nil) { | 1174 NilValue nil) { |
| 1171 return CompareNilICStub(nil, UNINITIALIZED).GetCode(isolate); | 1175 return CompareNilICStub(nil, UNINITIALIZED).GetCode(isolate); |
| 1172 } | 1176 } |
| 1173 | 1177 |
| 1174 virtual void InitializeInterfaceDescriptor( | 1178 virtual void InitializeInterfaceDescriptor( |
| 1175 Isolate* isolate, | 1179 Isolate* isolate, |
| 1176 CodeStubInterfaceDescriptor* descriptor); | 1180 CodeStubInterfaceDescriptor* descriptor); |
| 1177 | 1181 |
| 1178 static void InitializeForIsolate(Isolate* isolate) { | 1182 static void InitializeForIsolate(Isolate* isolate) { |
| 1179 CompareNilICStub compare_stub(kNullValue, UNINITIALIZED); | 1183 CompareNilICStub compare_stub(kNullValue, UNINITIALIZED); |
| 1180 compare_stub.InitializeInterfaceDescriptor( | 1184 compare_stub.InitializeInterfaceDescriptor( |
| 1181 isolate, | 1185 isolate, |
| 1182 isolate->code_stub_interface_descriptor(CodeStub::CompareNilIC)); | 1186 isolate->code_stub_interface_descriptor(CodeStub::CompareNilIC)); |
| 1183 } | 1187 } |
| 1184 | 1188 |
| 1185 virtual InlineCacheState GetICState() { | 1189 virtual InlineCacheState GetICState() { |
| 1186 if (types_ == Types::FullCompare()) { | 1190 if (state_ == State::Generic()) { |
| 1187 return MEGAMORPHIC; | 1191 return MEGAMORPHIC; |
| 1188 } else if (types_.Contains(MONOMORPHIC_MAP)) { | 1192 } else if (state_.Contains(MONOMORPHIC_MAP)) { |
| 1189 return MONOMORPHIC; | 1193 return MONOMORPHIC; |
| 1190 } else { | 1194 } else { |
| 1191 return PREMONOMORPHIC; | 1195 return PREMONOMORPHIC; |
| 1192 } | 1196 } |
| 1193 } | 1197 } |
| 1194 | 1198 |
| 1195 virtual Code::Kind GetCodeKind() const { return Code::COMPARE_NIL_IC; } | 1199 virtual Code::Kind GetCodeKind() const { return Code::COMPARE_NIL_IC; } |
| 1196 | 1200 |
| 1197 Handle<Code> GenerateCode(); | 1201 Handle<Code> GenerateCode(); |
| 1198 | 1202 |
| 1199 // extra ic state = nil_value | type_n-1 | ... | type_0 | 1203 // extra ic state = nil_value | type_n-1 | ... | type_0 |
| 1200 virtual Code::ExtraICState GetExtraICState() { | 1204 virtual Code::ExtraICState GetExtraICState() { |
| 1201 return NilValueField::encode(nil_value_) | | 1205 return NilValueField::encode(nil_value_) | state_.ToIntegral(); |
| 1202 types_.ToIntegral(); | |
| 1203 } | 1206 } |
| 1204 static byte ExtractTypesFromExtraICState( | 1207 static byte ExtractTypesFromExtraICState(Code::ExtraICState state) { |
| 1205 Code::ExtraICState state) { | |
| 1206 return state & ((1 << NUMBER_OF_TYPES) - 1); | 1208 return state & ((1 << NUMBER_OF_TYPES) - 1); |
| 1207 } | 1209 } |
| 1208 | 1210 |
| 1209 void Record(Handle<Object> object); | 1211 void Record(Handle<Object> object); |
| 1210 | 1212 |
| 1211 bool IsMonomorphic() const { return types_.Contains(MONOMORPHIC_MAP); } | 1213 bool IsMonomorphic() const { return state_.Contains(MONOMORPHIC_MAP); } |
| 1212 NilValue GetNilValue() const { return nil_value_; } | 1214 NilValue GetNilValue() const { return nil_value_; } |
| 1213 Types GetTypes() const { return types_; } | 1215 State GetState() const { return state_; } |
| 1214 void ClearTypes() { types_.RemoveAll(); } | 1216 void ClearState() { state_.RemoveAll(); } |
| 1215 | 1217 |
| 1216 virtual void PrintName(StringStream* stream); | 1218 virtual void PrintName(StringStream* stream); |
| 1217 | 1219 |
| 1218 private: | 1220 private: |
| 1219 friend class CompareNilIC; | 1221 friend class CompareNilIC; |
| 1220 | 1222 |
| 1221 CompareNilICStub(NilValue nil, InitializationState init_state) | 1223 CompareNilICStub(NilValue nil, InitializationState init_state) |
| 1222 : HydrogenCodeStub(init_state) { | 1224 : HydrogenCodeStub(init_state) { |
| 1223 nil_value_ = nil; | 1225 nil_value_ = nil; |
| 1224 } | 1226 } |
| 1225 | 1227 |
| 1226 class NilValueField : public BitField<NilValue, NUMBER_OF_TYPES, 1> {}; | 1228 class NilValueField : public BitField<NilValue, NUMBER_OF_TYPES, 1> {}; |
| 1227 | 1229 |
| 1228 virtual CodeStub::Major MajorKey() { return CompareNilIC; } | 1230 virtual CodeStub::Major MajorKey() { return CompareNilIC; } |
| 1229 virtual int NotMissMinorKey() { return GetExtraICState(); } | 1231 virtual int NotMissMinorKey() { return GetExtraICState(); } |
| 1230 | 1232 |
| 1231 NilValue nil_value_; | 1233 NilValue nil_value_; |
| 1232 Types types_; | 1234 State state_; |
| 1233 | 1235 |
| 1234 DISALLOW_COPY_AND_ASSIGN(CompareNilICStub); | 1236 DISALLOW_COPY_AND_ASSIGN(CompareNilICStub); |
| 1235 }; | 1237 }; |
| 1236 | 1238 |
| 1237 | 1239 |
| 1238 class CEntryStub : public PlatformCodeStub { | 1240 class CEntryStub : public PlatformCodeStub { |
| 1239 public: | 1241 public: |
| 1240 explicit CEntryStub(int result_size, | 1242 explicit CEntryStub(int result_size, |
| 1241 SaveFPRegsMode save_doubles = kDontSaveFPRegs) | 1243 SaveFPRegsMode save_doubles = kDontSaveFPRegs) |
| 1242 : result_size_(result_size), save_doubles_(save_doubles) { } | 1244 : result_size_(result_size), save_doubles_(save_doubles) { } |
| (...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2153 | 2155 |
| 2154 // The current function entry hook. | 2156 // The current function entry hook. |
| 2155 static FunctionEntryHook entry_hook_; | 2157 static FunctionEntryHook entry_hook_; |
| 2156 | 2158 |
| 2157 DISALLOW_COPY_AND_ASSIGN(ProfileEntryHookStub); | 2159 DISALLOW_COPY_AND_ASSIGN(ProfileEntryHookStub); |
| 2158 }; | 2160 }; |
| 2159 | 2161 |
| 2160 } } // namespace v8::internal | 2162 } } // namespace v8::internal |
| 2161 | 2163 |
| 2162 #endif // V8_CODE_STUBS_H_ | 2164 #endif // V8_CODE_STUBS_H_ |
| OLD | NEW |