| 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 TypeFeedbackId ast_id) { | 92 TypeFeedbackId ast_id) { |
| 93 int entry = dictionary_->FindEntry(IdToKey(ast_id)); | 93 int entry = dictionary_->FindEntry(IdToKey(ast_id)); |
| 94 if (entry != UnseededNumberDictionary::kNotFound) { | 94 if (entry != UnseededNumberDictionary::kNotFound) { |
| 95 Cell* cell = Cell::cast(dictionary_->ValueAt(entry)); | 95 Cell* cell = Cell::cast(dictionary_->ValueAt(entry)); |
| 96 return Handle<Cell>(cell, isolate_); | 96 return Handle<Cell>(cell, isolate_); |
| 97 } | 97 } |
| 98 return Handle<Cell>::null(); | 98 return Handle<Cell>::null(); |
| 99 } | 99 } |
| 100 | 100 |
| 101 | 101 |
| 102 bool TypeFeedbackOracle::LoadIsUninitialized(Property* expr) { | 102 bool TypeFeedbackOracle::LoadIsUninitialized(TypeFeedbackId id) { |
| 103 Handle<Object> map_or_code = GetInfo(expr->PropertyFeedbackId()); | 103 Handle<Object> map_or_code = GetInfo(id); |
| 104 if (map_or_code->IsMap()) return false; | 104 if (map_or_code->IsMap()) return false; |
| 105 if (map_or_code->IsCode()) { | 105 if (map_or_code->IsCode()) { |
| 106 Handle<Code> code = Handle<Code>::cast(map_or_code); | 106 Handle<Code> code = Handle<Code>::cast(map_or_code); |
| 107 return code->is_inline_cache_stub() && code->ic_state() == UNINITIALIZED; | 107 return code->is_inline_cache_stub() && code->ic_state() == UNINITIALIZED; |
| 108 } | 108 } |
| 109 return false; | 109 return false; |
| 110 } | 110 } |
| 111 | 111 |
| 112 | 112 |
| 113 bool TypeFeedbackOracle::LoadIsMonomorphicNormal(Property* expr) { | 113 bool TypeFeedbackOracle::LoadIsMonomorphicNormal(TypeFeedbackId id) { |
| 114 Handle<Object> map_or_code = GetInfo(expr->PropertyFeedbackId()); | 114 Handle<Object> map_or_code = GetInfo(id); |
| 115 if (map_or_code->IsMap()) return true; | 115 if (map_or_code->IsMap()) return true; |
| 116 if (map_or_code->IsCode()) { | 116 if (map_or_code->IsCode()) { |
| 117 Handle<Code> code = Handle<Code>::cast(map_or_code); | 117 Handle<Code> code = Handle<Code>::cast(map_or_code); |
| 118 bool preliminary_checks = code->is_keyed_load_stub() && | 118 bool preliminary_checks = code->is_keyed_load_stub() && |
| 119 code->ic_state() == MONOMORPHIC && | 119 code->ic_state() == MONOMORPHIC && |
| 120 Code::ExtractTypeFromFlags(code->flags()) == Code::NORMAL; | 120 Code::ExtractTypeFromFlags(code->flags()) == Code::NORMAL; |
| 121 if (!preliminary_checks) return false; | 121 if (!preliminary_checks) return false; |
| 122 Map* map = code->FindFirstMap(); | 122 Map* map = code->FindFirstMap(); |
| 123 if (map == NULL) return false; | 123 if (map == NULL) return false; |
| 124 map = map->CurrentMapForDeprecated(); | 124 map = map->CurrentMapForDeprecated(); |
| 125 return map != NULL && !CanRetainOtherContext(map, *native_context_); | 125 return map != NULL && !CanRetainOtherContext(map, *native_context_); |
| 126 } | 126 } |
| 127 return false; | 127 return false; |
| 128 } | 128 } |
| 129 | 129 |
| 130 | 130 |
| 131 bool TypeFeedbackOracle::LoadIsPreMonomorphic(Property* expr) { | 131 bool TypeFeedbackOracle::LoadIsPreMonomorphic(TypeFeedbackId id) { |
| 132 Handle<Object> map_or_code = GetInfo(expr->PropertyFeedbackId()); | 132 Handle<Object> map_or_code = GetInfo(id); |
| 133 if (map_or_code->IsCode()) { | 133 if (map_or_code->IsCode()) { |
| 134 Handle<Code> code = Handle<Code>::cast(map_or_code); | 134 Handle<Code> code = Handle<Code>::cast(map_or_code); |
| 135 return code->is_inline_cache_stub() && code->ic_state() == PREMONOMORPHIC; | 135 return code->is_inline_cache_stub() && code->ic_state() == PREMONOMORPHIC; |
| 136 } | 136 } |
| 137 return false; | 137 return false; |
| 138 } | 138 } |
| 139 | 139 |
| 140 | 140 |
| 141 bool TypeFeedbackOracle::LoadIsPolymorphic(Property* expr) { | 141 bool TypeFeedbackOracle::LoadIsPolymorphic(TypeFeedbackId id) { |
| 142 Handle<Object> map_or_code = GetInfo(expr->PropertyFeedbackId()); | 142 Handle<Object> map_or_code = GetInfo(id); |
| 143 if (map_or_code->IsCode()) { | 143 if (map_or_code->IsCode()) { |
| 144 Handle<Code> code = Handle<Code>::cast(map_or_code); | 144 Handle<Code> code = Handle<Code>::cast(map_or_code); |
| 145 return code->is_keyed_load_stub() && code->ic_state() == POLYMORPHIC; | 145 return code->is_keyed_load_stub() && code->ic_state() == POLYMORPHIC; |
| 146 } | 146 } |
| 147 return false; | 147 return false; |
| 148 } | 148 } |
| 149 | 149 |
| 150 | 150 |
| 151 bool TypeFeedbackOracle::StoreIsUninitialized(TypeFeedbackId ast_id) { | 151 bool TypeFeedbackOracle::StoreIsUninitialized(TypeFeedbackId ast_id) { |
| 152 Handle<Object> map_or_code = GetInfo(ast_id); | 152 Handle<Object> map_or_code = GetInfo(ast_id); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 | 226 |
| 227 | 227 |
| 228 byte TypeFeedbackOracle::ForInType(TypeFeedbackId id) { | 228 byte TypeFeedbackOracle::ForInType(TypeFeedbackId id) { |
| 229 Handle<Object> value = GetInfo(id); | 229 Handle<Object> value = GetInfo(id); |
| 230 return value->IsSmi() && | 230 return value->IsSmi() && |
| 231 Smi::cast(*value)->value() == TypeFeedbackCells::kForInFastCaseMarker | 231 Smi::cast(*value)->value() == TypeFeedbackCells::kForInFastCaseMarker |
| 232 ? ForInStatement::FAST_FOR_IN : ForInStatement::SLOW_FOR_IN; | 232 ? ForInStatement::FAST_FOR_IN : ForInStatement::SLOW_FOR_IN; |
| 233 } | 233 } |
| 234 | 234 |
| 235 | 235 |
| 236 Handle<Map> TypeFeedbackOracle::LoadMonomorphicReceiverType(Property* expr) { | 236 Handle<Map> TypeFeedbackOracle::LoadMonomorphicReceiverType(TypeFeedbackId id) { |
| 237 ASSERT(LoadIsMonomorphicNormal(expr)); | 237 ASSERT(LoadIsMonomorphicNormal(id)); |
| 238 Handle<Object> map_or_code = GetInfo(expr->PropertyFeedbackId()); | 238 Handle<Object> map_or_code = GetInfo(id); |
| 239 if (map_or_code->IsCode()) { | 239 if (map_or_code->IsCode()) { |
| 240 Handle<Code> code = Handle<Code>::cast(map_or_code); | 240 Handle<Code> code = Handle<Code>::cast(map_or_code); |
| 241 Map* map = code->FindFirstMap()->CurrentMapForDeprecated(); | 241 Map* map = code->FindFirstMap()->CurrentMapForDeprecated(); |
| 242 return map == NULL || CanRetainOtherContext(map, *native_context_) | 242 return map == NULL || CanRetainOtherContext(map, *native_context_) |
| 243 ? Handle<Map>::null() | 243 ? Handle<Map>::null() |
| 244 : Handle<Map>(map); | 244 : Handle<Map>(map); |
| 245 } | 245 } |
| 246 return Handle<Map>::cast(map_or_code); | 246 return Handle<Map>::cast(map_or_code); |
| 247 } | 247 } |
| 248 | 248 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 268 if (map_or_code->IsCode()) { | 268 if (map_or_code->IsCode()) { |
| 269 Handle<Code> code = Handle<Code>::cast(map_or_code); | 269 Handle<Code> code = Handle<Code>::cast(map_or_code); |
| 270 if (code->kind() == Code::KEYED_STORE_IC) { | 270 if (code->kind() == Code::KEYED_STORE_IC) { |
| 271 return Code::GetKeyedAccessStoreMode(code->extra_ic_state()); | 271 return Code::GetKeyedAccessStoreMode(code->extra_ic_state()); |
| 272 } | 272 } |
| 273 } | 273 } |
| 274 return STANDARD_STORE; | 274 return STANDARD_STORE; |
| 275 } | 275 } |
| 276 | 276 |
| 277 | 277 |
| 278 void TypeFeedbackOracle::LoadReceiverTypes(Property* expr, | 278 void TypeFeedbackOracle::LoadReceiverTypes(TypeFeedbackId id, |
| 279 Handle<String> name, | 279 Handle<String> name, |
| 280 SmallMapList* types) { | 280 SmallMapList* types) { |
| 281 Code::Flags flags = Code::ComputeFlags( | 281 Code::Flags flags = Code::ComputeFlags( |
| 282 Code::HANDLER, MONOMORPHIC, Code::kNoExtraICState, | 282 Code::HANDLER, MONOMORPHIC, Code::kNoExtraICState, |
| 283 Code::NORMAL, Code::LOAD_IC); | 283 Code::NORMAL, Code::LOAD_IC); |
| 284 CollectReceiverTypes(expr->PropertyFeedbackId(), name, flags, types); | 284 CollectReceiverTypes(id, name, flags, types); |
| 285 } | 285 } |
| 286 | 286 |
| 287 | 287 |
| 288 void TypeFeedbackOracle::StoreReceiverTypes(Assignment* expr, | 288 void TypeFeedbackOracle::StoreReceiverTypes(Assignment* expr, |
| 289 Handle<String> name, | 289 Handle<String> name, |
| 290 SmallMapList* types) { | 290 SmallMapList* types) { |
| 291 Code::Flags flags = Code::ComputeFlags( | 291 Code::Flags flags = Code::ComputeFlags( |
| 292 Code::HANDLER, MONOMORPHIC, Code::kNoExtraICState, | 292 Code::HANDLER, MONOMORPHIC, Code::kNoExtraICState, |
| 293 Code::NORMAL, Code::STORE_IC); | 293 Code::NORMAL, Code::STORE_IC); |
| 294 CollectReceiverTypes(expr->AssignmentFeedbackId(), name, flags, types); | 294 CollectReceiverTypes(expr->AssignmentFeedbackId(), name, flags, types); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 } | 346 } |
| 347 | 347 |
| 348 | 348 |
| 349 Handle<Map> TypeFeedbackOracle::GetObjectLiteralStoreMap( | 349 Handle<Map> TypeFeedbackOracle::GetObjectLiteralStoreMap( |
| 350 ObjectLiteral::Property* prop) { | 350 ObjectLiteral::Property* prop) { |
| 351 ASSERT(ObjectLiteralStoreIsMonomorphic(prop)); | 351 ASSERT(ObjectLiteralStoreIsMonomorphic(prop)); |
| 352 return Handle<Map>::cast(GetInfo(prop->key()->LiteralFeedbackId())); | 352 return Handle<Map>::cast(GetInfo(prop->key()->LiteralFeedbackId())); |
| 353 } | 353 } |
| 354 | 354 |
| 355 | 355 |
| 356 bool TypeFeedbackOracle::LoadIsBuiltin(Property* expr, Builtins::Name id) { | 356 bool TypeFeedbackOracle::LoadIsBuiltin( |
| 357 return *GetInfo(expr->PropertyFeedbackId()) == | 357 TypeFeedbackId id, Builtins::Name builtin) { |
| 358 isolate_->builtins()->builtin(id); | 358 return *GetInfo(id) == isolate_->builtins()->builtin(builtin); |
| 359 } | 359 } |
| 360 | 360 |
| 361 | 361 |
| 362 bool TypeFeedbackOracle::LoadIsStub(Property* expr, ICStub* stub) { | 362 bool TypeFeedbackOracle::LoadIsStub(TypeFeedbackId id, ICStub* stub) { |
| 363 Handle<Object> object = GetInfo(expr->PropertyFeedbackId()); | 363 Handle<Object> object = GetInfo(id); |
| 364 if (!object->IsCode()) return false; | 364 if (!object->IsCode()) return false; |
| 365 Handle<Code> code = Handle<Code>::cast(object); | 365 Handle<Code> code = Handle<Code>::cast(object); |
| 366 if (!code->is_load_stub()) return false; | 366 if (!code->is_load_stub()) return false; |
| 367 if (code->ic_state() != MONOMORPHIC) return false; | 367 if (code->ic_state() != MONOMORPHIC) return false; |
| 368 return stub->Describes(*code); | 368 return stub->Describes(*code); |
| 369 } | 369 } |
| 370 | 370 |
| 371 | 371 |
| 372 void TypeFeedbackOracle::CompareType(TypeFeedbackId id, | 372 void TypeFeedbackOracle::CompareType(TypeFeedbackId id, |
| 373 Handle<Type>* left_type, | 373 Handle<Type>* left_type, |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 Handle<Type> unknown(Type::None(), isolate_); | 449 Handle<Type> unknown(Type::None(), isolate_); |
| 450 if (!object->IsCode()) return unknown; | 450 if (!object->IsCode()) return unknown; |
| 451 Handle<Code> code = Handle<Code>::cast(object); | 451 Handle<Code> code = Handle<Code>::cast(object); |
| 452 if (!code->is_binary_op_stub()) return unknown; | 452 if (!code->is_binary_op_stub()) return unknown; |
| 453 | 453 |
| 454 BinaryOpStub stub(code->extended_extra_ic_state()); | 454 BinaryOpStub stub(code->extended_extra_ic_state()); |
| 455 return stub.GetLeftType(isolate()); | 455 return stub.GetLeftType(isolate()); |
| 456 } | 456 } |
| 457 | 457 |
| 458 | 458 |
| 459 void TypeFeedbackOracle::PropertyReceiverTypes( |
| 460 TypeFeedbackId id, Handle<String> name, |
| 461 SmallMapList* receiver_types, bool* is_prototype) { |
| 462 receiver_types->Clear(); |
| 463 FunctionPrototypeStub proto_stub(Code::LOAD_IC); |
| 464 *is_prototype = LoadIsStub(id, &proto_stub); |
| 465 if (!*is_prototype) { |
| 466 LoadReceiverTypes(id, name, receiver_types); |
| 467 } |
| 468 } |
| 469 |
| 470 |
| 471 void TypeFeedbackOracle::KeyedPropertyReceiverTypes( |
| 472 TypeFeedbackId id, SmallMapList* receiver_types, bool* is_string) { |
| 473 receiver_types->Clear(); |
| 474 *is_string = false; |
| 475 if (LoadIsBuiltin(id, Builtins::kKeyedLoadIC_String)) { |
| 476 *is_string = true; |
| 477 } else if (LoadIsMonomorphicNormal(id)) { |
| 478 receiver_types->Add(LoadMonomorphicReceiverType(id), zone()); |
| 479 } else if (LoadIsPolymorphic(id)) { |
| 480 receiver_types->Reserve(kMaxKeyedPolymorphism, zone()); |
| 481 CollectKeyedReceiverTypes(id, receiver_types); |
| 482 } |
| 483 } |
| 484 |
| 485 |
| 459 void TypeFeedbackOracle::CountReceiverTypes( | 486 void TypeFeedbackOracle::CountReceiverTypes( |
| 460 TypeFeedbackId id, SmallMapList* receiver_types) { | 487 TypeFeedbackId id, SmallMapList* receiver_types) { |
| 461 receiver_types->Clear(); | 488 receiver_types->Clear(); |
| 462 if (StoreIsMonomorphicNormal(id)) { | 489 if (StoreIsMonomorphicNormal(id)) { |
| 463 // Record receiver type for monomorphic keyed stores. | 490 // Record receiver type for monomorphic keyed stores. |
| 464 receiver_types->Add(StoreMonomorphicReceiverType(id), zone()); | 491 receiver_types->Add(StoreMonomorphicReceiverType(id), zone()); |
| 465 } else if (StoreIsKeyedPolymorphic(id)) { | 492 } else if (StoreIsKeyedPolymorphic(id)) { |
| 466 receiver_types->Reserve(kMaxKeyedPolymorphism, zone()); | 493 receiver_types->Reserve(kMaxKeyedPolymorphism, zone()); |
| 467 CollectKeyedReceiverTypes(id, receiver_types); | 494 CollectKeyedReceiverTypes(id, receiver_types); |
| 468 } else { | 495 } else { |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 714 if (info.IsUninitialized()) return Representation::None(); | 741 if (info.IsUninitialized()) return Representation::None(); |
| 715 if (info.IsSmi()) return Representation::Smi(); | 742 if (info.IsSmi()) return Representation::Smi(); |
| 716 if (info.IsInteger32()) return Representation::Integer32(); | 743 if (info.IsInteger32()) return Representation::Integer32(); |
| 717 if (info.IsDouble()) return Representation::Double(); | 744 if (info.IsDouble()) return Representation::Double(); |
| 718 if (info.IsNumber()) return Representation::Double(); | 745 if (info.IsNumber()) return Representation::Double(); |
| 719 return Representation::Tagged(); | 746 return Representation::Tagged(); |
| 720 } | 747 } |
| 721 | 748 |
| 722 | 749 |
| 723 } } // namespace v8::internal | 750 } } // namespace v8::internal |
| OLD | NEW |