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

Side by Side Diff: src/ic.cc

Issue 167303005: Track field types. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Support transitions in LookupResult. Created 6 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
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 1153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1164 PropertyDetails target_details = lookup->GetTransitionDetails(); 1164 PropertyDetails target_details = lookup->GetTransitionDetails();
1165 if (target_details.IsReadOnly()) return false; 1165 if (target_details.IsReadOnly()) return false;
1166 1166
1167 // If the value that's being stored does not fit in the field that the 1167 // If the value that's being stored does not fit in the field that the
1168 // instance would transition to, create a new transition that fits the value. 1168 // instance would transition to, create a new transition that fits the value.
1169 // This has to be done before generating the IC, since that IC will embed the 1169 // This has to be done before generating the IC, since that IC will embed the
1170 // transition target. 1170 // transition target.
1171 // Ensure the instance and its map were migrated before trying to update the 1171 // Ensure the instance and its map were migrated before trying to update the
1172 // transition target. 1172 // transition target.
1173 ASSERT(!receiver->map()->is_deprecated()); 1173 ASSERT(!receiver->map()->is_deprecated());
1174 Handle<HeapType> value_type = FLAG_track_field_types
1175 ? HeapType::OfCurrently(value, lookup->isolate())
1176 : HeapType::Any(lookup->isolate());
1177 Handle<Map> target(lookup->GetTransitionTarget());
1174 if (!value->FitsRepresentation(target_details.representation())) { 1178 if (!value->FitsRepresentation(target_details.representation())) {
1175 Handle<Map> target(lookup->GetTransitionTarget());
1176 Map::GeneralizeRepresentation( 1179 Map::GeneralizeRepresentation(
1177 target, target->LastAdded(), 1180 target, target->LastAdded(),
1178 value->OptimalRepresentation(), FORCE_FIELD); 1181 value->OptimalRepresentation(),
1182 value_type, FORCE_FIELD);
1179 // Lookup the transition again since the transition tree may have changed 1183 // Lookup the transition again since the transition tree may have changed
1180 // entirely by the migration above. 1184 // entirely by the migration above.
1181 receiver->map()->LookupTransition(*holder, *name, lookup); 1185 receiver->map()->LookupTransition(*holder, *name, lookup);
1182 if (!lookup->IsTransition()) return false; 1186 if (!lookup->IsTransition()) return false;
1183 ic->MarkMonomorphicPrototypeFailure(); 1187 ic->MarkMonomorphicPrototypeFailure();
1188 } else if (target_details.type() == FIELD &&
1189 target_details.representation().IsHeapObject()) {
1190 int descriptor_number = target->LastAdded();
1191 Handle<DescriptorArray> target_descriptors(target->instance_descriptors());
1192 Handle<HeapType> field_type(target_descriptors->GetFieldType(
1193 descriptor_number), lookup->isolate());
1194 if (!value_type->IsCurrently(field_type)) {
1195 if (!field_type->IsCurrently(value_type)) {
1196 value_type = HeapType::Any(lookup->isolate());
1197 }
1198 if (FLAG_trace_track_field_types) {
1199 #ifdef OBJECT_PRINT
1200 PrintF("[Updating type of field ");
1201 name->Print();
1202 PrintF(" in transition map ");
1203 target->ShortPrint();
1204 PrintF(": ");
1205 field_type->TypePrint(stdout);
1206 PrintF(" -> ");
1207 value_type->TypePrint(stdout);
1208 PrintF("]\n");
1209 #endif
1210 }
1211 target->UpdateFieldType(descriptor_number, *value_type);
1212 ic->MarkMonomorphicPrototypeFailure();
1213 }
1184 } 1214 }
1185 return true; 1215 return true;
1186 } 1216 }
1187 1217
1188 1218
1189 MaybeObject* StoreIC::Store(Handle<Object> object, 1219 MaybeObject* StoreIC::Store(Handle<Object> object,
1190 Handle<String> name, 1220 Handle<String> name,
1191 Handle<Object> value, 1221 Handle<Object> value,
1192 JSReceiver::StoreFromKeyed store_mode) { 1222 JSReceiver::StoreFromKeyed store_mode) {
1193 if (MigrateDeprecated(object) || object->IsJSProxy()) { 1223 if (MigrateDeprecated(object) || object->IsJSProxy()) {
(...skipping 1639 matching lines...) Expand 10 before | Expand all | Expand 10 after
2833 #undef ADDR 2863 #undef ADDR
2834 }; 2864 };
2835 2865
2836 2866
2837 Address IC::AddressFromUtilityId(IC::UtilityId id) { 2867 Address IC::AddressFromUtilityId(IC::UtilityId id) {
2838 return IC_utilities[id]; 2868 return IC_utilities[id];
2839 } 2869 }
2840 2870
2841 2871
2842 } } // namespace v8::internal 2872 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698