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 810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
821 return LoadICTFStub(isolate).GetCode(); | 821 return LoadICTFStub(isolate).GetCode(); |
822 } | 822 } |
823 return LoadICStub(isolate).GetCode(); | 823 return LoadICStub(isolate).GetCode(); |
824 } | 824 } |
825 | 825 |
826 Handle<Code> LoadGlobalIC::initialize_stub_in_optimized_code( | 826 Handle<Code> LoadGlobalIC::initialize_stub_in_optimized_code( |
827 Isolate* isolate, ExtraICState extra_state) { | 827 Isolate* isolate, ExtraICState extra_state) { |
828 return LoadGlobalICStub(isolate, LoadGlobalICState(extra_state)).GetCode(); | 828 return LoadGlobalICStub(isolate, LoadGlobalICState(extra_state)).GetCode(); |
829 } | 829 } |
830 | 830 |
831 Handle<Code> KeyedLoadIC::initialize_stub_in_optimized_code( | 831 Handle<Code> KeyedLoadIC::initialize_stub_in_optimized_code(Isolate* isolate) { |
832 Isolate* isolate, ExtraICState extra_state) { | |
833 // TODO(ishell): remove extra_ic_state | |
834 return KeyedLoadICStub(isolate).GetCode(); | 832 return KeyedLoadICStub(isolate).GetCode(); |
835 } | 833 } |
836 | 834 |
837 Handle<Code> KeyedStoreIC::initialize_stub_in_optimized_code( | 835 Handle<Code> KeyedStoreIC::initialize_stub_in_optimized_code( |
838 Isolate* isolate, LanguageMode language_mode) { | 836 Isolate* isolate, LanguageMode language_mode) { |
839 StoreICState state = StoreICState(language_mode); | 837 StoreICState state = StoreICState(language_mode); |
840 return KeyedStoreICStub(isolate, state).GetCode(); | 838 return KeyedStoreICStub(isolate, state).GetCode(); |
841 } | 839 } |
842 | 840 |
843 | 841 |
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1347 | 1345 |
1348 void KeyedLoadIC::UpdateLoadElement(Handle<HeapObject> receiver) { | 1346 void KeyedLoadIC::UpdateLoadElement(Handle<HeapObject> receiver) { |
1349 Handle<Map> receiver_map(receiver->map(), isolate()); | 1347 Handle<Map> receiver_map(receiver->map(), isolate()); |
1350 DCHECK(receiver_map->instance_type() != JS_VALUE_TYPE && | 1348 DCHECK(receiver_map->instance_type() != JS_VALUE_TYPE && |
1351 receiver_map->instance_type() != JS_PROXY_TYPE); // Checked by caller. | 1349 receiver_map->instance_type() != JS_PROXY_TYPE); // Checked by caller. |
1352 MapHandleList target_receiver_maps; | 1350 MapHandleList target_receiver_maps; |
1353 TargetMaps(&target_receiver_maps); | 1351 TargetMaps(&target_receiver_maps); |
1354 | 1352 |
1355 if (target_receiver_maps.length() == 0) { | 1353 if (target_receiver_maps.length() == 0) { |
1356 Handle<Code> handler = | 1354 Handle<Code> handler = |
1357 PropertyICCompiler::ComputeKeyedLoadMonomorphicHandler( | 1355 ElementHandlerCompiler::GetKeyedLoadHandler(receiver_map, isolate()); |
1358 receiver_map, extra_ic_state()); | |
1359 return ConfigureVectorState(Handle<Name>(), receiver_map, handler); | 1356 return ConfigureVectorState(Handle<Name>(), receiver_map, handler); |
1360 } | 1357 } |
1361 | 1358 |
1362 for (int i = 0; i < target_receiver_maps.length(); i++) { | 1359 for (int i = 0; i < target_receiver_maps.length(); i++) { |
1363 Handle<Map> map = target_receiver_maps.at(i); | 1360 Handle<Map> map = target_receiver_maps.at(i); |
1364 if (map.is_null()) continue; | 1361 if (map.is_null()) continue; |
1365 if (map->instance_type() == JS_VALUE_TYPE) { | 1362 if (map->instance_type() == JS_VALUE_TYPE) { |
1366 TRACE_GENERIC_IC(isolate(), "KeyedLoadIC", "JSValue"); | 1363 TRACE_GENERIC_IC(isolate(), "KeyedLoadIC", "JSValue"); |
1367 return; | 1364 return; |
1368 } | 1365 } |
1369 if (map->instance_type() == JS_PROXY_TYPE) { | 1366 if (map->instance_type() == JS_PROXY_TYPE) { |
1370 TRACE_GENERIC_IC(isolate(), "KeyedLoadIC", "JSProxy"); | 1367 TRACE_GENERIC_IC(isolate(), "KeyedLoadIC", "JSProxy"); |
1371 return; | 1368 return; |
1372 } | 1369 } |
1373 } | 1370 } |
1374 | 1371 |
1375 // The first time a receiver is seen that is a transitioned version of the | 1372 // 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 | 1373 // previous monomorphic receiver type, assume the new ElementsKind is the |
1377 // monomorphic type. This benefits global arrays that only transition | 1374 // monomorphic type. This benefits global arrays that only transition |
1378 // once, and all call sites accessing them are faster if they remain | 1375 // once, and all call sites accessing them are faster if they remain |
1379 // monomorphic. If this optimistic assumption is not true, the IC will | 1376 // monomorphic. If this optimistic assumption is not true, the IC will |
1380 // miss again and it will become polymorphic and support both the | 1377 // miss again and it will become polymorphic and support both the |
1381 // untransitioned and transitioned maps. | 1378 // untransitioned and transitioned maps. |
1382 if (state() == MONOMORPHIC && !receiver->IsString() && | 1379 if (state() == MONOMORPHIC && !receiver->IsString() && |
1383 IsMoreGeneralElementsKindTransition( | 1380 IsMoreGeneralElementsKindTransition( |
1384 target_receiver_maps.at(0)->elements_kind(), | 1381 target_receiver_maps.at(0)->elements_kind(), |
1385 Handle<JSObject>::cast(receiver)->GetElementsKind())) { | 1382 Handle<JSObject>::cast(receiver)->GetElementsKind())) { |
1386 Handle<Code> handler = | 1383 Handle<Code> handler = |
1387 PropertyICCompiler::ComputeKeyedLoadMonomorphicHandler( | 1384 ElementHandlerCompiler::GetKeyedLoadHandler(receiver_map, isolate()); |
1388 receiver_map, extra_ic_state()); | |
1389 return ConfigureVectorState(Handle<Name>(), receiver_map, handler); | 1385 return ConfigureVectorState(Handle<Name>(), receiver_map, handler); |
1390 } | 1386 } |
1391 | 1387 |
1392 DCHECK(state() != GENERIC); | 1388 DCHECK(state() != GENERIC); |
1393 | 1389 |
1394 // Determine the list of receiver maps that this call site has seen, | 1390 // Determine the list of receiver maps that this call site has seen, |
1395 // adding the map that was just encountered. | 1391 // adding the map that was just encountered. |
1396 if (!AddOneReceiverMapIfMissing(&target_receiver_maps, receiver_map)) { | 1392 if (!AddOneReceiverMapIfMissing(&target_receiver_maps, receiver_map)) { |
1397 // If the miss wasn't due to an unseen map, a polymorphic stub | 1393 // If the miss wasn't due to an unseen map, a polymorphic stub |
1398 // won't help, use the generic stub. | 1394 // won't help, use the generic stub. |
(...skipping 1613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3012 DCHECK_EQ(FeedbackVectorSlotKind::KEYED_LOAD_IC, | 3008 DCHECK_EQ(FeedbackVectorSlotKind::KEYED_LOAD_IC, |
3013 vector->GetKind(vector_slot)); | 3009 vector->GetKind(vector_slot)); |
3014 KeyedLoadICNexus nexus(vector, vector_slot); | 3010 KeyedLoadICNexus nexus(vector, vector_slot); |
3015 KeyedLoadIC ic(IC::EXTRA_CALL_FRAME, isolate, &nexus); | 3011 KeyedLoadIC ic(IC::EXTRA_CALL_FRAME, isolate, &nexus); |
3016 ic.UpdateState(receiver, key); | 3012 ic.UpdateState(receiver, key); |
3017 RETURN_RESULT_OR_FAILURE(isolate, ic.Load(receiver, key)); | 3013 RETURN_RESULT_OR_FAILURE(isolate, ic.Load(receiver, key)); |
3018 } | 3014 } |
3019 } | 3015 } |
3020 } // namespace internal | 3016 } // namespace internal |
3021 } // namespace v8 | 3017 } // namespace v8 |
OLD | NEW |