| 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) { | 673 template <class T> |
| 674 Isolate* isolate = map->GetIsolate(); | 674 typename T::TypeHandle IC::MapToType(Handle<Map> map, |
| 675 typename T::Region* region) { |
| 675 if (map->instance_type() == HEAP_NUMBER_TYPE) { | 676 if (map->instance_type() == HEAP_NUMBER_TYPE) { |
| 676 return HeapType::Number(isolate); | 677 return T::Number(region); |
| 677 } else if (map->instance_type() == ODDBALL_TYPE) { | 678 } else if (map->instance_type() == ODDBALL_TYPE) { |
| 678 // The only oddballs that can be recorded in ICs are booleans. | 679 // The only oddballs that can be recorded in ICs are booleans. |
| 679 return HeapType::Boolean(isolate); | 680 return T::Boolean(region); |
| 680 } else { | 681 } else { |
| 681 return HeapType::Class(map, isolate); | 682 return T::Class(map, region); |
| 682 } | 683 } |
| 683 } | 684 } |
| 684 | 685 |
| 685 | 686 |
| 687 template |
| 688 Type* IC::MapToType<Type>(Handle<Map> map, Zone* zone); |
| 689 |
| 690 |
| 691 template |
| 692 Handle<HeapType> IC::MapToType<HeapType>(Handle<Map> map, Isolate* region); |
| 693 |
| 694 |
| 686 void IC::UpdateMonomorphicIC(Handle<HeapType> type, | 695 void IC::UpdateMonomorphicIC(Handle<HeapType> type, |
| 687 Handle<Code> handler, | 696 Handle<Code> handler, |
| 688 Handle<String> name) { | 697 Handle<String> name) { |
| 689 if (!handler->is_handler()) return set_target(*handler); | 698 if (!handler->is_handler()) return set_target(*handler); |
| 690 Handle<Code> ic = isolate()->stub_cache()->ComputeMonomorphicIC( | 699 Handle<Code> ic = isolate()->stub_cache()->ComputeMonomorphicIC( |
| 691 name, type, handler, extra_ic_state()); | 700 name, type, handler, extra_ic_state()); |
| 692 set_target(*ic); | 701 set_target(*ic); |
| 693 } | 702 } |
| 694 | 703 |
| 695 | 704 |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 901 // There is only one shared stub for loading normalized | 910 // There is only one shared stub for loading normalized |
| 902 // properties. It does not traverse the prototype chain, so the | 911 // properties. It does not traverse the prototype chain, so the |
| 903 // property must be found in the object for the stub to be | 912 // property must be found in the object for the stub to be |
| 904 // applicable. | 913 // applicable. |
| 905 if (!object.is_identical_to(holder)) break; | 914 if (!object.is_identical_to(holder)) break; |
| 906 return isolate()->builtins()->LoadIC_Normal(); | 915 return isolate()->builtins()->LoadIC_Normal(); |
| 907 case CALLBACKS: { | 916 case CALLBACKS: { |
| 908 // Use simple field loads for some well-known callback properties. | 917 // Use simple field loads for some well-known callback properties. |
| 909 if (object->IsJSObject()) { | 918 if (object->IsJSObject()) { |
| 910 Handle<JSObject> receiver = Handle<JSObject>::cast(object); | 919 Handle<JSObject> receiver = Handle<JSObject>::cast(object); |
| 911 Handle<HeapType> type = IC::MapToType(handle(receiver->map())); | 920 Handle<HeapType> type = IC::MapToType<HeapType>( |
| 921 handle(receiver->map()), isolate()); |
| 912 int object_offset; | 922 int object_offset; |
| 913 if (Accessors::IsJSObjectFieldAccessor(type, name, &object_offset)) { | 923 if (Accessors::IsJSObjectFieldAccessor<HeapType>( |
| 924 type, name, &object_offset)) { |
| 914 return SimpleFieldLoad(object_offset / kPointerSize); | 925 return SimpleFieldLoad(object_offset / kPointerSize); |
| 915 } | 926 } |
| 916 } | 927 } |
| 917 | 928 |
| 918 Handle<Object> callback(lookup->GetCallbackObject(), isolate()); | 929 Handle<Object> callback(lookup->GetCallbackObject(), isolate()); |
| 919 if (callback->IsExecutableAccessorInfo()) { | 930 if (callback->IsExecutableAccessorInfo()) { |
| 920 Handle<ExecutableAccessorInfo> info = | 931 Handle<ExecutableAccessorInfo> info = |
| 921 Handle<ExecutableAccessorInfo>::cast(callback); | 932 Handle<ExecutableAccessorInfo>::cast(callback); |
| 922 if (v8::ToCData<Address>(info->getter()) == 0) break; | 933 if (v8::ToCData<Address>(info->getter()) == 0) break; |
| 923 if (!info->IsCompatibleReceiver(*object)) break; | 934 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()); | 1440 KeyedStoreIC::GetKeyedAccessStoreMode(target()->extra_ic_state()); |
| 1430 Handle<Map> previous_receiver_map = target_receiver_maps.at(0); | 1441 Handle<Map> previous_receiver_map = target_receiver_maps.at(0); |
| 1431 if (state() == MONOMORPHIC) { | 1442 if (state() == MONOMORPHIC) { |
| 1432 // If the "old" and "new" maps are in the same elements map family, stay | 1443 // 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. | 1444 // MONOMORPHIC and use the map for the most generic ElementsKind. |
| 1434 Handle<Map> transitioned_receiver_map = receiver_map; | 1445 Handle<Map> transitioned_receiver_map = receiver_map; |
| 1435 if (IsTransitionStoreMode(store_mode)) { | 1446 if (IsTransitionStoreMode(store_mode)) { |
| 1436 transitioned_receiver_map = | 1447 transitioned_receiver_map = |
| 1437 ComputeTransitionedMap(receiver, store_mode); | 1448 ComputeTransitionedMap(receiver, store_mode); |
| 1438 } | 1449 } |
| 1439 if (IsTransitionOfMonomorphicTarget(MapToType(transitioned_receiver_map))) { | 1450 if (IsTransitionOfMonomorphicTarget( |
| 1451 MapToType<HeapType>(transitioned_receiver_map, isolate()))) { |
| 1440 // Element family is the same, use the "worst" case map. | 1452 // Element family is the same, use the "worst" case map. |
| 1441 store_mode = GetNonTransitioningStoreMode(store_mode); | 1453 store_mode = GetNonTransitioningStoreMode(store_mode); |
| 1442 return isolate()->stub_cache()->ComputeKeyedStoreElement( | 1454 return isolate()->stub_cache()->ComputeKeyedStoreElement( |
| 1443 transitioned_receiver_map, strict_mode(), store_mode); | 1455 transitioned_receiver_map, strict_mode(), store_mode); |
| 1444 } else if (*previous_receiver_map == receiver->map() && | 1456 } else if (*previous_receiver_map == receiver->map() && |
| 1445 old_store_mode == STANDARD_STORE && | 1457 old_store_mode == STANDARD_STORE && |
| 1446 (IsGrowStoreMode(store_mode) || | 1458 (IsGrowStoreMode(store_mode) || |
| 1447 store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS || | 1459 store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS || |
| 1448 store_mode == STORE_NO_TRANSITION_HANDLE_COW)) { | 1460 store_mode == STORE_NO_TRANSITION_HANDLE_COW)) { |
| 1449 // A "normal" IC that handles stores can switch to a version that can | 1461 // 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 | 2817 #undef ADDR |
| 2806 }; | 2818 }; |
| 2807 | 2819 |
| 2808 | 2820 |
| 2809 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 2821 Address IC::AddressFromUtilityId(IC::UtilityId id) { |
| 2810 return IC_utilities[id]; | 2822 return IC_utilities[id]; |
| 2811 } | 2823 } |
| 2812 | 2824 |
| 2813 | 2825 |
| 2814 } } // namespace v8::internal | 2826 } } // namespace v8::internal |
| OLD | NEW |