Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(177)

Side by Side Diff: src/ic.cc

Issue 19005002: Allow NORMAL ICs to go polymorphic. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Remove debug break Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 960 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 receiver_maps->Add(new_receiver_map); 971 receiver_maps->Add(new_receiver_map);
972 return true; 972 return true;
973 } 973 }
974 974
975 975
976 bool IC::UpdatePolymorphicIC(State state, 976 bool IC::UpdatePolymorphicIC(State state,
977 Handle<JSObject> receiver, 977 Handle<JSObject> receiver,
978 Handle<String> name, 978 Handle<String> name,
979 Handle<Code> code, 979 Handle<Code> code,
980 StrictModeFlag strict_mode) { 980 StrictModeFlag strict_mode) {
981 if (code->type() == Code::NORMAL) return false;
982 if (target()->ic_state() == MONOMORPHIC &&
983 target()->type() == Code::NORMAL) {
984 return false;
985 }
986
987 MapHandleList receiver_maps; 981 MapHandleList receiver_maps;
988 CodeHandleList handlers; 982 CodeHandleList handlers;
989 983
990 int number_of_valid_maps; 984 int number_of_valid_maps;
991 int handler_to_overwrite = -1; 985 int handler_to_overwrite = -1;
992 Handle<Map> new_receiver_map(receiver->map()); 986 Handle<Map> new_receiver_map(receiver->map());
993 { 987 {
994 DisallowHeapAllocation no_gc; 988 DisallowHeapAllocation no_gc;
995 target()->FindAllMaps(&receiver_maps); 989 if (target()->ic_state() == POLYMORPHIC ||
990 (target()->ic_state() == MONOMORPHIC &&
991 target()->type() != Code::NORMAL)) {
992 target()->FindAllMaps(&receiver_maps);
993 }
994
996 int number_of_maps = receiver_maps.length(); 995 int number_of_maps = receiver_maps.length();
997 number_of_valid_maps = number_of_maps; 996 number_of_valid_maps = number_of_maps;
998 997
999 for (int i = 0; i < number_of_maps; i++) { 998 for (int i = 0; i < number_of_maps; i++) {
1000 Handle<Map> map = receiver_maps.at(i); 999 Handle<Map> map = receiver_maps.at(i);
1001 // Filter out deprecated maps to ensure its instances get migrated. 1000 // Filter out deprecated maps to ensure its instances get migrated.
1002 if (map->is_deprecated()) { 1001 if (map->is_deprecated()) {
1003 number_of_valid_maps--; 1002 number_of_valid_maps--;
1004 // If the receiver map is already in the polymorphic IC, this indicates 1003 // If the receiver map is already in the polymorphic IC, this indicates
1005 // there was a prototoype chain failure. In that case, just overwrite the 1004 // there was a prototoype chain failure. In that case, just overwrite the
1006 // handler. 1005 // handler.
1007 } else if (map.is_identical_to(new_receiver_map)) { 1006 } else if (map.is_identical_to(new_receiver_map)) {
1008 number_of_valid_maps--; 1007 number_of_valid_maps--;
1009 handler_to_overwrite = i; 1008 handler_to_overwrite = i;
1010 } 1009 }
1011 } 1010 }
1012 1011
1013 if (number_of_valid_maps >= 4) return false; 1012 if (number_of_valid_maps >= 4) return false;
1014 1013
1015 // Only allow 0 maps in case target() was reset to UNINITIALIZED by the GC. 1014 if (number_of_maps > 0) {
1016 // In that case, allow the IC to go back monomorphic. 1015 target()->FindAllCode(&handlers, receiver_maps.length());
1017 if (number_of_maps == 0 && target()->ic_state() != UNINITIALIZED) {
1018 return false;
1019 } 1016 }
1020 target()->FindAllCode(&handlers, receiver_maps.length());
1021 } 1017 }
1022 1018
1023 number_of_valid_maps++; 1019 number_of_valid_maps++;
1024 if (handler_to_overwrite >= 0) { 1020 if (handler_to_overwrite >= 0) {
1025 handlers.Set(handler_to_overwrite, code); 1021 handlers.Set(handler_to_overwrite, code);
1026 } else { 1022 } else {
1027 receiver_maps.Add(new_receiver_map); 1023 receiver_maps.Add(new_receiver_map);
1028 handlers.Add(code); 1024 handlers.Add(code);
1029 } 1025 }
1030 1026
(...skipping 2050 matching lines...) Expand 10 before | Expand all | Expand 10 after
3081 #undef ADDR 3077 #undef ADDR
3082 }; 3078 };
3083 3079
3084 3080
3085 Address IC::AddressFromUtilityId(IC::UtilityId id) { 3081 Address IC::AddressFromUtilityId(IC::UtilityId id) {
3086 return IC_utilities[id]; 3082 return IC_utilities[id];
3087 } 3083 }
3088 3084
3089 3085
3090 } } // namespace v8::internal 3086 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698