| 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 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 CompareICStub stub(target->stub_key(), isolate); | 599 CompareICStub stub(target->stub_key(), isolate); |
| 600 // Only clear CompareICs that can retain objects. | 600 // Only clear CompareICs that can retain objects. |
| 601 if (stub.state() != CompareICState::KNOWN_OBJECT) return; | 601 if (stub.state() != CompareICState::KNOWN_OBJECT) return; |
| 602 SetTargetAtAddress(address, GetRawUninitialized(isolate, stub.op()), | 602 SetTargetAtAddress(address, GetRawUninitialized(isolate, stub.op()), |
| 603 constant_pool); | 603 constant_pool); |
| 604 PatchInlinedSmiCode(address, DISABLE_INLINED_SMI_CHECK); | 604 PatchInlinedSmiCode(address, DISABLE_INLINED_SMI_CHECK); |
| 605 } | 605 } |
| 606 | 606 |
| 607 | 607 |
| 608 // static | 608 // static |
| 609 Handle<Code> KeyedLoadIC::megamorphic_stub(Isolate* isolate) { | 609 Handle<Code> KeyedLoadIC::ChooseMegamorphicStub(Isolate* isolate) { |
| 610 if (FLAG_compiled_keyed_generic_loads) { | 610 if (FLAG_compiled_keyed_generic_loads) { |
| 611 return KeyedLoadGenericStub(isolate).GetCode(); | 611 return KeyedLoadGenericStub(isolate).GetCode(); |
| 612 } else { | 612 } else { |
| 613 return isolate->builtins()->KeyedLoadIC_Megamorphic(); | 613 return isolate->builtins()->KeyedLoadIC_Megamorphic(); |
| 614 } | 614 } |
| 615 } | 615 } |
| 616 | 616 |
| 617 | 617 |
| 618 static bool MigrateDeprecated(Handle<Object> object) { | 618 static bool MigrateDeprecated(Handle<Object> object) { |
| 619 if (!object->IsJSObject()) return false; | 619 if (!object->IsJSObject()) return false; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 | 699 |
| 700 // Check if the name is trivially convertible to an index and get | 700 // Check if the name is trivially convertible to an index and get |
| 701 // the element or char if so. | 701 // the element or char if so. |
| 702 uint32_t index; | 702 uint32_t index; |
| 703 if (kind() == Code::KEYED_LOAD_IC && name->AsArrayIndex(&index)) { | 703 if (kind() == Code::KEYED_LOAD_IC && name->AsArrayIndex(&index)) { |
| 704 // Rewrite to the generic keyed load stub. | 704 // Rewrite to the generic keyed load stub. |
| 705 if (FLAG_use_ic) { | 705 if (FLAG_use_ic) { |
| 706 if (UseVector()) { | 706 if (UseVector()) { |
| 707 ConfigureVectorState(GENERIC); | 707 ConfigureVectorState(GENERIC); |
| 708 } else { | 708 } else { |
| 709 set_target(*KeyedLoadIC::megamorphic_stub(isolate())); | 709 set_target(*megamorphic_stub()); |
| 710 } | 710 } |
| 711 TRACE_IC("LoadIC", name); | 711 TRACE_IC("LoadIC", name); |
| 712 TRACE_GENERIC_IC(isolate(), "LoadIC", "name as array index"); | 712 TRACE_GENERIC_IC(isolate(), "LoadIC", "name as array index"); |
| 713 } | 713 } |
| 714 Handle<Object> result; | 714 Handle<Object> result; |
| 715 ASSIGN_RETURN_ON_EXCEPTION( | 715 ASSIGN_RETURN_ON_EXCEPTION( |
| 716 isolate(), result, | 716 isolate(), result, |
| 717 Runtime::GetElementOrCharAt(isolate(), object, index), Object); | 717 Runtime::GetElementOrCharAt(isolate(), object, index), Object); |
| 718 return result; | 718 return result; |
| 719 } | 719 } |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1010 return initialize_stub(isolate); | 1010 return initialize_stub(isolate); |
| 1011 } | 1011 } |
| 1012 | 1012 |
| 1013 | 1013 |
| 1014 Handle<Code> LoadIC::megamorphic_stub() { | 1014 Handle<Code> LoadIC::megamorphic_stub() { |
| 1015 if (kind() == Code::LOAD_IC) { | 1015 if (kind() == Code::LOAD_IC) { |
| 1016 MegamorphicLoadStub stub(isolate(), LoadICState(extra_ic_state())); | 1016 MegamorphicLoadStub stub(isolate(), LoadICState(extra_ic_state())); |
| 1017 return stub.GetCode(); | 1017 return stub.GetCode(); |
| 1018 } else { | 1018 } else { |
| 1019 DCHECK_EQ(Code::KEYED_LOAD_IC, kind()); | 1019 DCHECK_EQ(Code::KEYED_LOAD_IC, kind()); |
| 1020 return KeyedLoadIC::megamorphic_stub(isolate()); | 1020 return KeyedLoadIC::ChooseMegamorphicStub(isolate()); |
| 1021 } | 1021 } |
| 1022 } | 1022 } |
| 1023 | 1023 |
| 1024 | 1024 |
| 1025 Handle<Code> LoadIC::pre_monomorphic_stub(Isolate* isolate, | 1025 Handle<Code> LoadIC::pre_monomorphic_stub(Isolate* isolate, |
| 1026 ExtraICState extra_state) { | 1026 ExtraICState extra_state) { |
| 1027 DCHECK(!FLAG_vector_ics); | 1027 DCHECK(!FLAG_vector_ics); |
| 1028 return PropertyICCompiler::ComputeLoad(isolate, PREMONOMORPHIC, extra_state); | 1028 return PropertyICCompiler::ComputeLoad(isolate, PREMONOMORPHIC, extra_state); |
| 1029 } | 1029 } |
| 1030 | 1030 |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1356 } | 1356 } |
| 1357 | 1357 |
| 1358 DCHECK(state() != GENERIC); | 1358 DCHECK(state() != GENERIC); |
| 1359 | 1359 |
| 1360 // Determine the list of receiver maps that this call site has seen, | 1360 // Determine the list of receiver maps that this call site has seen, |
| 1361 // adding the map that was just encountered. | 1361 // adding the map that was just encountered. |
| 1362 if (!AddOneReceiverMapIfMissing(&target_receiver_maps, receiver_map)) { | 1362 if (!AddOneReceiverMapIfMissing(&target_receiver_maps, receiver_map)) { |
| 1363 // If the miss wasn't due to an unseen map, a polymorphic stub | 1363 // If the miss wasn't due to an unseen map, a polymorphic stub |
| 1364 // won't help, use the generic stub. | 1364 // won't help, use the generic stub. |
| 1365 TRACE_GENERIC_IC(isolate(), "KeyedLoadIC", "same map added twice"); | 1365 TRACE_GENERIC_IC(isolate(), "KeyedLoadIC", "same map added twice"); |
| 1366 return megamorphic_stub(isolate()); | 1366 return megamorphic_stub(); |
| 1367 } | 1367 } |
| 1368 | 1368 |
| 1369 // If the maximum number of receiver maps has been exceeded, use the generic | 1369 // If the maximum number of receiver maps has been exceeded, use the generic |
| 1370 // version of the IC. | 1370 // version of the IC. |
| 1371 if (target_receiver_maps.length() > kMaxKeyedPolymorphism) { | 1371 if (target_receiver_maps.length() > kMaxKeyedPolymorphism) { |
| 1372 TRACE_GENERIC_IC(isolate(), "KeyedLoadIC", "max polymorph exceeded"); | 1372 TRACE_GENERIC_IC(isolate(), "KeyedLoadIC", "max polymorph exceeded"); |
| 1373 return megamorphic_stub(isolate()); | 1373 return megamorphic_stub(); |
| 1374 } | 1374 } |
| 1375 | 1375 |
| 1376 if (FLAG_vector_ics) { | 1376 if (FLAG_vector_ics) { |
| 1377 CodeHandleList handlers(target_receiver_maps.length()); | 1377 CodeHandleList handlers(target_receiver_maps.length()); |
| 1378 ElementHandlerCompiler compiler(isolate()); | 1378 ElementHandlerCompiler compiler(isolate()); |
| 1379 compiler.CompileElementHandlers(&target_receiver_maps, &handlers); | 1379 compiler.CompileElementHandlers(&target_receiver_maps, &handlers); |
| 1380 TypeHandleList types(target_receiver_maps.length()); | 1380 TypeHandleList types(target_receiver_maps.length()); |
| 1381 for (int i = 0; i < target_receiver_maps.length(); i++) { | 1381 for (int i = 0; i < target_receiver_maps.length(); i++) { |
| 1382 types.Add(HeapType::Class(target_receiver_maps.at(i), isolate())); | 1382 types.Add(HeapType::Class(target_receiver_maps.at(i), isolate())); |
| 1383 } | 1383 } |
| 1384 ConfigureVectorState(Handle<Name>::null(), &types, &handlers); | 1384 ConfigureVectorState(Handle<Name>::null(), &types, &handlers); |
| 1385 return null_handle; | 1385 return null_handle; |
| 1386 } | 1386 } |
| 1387 | 1387 |
| 1388 return PropertyICCompiler::ComputeKeyedLoadPolymorphic(&target_receiver_maps); | 1388 return PropertyICCompiler::ComputeKeyedLoadPolymorphic(&target_receiver_maps); |
| 1389 } | 1389 } |
| 1390 | 1390 |
| 1391 | 1391 |
| 1392 MaybeHandle<Object> KeyedLoadIC::Load(Handle<Object> object, | 1392 MaybeHandle<Object> KeyedLoadIC::Load(Handle<Object> object, |
| 1393 Handle<Object> key) { | 1393 Handle<Object> key) { |
| 1394 if (MigrateDeprecated(object)) { | 1394 if (MigrateDeprecated(object)) { |
| 1395 Handle<Object> result; | 1395 Handle<Object> result; |
| 1396 ASSIGN_RETURN_ON_EXCEPTION( | 1396 ASSIGN_RETURN_ON_EXCEPTION( |
| 1397 isolate(), result, Runtime::GetObjectProperty(isolate(), object, key), | 1397 isolate(), result, Runtime::GetObjectProperty(isolate(), object, key), |
| 1398 Object); | 1398 Object); |
| 1399 return result; | 1399 return result; |
| 1400 } | 1400 } |
| 1401 | 1401 |
| 1402 Handle<Object> load_handle; | 1402 Handle<Object> load_handle; |
| 1403 Handle<Code> stub = megamorphic_stub(isolate()); | 1403 Handle<Code> stub = megamorphic_stub(); |
| 1404 | 1404 |
| 1405 // Check for non-string values that can be converted into an | 1405 // Check for non-string values that can be converted into an |
| 1406 // internalized string directly or is representable as a smi. | 1406 // internalized string directly or is representable as a smi. |
| 1407 key = TryConvertKey(key, isolate()); | 1407 key = TryConvertKey(key, isolate()); |
| 1408 | 1408 |
| 1409 if (key->IsInternalizedString() || key->IsSymbol()) { | 1409 if (key->IsInternalizedString() || key->IsSymbol()) { |
| 1410 ASSIGN_RETURN_ON_EXCEPTION(isolate(), load_handle, | 1410 ASSIGN_RETURN_ON_EXCEPTION(isolate(), load_handle, |
| 1411 LoadIC::Load(object, Handle<Name>::cast(key)), | 1411 LoadIC::Load(object, Handle<Name>::cast(key)), |
| 1412 Object); | 1412 Object); |
| 1413 } else if (FLAG_use_ic && !object->IsAccessCheckNeeded()) { | 1413 } else if (FLAG_use_ic && !object->IsAccessCheckNeeded()) { |
| 1414 if (object->IsJSObject() || (object->IsString() && key->IsNumber())) { | 1414 if (object->IsJSObject() || (object->IsString() && key->IsNumber())) { |
| 1415 Handle<HeapObject> receiver = Handle<HeapObject>::cast(object); | 1415 Handle<HeapObject> receiver = Handle<HeapObject>::cast(object); |
| 1416 if (object->IsString() || !Object::ToSmi(isolate(), key).is_null()) { | 1416 if (object->IsString() || !Object::ToSmi(isolate(), key).is_null()) { |
| 1417 stub = LoadElementStub(receiver); | 1417 stub = LoadElementStub(receiver); |
| 1418 } | 1418 } |
| 1419 } | 1419 } |
| 1420 } | 1420 } |
| 1421 | 1421 |
| 1422 if (!UseVector()) { | 1422 if (!UseVector()) { |
| 1423 if (!is_target_set()) { | 1423 if (!is_target_set()) { |
| 1424 Code* generic = *megamorphic_stub(isolate()); | 1424 Code* generic = *megamorphic_stub(); |
| 1425 if (*stub == generic) { | 1425 if (*stub == generic) { |
| 1426 TRACE_GENERIC_IC(isolate(), "KeyedLoadIC", "set generic"); | 1426 TRACE_GENERIC_IC(isolate(), "KeyedLoadIC", "set generic"); |
| 1427 } | 1427 } |
| 1428 | 1428 |
| 1429 set_target(*stub); | 1429 set_target(*stub); |
| 1430 TRACE_IC("LoadIC", key); | 1430 TRACE_IC("LoadIC", key); |
| 1431 } | 1431 } |
| 1432 } else { | 1432 } else { |
| 1433 if (!is_vector_set() || stub.is_null()) { | 1433 if (!is_vector_set() || stub.is_null()) { |
| 1434 Code* generic = *megamorphic_stub(isolate()); | 1434 Code* generic = *megamorphic_stub(); |
| 1435 if (!stub.is_null() && *stub == generic) { | 1435 if (!stub.is_null() && *stub == generic) { |
| 1436 ConfigureVectorState(GENERIC); | 1436 ConfigureVectorState(GENERIC); |
| 1437 TRACE_GENERIC_IC(isolate(), "KeyedLoadIC", "set generic"); | 1437 TRACE_GENERIC_IC(isolate(), "KeyedLoadIC", "set generic"); |
| 1438 } | 1438 } |
| 1439 | 1439 |
| 1440 TRACE_IC("LoadIC", key); | 1440 TRACE_IC("LoadIC", key); |
| 1441 } | 1441 } |
| 1442 } | 1442 } |
| 1443 | 1443 |
| 1444 if (!load_handle.is_null()) return load_handle; | 1444 if (!load_handle.is_null()) return load_handle; |
| (...skipping 1555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3000 static const Address IC_utilities[] = { | 3000 static const Address IC_utilities[] = { |
| 3001 #define ADDR(name) FUNCTION_ADDR(name), | 3001 #define ADDR(name) FUNCTION_ADDR(name), |
| 3002 IC_UTIL_LIST(ADDR) NULL | 3002 IC_UTIL_LIST(ADDR) NULL |
| 3003 #undef ADDR | 3003 #undef ADDR |
| 3004 }; | 3004 }; |
| 3005 | 3005 |
| 3006 | 3006 |
| 3007 Address IC::AddressFromUtilityId(IC::UtilityId id) { return IC_utilities[id]; } | 3007 Address IC::AddressFromUtilityId(IC::UtilityId id) { return IC_utilities[id]; } |
| 3008 } | 3008 } |
| 3009 } // namespace v8::internal | 3009 } // namespace v8::internal |
| OLD | NEW |