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 931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
942 if (!receiver_maps->at(current).is_null() && | 942 if (!receiver_maps->at(current).is_null() && |
943 receiver_maps->at(current).is_identical_to(new_receiver_map)) { | 943 receiver_maps->at(current).is_identical_to(new_receiver_map)) { |
944 return false; | 944 return false; |
945 } | 945 } |
946 } | 946 } |
947 receiver_maps->Add(new_receiver_map); | 947 receiver_maps->Add(new_receiver_map); |
948 return true; | 948 return true; |
949 } | 949 } |
950 | 950 |
951 | 951 |
952 bool IC::UpdatePolymorphicIC(Handle<HeapObject> receiver, | 952 bool IC::UpdatePolymorphicIC(Handle<Object> receiver, |
953 Handle<String> name, | 953 Handle<String> name, |
954 Handle<Code> code) { | 954 Handle<Code> code) { |
955 if (!code->is_handler()) return false; | 955 if (!code->is_handler()) return false; |
956 MapHandleList receiver_maps; | 956 MapHandleList receiver_maps; |
957 CodeHandleList handlers; | 957 CodeHandleList handlers; |
958 | 958 |
959 int number_of_valid_maps; | 959 int number_of_valid_maps; |
960 int handler_to_overwrite = -1; | 960 int handler_to_overwrite = -1; |
961 Handle<Map> new_receiver_map(receiver->map()); | 961 Handle<Map> new_receiver_map(receiver->GetMarkerMap(isolate())); |
962 | 962 |
963 target()->FindAllMaps(&receiver_maps); | 963 target()->FindAllMaps(&receiver_maps); |
964 int number_of_maps = receiver_maps.length(); | 964 int number_of_maps = receiver_maps.length(); |
965 number_of_valid_maps = number_of_maps; | 965 number_of_valid_maps = number_of_maps; |
966 | 966 |
967 for (int i = 0; i < number_of_maps; i++) { | 967 for (int i = 0; i < number_of_maps; i++) { |
968 Handle<Map> map = receiver_maps.at(i); | 968 Handle<Map> map = receiver_maps.at(i); |
969 // Filter out deprecated maps to ensure its instances get migrated. | 969 // Filter out deprecated maps to ensure its instances get migrated. |
970 if (map->is_deprecated()) { | 970 if (map->is_deprecated()) { |
971 number_of_valid_maps--; | 971 number_of_valid_maps--; |
(...skipping 21 matching lines...) Expand all Loading... |
993 handlers.Add(code); | 993 handlers.Add(code); |
994 } | 994 } |
995 | 995 |
996 Handle<Code> ic = isolate()->stub_cache()->ComputePolymorphicIC( | 996 Handle<Code> ic = isolate()->stub_cache()->ComputePolymorphicIC( |
997 &receiver_maps, &handlers, number_of_valid_maps, name, strict_mode()); | 997 &receiver_maps, &handlers, number_of_valid_maps, name, strict_mode()); |
998 set_target(*ic); | 998 set_target(*ic); |
999 return true; | 999 return true; |
1000 } | 1000 } |
1001 | 1001 |
1002 | 1002 |
1003 void IC::UpdateMonomorphicIC(Handle<HeapObject> receiver, | 1003 void IC::UpdateMonomorphicIC(Handle<Object> receiver, |
1004 Handle<Code> handler, | 1004 Handle<Code> handler, |
1005 Handle<String> name) { | 1005 Handle<String> name) { |
1006 if (!handler->is_handler()) return set_target(*handler); | 1006 if (!handler->is_handler()) return set_target(*handler); |
1007 Handle<Code> ic = isolate()->stub_cache()->ComputeMonomorphicIC( | 1007 Handle<Code> ic = isolate()->stub_cache()->ComputeMonomorphicIC( |
1008 name, receiver, handler, strict_mode()); | 1008 name, receiver, handler, strict_mode()); |
1009 set_target(*ic); | 1009 set_target(*ic); |
1010 } | 1010 } |
1011 | 1011 |
1012 | 1012 |
1013 void IC::CopyICToMegamorphicCache(Handle<String> name) { | 1013 void IC::CopyICToMegamorphicCache(Handle<String> name) { |
(...skipping 17 matching lines...) Expand all Loading... |
1031 ? current_map->LookupElementsTransitionMap(receiver_elements_kind) | 1031 ? current_map->LookupElementsTransitionMap(receiver_elements_kind) |
1032 : NULL; | 1032 : NULL; |
1033 | 1033 |
1034 return transitioned_map == receiver_map; | 1034 return transitioned_map == receiver_map; |
1035 } | 1035 } |
1036 | 1036 |
1037 | 1037 |
1038 void IC::PatchCache(Handle<Object> object, | 1038 void IC::PatchCache(Handle<Object> object, |
1039 Handle<String> name, | 1039 Handle<String> name, |
1040 Handle<Code> code) { | 1040 Handle<Code> code) { |
1041 // TODO(verwaest): Handle smi here as well. | |
1042 if (!object->IsHeapObject()) return; | |
1043 | |
1044 Handle<HeapObject> receiver = Handle<HeapObject>::cast(object); | |
1045 switch (state()) { | 1041 switch (state()) { |
1046 case UNINITIALIZED: | 1042 case UNINITIALIZED: |
1047 case PREMONOMORPHIC: | 1043 case PREMONOMORPHIC: |
1048 case MONOMORPHIC_PROTOTYPE_FAILURE: | 1044 case MONOMORPHIC_PROTOTYPE_FAILURE: |
1049 UpdateMonomorphicIC(receiver, code, name); | 1045 UpdateMonomorphicIC(object, code, name); |
1050 break; | 1046 break; |
1051 case MONOMORPHIC: | 1047 case MONOMORPHIC: { |
1052 // For now, call stubs are allowed to rewrite to the same stub. This | 1048 // For now, call stubs are allowed to rewrite to the same stub. This |
1053 // happens e.g., when the field does not contain a function. | 1049 // happens e.g., when the field does not contain a function. |
1054 ASSERT(target()->is_call_stub() || | 1050 ASSERT(target()->is_call_stub() || |
1055 target()->is_keyed_call_stub() || | 1051 target()->is_keyed_call_stub() || |
1056 !target().is_identical_to(code)); | 1052 !target().is_identical_to(code)); |
1057 if (!target()->is_keyed_stub()) { | 1053 Code* old_handler = target()->FindFirstHandler(); |
1058 bool is_same_handler = false; | 1054 if (old_handler == *code && |
1059 Code* old_handler = target()->FindFirstHandler(); | 1055 IsTransitionedMapOfMonomorphicTarget( |
1060 is_same_handler = old_handler == *code; | 1056 object->GetMarkerMap(isolate()))) { |
1061 | 1057 UpdateMonomorphicIC(object, code, name); |
1062 if (is_same_handler && | 1058 break; |
1063 IsTransitionedMapOfMonomorphicTarget(receiver->map())) { | |
1064 UpdateMonomorphicIC(receiver, code, name); | |
1065 break; | |
1066 } | |
1067 } | 1059 } |
1068 // Fall through. | 1060 // Fall through. |
| 1061 } |
1069 case POLYMORPHIC: | 1062 case POLYMORPHIC: |
1070 if (!target()->is_keyed_stub()) { | 1063 if (!target()->is_keyed_stub()) { |
1071 if (UpdatePolymorphicIC(receiver, name, code)) break; | 1064 if (UpdatePolymorphicIC(object, name, code)) break; |
1072 CopyICToMegamorphicCache(name); | 1065 CopyICToMegamorphicCache(name); |
1073 } | 1066 } |
1074 set_target(*megamorphic_stub()); | 1067 set_target(*megamorphic_stub()); |
1075 // Fall through. | 1068 // Fall through. |
1076 case MEGAMORPHIC: | 1069 case MEGAMORPHIC: |
1077 UpdateMegamorphicCache(receiver->map(), *name, *code); | 1070 UpdateMegamorphicCache(object->GetMarkerMap(isolate()), *name, *code); |
1078 break; | 1071 break; |
1079 case DEBUG_STUB: | 1072 case DEBUG_STUB: |
1080 break; | 1073 break; |
1081 case GENERIC: | 1074 case GENERIC: |
1082 UNREACHABLE(); | 1075 UNREACHABLE(); |
1083 break; | 1076 break; |
1084 } | 1077 } |
1085 } | 1078 } |
1086 | 1079 |
1087 | 1080 |
(...skipping 1663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2751 #undef ADDR | 2744 #undef ADDR |
2752 }; | 2745 }; |
2753 | 2746 |
2754 | 2747 |
2755 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 2748 Address IC::AddressFromUtilityId(IC::UtilityId id) { |
2756 return IC_utilities[id]; | 2749 return IC_utilities[id]; |
2757 } | 2750 } |
2758 | 2751 |
2759 | 2752 |
2760 } } // namespace v8::internal | 2753 } } // namespace v8::internal |
OLD | NEW |