Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
| 8 #include "src/api.h" | 8 #include "src/api.h" |
| 9 #include "src/arguments.h" | 9 #include "src/arguments.h" |
| 10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
| (...skipping 1209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1220 key = Handle<Smi>(Smi::FromInt(int_value), isolate); | 1220 key = Handle<Smi>(Smi::FromInt(int_value), isolate); |
| 1221 } | 1221 } |
| 1222 } | 1222 } |
| 1223 } else if (key->IsUndefined()) { | 1223 } else if (key->IsUndefined()) { |
| 1224 key = isolate->factory()->undefined_string(); | 1224 key = isolate->factory()->undefined_string(); |
| 1225 } | 1225 } |
| 1226 return key; | 1226 return key; |
| 1227 } | 1227 } |
| 1228 | 1228 |
| 1229 | 1229 |
| 1230 Handle<Code> KeyedLoadIC::LoadElementStub(Handle<HeapObject> receiver) { | 1230 Handle<Code> KeyedLoadIC::LoadElementStub(Handle<HeapObject> receiver, |
| 1231 Handle<Object> key) { | |
| 1231 Handle<Map> receiver_map(receiver->map(), isolate()); | 1232 Handle<Map> receiver_map(receiver->map(), isolate()); |
| 1232 MapHandleList target_receiver_maps; | 1233 MapHandleList target_receiver_maps; |
| 1233 TargetMaps(&target_receiver_maps); | 1234 TargetMaps(&target_receiver_maps); |
| 1234 | 1235 |
| 1236 IcCheckType key_type = key->IsString() ? PROPERTY : ELEMENT; | |
|
Jakob Kummerow
2014/12/10 15:21:18
This should be key->IsName(). Then again the key i
| |
| 1237 | |
| 1235 if (target_receiver_maps.length() == 0) { | 1238 if (target_receiver_maps.length() == 0) { |
| 1236 return PropertyICCompiler::ComputeKeyedLoadMonomorphic(receiver_map); | 1239 return PropertyICCompiler::ComputeKeyedLoadMonomorphic(receiver_map, |
| 1240 key_type); | |
| 1237 } | 1241 } |
| 1238 | 1242 |
| 1239 // The first time a receiver is seen that is a transitioned version of the | 1243 // The first time a receiver is seen that is a transitioned version of the |
| 1240 // previous monomorphic receiver type, assume the new ElementsKind is the | 1244 // previous monomorphic receiver type, assume the new ElementsKind is the |
| 1241 // monomorphic type. This benefits global arrays that only transition | 1245 // monomorphic type. This benefits global arrays that only transition |
| 1242 // once, and all call sites accessing them are faster if they remain | 1246 // once, and all call sites accessing them are faster if they remain |
| 1243 // monomorphic. If this optimistic assumption is not true, the IC will | 1247 // monomorphic. If this optimistic assumption is not true, the IC will |
| 1244 // miss again and it will become polymorphic and support both the | 1248 // miss again and it will become polymorphic and support both the |
| 1245 // untransitioned and transitioned maps. | 1249 // untransitioned and transitioned maps. |
| 1246 if (state() == MONOMORPHIC && !receiver->IsString() && | 1250 if (state() == MONOMORPHIC && !receiver->IsString() && |
| 1247 IsMoreGeneralElementsKindTransition( | 1251 IsMoreGeneralElementsKindTransition( |
| 1248 target_receiver_maps.at(0)->elements_kind(), | 1252 target_receiver_maps.at(0)->elements_kind(), |
| 1249 Handle<JSObject>::cast(receiver)->GetElementsKind())) { | 1253 Handle<JSObject>::cast(receiver)->GetElementsKind())) { |
| 1250 return PropertyICCompiler::ComputeKeyedLoadMonomorphic(receiver_map); | 1254 return PropertyICCompiler::ComputeKeyedLoadMonomorphic(receiver_map, |
| 1255 key_type); | |
| 1251 } | 1256 } |
| 1252 | 1257 |
| 1253 DCHECK(state() != GENERIC); | 1258 DCHECK(state() != GENERIC); |
| 1254 | 1259 |
| 1255 // Determine the list of receiver maps that this call site has seen, | 1260 // Determine the list of receiver maps that this call site has seen, |
| 1256 // adding the map that was just encountered. | 1261 // adding the map that was just encountered. |
| 1257 if (!AddOneReceiverMapIfMissing(&target_receiver_maps, receiver_map)) { | 1262 if (!AddOneReceiverMapIfMissing(&target_receiver_maps, receiver_map)) { |
| 1258 // If the miss wasn't due to an unseen map, a polymorphic stub | 1263 // If the miss wasn't due to an unseen map, a polymorphic stub |
| 1259 // won't help, use the generic stub. | 1264 // won't help, use the generic stub. |
| 1260 TRACE_GENERIC_IC(isolate(), "KeyedLoadIC", "same map added twice"); | 1265 TRACE_GENERIC_IC(isolate(), "KeyedLoadIC", "same map added twice"); |
| 1261 return generic_stub(); | 1266 return generic_stub(); |
| 1262 } | 1267 } |
| 1263 | 1268 |
| 1264 // If the maximum number of receiver maps has been exceeded, use the generic | 1269 // If the maximum number of receiver maps has been exceeded, use the generic |
| 1265 // version of the IC. | 1270 // version of the IC. |
| 1266 if (target_receiver_maps.length() > kMaxKeyedPolymorphism) { | 1271 if (target_receiver_maps.length() > kMaxKeyedPolymorphism) { |
| 1267 TRACE_GENERIC_IC(isolate(), "KeyedLoadIC", "max polymorph exceeded"); | 1272 TRACE_GENERIC_IC(isolate(), "KeyedLoadIC", "max polymorph exceeded"); |
| 1268 return generic_stub(); | 1273 return generic_stub(); |
| 1269 } | 1274 } |
| 1270 | 1275 |
| 1271 return PropertyICCompiler::ComputeKeyedLoadPolymorphic(&target_receiver_maps); | 1276 return PropertyICCompiler::ComputeKeyedLoadPolymorphic(&target_receiver_maps, |
| 1277 key_type); | |
| 1272 } | 1278 } |
| 1273 | 1279 |
| 1274 | 1280 |
| 1275 MaybeHandle<Object> KeyedLoadIC::Load(Handle<Object> object, | 1281 MaybeHandle<Object> KeyedLoadIC::Load(Handle<Object> object, |
| 1276 Handle<Object> key) { | 1282 Handle<Object> key) { |
| 1277 if (MigrateDeprecated(object)) { | 1283 if (MigrateDeprecated(object)) { |
| 1278 Handle<Object> result; | 1284 Handle<Object> result; |
| 1279 ASSIGN_RETURN_ON_EXCEPTION( | 1285 ASSIGN_RETURN_ON_EXCEPTION( |
| 1280 isolate(), result, Runtime::GetObjectProperty(isolate(), object, key), | 1286 isolate(), result, Runtime::GetObjectProperty(isolate(), object, key), |
| 1281 Object); | 1287 Object); |
| 1282 return result; | 1288 return result; |
| 1283 } | 1289 } |
| 1284 | 1290 |
| 1285 Handle<Object> load_handle; | 1291 Handle<Object> load_handle; |
| 1286 Handle<Code> stub = generic_stub(); | 1292 Handle<Code> stub = generic_stub(); |
| 1287 | 1293 |
| 1288 // Check for non-string values that can be converted into an | 1294 // Check for non-string values that can be converted into an |
| 1289 // internalized string directly or is representable as a smi. | 1295 // internalized string directly or is representable as a smi. |
| 1290 key = TryConvertKey(key, isolate()); | 1296 key = TryConvertKey(key, isolate()); |
| 1291 | 1297 |
| 1292 if (key->IsInternalizedString() || key->IsSymbol()) { | 1298 if (key->IsInternalizedString() || key->IsSymbol()) { |
| 1293 ASSIGN_RETURN_ON_EXCEPTION(isolate(), load_handle, | 1299 ASSIGN_RETURN_ON_EXCEPTION(isolate(), load_handle, |
| 1294 LoadIC::Load(object, Handle<Name>::cast(key)), | 1300 LoadIC::Load(object, Handle<Name>::cast(key)), |
| 1295 Object); | 1301 Object); |
| 1296 } else if (FLAG_use_ic && !object->IsAccessCheckNeeded()) { | 1302 } else if (FLAG_use_ic && !object->IsAccessCheckNeeded()) { |
| 1297 if (object->IsJSObject() || (object->IsString() && key->IsNumber())) { | 1303 if (object->IsJSObject() || (object->IsString() && key->IsNumber())) { |
| 1298 Handle<HeapObject> receiver = Handle<HeapObject>::cast(object); | 1304 Handle<HeapObject> receiver = Handle<HeapObject>::cast(object); |
| 1299 if (object->IsString() || !Object::ToSmi(isolate(), key).is_null()) { | 1305 if (object->IsString() || !Object::ToSmi(isolate(), key).is_null()) { |
| 1300 stub = LoadElementStub(receiver); | 1306 stub = LoadElementStub(receiver, key); |
|
Jakob Kummerow
2014/12/10 15:21:18
Look at the conditions above. We only get here if
| |
| 1301 } | 1307 } |
| 1302 } | 1308 } |
| 1303 } | 1309 } |
| 1304 | 1310 |
| 1305 if (!is_target_set()) { | 1311 if (!is_target_set()) { |
| 1306 Code* generic = *generic_stub(); | 1312 Code* generic = *generic_stub(); |
| 1307 if (*stub == generic) { | 1313 if (*stub == generic) { |
| 1308 TRACE_GENERIC_IC(isolate(), "KeyedLoadIC", "set generic"); | 1314 TRACE_GENERIC_IC(isolate(), "KeyedLoadIC", "set generic"); |
| 1309 } | 1315 } |
| 1310 set_target(*stub); | 1316 set_target(*stub); |
| (...skipping 1470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2781 static const Address IC_utilities[] = { | 2787 static const Address IC_utilities[] = { |
| 2782 #define ADDR(name) FUNCTION_ADDR(name), | 2788 #define ADDR(name) FUNCTION_ADDR(name), |
| 2783 IC_UTIL_LIST(ADDR) NULL | 2789 IC_UTIL_LIST(ADDR) NULL |
| 2784 #undef ADDR | 2790 #undef ADDR |
| 2785 }; | 2791 }; |
| 2786 | 2792 |
| 2787 | 2793 |
| 2788 Address IC::AddressFromUtilityId(IC::UtilityId id) { return IC_utilities[id]; } | 2794 Address IC::AddressFromUtilityId(IC::UtilityId id) { return IC_utilities[id]; } |
| 2789 } | 2795 } |
| 2790 } // namespace v8::internal | 2796 } // namespace v8::internal |
| OLD | NEW |