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 978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
989 receiver_maps->Add(new_receiver_map); | 989 receiver_maps->Add(new_receiver_map); |
990 return true; | 990 return true; |
991 } | 991 } |
992 | 992 |
993 | 993 |
994 bool IC::UpdatePolymorphicIC(State state, | 994 bool IC::UpdatePolymorphicIC(State state, |
995 Handle<HeapObject> receiver, | 995 Handle<HeapObject> receiver, |
996 Handle<String> name, | 996 Handle<String> name, |
997 Handle<Code> code, | 997 Handle<Code> code, |
998 StrictModeFlag strict_mode) { | 998 StrictModeFlag strict_mode) { |
999 if (code->kind() != Code::HANDLER) return false; | 999 if (!code->is_handler()) return false; |
1000 | 1000 |
1001 MapHandleList receiver_maps; | 1001 MapHandleList receiver_maps; |
1002 CodeHandleList handlers; | 1002 CodeHandleList handlers; |
1003 | 1003 |
1004 int number_of_valid_maps; | 1004 int number_of_valid_maps; |
1005 int handler_to_overwrite = -1; | 1005 int handler_to_overwrite = -1; |
1006 Handle<Map> new_receiver_map(receiver->map()); | 1006 Handle<Map> new_receiver_map(receiver->map()); |
1007 { | 1007 { |
1008 DisallowHeapAllocation no_gc; | 1008 DisallowHeapAllocation no_gc; |
1009 target()->FindAllMaps(&receiver_maps); | 1009 target()->FindAllMaps(&receiver_maps); |
(...skipping 28 matching lines...) Expand all Loading... |
1038 } | 1038 } |
1039 | 1039 |
1040 number_of_valid_maps++; | 1040 number_of_valid_maps++; |
1041 if (handler_to_overwrite >= 0) { | 1041 if (handler_to_overwrite >= 0) { |
1042 handlers.Set(handler_to_overwrite, code); | 1042 handlers.Set(handler_to_overwrite, code); |
1043 } else { | 1043 } else { |
1044 receiver_maps.Add(new_receiver_map); | 1044 receiver_maps.Add(new_receiver_map); |
1045 handlers.Add(code); | 1045 handlers.Add(code); |
1046 } | 1046 } |
1047 | 1047 |
1048 Handle<Code> ic = ComputePolymorphicIC( | 1048 Handle<Code> ic = isolate()->stub_cache()->ComputePolymorphicIC( |
1049 &receiver_maps, &handlers, number_of_valid_maps, name, strict_mode); | 1049 &receiver_maps, &handlers, number_of_valid_maps, name, strict_mode); |
1050 set_target(*ic); | 1050 set_target(*ic); |
1051 return true; | 1051 return true; |
1052 } | 1052 } |
1053 | 1053 |
1054 | 1054 |
1055 Handle<Code> LoadIC::ComputePolymorphicIC(MapHandleList* receiver_maps, | 1055 void IC::UpdateMonomorphicIC(Handle<HeapObject> receiver, |
1056 CodeHandleList* handlers, | 1056 Handle<Code> handler, |
1057 int number_of_valid_maps, | 1057 Handle<String> name, |
1058 Handle<Name> name, | 1058 StrictModeFlag strict_mode) { |
1059 StrictModeFlag strict_mode) { | 1059 if (!handler->is_handler()) return set_target(*handler); |
1060 return isolate()->stub_cache()->ComputePolymorphicLoadIC( | 1060 Handle<Code> ic = isolate()->stub_cache()->ComputeMonomorphicIC( |
1061 receiver_maps, handlers, number_of_valid_maps, name); | |
1062 } | |
1063 | |
1064 | |
1065 Handle<Code> StoreIC::ComputePolymorphicIC(MapHandleList* receiver_maps, | |
1066 CodeHandleList* handlers, | |
1067 int number_of_valid_maps, | |
1068 Handle<Name> name, | |
1069 StrictModeFlag strict_mode) { | |
1070 return isolate()->stub_cache()->ComputePolymorphicStoreIC( | |
1071 receiver_maps, handlers, number_of_valid_maps, name, strict_mode); | |
1072 } | |
1073 | |
1074 | |
1075 void LoadIC::UpdateMonomorphicIC(Handle<HeapObject> receiver, | |
1076 Handle<Code> handler, | |
1077 Handle<String> name, | |
1078 StrictModeFlag strict_mode) { | |
1079 if (handler->is_load_stub()) return set_target(*handler); | |
1080 Handle<Code> ic = isolate()->stub_cache()->ComputeMonomorphicLoadIC( | |
1081 receiver, handler, name); | |
1082 set_target(*ic); | |
1083 } | |
1084 | |
1085 | |
1086 void KeyedLoadIC::UpdateMonomorphicIC(Handle<HeapObject> receiver, | |
1087 Handle<Code> handler, | |
1088 Handle<String> name, | |
1089 StrictModeFlag strict_mode) { | |
1090 if (handler->is_keyed_load_stub()) return set_target(*handler); | |
1091 Handle<Code> ic = isolate()->stub_cache()->ComputeMonomorphicKeyedLoadIC( | |
1092 receiver, handler, name); | |
1093 set_target(*ic); | |
1094 } | |
1095 | |
1096 | |
1097 void StoreIC::UpdateMonomorphicIC(Handle<HeapObject> receiver, | |
1098 Handle<Code> handler, | |
1099 Handle<String> name, | |
1100 StrictModeFlag strict_mode) { | |
1101 if (handler->is_store_stub()) return set_target(*handler); | |
1102 Handle<Code> ic = isolate()->stub_cache()->ComputeMonomorphicStoreIC( | |
1103 receiver, handler, name, strict_mode); | 1061 receiver, handler, name, strict_mode); |
1104 set_target(*ic); | 1062 set_target(*ic); |
1105 } | 1063 } |
1106 | |
1107 | |
1108 void KeyedStoreIC::UpdateMonomorphicIC(Handle<HeapObject> receiver, | |
1109 Handle<Code> handler, | |
1110 Handle<String> name, | |
1111 StrictModeFlag strict_mode) { | |
1112 if (handler->is_keyed_store_stub()) return set_target(*handler); | |
1113 Handle<Code> ic = isolate()->stub_cache()->ComputeMonomorphicKeyedStoreIC( | |
1114 receiver, handler, name, strict_mode); | |
1115 set_target(*ic); | |
1116 } | |
1117 | 1064 |
1118 | 1065 |
1119 void IC::CopyICToMegamorphicCache(Handle<String> name) { | 1066 void IC::CopyICToMegamorphicCache(Handle<String> name) { |
1120 MapHandleList receiver_maps; | 1067 MapHandleList receiver_maps; |
1121 CodeHandleList handlers; | 1068 CodeHandleList handlers; |
1122 { | 1069 { |
1123 DisallowHeapAllocation no_gc; | 1070 DisallowHeapAllocation no_gc; |
1124 target()->FindAllMaps(&receiver_maps); | 1071 target()->FindAllMaps(&receiver_maps); |
1125 if (!target()->FindHandlers(&handlers, receiver_maps.length())) return; | 1072 if (!target()->FindHandlers(&handlers, receiver_maps.length())) return; |
1126 } | 1073 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1181 CopyICToMegamorphicCache(name); | 1128 CopyICToMegamorphicCache(name); |
1182 } | 1129 } |
1183 | 1130 |
1184 UpdateMegamorphicCache(receiver->map(), *name, *code); | 1131 UpdateMegamorphicCache(receiver->map(), *name, *code); |
1185 set_target((strict_mode == kStrictMode) | 1132 set_target((strict_mode == kStrictMode) |
1186 ? *megamorphic_stub_strict() | 1133 ? *megamorphic_stub_strict() |
1187 : *megamorphic_stub()); | 1134 : *megamorphic_stub()); |
1188 } | 1135 } |
1189 break; | 1136 break; |
1190 case MEGAMORPHIC: | 1137 case MEGAMORPHIC: |
1191 // Update the stub cache. | |
1192 UpdateMegamorphicCache(receiver->map(), *name, *code); | 1138 UpdateMegamorphicCache(receiver->map(), *name, *code); |
1193 break; | 1139 break; |
1194 case POLYMORPHIC: | 1140 case POLYMORPHIC: |
1195 if (target()->is_load_stub() || target()->is_store_stub()) { | 1141 if (target()->is_load_stub() || target()->is_store_stub()) { |
1196 if (UpdatePolymorphicIC(state, receiver, name, code, strict_mode)) { | 1142 if (UpdatePolymorphicIC(state, receiver, name, code, strict_mode)) { |
1197 break; | 1143 break; |
1198 } | 1144 } |
1199 CopyICToMegamorphicCache(name); | 1145 CopyICToMegamorphicCache(name); |
1200 UpdateMegamorphicCache(receiver->map(), *name, *code); | 1146 UpdateMegamorphicCache(receiver->map(), *name, *code); |
1201 set_target((strict_mode == kStrictMode) | 1147 set_target((strict_mode == kStrictMode) |
(...skipping 1954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3156 #undef ADDR | 3102 #undef ADDR |
3157 }; | 3103 }; |
3158 | 3104 |
3159 | 3105 |
3160 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 3106 Address IC::AddressFromUtilityId(IC::UtilityId id) { |
3161 return IC_utilities[id]; | 3107 return IC_utilities[id]; |
3162 } | 3108 } |
3163 | 3109 |
3164 | 3110 |
3165 } } // namespace v8::internal | 3111 } } // namespace v8::internal |
OLD | NEW |