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

Side by Side Diff: src/ic.cc

Issue 12521007: Cleanup the copying of ICs to the Megamorphic Code Cache (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 9 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 | « src/ic.h ('k') | 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 992 matching lines...) Expand 10 before | Expand all | Expand 10 after
1003 void KeyedLoadIC::UpdateMonomorphicIC(Handle<JSObject> receiver, 1003 void KeyedLoadIC::UpdateMonomorphicIC(Handle<JSObject> receiver,
1004 Handle<Code> handler, 1004 Handle<Code> handler,
1005 Handle<String> name) { 1005 Handle<String> name) {
1006 if (handler->type() == Code::NORMAL) return set_target(*handler); 1006 if (handler->type() == Code::NORMAL) return set_target(*handler);
1007 Handle<Code> ic = isolate()->stub_cache()->ComputeKeyedMonomorphicIC( 1007 Handle<Code> ic = isolate()->stub_cache()->ComputeKeyedMonomorphicIC(
1008 receiver, handler, name); 1008 receiver, handler, name);
1009 set_target(*ic); 1009 set_target(*ic);
1010 } 1010 }
1011 1011
1012 1012
1013 void IC::CopyICToMegamorphicCache(Handle<String> name) {
1014 MapHandleList receiver_maps;
1015 CodeHandleList handlers;
1016 {
1017 AssertNoAllocation no_gc;
1018 target()->FindAllMaps(&receiver_maps);
1019 target()->FindAllCode(&handlers, receiver_maps.length());
1020 }
1021 for (int i = 0; i < receiver_maps.length(); i++) {
1022 UpdateMegamorphicCache(*receiver_maps.at(i), *name, *handlers.at(i));
1023 }
1024 }
1025
1026
1013 // Since GC may have been invoked, by the time PatchCache is called, |state| is 1027 // Since GC may have been invoked, by the time PatchCache is called, |state| is
1014 // not necessarily equal to target()->state(). 1028 // not necessarily equal to target()->state().
1015 void IC::PatchCache(State state, 1029 void IC::PatchCache(State state,
1016 StrictModeFlag strict_mode, 1030 StrictModeFlag strict_mode,
1017 Handle<JSObject> receiver, 1031 Handle<JSObject> receiver,
1018 Handle<String> name, 1032 Handle<String> name,
1019 Handle<Code> code) { 1033 Handle<Code> code) {
1020 switch (state) { 1034 switch (state) {
1021 case UNINITIALIZED: 1035 case UNINITIALIZED:
1022 case PREMONOMORPHIC: 1036 case PREMONOMORPHIC:
1023 case MONOMORPHIC_PROTOTYPE_FAILURE: 1037 case MONOMORPHIC_PROTOTYPE_FAILURE:
1024 UpdateMonomorphicIC(receiver, code, name); 1038 UpdateMonomorphicIC(receiver, code, name);
1025 break; 1039 break;
1026 case MONOMORPHIC: 1040 case MONOMORPHIC:
1027 // Only move to megamorphic if the target changes. 1041 // Only move to megamorphic if the target changes.
1028 if (target() != *code) { 1042 if (target() != *code) {
1029 if (target()->is_load_stub()) { 1043 if (target()->is_load_stub()) {
1030 if (UpdatePolymorphicIC(state, strict_mode, receiver, name, code)) { 1044 if (UpdatePolymorphicIC(state, strict_mode, receiver, name, code)) {
1031 break; 1045 break;
1032 } 1046 }
1033 } 1047 }
1034 if (target()->type() != Code::NORMAL) { 1048 if (target()->type() != Code::NORMAL) {
1035 // We are transitioning from monomorphic to megamorphic case. Place 1049 if (target()->is_load_stub()) {
1036 // the stub compiled for the receiver into stub cache. 1050 CopyICToMegamorphicCache(name);
1037 Map* map; 1051 } else {
1038 Code* handler; 1052 Code* handler = target();
1039 { 1053 Map* map = handler->FindFirstMap();
1040 AssertNoAllocation no_gc;
1041 map = target()->FindFirstMap();
1042 if (map != NULL) { 1054 if (map != NULL) {
1043 if (target()->is_load_stub()) { 1055 UpdateMegamorphicCache(map, *name, target());
Jakob Kummerow 2013/03/07 11:26:40 You can s/target()/handler/ here.
Toon Verwaest 2013/03/11 15:11:19 Done.
1044 handler = target()->FindFirstCode();
1045 } else {
1046 handler = target();
1047 }
1048 } else {
1049 // Avoid compiler warnings.
1050 handler = NULL;
1051 } 1056 }
1052 } 1057 }
1053 if (handler != NULL) {
1054 UpdateMegamorphicCache(map, *name, handler);
1055 }
1056 } 1058 }
1059
1057 UpdateMegamorphicCache(receiver->map(), *name, *code); 1060 UpdateMegamorphicCache(receiver->map(), *name, *code);
1058 set_target((strict_mode == kStrictMode) 1061 set_target((strict_mode == kStrictMode)
1059 ? *megamorphic_stub_strict() 1062 ? *megamorphic_stub_strict()
1060 : *megamorphic_stub()); 1063 : *megamorphic_stub());
1061 } 1064 }
1062 break; 1065 break;
1063 case MEGAMORPHIC: 1066 case MEGAMORPHIC:
1064 // Update the stub cache. 1067 // Update the stub cache.
1065 UpdateMegamorphicCache(receiver->map(), *name, *code); 1068 UpdateMegamorphicCache(receiver->map(), *name, *code);
1066 break; 1069 break;
1067 case POLYMORPHIC: 1070 case POLYMORPHIC:
1068 if (target()->is_load_stub()) { 1071 if (target()->is_load_stub()) {
1069 if (UpdatePolymorphicIC(state, strict_mode, receiver, name, code)) { 1072 if (UpdatePolymorphicIC(state, strict_mode, receiver, name, code)) {
1070 break; 1073 break;
1071 } 1074 }
1072 MapHandleList receiver_maps; 1075 CopyICToMegamorphicCache(name);
1073 CodeHandleList handlers;
1074 {
1075 AssertNoAllocation no_gc;
1076 target()->FindAllMaps(&receiver_maps);
1077 target()->FindAllCode(&handlers, receiver_maps.length());
1078 }
1079 for (int i = 0; i < receiver_maps.length(); i++) {
1080 UpdateMegamorphicCache(*receiver_maps.at(i), *name, *handlers.at(i));
1081 }
1082 UpdateMegamorphicCache(receiver->map(), *name, *code); 1076 UpdateMegamorphicCache(receiver->map(), *name, *code);
1083 set_target(*megamorphic_stub()); 1077 set_target(*megamorphic_stub());
1084 } else { 1078 } else {
1085 // When trying to patch a polymorphic keyed load/store element stub 1079 // When trying to patch a polymorphic keyed load/store element stub
1086 // with anything other than another polymorphic stub, go generic. 1080 // with anything other than another polymorphic stub, go generic.
1087 set_target((strict_mode == kStrictMode) 1081 set_target((strict_mode == kStrictMode)
1088 ? *generic_stub_strict() 1082 ? *generic_stub_strict()
1089 : *generic_stub()); 1083 : *generic_stub());
1090 } 1084 }
1091 break; 1085 break;
(...skipping 1582 matching lines...) Expand 10 before | Expand all | Expand 10 after
2674 #undef ADDR 2668 #undef ADDR
2675 }; 2669 };
2676 2670
2677 2671
2678 Address IC::AddressFromUtilityId(IC::UtilityId id) { 2672 Address IC::AddressFromUtilityId(IC::UtilityId id) {
2679 return IC_utilities[id]; 2673 return IC_utilities[id];
2680 } 2674 }
2681 2675
2682 2676
2683 } } // namespace v8::internal 2677 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ic.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698