| 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 1242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1253 Token::Value op_; | 1253 Token::Value op_; |
| 1254 CompareIC::State left_; | 1254 CompareIC::State left_; |
| 1255 CompareIC::State right_; | 1255 CompareIC::State right_; |
| 1256 CompareIC::State state_; | 1256 CompareIC::State state_; |
| 1257 Handle<Map> known_map_; | 1257 Handle<Map> known_map_; |
| 1258 }; | 1258 }; |
| 1259 | 1259 |
| 1260 | 1260 |
| 1261 class CompareNilICStub : public HydrogenCodeStub { | 1261 class CompareNilICStub : public HydrogenCodeStub { |
| 1262 public: | 1262 public: |
| 1263 enum CompareNilType { | 1263 Handle<Type> GetType(Isolate* isolate, Handle<Map> map = Handle<Map>()); |
| 1264 UNDEFINED, | 1264 Handle<Type> GetInputType(Isolate* isolate, Handle<Map> map); |
| 1265 NULL_TYPE, | |
| 1266 MONOMORPHIC_MAP, | |
| 1267 UNDETECTABLE, | |
| 1268 GENERIC, | |
| 1269 NUMBER_OF_TYPES | |
| 1270 }; | |
| 1271 | 1265 |
| 1272 class State : public EnumSet<CompareNilType, byte> { | 1266 explicit CompareNilICStub(NilValue nil) : nil_value_(nil) { } |
| 1273 public: | |
| 1274 State() : EnumSet<CompareNilType, byte>(0) { } | |
| 1275 explicit State(byte bits) : EnumSet<CompareNilType, byte>(bits) { } | |
| 1276 | |
| 1277 static State Generic() { | |
| 1278 State set; | |
| 1279 set.Add(UNDEFINED); | |
| 1280 set.Add(NULL_TYPE); | |
| 1281 set.Add(UNDETECTABLE); | |
| 1282 set.Add(GENERIC); | |
| 1283 return set; | |
| 1284 } | |
| 1285 | |
| 1286 void Print(StringStream* stream) const; | |
| 1287 }; | |
| 1288 | |
| 1289 static Handle<Type> StateToType( | |
| 1290 Isolate* isolate, State state, Handle<Map> map = Handle<Map>()); | |
| 1291 | |
| 1292 // At most 6 different types can be distinguished, because the Code object | |
| 1293 // only has room for a single byte to hold a set and there are two more | |
| 1294 // boolean flags we need to store. :-P | |
| 1295 STATIC_ASSERT(NUMBER_OF_TYPES <= 6); | |
| 1296 | |
| 1297 CompareNilICStub(NilValue nil, State state = State()) | |
| 1298 : nil_value_(nil), state_(state) { | |
| 1299 } | |
| 1300 | 1267 |
| 1301 CompareNilICStub(Code::ExtraICState ic_state, | 1268 CompareNilICStub(Code::ExtraICState ic_state, |
| 1302 InitializationState init_state = INITIALIZED) | 1269 InitializationState init_state = INITIALIZED) |
| 1303 : HydrogenCodeStub(init_state) { | 1270 : HydrogenCodeStub(init_state), |
| 1304 nil_value_ = NilValueField::decode(ic_state); | 1271 nil_value_(NilValueField::decode(ic_state)), |
| 1305 state_ = State(ExtractTypesFromExtraICState(ic_state)); | 1272 state_(State(TypesField::decode(ic_state))) { |
| 1306 } | 1273 } |
| 1307 | 1274 |
| 1308 static Handle<Code> GetUninitialized(Isolate* isolate, | 1275 static Handle<Code> GetUninitialized(Isolate* isolate, |
| 1309 NilValue nil) { | 1276 NilValue nil) { |
| 1310 return CompareNilICStub(nil, UNINITIALIZED).GetCode(isolate); | 1277 return CompareNilICStub(nil, UNINITIALIZED).GetCode(isolate); |
| 1311 } | 1278 } |
| 1312 | 1279 |
| 1313 virtual void InitializeInterfaceDescriptor( | 1280 virtual void InitializeInterfaceDescriptor( |
| 1314 Isolate* isolate, | 1281 Isolate* isolate, |
| 1315 CodeStubInterfaceDescriptor* descriptor); | 1282 CodeStubInterfaceDescriptor* descriptor); |
| 1316 | 1283 |
| 1317 static void InitializeForIsolate(Isolate* isolate) { | 1284 static void InitializeForIsolate(Isolate* isolate) { |
| 1318 CompareNilICStub compare_stub(kNullValue, UNINITIALIZED); | 1285 CompareNilICStub compare_stub(kNullValue, UNINITIALIZED); |
| 1319 compare_stub.InitializeInterfaceDescriptor( | 1286 compare_stub.InitializeInterfaceDescriptor( |
| 1320 isolate, | 1287 isolate, |
| 1321 isolate->code_stub_interface_descriptor(CodeStub::CompareNilIC)); | 1288 isolate->code_stub_interface_descriptor(CodeStub::CompareNilIC)); |
| 1322 } | 1289 } |
| 1323 | 1290 |
| 1324 virtual InlineCacheState GetICState() { | 1291 virtual InlineCacheState GetICState() { |
| 1325 if (state_ == State::Generic()) { | 1292 if (state_.Contains(GENERIC)) { |
| 1326 return MEGAMORPHIC; | 1293 return MEGAMORPHIC; |
| 1327 } else if (state_.Contains(MONOMORPHIC_MAP)) { | 1294 } else if (state_.Contains(MONOMORPHIC_MAP)) { |
| 1328 return MONOMORPHIC; | 1295 return MONOMORPHIC; |
| 1329 } else { | 1296 } else { |
| 1330 return PREMONOMORPHIC; | 1297 return PREMONOMORPHIC; |
| 1331 } | 1298 } |
| 1332 } | 1299 } |
| 1333 | 1300 |
| 1334 virtual Code::Kind GetCodeKind() const { return Code::COMPARE_NIL_IC; } | 1301 virtual Code::Kind GetCodeKind() const { return Code::COMPARE_NIL_IC; } |
| 1335 | 1302 |
| 1336 Handle<Code> GenerateCode(); | 1303 Handle<Code> GenerateCode(); |
| 1337 | 1304 |
| 1338 // extra ic state = nil_value | type_n-1 | ... | type_0 | |
| 1339 virtual Code::ExtraICState GetExtraICState() { | 1305 virtual Code::ExtraICState GetExtraICState() { |
| 1340 return NilValueField::encode(nil_value_) | state_.ToIntegral(); | 1306 return NilValueField::encode(nil_value_) | |
| 1341 } | 1307 TypesField::encode(state_.ToIntegral()); |
| 1342 static byte ExtractTypesFromExtraICState(Code::ExtraICState state) { | |
| 1343 return state & ((1 << NUMBER_OF_TYPES) - 1); | |
| 1344 } | |
| 1345 static NilValue ExtractNilValueFromExtraICState(Code::ExtraICState state) { | |
| 1346 return NilValueField::decode(state); | |
| 1347 } | 1308 } |
| 1348 | 1309 |
| 1349 void UpdateStatus(Handle<Object> object); | 1310 void UpdateStatus(Handle<Object> object); |
| 1350 | 1311 |
| 1351 bool IsMonomorphic() const { return state_.Contains(MONOMORPHIC_MAP); } | 1312 bool IsMonomorphic() const { return state_.Contains(MONOMORPHIC_MAP); } |
| 1352 NilValue GetNilValue() const { return nil_value_; } | 1313 NilValue GetNilValue() const { return nil_value_; } |
| 1353 State GetState() const { return state_; } | |
| 1354 void ClearState() { state_.RemoveAll(); } | 1314 void ClearState() { state_.RemoveAll(); } |
| 1355 | 1315 |
| 1356 virtual void PrintState(StringStream* stream); | 1316 virtual void PrintState(StringStream* stream); |
| 1357 virtual void PrintBaseName(StringStream* stream); | 1317 virtual void PrintBaseName(StringStream* stream); |
| 1358 | 1318 |
| 1359 private: | 1319 private: |
| 1360 friend class CompareNilIC; | 1320 friend class CompareNilIC; |
| 1361 | 1321 |
| 1322 enum CompareNilType { |
| 1323 UNDEFINED, |
| 1324 NULL_TYPE, |
| 1325 MONOMORPHIC_MAP, |
| 1326 GENERIC, |
| 1327 NUMBER_OF_TYPES |
| 1328 }; |
| 1329 |
| 1330 // At most 6 different types can be distinguished, because the Code object |
| 1331 // only has room for a single byte to hold a set and there are two more |
| 1332 // boolean flags we need to store. :-P |
| 1333 STATIC_ASSERT(NUMBER_OF_TYPES <= 6); |
| 1334 |
| 1335 class State : public EnumSet<CompareNilType, byte> { |
| 1336 public: |
| 1337 State() : EnumSet<CompareNilType, byte>(0) { } |
| 1338 explicit State(byte bits) : EnumSet<CompareNilType, byte>(bits) { } |
| 1339 |
| 1340 void Print(StringStream* stream) const; |
| 1341 }; |
| 1342 |
| 1362 CompareNilICStub(NilValue nil, InitializationState init_state) | 1343 CompareNilICStub(NilValue nil, InitializationState init_state) |
| 1363 : HydrogenCodeStub(init_state) { | 1344 : HydrogenCodeStub(init_state), nil_value_(nil) { } |
| 1364 nil_value_ = nil; | |
| 1365 } | |
| 1366 | 1345 |
| 1367 class NilValueField : public BitField<NilValue, NUMBER_OF_TYPES, 1> {}; | 1346 class NilValueField : public BitField<NilValue, 0, 1> {}; |
| 1347 class TypesField : public BitField<byte, 1, NUMBER_OF_TYPES> {}; |
| 1368 | 1348 |
| 1369 virtual CodeStub::Major MajorKey() { return CompareNilIC; } | 1349 virtual CodeStub::Major MajorKey() { return CompareNilIC; } |
| 1370 virtual int NotMissMinorKey() { return GetExtraICState(); } | 1350 virtual int NotMissMinorKey() { return GetExtraICState(); } |
| 1371 | 1351 |
| 1372 NilValue nil_value_; | 1352 NilValue nil_value_; |
| 1373 State state_; | 1353 State state_; |
| 1374 | 1354 |
| 1375 DISALLOW_COPY_AND_ASSIGN(CompareNilICStub); | 1355 DISALLOW_COPY_AND_ASSIGN(CompareNilICStub); |
| 1376 }; | 1356 }; |
| 1377 | 1357 |
| (...skipping 938 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2316 int MinorKey() { return 0; } | 2296 int MinorKey() { return 0; } |
| 2317 | 2297 |
| 2318 void Generate(MacroAssembler* masm); | 2298 void Generate(MacroAssembler* masm); |
| 2319 | 2299 |
| 2320 DISALLOW_COPY_AND_ASSIGN(ProfileEntryHookStub); | 2300 DISALLOW_COPY_AND_ASSIGN(ProfileEntryHookStub); |
| 2321 }; | 2301 }; |
| 2322 | 2302 |
| 2323 } } // namespace v8::internal | 2303 } } // namespace v8::internal |
| 2324 | 2304 |
| 2325 #endif // V8_CODE_STUBS_H_ | 2305 #endif // V8_CODE_STUBS_H_ |
| OLD | NEW |