| 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/codegen.h" | 10 #include "src/codegen.h" |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 ConstantPoolArray* constant_pool) { | 475 ConstantPoolArray* constant_pool) { |
| 476 // Currently, CallIC doesn't have state changes. | 476 // Currently, CallIC doesn't have state changes. |
| 477 } | 477 } |
| 478 | 478 |
| 479 | 479 |
| 480 void LoadIC::Clear(Isolate* isolate, | 480 void LoadIC::Clear(Isolate* isolate, |
| 481 Address address, | 481 Address address, |
| 482 Code* target, | 482 Code* target, |
| 483 ConstantPoolArray* constant_pool) { | 483 ConstantPoolArray* constant_pool) { |
| 484 if (IsCleared(target)) return; | 484 if (IsCleared(target)) return; |
| 485 Code* code = target->GetIsolate()->stub_cache()->FindPreMonomorphicIC( | 485 Code* code = PropertyICCompiler::FindPreMonomorphicIC( |
| 486 Code::LOAD_IC, target->extra_ic_state()); | 486 isolate, Code::LOAD_IC, target->extra_ic_state()); |
| 487 SetTargetAtAddress(address, code, constant_pool); | 487 SetTargetAtAddress(address, code, constant_pool); |
| 488 } | 488 } |
| 489 | 489 |
| 490 | 490 |
| 491 void StoreIC::Clear(Isolate* isolate, | 491 void StoreIC::Clear(Isolate* isolate, |
| 492 Address address, | 492 Address address, |
| 493 Code* target, | 493 Code* target, |
| 494 ConstantPoolArray* constant_pool) { | 494 ConstantPoolArray* constant_pool) { |
| 495 if (IsCleared(target)) return; | 495 if (IsCleared(target)) return; |
| 496 Code* code = target->GetIsolate()->stub_cache()->FindPreMonomorphicIC( | 496 Code* code = PropertyICCompiler::FindPreMonomorphicIC( |
| 497 Code::STORE_IC, target->extra_ic_state()); | 497 isolate, Code::STORE_IC, target->extra_ic_state()); |
| 498 SetTargetAtAddress(address, code, constant_pool); | 498 SetTargetAtAddress(address, code, constant_pool); |
| 499 } | 499 } |
| 500 | 500 |
| 501 | 501 |
| 502 void KeyedStoreIC::Clear(Isolate* isolate, | 502 void KeyedStoreIC::Clear(Isolate* isolate, |
| 503 Address address, | 503 Address address, |
| 504 Code* target, | 504 Code* target, |
| 505 ConstantPoolArray* constant_pool) { | 505 ConstantPoolArray* constant_pool) { |
| 506 if (IsCleared(target)) return; | 506 if (IsCleared(target)) return; |
| 507 SetTargetAtAddress(address, | 507 SetTargetAtAddress(address, |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 number_of_types - deprecated_types - (handler_to_overwrite != -1); | 653 number_of_types - deprecated_types - (handler_to_overwrite != -1); |
| 654 | 654 |
| 655 if (number_of_valid_types >= 4) return false; | 655 if (number_of_valid_types >= 4) return false; |
| 656 if (number_of_types == 0) return false; | 656 if (number_of_types == 0) return false; |
| 657 if (!target()->FindHandlers(&handlers, types.length())) return false; | 657 if (!target()->FindHandlers(&handlers, types.length())) return false; |
| 658 | 658 |
| 659 number_of_valid_types++; | 659 number_of_valid_types++; |
| 660 if (number_of_valid_types > 1 && target()->is_keyed_stub()) return false; | 660 if (number_of_valid_types > 1 && target()->is_keyed_stub()) return false; |
| 661 Handle<Code> ic; | 661 Handle<Code> ic; |
| 662 if (number_of_valid_types == 1) { | 662 if (number_of_valid_types == 1) { |
| 663 ic = isolate()->stub_cache()->ComputeMonomorphicIC(kind(), name, type, code, | 663 ic = PropertyICCompiler::ComputeMonomorphicIC(kind(), name, type, code, |
| 664 extra_ic_state()); | 664 extra_ic_state()); |
| 665 } else { | 665 } else { |
| 666 if (handler_to_overwrite >= 0) { | 666 if (handler_to_overwrite >= 0) { |
| 667 handlers.Set(handler_to_overwrite, code); | 667 handlers.Set(handler_to_overwrite, code); |
| 668 if (!type->NowIs(types.at(handler_to_overwrite))) { | 668 if (!type->NowIs(types.at(handler_to_overwrite))) { |
| 669 types.Set(handler_to_overwrite, type); | 669 types.Set(handler_to_overwrite, type); |
| 670 } | 670 } |
| 671 } else { | 671 } else { |
| 672 types.Add(type); | 672 types.Add(type); |
| 673 handlers.Add(code); | 673 handlers.Add(code); |
| 674 } | 674 } |
| 675 ic = isolate()->stub_cache()->ComputePolymorphicIC( | 675 ic = PropertyICCompiler::ComputePolymorphicIC(kind(), &types, &handlers, |
| 676 kind(), &types, &handlers, number_of_valid_types, name, | 676 number_of_valid_types, name, |
| 677 extra_ic_state()); | 677 extra_ic_state()); |
| 678 } | 678 } |
| 679 set_target(*ic); | 679 set_target(*ic); |
| 680 return true; | 680 return true; |
| 681 } | 681 } |
| 682 | 682 |
| 683 | 683 |
| 684 Handle<HeapType> IC::CurrentTypeOf(Handle<Object> object, Isolate* isolate) { | 684 Handle<HeapType> IC::CurrentTypeOf(Handle<Object> object, Isolate* isolate) { |
| 685 return object->IsJSGlobalObject() | 685 return object->IsJSGlobalObject() |
| 686 ? HeapType::Constant(Handle<JSGlobalObject>::cast(object), isolate) | 686 ? HeapType::Constant(Handle<JSGlobalObject>::cast(object), isolate) |
| 687 : HeapType::NowOf(object, isolate); | 687 : HeapType::NowOf(object, isolate); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 718 template | 718 template |
| 719 Type* IC::MapToType<Type>(Handle<Map> map, Zone* zone); | 719 Type* IC::MapToType<Type>(Handle<Map> map, Zone* zone); |
| 720 | 720 |
| 721 | 721 |
| 722 template | 722 template |
| 723 Handle<HeapType> IC::MapToType<HeapType>(Handle<Map> map, Isolate* region); | 723 Handle<HeapType> IC::MapToType<HeapType>(Handle<Map> map, Isolate* region); |
| 724 | 724 |
| 725 | 725 |
| 726 void IC::UpdateMonomorphicIC(Handle<Code> handler, Handle<String> name) { | 726 void IC::UpdateMonomorphicIC(Handle<Code> handler, Handle<String> name) { |
| 727 if (!handler->is_handler()) return set_target(*handler); | 727 if (!handler->is_handler()) return set_target(*handler); |
| 728 Handle<Code> ic = isolate()->stub_cache()->ComputeMonomorphicIC( | 728 Handle<Code> ic = PropertyICCompiler::ComputeMonomorphicIC( |
| 729 kind(), name, receiver_type(), handler, extra_ic_state()); | 729 kind(), name, receiver_type(), handler, extra_ic_state()); |
| 730 set_target(*ic); | 730 set_target(*ic); |
| 731 } | 731 } |
| 732 | 732 |
| 733 | 733 |
| 734 void IC::CopyICToMegamorphicCache(Handle<String> name) { | 734 void IC::CopyICToMegamorphicCache(Handle<String> name) { |
| 735 TypeHandleList types; | 735 TypeHandleList types; |
| 736 CodeHandleList handlers; | 736 CodeHandleList handlers; |
| 737 TargetTypes(&types); | 737 TargetTypes(&types); |
| 738 if (!target()->FindHandlers(&handlers, types.length())) return; | 738 if (!target()->FindHandlers(&handlers, types.length())) return; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 779 break; | 779 break; |
| 780 case GENERIC: | 780 case GENERIC: |
| 781 UNREACHABLE(); | 781 UNREACHABLE(); |
| 782 break; | 782 break; |
| 783 } | 783 } |
| 784 } | 784 } |
| 785 | 785 |
| 786 | 786 |
| 787 Handle<Code> LoadIC::initialize_stub(Isolate* isolate, | 787 Handle<Code> LoadIC::initialize_stub(Isolate* isolate, |
| 788 ExtraICState extra_state) { | 788 ExtraICState extra_state) { |
| 789 return isolate->stub_cache()->ComputeLoad(UNINITIALIZED, extra_state); | 789 return PropertyICCompiler::ComputeLoad(isolate, UNINITIALIZED, extra_state); |
| 790 } | 790 } |
| 791 | 791 |
| 792 | 792 |
| 793 Handle<Code> LoadIC::megamorphic_stub() { | 793 Handle<Code> LoadIC::megamorphic_stub() { |
| 794 if (kind() == Code::LOAD_IC) { | 794 if (kind() == Code::LOAD_IC) { |
| 795 return isolate()->stub_cache()->ComputeLoad(MEGAMORPHIC, extra_ic_state()); | 795 return PropertyICCompiler::ComputeLoad(isolate(), MEGAMORPHIC, |
| 796 extra_ic_state()); |
| 796 } else { | 797 } else { |
| 797 ASSERT_EQ(Code::KEYED_LOAD_IC, kind()); | 798 ASSERT_EQ(Code::KEYED_LOAD_IC, kind()); |
| 798 return KeyedLoadIC::generic_stub(isolate()); | 799 return KeyedLoadIC::generic_stub(isolate()); |
| 799 } | 800 } |
| 800 } | 801 } |
| 801 | 802 |
| 802 | 803 |
| 803 Handle<Code> LoadIC::pre_monomorphic_stub(Isolate* isolate, | 804 Handle<Code> LoadIC::pre_monomorphic_stub(Isolate* isolate, |
| 804 ExtraICState extra_state) { | 805 ExtraICState extra_state) { |
| 805 return isolate->stub_cache()->ComputeLoad(PREMONOMORPHIC, extra_state); | 806 return PropertyICCompiler::ComputeLoad(isolate, PREMONOMORPHIC, extra_state); |
| 806 } | 807 } |
| 807 | 808 |
| 808 | 809 |
| 809 Handle<Code> KeyedLoadIC::pre_monomorphic_stub(Isolate* isolate) { | 810 Handle<Code> KeyedLoadIC::pre_monomorphic_stub(Isolate* isolate) { |
| 810 return isolate->builtins()->KeyedLoadIC_PreMonomorphic(); | 811 return isolate->builtins()->KeyedLoadIC_PreMonomorphic(); |
| 811 } | 812 } |
| 812 | 813 |
| 813 | 814 |
| 814 Handle<Code> LoadIC::pre_monomorphic_stub() const { | 815 Handle<Code> LoadIC::pre_monomorphic_stub() const { |
| 815 if (kind() == Code::LOAD_IC) { | 816 if (kind() == Code::LOAD_IC) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 838 TRACE_IC("LoadIC", name); | 839 TRACE_IC("LoadIC", name); |
| 839 return; | 840 return; |
| 840 } | 841 } |
| 841 | 842 |
| 842 Handle<Code> code; | 843 Handle<Code> code; |
| 843 if (!lookup->IsCacheable()) { | 844 if (!lookup->IsCacheable()) { |
| 844 // Bail out if the result is not cacheable. | 845 // Bail out if the result is not cacheable. |
| 845 code = slow_stub(); | 846 code = slow_stub(); |
| 846 } else if (!lookup->IsProperty()) { | 847 } else if (!lookup->IsProperty()) { |
| 847 if (kind() == Code::LOAD_IC) { | 848 if (kind() == Code::LOAD_IC) { |
| 848 code = isolate()->stub_cache()->ComputeLoadNonexistent(name, | 849 code = NamedLoadHandlerCompiler::ComputeLoadNonexistent(name, |
| 849 receiver_type()); | 850 receiver_type()); |
| 850 // TODO(jkummerow/verwaest): Introduce a builtin that handles this case. | 851 // TODO(jkummerow/verwaest): Introduce a builtin that handles this case. |
| 851 if (code.is_null()) code = slow_stub(); | 852 if (code.is_null()) code = slow_stub(); |
| 852 } else { | 853 } else { |
| 853 code = slow_stub(); | 854 code = slow_stub(); |
| 854 } | 855 } |
| 855 } else { | 856 } else { |
| 856 code = ComputeHandler(lookup, object, name); | 857 code = ComputeHandler(lookup, object, name); |
| 857 } | 858 } |
| 858 | 859 |
| 859 PatchCache(name, code); | 860 PatchCache(name, code); |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1065 } | 1066 } |
| 1066 | 1067 |
| 1067 Handle<Map> receiver_map(receiver->map(), isolate()); | 1068 Handle<Map> receiver_map(receiver->map(), isolate()); |
| 1068 MapHandleList target_receiver_maps; | 1069 MapHandleList target_receiver_maps; |
| 1069 if (target().is_identical_to(string_stub())) { | 1070 if (target().is_identical_to(string_stub())) { |
| 1070 target_receiver_maps.Add(isolate()->factory()->string_map()); | 1071 target_receiver_maps.Add(isolate()->factory()->string_map()); |
| 1071 } else { | 1072 } else { |
| 1072 TargetMaps(&target_receiver_maps); | 1073 TargetMaps(&target_receiver_maps); |
| 1073 } | 1074 } |
| 1074 if (target_receiver_maps.length() == 0) { | 1075 if (target_receiver_maps.length() == 0) { |
| 1075 return isolate()->stub_cache()->ComputeKeyedLoadElement(receiver_map); | 1076 return PropertyICCompiler::ComputeKeyedLoadElement(receiver_map); |
| 1076 } | 1077 } |
| 1077 | 1078 |
| 1078 // The first time a receiver is seen that is a transitioned version of the | 1079 // The first time a receiver is seen that is a transitioned version of the |
| 1079 // previous monomorphic receiver type, assume the new ElementsKind is the | 1080 // previous monomorphic receiver type, assume the new ElementsKind is the |
| 1080 // monomorphic type. This benefits global arrays that only transition | 1081 // monomorphic type. This benefits global arrays that only transition |
| 1081 // once, and all call sites accessing them are faster if they remain | 1082 // once, and all call sites accessing them are faster if they remain |
| 1082 // monomorphic. If this optimistic assumption is not true, the IC will | 1083 // monomorphic. If this optimistic assumption is not true, the IC will |
| 1083 // miss again and it will become polymorphic and support both the | 1084 // miss again and it will become polymorphic and support both the |
| 1084 // untransitioned and transitioned maps. | 1085 // untransitioned and transitioned maps. |
| 1085 if (state() == MONOMORPHIC && | 1086 if (state() == MONOMORPHIC && |
| 1086 IsMoreGeneralElementsKindTransition( | 1087 IsMoreGeneralElementsKindTransition( |
| 1087 target_receiver_maps.at(0)->elements_kind(), | 1088 target_receiver_maps.at(0)->elements_kind(), |
| 1088 receiver->GetElementsKind())) { | 1089 receiver->GetElementsKind())) { |
| 1089 return isolate()->stub_cache()->ComputeKeyedLoadElement(receiver_map); | 1090 return PropertyICCompiler::ComputeKeyedLoadElement(receiver_map); |
| 1090 } | 1091 } |
| 1091 | 1092 |
| 1092 ASSERT(state() != GENERIC); | 1093 ASSERT(state() != GENERIC); |
| 1093 | 1094 |
| 1094 // Determine the list of receiver maps that this call site has seen, | 1095 // Determine the list of receiver maps that this call site has seen, |
| 1095 // adding the map that was just encountered. | 1096 // adding the map that was just encountered. |
| 1096 if (!AddOneReceiverMapIfMissing(&target_receiver_maps, receiver_map)) { | 1097 if (!AddOneReceiverMapIfMissing(&target_receiver_maps, receiver_map)) { |
| 1097 // If the miss wasn't due to an unseen map, a polymorphic stub | 1098 // If the miss wasn't due to an unseen map, a polymorphic stub |
| 1098 // won't help, use the generic stub. | 1099 // won't help, use the generic stub. |
| 1099 TRACE_GENERIC_IC(isolate(), "KeyedIC", "same map added twice"); | 1100 TRACE_GENERIC_IC(isolate(), "KeyedIC", "same map added twice"); |
| 1100 return generic_stub(); | 1101 return generic_stub(); |
| 1101 } | 1102 } |
| 1102 | 1103 |
| 1103 // If the maximum number of receiver maps has been exceeded, use the generic | 1104 // If the maximum number of receiver maps has been exceeded, use the generic |
| 1104 // version of the IC. | 1105 // version of the IC. |
| 1105 if (target_receiver_maps.length() > kMaxKeyedPolymorphism) { | 1106 if (target_receiver_maps.length() > kMaxKeyedPolymorphism) { |
| 1106 TRACE_GENERIC_IC(isolate(), "KeyedIC", "max polymorph exceeded"); | 1107 TRACE_GENERIC_IC(isolate(), "KeyedIC", "max polymorph exceeded"); |
| 1107 return generic_stub(); | 1108 return generic_stub(); |
| 1108 } | 1109 } |
| 1109 | 1110 |
| 1110 return isolate()->stub_cache()->ComputeLoadElementPolymorphic( | 1111 return PropertyICCompiler::ComputeLoadElementPolymorphic( |
| 1111 &target_receiver_maps); | 1112 &target_receiver_maps); |
| 1112 } | 1113 } |
| 1113 | 1114 |
| 1114 | 1115 |
| 1115 MaybeHandle<Object> KeyedLoadIC::Load(Handle<Object> object, | 1116 MaybeHandle<Object> KeyedLoadIC::Load(Handle<Object> object, |
| 1116 Handle<Object> key) { | 1117 Handle<Object> key) { |
| 1117 if (MigrateDeprecated(object)) { | 1118 if (MigrateDeprecated(object)) { |
| 1118 Handle<Object> result; | 1119 Handle<Object> result; |
| 1119 ASSIGN_RETURN_ON_EXCEPTION( | 1120 ASSIGN_RETURN_ON_EXCEPTION( |
| 1120 isolate(), | 1121 isolate(), |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1334 CallType call_type) { | 1335 CallType call_type) { |
| 1335 CallICStub stub(isolate, State(argc, call_type)); | 1336 CallICStub stub(isolate, State(argc, call_type)); |
| 1336 Handle<Code> code = stub.GetCode(); | 1337 Handle<Code> code = stub.GetCode(); |
| 1337 return code; | 1338 return code; |
| 1338 } | 1339 } |
| 1339 | 1340 |
| 1340 | 1341 |
| 1341 Handle<Code> StoreIC::initialize_stub(Isolate* isolate, | 1342 Handle<Code> StoreIC::initialize_stub(Isolate* isolate, |
| 1342 StrictMode strict_mode) { | 1343 StrictMode strict_mode) { |
| 1343 ExtraICState extra_state = ComputeExtraICState(strict_mode); | 1344 ExtraICState extra_state = ComputeExtraICState(strict_mode); |
| 1344 Handle<Code> ic = isolate->stub_cache()->ComputeStore( | 1345 Handle<Code> ic = |
| 1345 UNINITIALIZED, extra_state); | 1346 PropertyICCompiler::ComputeStore(isolate, UNINITIALIZED, extra_state); |
| 1346 return ic; | 1347 return ic; |
| 1347 } | 1348 } |
| 1348 | 1349 |
| 1349 | 1350 |
| 1350 Handle<Code> StoreIC::megamorphic_stub() { | 1351 Handle<Code> StoreIC::megamorphic_stub() { |
| 1351 return isolate()->stub_cache()->ComputeStore(MEGAMORPHIC, extra_ic_state()); | 1352 return PropertyICCompiler::ComputeStore(isolate(), MEGAMORPHIC, |
| 1353 extra_ic_state()); |
| 1352 } | 1354 } |
| 1353 | 1355 |
| 1354 | 1356 |
| 1355 Handle<Code> StoreIC::generic_stub() const { | 1357 Handle<Code> StoreIC::generic_stub() const { |
| 1356 return isolate()->stub_cache()->ComputeStore(GENERIC, extra_ic_state()); | 1358 return PropertyICCompiler::ComputeStore(isolate(), GENERIC, extra_ic_state()); |
| 1357 } | 1359 } |
| 1358 | 1360 |
| 1359 | 1361 |
| 1360 Handle<Code> StoreIC::pre_monomorphic_stub(Isolate* isolate, | 1362 Handle<Code> StoreIC::pre_monomorphic_stub(Isolate* isolate, |
| 1361 StrictMode strict_mode) { | 1363 StrictMode strict_mode) { |
| 1362 ExtraICState state = ComputeExtraICState(strict_mode); | 1364 ExtraICState state = ComputeExtraICState(strict_mode); |
| 1363 return isolate->stub_cache()->ComputeStore(PREMONOMORPHIC, state); | 1365 return PropertyICCompiler::ComputeStore(isolate, PREMONOMORPHIC, state); |
| 1364 } | 1366 } |
| 1365 | 1367 |
| 1366 | 1368 |
| 1367 void StoreIC::UpdateCaches(LookupResult* lookup, | 1369 void StoreIC::UpdateCaches(LookupResult* lookup, |
| 1368 Handle<JSObject> receiver, | 1370 Handle<JSObject> receiver, |
| 1369 Handle<String> name, | 1371 Handle<String> name, |
| 1370 Handle<Object> value) { | 1372 Handle<Object> value) { |
| 1371 ASSERT(lookup->IsFound()); | 1373 ASSERT(lookup->IsFound()); |
| 1372 | 1374 |
| 1373 // These are not cacheable, so we never see such LookupResults here. | 1375 // These are not cacheable, so we never see such LookupResults here. |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1485 return generic_stub(); | 1487 return generic_stub(); |
| 1486 } | 1488 } |
| 1487 | 1489 |
| 1488 Handle<Map> receiver_map(receiver->map(), isolate()); | 1490 Handle<Map> receiver_map(receiver->map(), isolate()); |
| 1489 MapHandleList target_receiver_maps; | 1491 MapHandleList target_receiver_maps; |
| 1490 TargetMaps(&target_receiver_maps); | 1492 TargetMaps(&target_receiver_maps); |
| 1491 if (target_receiver_maps.length() == 0) { | 1493 if (target_receiver_maps.length() == 0) { |
| 1492 Handle<Map> monomorphic_map = | 1494 Handle<Map> monomorphic_map = |
| 1493 ComputeTransitionedMap(receiver_map, store_mode); | 1495 ComputeTransitionedMap(receiver_map, store_mode); |
| 1494 store_mode = GetNonTransitioningStoreMode(store_mode); | 1496 store_mode = GetNonTransitioningStoreMode(store_mode); |
| 1495 return isolate()->stub_cache()->ComputeKeyedStoreElement( | 1497 return PropertyICCompiler::ComputeKeyedStoreElement( |
| 1496 monomorphic_map, strict_mode(), store_mode); | 1498 monomorphic_map, strict_mode(), store_mode); |
| 1497 } | 1499 } |
| 1498 | 1500 |
| 1499 // There are several special cases where an IC that is MONOMORPHIC can still | 1501 // There are several special cases where an IC that is MONOMORPHIC can still |
| 1500 // transition to a different GetNonTransitioningStoreMode IC that handles a | 1502 // transition to a different GetNonTransitioningStoreMode IC that handles a |
| 1501 // superset of the original IC. Handle those here if the receiver map hasn't | 1503 // superset of the original IC. Handle those here if the receiver map hasn't |
| 1502 // changed or it has transitioned to a more general kind. | 1504 // changed or it has transitioned to a more general kind. |
| 1503 KeyedAccessStoreMode old_store_mode = | 1505 KeyedAccessStoreMode old_store_mode = |
| 1504 KeyedStoreIC::GetKeyedAccessStoreMode(target()->extra_ic_state()); | 1506 KeyedStoreIC::GetKeyedAccessStoreMode(target()->extra_ic_state()); |
| 1505 Handle<Map> previous_receiver_map = target_receiver_maps.at(0); | 1507 Handle<Map> previous_receiver_map = target_receiver_maps.at(0); |
| 1506 if (state() == MONOMORPHIC) { | 1508 if (state() == MONOMORPHIC) { |
| 1507 Handle<Map> transitioned_receiver_map = receiver_map; | 1509 Handle<Map> transitioned_receiver_map = receiver_map; |
| 1508 if (IsTransitionStoreMode(store_mode)) { | 1510 if (IsTransitionStoreMode(store_mode)) { |
| 1509 transitioned_receiver_map = | 1511 transitioned_receiver_map = |
| 1510 ComputeTransitionedMap(receiver_map, store_mode); | 1512 ComputeTransitionedMap(receiver_map, store_mode); |
| 1511 } | 1513 } |
| 1512 if ((receiver_map.is_identical_to(previous_receiver_map) && | 1514 if ((receiver_map.is_identical_to(previous_receiver_map) && |
| 1513 IsTransitionStoreMode(store_mode)) || | 1515 IsTransitionStoreMode(store_mode)) || |
| 1514 IsTransitionOfMonomorphicTarget(*previous_receiver_map, | 1516 IsTransitionOfMonomorphicTarget(*previous_receiver_map, |
| 1515 *transitioned_receiver_map)) { | 1517 *transitioned_receiver_map)) { |
| 1516 // If the "old" and "new" maps are in the same elements map family, or | 1518 // If the "old" and "new" maps are in the same elements map family, or |
| 1517 // if they at least come from the same origin for a transitioning store, | 1519 // if they at least come from the same origin for a transitioning store, |
| 1518 // stay MONOMORPHIC and use the map for the most generic ElementsKind. | 1520 // stay MONOMORPHIC and use the map for the most generic ElementsKind. |
| 1519 store_mode = GetNonTransitioningStoreMode(store_mode); | 1521 store_mode = GetNonTransitioningStoreMode(store_mode); |
| 1520 return isolate()->stub_cache()->ComputeKeyedStoreElement( | 1522 return PropertyICCompiler::ComputeKeyedStoreElement( |
| 1521 transitioned_receiver_map, strict_mode(), store_mode); | 1523 transitioned_receiver_map, strict_mode(), store_mode); |
| 1522 } else if (*previous_receiver_map == receiver->map() && | 1524 } else if (*previous_receiver_map == receiver->map() && |
| 1523 old_store_mode == STANDARD_STORE && | 1525 old_store_mode == STANDARD_STORE && |
| 1524 (store_mode == STORE_AND_GROW_NO_TRANSITION || | 1526 (store_mode == STORE_AND_GROW_NO_TRANSITION || |
| 1525 store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS || | 1527 store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS || |
| 1526 store_mode == STORE_NO_TRANSITION_HANDLE_COW)) { | 1528 store_mode == STORE_NO_TRANSITION_HANDLE_COW)) { |
| 1527 // A "normal" IC that handles stores can switch to a version that can | 1529 // A "normal" IC that handles stores can switch to a version that can |
| 1528 // grow at the end of the array, handle OOB accesses or copy COW arrays | 1530 // grow at the end of the array, handle OOB accesses or copy COW arrays |
| 1529 // and still stay MONOMORPHIC. | 1531 // and still stay MONOMORPHIC. |
| 1530 return isolate()->stub_cache()->ComputeKeyedStoreElement( | 1532 return PropertyICCompiler::ComputeKeyedStoreElement( |
| 1531 receiver_map, strict_mode(), store_mode); | 1533 receiver_map, strict_mode(), store_mode); |
| 1532 } | 1534 } |
| 1533 } | 1535 } |
| 1534 | 1536 |
| 1535 ASSERT(state() != GENERIC); | 1537 ASSERT(state() != GENERIC); |
| 1536 | 1538 |
| 1537 bool map_added = | 1539 bool map_added = |
| 1538 AddOneReceiverMapIfMissing(&target_receiver_maps, receiver_map); | 1540 AddOneReceiverMapIfMissing(&target_receiver_maps, receiver_map); |
| 1539 | 1541 |
| 1540 if (IsTransitionStoreMode(store_mode)) { | 1542 if (IsTransitionStoreMode(store_mode)) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1582 } | 1584 } |
| 1583 } | 1585 } |
| 1584 if (external_arrays != 0 && | 1586 if (external_arrays != 0 && |
| 1585 external_arrays != target_receiver_maps.length()) { | 1587 external_arrays != target_receiver_maps.length()) { |
| 1586 TRACE_GENERIC_IC(isolate(), "KeyedIC", | 1588 TRACE_GENERIC_IC(isolate(), "KeyedIC", |
| 1587 "unsupported combination of external and normal arrays"); | 1589 "unsupported combination of external and normal arrays"); |
| 1588 return generic_stub(); | 1590 return generic_stub(); |
| 1589 } | 1591 } |
| 1590 } | 1592 } |
| 1591 | 1593 |
| 1592 return isolate()->stub_cache()->ComputeStoreElementPolymorphic( | 1594 return PropertyICCompiler::ComputeStoreElementPolymorphic( |
| 1593 &target_receiver_maps, store_mode, strict_mode()); | 1595 &target_receiver_maps, store_mode, strict_mode()); |
| 1594 } | 1596 } |
| 1595 | 1597 |
| 1596 | 1598 |
| 1597 Handle<Map> KeyedStoreIC::ComputeTransitionedMap( | 1599 Handle<Map> KeyedStoreIC::ComputeTransitionedMap( |
| 1598 Handle<Map> map, | 1600 Handle<Map> map, |
| 1599 KeyedAccessStoreMode store_mode) { | 1601 KeyedAccessStoreMode store_mode) { |
| 1600 switch (store_mode) { | 1602 switch (store_mode) { |
| 1601 case STORE_TRANSITION_SMI_TO_OBJECT: | 1603 case STORE_TRANSITION_SMI_TO_OBJECT: |
| 1602 case STORE_TRANSITION_DOUBLE_TO_OBJECT: | 1604 case STORE_TRANSITION_DOUBLE_TO_OBJECT: |
| (...skipping 1332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2935 stub.UpdateStatus(object); | 2937 stub.UpdateStatus(object); |
| 2936 | 2938 |
| 2937 NilValue nil = stub.GetNilValue(); | 2939 NilValue nil = stub.GetNilValue(); |
| 2938 | 2940 |
| 2939 // Find or create the specialized stub to support the new set of types. | 2941 // Find or create the specialized stub to support the new set of types. |
| 2940 Handle<Code> code; | 2942 Handle<Code> code; |
| 2941 if (stub.IsMonomorphic()) { | 2943 if (stub.IsMonomorphic()) { |
| 2942 Handle<Map> monomorphic_map(already_monomorphic && FirstTargetMap() != NULL | 2944 Handle<Map> monomorphic_map(already_monomorphic && FirstTargetMap() != NULL |
| 2943 ? FirstTargetMap() | 2945 ? FirstTargetMap() |
| 2944 : HeapObject::cast(*object)->map()); | 2946 : HeapObject::cast(*object)->map()); |
| 2945 code = isolate()->stub_cache()->ComputeCompareNil(monomorphic_map, &stub); | 2947 code = PropertyICCompiler::ComputeCompareNil(monomorphic_map, &stub); |
| 2946 } else { | 2948 } else { |
| 2947 code = stub.GetCode(); | 2949 code = stub.GetCode(); |
| 2948 } | 2950 } |
| 2949 set_target(*code); | 2951 set_target(*code); |
| 2950 return DoCompareNilSlow(isolate(), nil, object); | 2952 return DoCompareNilSlow(isolate(), nil, object); |
| 2951 } | 2953 } |
| 2952 | 2954 |
| 2953 | 2955 |
| 2954 RUNTIME_FUNCTION(CompareNilIC_Miss) { | 2956 RUNTIME_FUNCTION(CompareNilIC_Miss) { |
| 2955 TimerEventScope<TimerEventIcMiss> timer(isolate); | 2957 TimerEventScope<TimerEventIcMiss> timer(isolate); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3034 #undef ADDR | 3036 #undef ADDR |
| 3035 }; | 3037 }; |
| 3036 | 3038 |
| 3037 | 3039 |
| 3038 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 3040 Address IC::AddressFromUtilityId(IC::UtilityId id) { |
| 3039 return IC_utilities[id]; | 3041 return IC_utilities[id]; |
| 3040 } | 3042 } |
| 3041 | 3043 |
| 3042 | 3044 |
| 3043 } } // namespace v8::internal | 3045 } } // namespace v8::internal |
| OLD | NEW |