| 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 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 default: | 505 default: |
| 506 UNREACHABLE(); | 506 UNREACHABLE(); |
| 507 } | 507 } |
| 508 } | 508 } |
| 509 | 509 |
| 510 | 510 |
| 511 void KeyedLoadIC::Clear(Isolate* isolate, Address address, Code* target, | 511 void KeyedLoadIC::Clear(Isolate* isolate, Address address, Code* target, |
| 512 ConstantPoolArray* constant_pool) { | 512 ConstantPoolArray* constant_pool) { |
| 513 if (IsCleared(target)) return; | 513 if (IsCleared(target)) return; |
| 514 | 514 |
| 515 // If the target is the string_stub, then don't clear it. It is the | 515 // Make sure to also clear the map used in inline fast cases. If we |
| 516 // perfect stub if we continue to see strings. Holding this | 516 // do not clear these maps, cached code can keep objects alive |
| 517 // state is not preventing learning new information. | 517 // through the embedded maps. |
| 518 if (target != *isolate->builtins()->KeyedLoadIC_String()) { | 518 SetTargetAtAddress(address, *pre_monomorphic_stub(isolate), constant_pool); |
| 519 // Make sure to also clear the map used in inline fast cases. If we | |
| 520 // do not clear these maps, cached code can keep objects alive | |
| 521 // through the embedded maps. | |
| 522 SetTargetAtAddress(address, *pre_monomorphic_stub(isolate), constant_pool); | |
| 523 } | |
| 524 } | 519 } |
| 525 | 520 |
| 526 | 521 |
| 527 void CallIC::Clear(Isolate* isolate, Address address, Code* target, | 522 void CallIC::Clear(Isolate* isolate, Address address, Code* target, |
| 528 ConstantPoolArray* constant_pool) { | 523 ConstantPoolArray* constant_pool) { |
| 529 // Currently, CallIC doesn't have state changes. | 524 // Currently, CallIC doesn't have state changes. |
| 530 } | 525 } |
| 531 | 526 |
| 532 | 527 |
| 533 void LoadIC::Clear(Isolate* isolate, Address address, Code* target, | 528 void LoadIC::Clear(Isolate* isolate, Address address, Code* target, |
| (...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1120 key = Handle<Smi>(Smi::FromInt(int_value), isolate); | 1115 key = Handle<Smi>(Smi::FromInt(int_value), isolate); |
| 1121 } | 1116 } |
| 1122 } | 1117 } |
| 1123 } else if (key->IsUndefined()) { | 1118 } else if (key->IsUndefined()) { |
| 1124 key = isolate->factory()->undefined_string(); | 1119 key = isolate->factory()->undefined_string(); |
| 1125 } | 1120 } |
| 1126 return key; | 1121 return key; |
| 1127 } | 1122 } |
| 1128 | 1123 |
| 1129 | 1124 |
| 1130 Handle<Code> KeyedLoadIC::LoadElementStub(Handle<JSObject> receiver) { | 1125 Handle<Code> KeyedLoadIC::LoadElementStub(Handle<HeapObject> receiver) { |
| 1131 Handle<Map> receiver_map(receiver->map(), isolate()); | 1126 Handle<Map> receiver_map(receiver->map(), isolate()); |
| 1132 MapHandleList target_receiver_maps; | 1127 MapHandleList target_receiver_maps; |
| 1133 if (target().is_identical_to(string_stub())) { | 1128 TargetMaps(&target_receiver_maps); |
| 1134 target_receiver_maps.Add(isolate()->factory()->string_map()); | 1129 |
| 1135 } else { | |
| 1136 TargetMaps(&target_receiver_maps); | |
| 1137 } | |
| 1138 if (target_receiver_maps.length() == 0) { | 1130 if (target_receiver_maps.length() == 0) { |
| 1139 return PropertyICCompiler::ComputeKeyedLoadMonomorphic(receiver_map); | 1131 return PropertyICCompiler::ComputeKeyedLoadMonomorphic(receiver_map); |
| 1140 } | 1132 } |
| 1141 | 1133 |
| 1142 // The first time a receiver is seen that is a transitioned version of the | 1134 // The first time a receiver is seen that is a transitioned version of the |
| 1143 // previous monomorphic receiver type, assume the new ElementsKind is the | 1135 // previous monomorphic receiver type, assume the new ElementsKind is the |
| 1144 // monomorphic type. This benefits global arrays that only transition | 1136 // monomorphic type. This benefits global arrays that only transition |
| 1145 // once, and all call sites accessing them are faster if they remain | 1137 // once, and all call sites accessing them are faster if they remain |
| 1146 // monomorphic. If this optimistic assumption is not true, the IC will | 1138 // monomorphic. If this optimistic assumption is not true, the IC will |
| 1147 // miss again and it will become polymorphic and support both the | 1139 // miss again and it will become polymorphic and support both the |
| 1148 // untransitioned and transitioned maps. | 1140 // untransitioned and transitioned maps. |
| 1149 if (state() == MONOMORPHIC && IsMoreGeneralElementsKindTransition( | 1141 if (state() == MONOMORPHIC && !receiver->IsString() && |
| 1150 target_receiver_maps.at(0)->elements_kind(), | 1142 IsMoreGeneralElementsKindTransition( |
| 1151 receiver->GetElementsKind())) { | 1143 target_receiver_maps.at(0)->elements_kind(), |
| 1144 Handle<JSObject>::cast(receiver)->GetElementsKind())) { |
| 1152 return PropertyICCompiler::ComputeKeyedLoadMonomorphic(receiver_map); | 1145 return PropertyICCompiler::ComputeKeyedLoadMonomorphic(receiver_map); |
| 1153 } | 1146 } |
| 1154 | 1147 |
| 1155 DCHECK(state() != GENERIC); | 1148 DCHECK(state() != GENERIC); |
| 1156 | 1149 |
| 1157 // Determine the list of receiver maps that this call site has seen, | 1150 // Determine the list of receiver maps that this call site has seen, |
| 1158 // adding the map that was just encountered. | 1151 // adding the map that was just encountered. |
| 1159 if (!AddOneReceiverMapIfMissing(&target_receiver_maps, receiver_map)) { | 1152 if (!AddOneReceiverMapIfMissing(&target_receiver_maps, receiver_map)) { |
| 1160 // If the miss wasn't due to an unseen map, a polymorphic stub | 1153 // If the miss wasn't due to an unseen map, a polymorphic stub |
| 1161 // won't help, use the generic stub. | 1154 // won't help, use the generic stub. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1189 | 1182 |
| 1190 // Check for non-string values that can be converted into an | 1183 // Check for non-string values that can be converted into an |
| 1191 // internalized string directly or is representable as a smi. | 1184 // internalized string directly or is representable as a smi. |
| 1192 key = TryConvertKey(key, isolate()); | 1185 key = TryConvertKey(key, isolate()); |
| 1193 | 1186 |
| 1194 if (key->IsInternalizedString() || key->IsSymbol()) { | 1187 if (key->IsInternalizedString() || key->IsSymbol()) { |
| 1195 ASSIGN_RETURN_ON_EXCEPTION(isolate(), load_handle, | 1188 ASSIGN_RETURN_ON_EXCEPTION(isolate(), load_handle, |
| 1196 LoadIC::Load(object, Handle<Name>::cast(key)), | 1189 LoadIC::Load(object, Handle<Name>::cast(key)), |
| 1197 Object); | 1190 Object); |
| 1198 } else if (FLAG_use_ic && !object->IsAccessCheckNeeded()) { | 1191 } else if (FLAG_use_ic && !object->IsAccessCheckNeeded()) { |
| 1199 if (object->IsString() && key->IsNumber()) { | 1192 if (object->IsJSObject() || (object->IsString() && key->IsNumber())) { |
| 1200 if (state() == UNINITIALIZED) stub = string_stub(); | 1193 Handle<HeapObject> receiver = Handle<HeapObject>::cast(object); |
| 1201 } else if (object->IsJSObject()) { | 1194 if (object->IsString() || !Object::ToSmi(isolate(), key).is_null()) { |
| 1202 Handle<JSObject> receiver = Handle<JSObject>::cast(object); | |
| 1203 if (!Object::ToSmi(isolate(), key).is_null()) { | |
| 1204 stub = LoadElementStub(receiver); | 1195 stub = LoadElementStub(receiver); |
| 1205 } | 1196 } |
| 1206 } | 1197 } |
| 1207 } | 1198 } |
| 1208 | 1199 |
| 1209 if (!is_target_set()) { | 1200 if (!is_target_set()) { |
| 1210 Code* generic = *generic_stub(); | 1201 Code* generic = *generic_stub(); |
| 1211 if (*stub == generic) { | 1202 if (*stub == generic) { |
| 1212 TRACE_GENERIC_IC(isolate(), "KeyedLoadIC", "set generic"); | 1203 TRACE_GENERIC_IC(isolate(), "KeyedLoadIC", "set generic"); |
| 1213 } | 1204 } |
| (...skipping 1448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2662 static const Address IC_utilities[] = { | 2653 static const Address IC_utilities[] = { |
| 2663 #define ADDR(name) FUNCTION_ADDR(name), | 2654 #define ADDR(name) FUNCTION_ADDR(name), |
| 2664 IC_UTIL_LIST(ADDR) NULL | 2655 IC_UTIL_LIST(ADDR) NULL |
| 2665 #undef ADDR | 2656 #undef ADDR |
| 2666 }; | 2657 }; |
| 2667 | 2658 |
| 2668 | 2659 |
| 2669 Address IC::AddressFromUtilityId(IC::UtilityId id) { return IC_utilities[id]; } | 2660 Address IC::AddressFromUtilityId(IC::UtilityId id) { return IC_utilities[id]; } |
| 2670 } | 2661 } |
| 2671 } // namespace v8::internal | 2662 } // namespace v8::internal |
| OLD | NEW |