| 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 652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 return isolate->factory()->heap_number_map(); | 663 return isolate->factory()->heap_number_map(); |
| 664 if (type->Is(HeapType::Boolean())) return isolate->factory()->oddball_map(); | 664 if (type->Is(HeapType::Boolean())) return isolate->factory()->oddball_map(); |
| 665 if (type->IsConstant()) { | 665 if (type->IsConstant()) { |
| 666 return handle(Handle<JSGlobalObject>::cast(type->AsConstant())->map()); | 666 return handle(Handle<JSGlobalObject>::cast(type->AsConstant())->map()); |
| 667 } | 667 } |
| 668 ASSERT(type->IsClass()); | 668 ASSERT(type->IsClass()); |
| 669 return type->AsClass(); | 669 return type->AsClass(); |
| 670 } | 670 } |
| 671 | 671 |
| 672 | 672 |
| 673 Handle<HeapType> IC::MapToType(Handle<Map> map) { | |
| 674 Isolate* isolate = map->GetIsolate(); | |
| 675 if (map->instance_type() == HEAP_NUMBER_TYPE) { | |
| 676 return HeapType::Number(isolate); | |
| 677 } else if (map->instance_type() == ODDBALL_TYPE) { | |
| 678 // The only oddballs that can be recorded in ICs are booleans. | |
| 679 return HeapType::Boolean(isolate); | |
| 680 } else { | |
| 681 return HeapType::Class(map, isolate); | |
| 682 } | |
| 683 } | |
| 684 | |
| 685 | |
| 686 void IC::UpdateMonomorphicIC(Handle<HeapType> type, | 673 void IC::UpdateMonomorphicIC(Handle<HeapType> type, |
| 687 Handle<Code> handler, | 674 Handle<Code> handler, |
| 688 Handle<String> name) { | 675 Handle<String> name) { |
| 689 if (!handler->is_handler()) return set_target(*handler); | 676 if (!handler->is_handler()) return set_target(*handler); |
| 690 Handle<Code> ic = isolate()->stub_cache()->ComputeMonomorphicIC( | 677 Handle<Code> ic = isolate()->stub_cache()->ComputeMonomorphicIC( |
| 691 name, type, handler, extra_ic_state()); | 678 name, type, handler, extra_ic_state()); |
| 692 set_target(*ic); | 679 set_target(*ic); |
| 693 } | 680 } |
| 694 | 681 |
| 695 | 682 |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 901 // There is only one shared stub for loading normalized | 888 // There is only one shared stub for loading normalized |
| 902 // properties. It does not traverse the prototype chain, so the | 889 // properties. It does not traverse the prototype chain, so the |
| 903 // property must be found in the object for the stub to be | 890 // property must be found in the object for the stub to be |
| 904 // applicable. | 891 // applicable. |
| 905 if (!object.is_identical_to(holder)) break; | 892 if (!object.is_identical_to(holder)) break; |
| 906 return isolate()->builtins()->LoadIC_Normal(); | 893 return isolate()->builtins()->LoadIC_Normal(); |
| 907 case CALLBACKS: { | 894 case CALLBACKS: { |
| 908 // Use simple field loads for some well-known callback properties. | 895 // Use simple field loads for some well-known callback properties. |
| 909 if (object->IsJSObject()) { | 896 if (object->IsJSObject()) { |
| 910 Handle<JSObject> receiver = Handle<JSObject>::cast(object); | 897 Handle<JSObject> receiver = Handle<JSObject>::cast(object); |
| 911 Handle<HeapType> type = IC::MapToType(handle(receiver->map())); | 898 Handle<HeapType> type = IC::MapToType<HeapType>( |
| 899 handle(receiver->map()), isolate()); |
| 912 int object_offset; | 900 int object_offset; |
| 913 if (Accessors::IsJSObjectFieldAccessor(type, name, &object_offset)) { | 901 if (Accessors::IsJSObjectFieldAccessor<HeapType>( |
| 902 type, name, &object_offset)) { |
| 914 return SimpleFieldLoad(object_offset / kPointerSize); | 903 return SimpleFieldLoad(object_offset / kPointerSize); |
| 915 } | 904 } |
| 916 } | 905 } |
| 917 | 906 |
| 918 Handle<Object> callback(lookup->GetCallbackObject(), isolate()); | 907 Handle<Object> callback(lookup->GetCallbackObject(), isolate()); |
| 919 if (callback->IsExecutableAccessorInfo()) { | 908 if (callback->IsExecutableAccessorInfo()) { |
| 920 Handle<ExecutableAccessorInfo> info = | 909 Handle<ExecutableAccessorInfo> info = |
| 921 Handle<ExecutableAccessorInfo>::cast(callback); | 910 Handle<ExecutableAccessorInfo>::cast(callback); |
| 922 if (v8::ToCData<Address>(info->getter()) == 0) break; | 911 if (v8::ToCData<Address>(info->getter()) == 0) break; |
| 923 if (!info->IsCompatibleReceiver(*object)) break; | 912 if (!info->IsCompatibleReceiver(*object)) break; |
| (...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1429 KeyedStoreIC::GetKeyedAccessStoreMode(target()->extra_ic_state()); | 1418 KeyedStoreIC::GetKeyedAccessStoreMode(target()->extra_ic_state()); |
| 1430 Handle<Map> previous_receiver_map = target_receiver_maps.at(0); | 1419 Handle<Map> previous_receiver_map = target_receiver_maps.at(0); |
| 1431 if (state() == MONOMORPHIC) { | 1420 if (state() == MONOMORPHIC) { |
| 1432 // If the "old" and "new" maps are in the same elements map family, stay | 1421 // If the "old" and "new" maps are in the same elements map family, stay |
| 1433 // MONOMORPHIC and use the map for the most generic ElementsKind. | 1422 // MONOMORPHIC and use the map for the most generic ElementsKind. |
| 1434 Handle<Map> transitioned_receiver_map = receiver_map; | 1423 Handle<Map> transitioned_receiver_map = receiver_map; |
| 1435 if (IsTransitionStoreMode(store_mode)) { | 1424 if (IsTransitionStoreMode(store_mode)) { |
| 1436 transitioned_receiver_map = | 1425 transitioned_receiver_map = |
| 1437 ComputeTransitionedMap(receiver, store_mode); | 1426 ComputeTransitionedMap(receiver, store_mode); |
| 1438 } | 1427 } |
| 1439 if (IsTransitionOfMonomorphicTarget(MapToType(transitioned_receiver_map))) { | 1428 if (IsTransitionOfMonomorphicTarget( |
| 1429 MapToType<HeapType>(transitioned_receiver_map, isolate()))) { |
| 1440 // Element family is the same, use the "worst" case map. | 1430 // Element family is the same, use the "worst" case map. |
| 1441 store_mode = GetNonTransitioningStoreMode(store_mode); | 1431 store_mode = GetNonTransitioningStoreMode(store_mode); |
| 1442 return isolate()->stub_cache()->ComputeKeyedStoreElement( | 1432 return isolate()->stub_cache()->ComputeKeyedStoreElement( |
| 1443 transitioned_receiver_map, strict_mode(), store_mode); | 1433 transitioned_receiver_map, strict_mode(), store_mode); |
| 1444 } else if (*previous_receiver_map == receiver->map() && | 1434 } else if (*previous_receiver_map == receiver->map() && |
| 1445 old_store_mode == STANDARD_STORE && | 1435 old_store_mode == STANDARD_STORE && |
| 1446 (IsGrowStoreMode(store_mode) || | 1436 (IsGrowStoreMode(store_mode) || |
| 1447 store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS || | 1437 store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS || |
| 1448 store_mode == STORE_NO_TRANSITION_HANDLE_COW)) { | 1438 store_mode == STORE_NO_TRANSITION_HANDLE_COW)) { |
| 1449 // A "normal" IC that handles stores can switch to a version that can | 1439 // A "normal" IC that handles stores can switch to a version that can |
| (...skipping 1355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2805 #undef ADDR | 2795 #undef ADDR |
| 2806 }; | 2796 }; |
| 2807 | 2797 |
| 2808 | 2798 |
| 2809 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 2799 Address IC::AddressFromUtilityId(IC::UtilityId id) { |
| 2810 return IC_utilities[id]; | 2800 return IC_utilities[id]; |
| 2811 } | 2801 } |
| 2812 | 2802 |
| 2813 | 2803 |
| 2814 } } // namespace v8::internal | 2804 } } // namespace v8::internal |
| OLD | NEW |