| 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 bool TypeFeedbackOracle::LoadIsPolymorphic(Property* expr) { | 131 bool TypeFeedbackOracle::LoadIsPolymorphic(Property* expr) { |
| 132 Handle<Object> map_or_code = GetInfo(expr->PropertyFeedbackId()); | 132 Handle<Object> map_or_code = GetInfo(expr->PropertyFeedbackId()); |
| 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_keyed_load_stub() && code->ic_state() == POLYMORPHIC; | 135 return code->is_keyed_load_stub() && code->ic_state() == POLYMORPHIC; |
| 136 } | 136 } |
| 137 return false; | 137 return false; |
| 138 } | 138 } |
| 139 | 139 |
| 140 | 140 |
| 141 bool TypeFeedbackOracle::StoreIsUninitialized(TypeFeedbackId ast_id) { |
| 142 Handle<Object> map_or_code = GetInfo(ast_id); |
| 143 if (map_or_code->IsMap()) return false; |
| 144 if (!map_or_code->IsCode()) return true; |
| 145 Handle<Code> code = Handle<Code>::cast(map_or_code); |
| 146 return code->ic_state() == UNINITIALIZED; |
| 147 } |
| 148 |
| 149 |
| 141 bool TypeFeedbackOracle::StoreIsMonomorphicNormal(TypeFeedbackId ast_id) { | 150 bool TypeFeedbackOracle::StoreIsMonomorphicNormal(TypeFeedbackId ast_id) { |
| 142 Handle<Object> map_or_code = GetInfo(ast_id); | 151 Handle<Object> map_or_code = GetInfo(ast_id); |
| 143 if (map_or_code->IsMap()) return true; | 152 if (map_or_code->IsMap()) return true; |
| 144 if (map_or_code->IsCode()) { | 153 if (map_or_code->IsCode()) { |
| 145 Handle<Code> code = Handle<Code>::cast(map_or_code); | 154 Handle<Code> code = Handle<Code>::cast(map_or_code); |
| 146 bool standard_store = FLAG_compiled_keyed_stores || | 155 bool standard_store = FLAG_compiled_keyed_stores || |
| 147 (Code::GetKeyedAccessStoreMode(code->extra_ic_state()) == | 156 (Code::GetKeyedAccessStoreMode(code->extra_ic_state()) == |
| 148 STANDARD_STORE); | 157 STANDARD_STORE); |
| 149 bool preliminary_checks = | 158 bool preliminary_checks = |
| 150 code->is_keyed_store_stub() && | 159 code->is_keyed_store_stub() && |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 return Code::GetKeyedAccessStoreMode(code->extra_ic_state()); | 249 return Code::GetKeyedAccessStoreMode(code->extra_ic_state()); |
| 241 } | 250 } |
| 242 } | 251 } |
| 243 return STANDARD_STORE; | 252 return STANDARD_STORE; |
| 244 } | 253 } |
| 245 | 254 |
| 246 | 255 |
| 247 void TypeFeedbackOracle::LoadReceiverTypes(Property* expr, | 256 void TypeFeedbackOracle::LoadReceiverTypes(Property* expr, |
| 248 Handle<String> name, | 257 Handle<String> name, |
| 249 SmallMapList* types) { | 258 SmallMapList* types) { |
| 250 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC); | 259 Code::Flags flags = Code::ComputeFlags( |
| 260 Code::STUB, MONOMORPHIC, Code::kNoExtraICState, |
| 261 Code::NORMAL, Code::LOAD_IC); |
| 251 CollectReceiverTypes(expr->PropertyFeedbackId(), name, flags, types); | 262 CollectReceiverTypes(expr->PropertyFeedbackId(), name, flags, types); |
| 252 } | 263 } |
| 253 | 264 |
| 254 | 265 |
| 255 void TypeFeedbackOracle::StoreReceiverTypes(Assignment* expr, | 266 void TypeFeedbackOracle::StoreReceiverTypes(Assignment* expr, |
| 256 Handle<String> name, | 267 Handle<String> name, |
| 257 SmallMapList* types) { | 268 SmallMapList* types) { |
| 258 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::STORE_IC); | 269 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::STORE_IC); |
| 259 CollectReceiverTypes(expr->AssignmentFeedbackId(), name, flags, types); | 270 CollectReceiverTypes(expr->AssignmentFeedbackId(), name, flags, types); |
| 260 } | 271 } |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 bool TypeFeedbackOracle::LoadIsStub(Property* expr, ICStub* stub) { | 345 bool TypeFeedbackOracle::LoadIsStub(Property* expr, ICStub* stub) { |
| 335 Handle<Object> object = GetInfo(expr->PropertyFeedbackId()); | 346 Handle<Object> object = GetInfo(expr->PropertyFeedbackId()); |
| 336 if (!object->IsCode()) return false; | 347 if (!object->IsCode()) return false; |
| 337 Handle<Code> code = Handle<Code>::cast(object); | 348 Handle<Code> code = Handle<Code>::cast(object); |
| 338 if (!code->is_load_stub()) return false; | 349 if (!code->is_load_stub()) return false; |
| 339 if (code->ic_state() != MONOMORPHIC) return false; | 350 if (code->ic_state() != MONOMORPHIC) return false; |
| 340 return stub->Describes(*code); | 351 return stub->Describes(*code); |
| 341 } | 352 } |
| 342 | 353 |
| 343 | 354 |
| 344 void TypeFeedbackOracle::CompareTypes(TypeFeedbackId id, | 355 void TypeFeedbackOracle::CompareType(TypeFeedbackId id, |
| 345 Handle<Type>* left_type, | 356 Handle<Type>* left_type, |
| 346 Handle<Type>* right_type, | 357 Handle<Type>* right_type, |
| 347 Handle<Type>* overall_type, | 358 Handle<Type>* combined_type) { |
| 348 Handle<Type>* compare_nil_type) { | 359 *left_type = *right_type = *combined_type = handle(Type::Any(), isolate_); |
| 349 *left_type = *right_type = *overall_type = *compare_nil_type = | |
| 350 handle(Type::Any(), isolate_); | |
| 351 Handle<Object> info = GetInfo(id); | 360 Handle<Object> info = GetInfo(id); |
| 352 if (!info->IsCode()) return; | 361 if (!info->IsCode()) return; |
| 353 Handle<Code> code = Handle<Code>::cast(info); | 362 Handle<Code> code = Handle<Code>::cast(info); |
| 354 | 363 |
| 355 Handle<Map> map; | 364 Handle<Map> map; |
| 356 Map* raw_map = code->FindFirstMap(); | 365 Map* raw_map = code->FindFirstMap(); |
| 357 if (raw_map != NULL) { | 366 if (raw_map != NULL) { |
| 358 raw_map = raw_map->CurrentMapForDeprecated(); | 367 raw_map = raw_map->CurrentMapForDeprecated(); |
| 359 if (raw_map != NULL && !CanRetainOtherContext(raw_map, *native_context_)) { | 368 if (raw_map != NULL && !CanRetainOtherContext(raw_map, *native_context_)) { |
| 360 map = handle(raw_map, isolate_); | 369 map = handle(raw_map, isolate_); |
| 361 } | 370 } |
| 362 } | 371 } |
| 363 | 372 |
| 364 if (code->is_compare_ic_stub()) { | 373 if (code->is_compare_ic_stub()) { |
| 365 int stub_minor_key = code->stub_info(); | 374 int stub_minor_key = code->stub_info(); |
| 366 CompareIC::StubInfoToType( | 375 CompareIC::StubInfoToType( |
| 367 stub_minor_key, left_type, right_type, overall_type, map, isolate()); | 376 stub_minor_key, left_type, right_type, combined_type, map, isolate()); |
| 368 } else if (code->is_compare_nil_ic_stub()) { | 377 } else if (code->is_compare_nil_ic_stub()) { |
| 369 CompareNilICStub::State state(code->compare_nil_state()); | 378 CompareNilICStub::State state(code->compare_nil_state()); |
| 370 *compare_nil_type = CompareNilICStub::StateToType(isolate_, state, map); | 379 *combined_type = CompareNilICStub::StateToType(isolate_, state, map); |
| 380 Handle<Type> nil_type = handle(code->compare_nil_value() == kNullValue |
| 381 ? Type::Null() : Type::Undefined(), isolate_); |
| 382 *left_type = *right_type = |
| 383 handle(Type::Union(*combined_type, nil_type), isolate_); |
| 371 } | 384 } |
| 372 } | 385 } |
| 373 | 386 |
| 374 | 387 |
| 375 Handle<Type> TypeFeedbackOracle::UnaryType(TypeFeedbackId id) { | 388 Handle<Type> TypeFeedbackOracle::UnaryType(TypeFeedbackId id) { |
| 376 Handle<Object> object = GetInfo(id); | 389 Handle<Object> object = GetInfo(id); |
| 377 if (!object->IsCode()) return handle(Type::Any(), isolate()); | 390 if (!object->IsCode()) return handle(Type::Any(), isolate()); |
| 378 Handle<Code> code = Handle<Code>::cast(object); | 391 Handle<Code> code = Handle<Code>::cast(object); |
| 379 ASSERT(code->is_unary_op_stub()); | 392 ASSERT(code->is_unary_op_stub()); |
| 380 return UnaryOpIC::TypeInfoToType( | 393 return UnaryOpIC::TypeInfoToType( |
| 381 static_cast<UnaryOpIC::TypeInfo>(code->unary_op_type()), isolate()); | 394 static_cast<UnaryOpIC::TypeInfo>(code->unary_op_type()), isolate()); |
| 382 } | 395 } |
| 383 | 396 |
| 384 | 397 |
| 385 void TypeFeedbackOracle::BinaryType(TypeFeedbackId id, | 398 void TypeFeedbackOracle::BinaryType(TypeFeedbackId id, |
| 386 Handle<Type>* left, | 399 Handle<Type>* left, |
| 387 Handle<Type>* right, | 400 Handle<Type>* right, |
| 388 Handle<Type>* result, | 401 Handle<Type>* result, |
| 389 bool* has_fixed_right_arg, | 402 Maybe<int>* fixed_right_arg) { |
| 390 int* fixed_right_arg_value) { | |
| 391 Handle<Object> object = GetInfo(id); | 403 Handle<Object> object = GetInfo(id); |
| 392 *left = *right = *result = handle(Type::Any(), isolate_); | 404 *left = *right = *result = handle(Type::Any(), isolate_); |
| 393 if (!object->IsCode()) return; | 405 if (!object->IsCode()) return; |
| 394 Handle<Code> code = Handle<Code>::cast(object); | 406 Handle<Code> code = Handle<Code>::cast(object); |
| 395 if (!code->is_binary_op_stub()) return; | 407 if (!code->is_binary_op_stub()) return; |
| 396 | 408 |
| 397 int minor_key = code->stub_info(); | 409 int minor_key = code->stub_info(); |
| 398 BinaryOpIC::StubInfoToType(minor_key, left, right, result, isolate()); | 410 BinaryOpIC::StubInfoToType(minor_key, left, right, result, isolate()); |
| 399 *has_fixed_right_arg = | 411 *fixed_right_arg = |
| 400 BinaryOpStub::decode_has_fixed_right_arg_from_minor_key(minor_key); | 412 BinaryOpStub::decode_fixed_right_arg_from_minor_key(minor_key); |
| 401 *fixed_right_arg_value = | |
| 402 BinaryOpStub::decode_fixed_right_arg_value_from_minor_key(minor_key); | |
| 403 } | 413 } |
| 404 | 414 |
| 405 | 415 |
| 406 Handle<Type> TypeFeedbackOracle::ClauseType(TypeFeedbackId id) { | 416 Handle<Type> TypeFeedbackOracle::ClauseType(TypeFeedbackId id) { |
| 407 Handle<Object> info = GetInfo(id); | 417 Handle<Object> info = GetInfo(id); |
| 408 Handle<Type> result(Type::None(), isolate_); | 418 Handle<Type> result(Type::None(), isolate_); |
| 409 if (info->IsCode() && Handle<Code>::cast(info)->is_compare_ic_stub()) { | 419 if (info->IsCode() && Handle<Code>::cast(info)->is_compare_ic_stub()) { |
| 410 Handle<Code> code = Handle<Code>::cast(info); | 420 Handle<Code> code = Handle<Code>::cast(info); |
| 411 CompareIC::State state = ICCompareStub::CompareState(code->stub_info()); | 421 CompareIC::State state = ICCompareStub::CompareState(code->stub_info()); |
| 412 result = CompareIC::StateToType(isolate_, state); | 422 result = CompareIC::StateToType(isolate_, state); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 SmallMapList* types) { | 478 SmallMapList* types) { |
| 469 Handle<Object> object = GetInfo(ast_id); | 479 Handle<Object> object = GetInfo(ast_id); |
| 470 if (object->IsUndefined() || object->IsSmi()) return; | 480 if (object->IsUndefined() || object->IsSmi()) return; |
| 471 | 481 |
| 472 if (object.is_identical_to(isolate_->builtins()->StoreIC_GlobalProxy())) { | 482 if (object.is_identical_to(isolate_->builtins()->StoreIC_GlobalProxy())) { |
| 473 // TODO(fschneider): We could collect the maps and signal that | 483 // TODO(fschneider): We could collect the maps and signal that |
| 474 // we need a generic store (or load) here. | 484 // we need a generic store (or load) here. |
| 475 ASSERT(Handle<Code>::cast(object)->ic_state() == GENERIC); | 485 ASSERT(Handle<Code>::cast(object)->ic_state() == GENERIC); |
| 476 } else if (object->IsMap()) { | 486 } else if (object->IsMap()) { |
| 477 types->AddMapIfMissing(Handle<Map>::cast(object), zone()); | 487 types->AddMapIfMissing(Handle<Map>::cast(object), zone()); |
| 478 } else if (Handle<Code>::cast(object)->ic_state() == POLYMORPHIC) { | 488 } else if (Handle<Code>::cast(object)->ic_state() == POLYMORPHIC || |
| 489 Handle<Code>::cast(object)->ic_state() == MONOMORPHIC) { |
| 479 CollectPolymorphicMaps(Handle<Code>::cast(object), types); | 490 CollectPolymorphicMaps(Handle<Code>::cast(object), types); |
| 480 } else if (FLAG_collect_megamorphic_maps_from_stub_cache && | 491 } else if (FLAG_collect_megamorphic_maps_from_stub_cache && |
| 481 Handle<Code>::cast(object)->ic_state() == MEGAMORPHIC) { | 492 Handle<Code>::cast(object)->ic_state() == MEGAMORPHIC) { |
| 482 types->Reserve(4, zone()); | 493 types->Reserve(4, zone()); |
| 483 ASSERT(object->IsCode()); | 494 ASSERT(object->IsCode()); |
| 484 isolate_->stub_cache()->CollectMatchingMaps(types, | 495 isolate_->stub_cache()->CollectMatchingMaps(types, |
| 485 name, | 496 name, |
| 486 flags, | 497 flags, |
| 487 native_context_, | 498 native_context_, |
| 488 zone()); | 499 zone()); |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 USE(maybe_result); | 684 USE(maybe_result); |
| 674 #ifdef DEBUG | 685 #ifdef DEBUG |
| 675 Object* result = NULL; | 686 Object* result = NULL; |
| 676 // Dictionary has been allocated with sufficient size for all elements. | 687 // Dictionary has been allocated with sufficient size for all elements. |
| 677 ASSERT(maybe_result->ToObject(&result)); | 688 ASSERT(maybe_result->ToObject(&result)); |
| 678 ASSERT(*dictionary_ == result); | 689 ASSERT(*dictionary_ == result); |
| 679 #endif | 690 #endif |
| 680 } | 691 } |
| 681 | 692 |
| 682 } } // namespace v8::internal | 693 } } // namespace v8::internal |
| OLD | NEW |