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

Side by Side Diff: src/ic.cc

Issue 23578030: Reland Handle non-JSObject heap objects using slow-path IC stub guarded by the map. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments Created 7 years, 3 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') | src/objects.h » ('j') | 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 978 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 receiver_maps->at(current).is_identical_to(new_receiver_map)) { 989 receiver_maps->at(current).is_identical_to(new_receiver_map)) {
990 return false; 990 return false;
991 } 991 }
992 } 992 }
993 receiver_maps->Add(new_receiver_map); 993 receiver_maps->Add(new_receiver_map);
994 return true; 994 return true;
995 } 995 }
996 996
997 997
998 bool IC::UpdatePolymorphicIC(State state, 998 bool IC::UpdatePolymorphicIC(State state,
999 Handle<JSObject> receiver, 999 Handle<HeapObject> receiver,
1000 Handle<String> name, 1000 Handle<String> name,
1001 Handle<Code> code, 1001 Handle<Code> code,
1002 StrictModeFlag strict_mode) { 1002 StrictModeFlag strict_mode) {
1003 if (code->type() == Code::NORMAL) return false; 1003 if (code->type() == Code::NORMAL) return false;
1004 if (target()->ic_state() == MONOMORPHIC && 1004 if (target()->ic_state() == MONOMORPHIC &&
1005 target()->type() == Code::NORMAL) { 1005 target()->type() == Code::NORMAL) {
1006 return false; 1006 return false;
1007 } 1007 }
1008 1008
1009 MapHandleList receiver_maps; 1009 MapHandleList receiver_maps;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1070 Handle<Code> StoreIC::ComputePolymorphicIC(MapHandleList* receiver_maps, 1070 Handle<Code> StoreIC::ComputePolymorphicIC(MapHandleList* receiver_maps,
1071 CodeHandleList* handlers, 1071 CodeHandleList* handlers,
1072 int number_of_valid_maps, 1072 int number_of_valid_maps,
1073 Handle<Name> name, 1073 Handle<Name> name,
1074 StrictModeFlag strict_mode) { 1074 StrictModeFlag strict_mode) {
1075 return isolate()->stub_cache()->ComputePolymorphicStoreIC( 1075 return isolate()->stub_cache()->ComputePolymorphicStoreIC(
1076 receiver_maps, handlers, number_of_valid_maps, name, strict_mode); 1076 receiver_maps, handlers, number_of_valid_maps, name, strict_mode);
1077 } 1077 }
1078 1078
1079 1079
1080 void LoadIC::UpdateMonomorphicIC(Handle<JSObject> receiver, 1080 void LoadIC::UpdateMonomorphicIC(Handle<HeapObject> receiver,
1081 Handle<Code> handler, 1081 Handle<Code> handler,
1082 Handle<String> name, 1082 Handle<String> name,
1083 StrictModeFlag strict_mode) { 1083 StrictModeFlag strict_mode) {
1084 if (handler->type() == Code::NORMAL) return set_target(*handler); 1084 if (handler->is_load_stub()) return set_target(*handler);
1085 Handle<Code> ic = isolate()->stub_cache()->ComputeMonomorphicLoadIC( 1085 Handle<Code> ic = isolate()->stub_cache()->ComputeMonomorphicLoadIC(
1086 receiver, handler, name); 1086 receiver, handler, name);
1087 set_target(*ic); 1087 set_target(*ic);
1088 } 1088 }
1089 1089
1090 1090
1091 void KeyedLoadIC::UpdateMonomorphicIC(Handle<JSObject> receiver, 1091 void KeyedLoadIC::UpdateMonomorphicIC(Handle<HeapObject> receiver,
1092 Handle<Code> handler, 1092 Handle<Code> handler,
1093 Handle<String> name, 1093 Handle<String> name,
1094 StrictModeFlag strict_mode) { 1094 StrictModeFlag strict_mode) {
1095 if (handler->type() == Code::NORMAL) return set_target(*handler); 1095 if (handler->is_keyed_load_stub()) return set_target(*handler);
1096 Handle<Code> ic = isolate()->stub_cache()->ComputeMonomorphicKeyedLoadIC( 1096 Handle<Code> ic = isolate()->stub_cache()->ComputeMonomorphicKeyedLoadIC(
1097 receiver, handler, name); 1097 receiver, handler, name);
1098 set_target(*ic); 1098 set_target(*ic);
1099 } 1099 }
1100 1100
1101 1101
1102 void StoreIC::UpdateMonomorphicIC(Handle<JSObject> receiver, 1102 void StoreIC::UpdateMonomorphicIC(Handle<HeapObject> receiver,
1103 Handle<Code> handler, 1103 Handle<Code> handler,
1104 Handle<String> name, 1104 Handle<String> name,
1105 StrictModeFlag strict_mode) { 1105 StrictModeFlag strict_mode) {
1106 if (handler->type() == Code::NORMAL) return set_target(*handler); 1106 if (handler->is_store_stub()) return set_target(*handler);
1107 Handle<Code> ic = isolate()->stub_cache()->ComputeMonomorphicStoreIC( 1107 Handle<Code> ic = isolate()->stub_cache()->ComputeMonomorphicStoreIC(
1108 receiver, handler, name, strict_mode); 1108 receiver, handler, name, strict_mode);
1109 set_target(*ic); 1109 set_target(*ic);
1110 } 1110 }
1111 1111
1112 1112
1113 void KeyedStoreIC::UpdateMonomorphicIC(Handle<JSObject> receiver, 1113 void KeyedStoreIC::UpdateMonomorphicIC(Handle<HeapObject> receiver,
1114 Handle<Code> handler, 1114 Handle<Code> handler,
1115 Handle<String> name, 1115 Handle<String> name,
1116 StrictModeFlag strict_mode) { 1116 StrictModeFlag strict_mode) {
1117 if (handler->type() == Code::NORMAL) return set_target(*handler); 1117 if (handler->is_keyed_store_stub()) return set_target(*handler);
1118 Handle<Code> ic = isolate()->stub_cache()->ComputeMonomorphicKeyedStoreIC( 1118 Handle<Code> ic = isolate()->stub_cache()->ComputeMonomorphicKeyedStoreIC(
1119 receiver, handler, name, strict_mode); 1119 receiver, handler, name, strict_mode);
1120 set_target(*ic); 1120 set_target(*ic);
1121 } 1121 }
1122 1122
1123 1123
1124 void IC::CopyICToMegamorphicCache(Handle<String> name) { 1124 void IC::CopyICToMegamorphicCache(Handle<String> name) {
1125 MapHandleList receiver_maps; 1125 MapHandleList receiver_maps;
1126 CodeHandleList handlers; 1126 CodeHandleList handlers;
1127 { 1127 {
(...skipping 20 matching lines...) Expand all
1148 : NULL; 1148 : NULL;
1149 1149
1150 return transitioned_map == receiver_map; 1150 return transitioned_map == receiver_map;
1151 } 1151 }
1152 1152
1153 1153
1154 // Since GC may have been invoked, by the time PatchCache is called, |state| is 1154 // Since GC may have been invoked, by the time PatchCache is called, |state| is
1155 // not necessarily equal to target()->state(). 1155 // not necessarily equal to target()->state().
1156 void IC::PatchCache(State state, 1156 void IC::PatchCache(State state,
1157 StrictModeFlag strict_mode, 1157 StrictModeFlag strict_mode,
1158 Handle<JSObject> receiver, 1158 Handle<HeapObject> receiver,
1159 Handle<String> name, 1159 Handle<String> name,
1160 Handle<Code> code) { 1160 Handle<Code> code) {
1161 switch (state) { 1161 switch (state) {
1162 case UNINITIALIZED: 1162 case UNINITIALIZED:
1163 case PREMONOMORPHIC: 1163 case PREMONOMORPHIC:
1164 case MONOMORPHIC_PROTOTYPE_FAILURE: 1164 case MONOMORPHIC_PROTOTYPE_FAILURE:
1165 UpdateMonomorphicIC(receiver, code, name, strict_mode); 1165 UpdateMonomorphicIC(receiver, code, name, strict_mode);
1166 break; 1166 break;
1167 case MONOMORPHIC: 1167 case MONOMORPHIC:
1168 // Only move to megamorphic if the target changes. 1168 // Only move to megamorphic if the target changes.
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
1258 UNREACHABLE(); 1258 UNREACHABLE();
1259 break; 1259 break;
1260 } 1260 }
1261 } 1261 }
1262 1262
1263 1263
1264 void LoadIC::UpdateCaches(LookupResult* lookup, 1264 void LoadIC::UpdateCaches(LookupResult* lookup,
1265 State state, 1265 State state,
1266 Handle<Object> object, 1266 Handle<Object> object,
1267 Handle<String> name) { 1267 Handle<String> name) {
1268 // Bail out if the result is not cacheable. 1268 if (!object->IsHeapObject()) return;
1269 if (!lookup->IsCacheable()) {
1270 set_target(*generic_stub());
1271 return;
1272 }
1273 1269
1274 // TODO(jkummerow): It would be nice to support non-JSObjects in 1270 Handle<HeapObject> receiver = Handle<HeapObject>::cast(object);
1275 // UpdateCaches, then we wouldn't need to go generic here.
1276 if (!object->IsJSObject()) {
1277 set_target(*generic_stub());
1278 return;
1279 }
1280 1271
1281 Handle<JSObject> receiver = Handle<JSObject>::cast(object);
1282 Handle<Code> code; 1272 Handle<Code> code;
1283 if (state == UNINITIALIZED) { 1273 if (state == UNINITIALIZED) {
1284 // This is the first time we execute this inline cache. 1274 // This is the first time we execute this inline cache.
1285 // Set the target to the pre monomorphic stub to delay 1275 // Set the target to the pre monomorphic stub to delay
1286 // setting the monomorphic state. 1276 // setting the monomorphic state.
1287 code = pre_monomorphic_stub(); 1277 code = pre_monomorphic_stub();
1278 } else if (!lookup->IsCacheable()) {
1279 // Bail out if the result is not cacheable.
1280 code = slow_stub();
1281 } else if (!object->IsJSObject()) {
1282 // TODO(jkummerow): It would be nice to support non-JSObjects in
1283 // ComputeLoadHandler, then we wouldn't need to go generic here.
1284 code = slow_stub();
1288 } else { 1285 } else {
1289 code = ComputeLoadHandler(lookup, receiver, name); 1286 code = ComputeLoadHandler(lookup, Handle<JSObject>::cast(receiver), name);
1290 if (code.is_null()) { 1287 if (code.is_null()) code = slow_stub();
1291 set_target(*generic_stub());
1292 return;
1293 }
1294 } 1288 }
1295 1289
1296 PatchCache(state, kNonStrictMode, receiver, name, code); 1290 PatchCache(state, kNonStrictMode, receiver, name, code);
1297 TRACE_IC("LoadIC", name, state, target()); 1291 TRACE_IC("LoadIC", name, state, target());
1298 } 1292 }
1299 1293
1300 1294
1301 void IC::UpdateMegamorphicCache(Map* map, Name* name, Code* code) { 1295 void IC::UpdateMegamorphicCache(Map* map, Name* name, Code* code) {
1302 // Cache code holding map should be consistent with 1296 // Cache code holding map should be consistent with
1303 // GenerateMonomorphicCacheProbe. 1297 // GenerateMonomorphicCacheProbe.
(...skipping 1835 matching lines...) Expand 10 before | Expand all | Expand 10 after
3139 #undef ADDR 3133 #undef ADDR
3140 }; 3134 };
3141 3135
3142 3136
3143 Address IC::AddressFromUtilityId(IC::UtilityId id) { 3137 Address IC::AddressFromUtilityId(IC::UtilityId id) {
3144 return IC_utilities[id]; 3138 return IC_utilities[id];
3145 } 3139 }
3146 3140
3147 3141
3148 } } // namespace v8::internal 3142 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ic.h ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698