| 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 1310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1321 } | 1321 } |
| 1322 | 1322 |
| 1323 void KeyedLoadIC::UpdateLoadElement(Handle<HeapObject> receiver) { | 1323 void KeyedLoadIC::UpdateLoadElement(Handle<HeapObject> receiver) { |
| 1324 Handle<Map> receiver_map(receiver->map(), isolate()); | 1324 Handle<Map> receiver_map(receiver->map(), isolate()); |
| 1325 DCHECK(receiver_map->instance_type() != JS_VALUE_TYPE && | 1325 DCHECK(receiver_map->instance_type() != JS_VALUE_TYPE && |
| 1326 receiver_map->instance_type() != JS_PROXY_TYPE); // Checked by caller. | 1326 receiver_map->instance_type() != JS_PROXY_TYPE); // Checked by caller. |
| 1327 MapHandleList target_receiver_maps; | 1327 MapHandleList target_receiver_maps; |
| 1328 TargetMaps(&target_receiver_maps); | 1328 TargetMaps(&target_receiver_maps); |
| 1329 | 1329 |
| 1330 if (target_receiver_maps.length() == 0) { | 1330 if (target_receiver_maps.length() == 0) { |
| 1331 Handle<Code> handler = | 1331 Handle<Object> handler = |
| 1332 ElementHandlerCompiler::GetKeyedLoadHandler(receiver_map, isolate()); | 1332 ElementHandlerCompiler::GetKeyedLoadHandler(receiver_map, isolate()); |
| 1333 return ConfigureVectorState(Handle<Name>(), receiver_map, handler); | 1333 return ConfigureVectorState(Handle<Name>(), receiver_map, handler); |
| 1334 } | 1334 } |
| 1335 | 1335 |
| 1336 for (int i = 0; i < target_receiver_maps.length(); i++) { | 1336 for (int i = 0; i < target_receiver_maps.length(); i++) { |
| 1337 Handle<Map> map = target_receiver_maps.at(i); | 1337 Handle<Map> map = target_receiver_maps.at(i); |
| 1338 if (map.is_null()) continue; | 1338 if (map.is_null()) continue; |
| 1339 if (map->instance_type() == JS_VALUE_TYPE) { | 1339 if (map->instance_type() == JS_VALUE_TYPE) { |
| 1340 TRACE_GENERIC_IC(isolate(), "KeyedLoadIC", "JSValue"); | 1340 TRACE_GENERIC_IC(isolate(), "KeyedLoadIC", "JSValue"); |
| 1341 return; | 1341 return; |
| 1342 } | 1342 } |
| 1343 if (map->instance_type() == JS_PROXY_TYPE) { | 1343 if (map->instance_type() == JS_PROXY_TYPE) { |
| 1344 TRACE_GENERIC_IC(isolate(), "KeyedLoadIC", "JSProxy"); | 1344 TRACE_GENERIC_IC(isolate(), "KeyedLoadIC", "JSProxy"); |
| 1345 return; | 1345 return; |
| 1346 } | 1346 } |
| 1347 } | 1347 } |
| 1348 | 1348 |
| 1349 // The first time a receiver is seen that is a transitioned version of the | 1349 // The first time a receiver is seen that is a transitioned version of the |
| 1350 // previous monomorphic receiver type, assume the new ElementsKind is the | 1350 // previous monomorphic receiver type, assume the new ElementsKind is the |
| 1351 // monomorphic type. This benefits global arrays that only transition | 1351 // monomorphic type. This benefits global arrays that only transition |
| 1352 // once, and all call sites accessing them are faster if they remain | 1352 // once, and all call sites accessing them are faster if they remain |
| 1353 // monomorphic. If this optimistic assumption is not true, the IC will | 1353 // monomorphic. If this optimistic assumption is not true, the IC will |
| 1354 // miss again and it will become polymorphic and support both the | 1354 // miss again and it will become polymorphic and support both the |
| 1355 // untransitioned and transitioned maps. | 1355 // untransitioned and transitioned maps. |
| 1356 if (state() == MONOMORPHIC && !receiver->IsString() && | 1356 if (state() == MONOMORPHIC && !receiver->IsString() && |
| 1357 IsMoreGeneralElementsKindTransition( | 1357 IsMoreGeneralElementsKindTransition( |
| 1358 target_receiver_maps.at(0)->elements_kind(), | 1358 target_receiver_maps.at(0)->elements_kind(), |
| 1359 Handle<JSObject>::cast(receiver)->GetElementsKind())) { | 1359 Handle<JSObject>::cast(receiver)->GetElementsKind())) { |
| 1360 Handle<Code> handler = | 1360 Handle<Object> handler = |
| 1361 ElementHandlerCompiler::GetKeyedLoadHandler(receiver_map, isolate()); | 1361 ElementHandlerCompiler::GetKeyedLoadHandler(receiver_map, isolate()); |
| 1362 return ConfigureVectorState(Handle<Name>(), receiver_map, handler); | 1362 return ConfigureVectorState(Handle<Name>(), receiver_map, handler); |
| 1363 } | 1363 } |
| 1364 | 1364 |
| 1365 DCHECK(state() != GENERIC); | 1365 DCHECK(state() != GENERIC); |
| 1366 | 1366 |
| 1367 // Determine the list of receiver maps that this call site has seen, | 1367 // Determine the list of receiver maps that this call site has seen, |
| 1368 // adding the map that was just encountered. | 1368 // adding the map that was just encountered. |
| 1369 if (!AddOneReceiverMapIfMissing(&target_receiver_maps, receiver_map)) { | 1369 if (!AddOneReceiverMapIfMissing(&target_receiver_maps, receiver_map)) { |
| 1370 // If the miss wasn't due to an unseen map, a polymorphic stub | 1370 // If the miss wasn't due to an unseen map, a polymorphic stub |
| (...skipping 1620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2991 DCHECK_EQ(FeedbackVectorSlotKind::KEYED_LOAD_IC, | 2991 DCHECK_EQ(FeedbackVectorSlotKind::KEYED_LOAD_IC, |
| 2992 vector->GetKind(vector_slot)); | 2992 vector->GetKind(vector_slot)); |
| 2993 KeyedLoadICNexus nexus(vector, vector_slot); | 2993 KeyedLoadICNexus nexus(vector, vector_slot); |
| 2994 KeyedLoadIC ic(IC::EXTRA_CALL_FRAME, isolate, &nexus); | 2994 KeyedLoadIC ic(IC::EXTRA_CALL_FRAME, isolate, &nexus); |
| 2995 ic.UpdateState(receiver, key); | 2995 ic.UpdateState(receiver, key); |
| 2996 RETURN_RESULT_OR_FAILURE(isolate, ic.Load(receiver, key)); | 2996 RETURN_RESULT_OR_FAILURE(isolate, ic.Load(receiver, key)); |
| 2997 } | 2997 } |
| 2998 } | 2998 } |
| 2999 } // namespace internal | 2999 } // namespace internal |
| 3000 } // namespace v8 | 3000 } // namespace v8 |
| OLD | NEW |