| 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/ic/ic.h" | 5 #include "src/ic/ic.h" |
| 6 | 6 |
| 7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
| 8 #include "src/api-arguments-inl.h" | 8 #include "src/api-arguments-inl.h" |
| 9 #include "src/api.h" | 9 #include "src/api.h" |
| 10 #include "src/arguments.h" | 10 #include "src/arguments.h" |
| (...skipping 1336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1347 } | 1347 } |
| 1348 | 1348 |
| 1349 void KeyedLoadIC::UpdateLoadElement(Handle<HeapObject> receiver) { | 1349 void KeyedLoadIC::UpdateLoadElement(Handle<HeapObject> receiver) { |
| 1350 Handle<Map> receiver_map(receiver->map(), isolate()); | 1350 Handle<Map> receiver_map(receiver->map(), isolate()); |
| 1351 DCHECK(receiver_map->instance_type() != JS_VALUE_TYPE && | 1351 DCHECK(receiver_map->instance_type() != JS_VALUE_TYPE && |
| 1352 receiver_map->instance_type() != JS_PROXY_TYPE); // Checked by caller. | 1352 receiver_map->instance_type() != JS_PROXY_TYPE); // Checked by caller. |
| 1353 MapHandleList target_receiver_maps; | 1353 MapHandleList target_receiver_maps; |
| 1354 TargetMaps(&target_receiver_maps); | 1354 TargetMaps(&target_receiver_maps); |
| 1355 | 1355 |
| 1356 if (target_receiver_maps.length() == 0) { | 1356 if (target_receiver_maps.length() == 0) { |
| 1357 Handle<Code> handler = | 1357 Handle<Object> handler = |
| 1358 ElementHandlerCompiler::GetKeyedLoadHandler(receiver_map, isolate()); | 1358 ElementHandlerCompiler::GetKeyedLoadHandler(receiver_map, isolate()); |
| 1359 return ConfigureVectorState(Handle<Name>(), receiver_map, handler); | 1359 return ConfigureVectorState(Handle<Name>(), receiver_map, handler); |
| 1360 } | 1360 } |
| 1361 | 1361 |
| 1362 for (int i = 0; i < target_receiver_maps.length(); i++) { | 1362 for (int i = 0; i < target_receiver_maps.length(); i++) { |
| 1363 Handle<Map> map = target_receiver_maps.at(i); | 1363 Handle<Map> map = target_receiver_maps.at(i); |
| 1364 if (map.is_null()) continue; | 1364 if (map.is_null()) continue; |
| 1365 if (map->instance_type() == JS_VALUE_TYPE) { | 1365 if (map->instance_type() == JS_VALUE_TYPE) { |
| 1366 TRACE_GENERIC_IC(isolate(), "KeyedLoadIC", "JSValue"); | 1366 TRACE_GENERIC_IC(isolate(), "KeyedLoadIC", "JSValue"); |
| 1367 return; | 1367 return; |
| 1368 } | 1368 } |
| 1369 if (map->instance_type() == JS_PROXY_TYPE) { | 1369 if (map->instance_type() == JS_PROXY_TYPE) { |
| 1370 TRACE_GENERIC_IC(isolate(), "KeyedLoadIC", "JSProxy"); | 1370 TRACE_GENERIC_IC(isolate(), "KeyedLoadIC", "JSProxy"); |
| 1371 return; | 1371 return; |
| 1372 } | 1372 } |
| 1373 } | 1373 } |
| 1374 | 1374 |
| 1375 // The first time a receiver is seen that is a transitioned version of the | 1375 // The first time a receiver is seen that is a transitioned version of the |
| 1376 // previous monomorphic receiver type, assume the new ElementsKind is the | 1376 // previous monomorphic receiver type, assume the new ElementsKind is the |
| 1377 // monomorphic type. This benefits global arrays that only transition | 1377 // monomorphic type. This benefits global arrays that only transition |
| 1378 // once, and all call sites accessing them are faster if they remain | 1378 // once, and all call sites accessing them are faster if they remain |
| 1379 // monomorphic. If this optimistic assumption is not true, the IC will | 1379 // monomorphic. If this optimistic assumption is not true, the IC will |
| 1380 // miss again and it will become polymorphic and support both the | 1380 // miss again and it will become polymorphic and support both the |
| 1381 // untransitioned and transitioned maps. | 1381 // untransitioned and transitioned maps. |
| 1382 if (state() == MONOMORPHIC && !receiver->IsString() && | 1382 if (state() == MONOMORPHIC && !receiver->IsString() && |
| 1383 IsMoreGeneralElementsKindTransition( | 1383 IsMoreGeneralElementsKindTransition( |
| 1384 target_receiver_maps.at(0)->elements_kind(), | 1384 target_receiver_maps.at(0)->elements_kind(), |
| 1385 Handle<JSObject>::cast(receiver)->GetElementsKind())) { | 1385 Handle<JSObject>::cast(receiver)->GetElementsKind())) { |
| 1386 Handle<Code> handler = | 1386 Handle<Object> handler = |
| 1387 ElementHandlerCompiler::GetKeyedLoadHandler(receiver_map, isolate()); | 1387 ElementHandlerCompiler::GetKeyedLoadHandler(receiver_map, isolate()); |
| 1388 return ConfigureVectorState(Handle<Name>(), receiver_map, handler); | 1388 return ConfigureVectorState(Handle<Name>(), receiver_map, handler); |
| 1389 } | 1389 } |
| 1390 | 1390 |
| 1391 DCHECK(state() != GENERIC); | 1391 DCHECK(state() != GENERIC); |
| 1392 | 1392 |
| 1393 // Determine the list of receiver maps that this call site has seen, | 1393 // Determine the list of receiver maps that this call site has seen, |
| 1394 // adding the map that was just encountered. | 1394 // adding the map that was just encountered. |
| 1395 if (!AddOneReceiverMapIfMissing(&target_receiver_maps, receiver_map)) { | 1395 if (!AddOneReceiverMapIfMissing(&target_receiver_maps, receiver_map)) { |
| 1396 // If the miss wasn't due to an unseen map, a polymorphic stub | 1396 // If the miss wasn't due to an unseen map, a polymorphic stub |
| (...skipping 1642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3039 DCHECK_EQ(FeedbackVectorSlotKind::KEYED_LOAD_IC, | 3039 DCHECK_EQ(FeedbackVectorSlotKind::KEYED_LOAD_IC, |
| 3040 vector->GetKind(vector_slot)); | 3040 vector->GetKind(vector_slot)); |
| 3041 KeyedLoadICNexus nexus(vector, vector_slot); | 3041 KeyedLoadICNexus nexus(vector, vector_slot); |
| 3042 KeyedLoadIC ic(IC::EXTRA_CALL_FRAME, isolate, &nexus); | 3042 KeyedLoadIC ic(IC::EXTRA_CALL_FRAME, isolate, &nexus); |
| 3043 ic.UpdateState(receiver, key); | 3043 ic.UpdateState(receiver, key); |
| 3044 RETURN_RESULT_OR_FAILURE(isolate, ic.Load(receiver, key)); | 3044 RETURN_RESULT_OR_FAILURE(isolate, ic.Load(receiver, key)); |
| 3045 } | 3045 } |
| 3046 } | 3046 } |
| 3047 } // namespace internal | 3047 } // namespace internal |
| 3048 } // namespace v8 | 3048 } // namespace v8 |
| OLD | NEW |