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.h" | 8 #include "src/api.h" |
9 #include "src/api-arguments.h" | 9 #include "src/api-arguments.h" |
10 #include "src/arguments.h" | 10 #include "src/arguments.h" |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 for (; it->IsFound(); it->Next()) { | 228 for (; it->IsFound(); it->Next()) { |
229 switch (it->state()) { | 229 switch (it->state()) { |
230 case LookupIterator::NOT_FOUND: | 230 case LookupIterator::NOT_FOUND: |
231 case LookupIterator::TRANSITION: | 231 case LookupIterator::TRANSITION: |
232 UNREACHABLE(); | 232 UNREACHABLE(); |
233 case LookupIterator::JSPROXY: | 233 case LookupIterator::JSPROXY: |
234 return; | 234 return; |
235 case LookupIterator::INTERCEPTOR: { | 235 case LookupIterator::INTERCEPTOR: { |
236 // If there is a getter, return; otherwise loop to perform the lookup. | 236 // If there is a getter, return; otherwise loop to perform the lookup. |
237 Handle<JSObject> holder = it->GetHolder<JSObject>(); | 237 Handle<JSObject> holder = it->GetHolder<JSObject>(); |
238 if (!holder->GetNamedInterceptor()->getter()->IsUndefined()) { | 238 if (!holder->GetNamedInterceptor()->getter()->IsUndefined( |
| 239 it->isolate())) { |
239 return; | 240 return; |
240 } | 241 } |
241 break; | 242 break; |
242 } | 243 } |
243 case LookupIterator::ACCESS_CHECK: | 244 case LookupIterator::ACCESS_CHECK: |
244 // PropertyHandlerCompiler::CheckPrototypes() knows how to emit | 245 // PropertyHandlerCompiler::CheckPrototypes() knows how to emit |
245 // access checks for global proxies. | 246 // access checks for global proxies. |
246 if (it->GetHolder<JSObject>()->IsJSGlobalProxy() && it->HasAccess()) { | 247 if (it->GetHolder<JSObject>()->IsJSGlobalProxy() && it->HasAccess()) { |
247 break; | 248 break; |
248 } | 249 } |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
581 nexus->ConfigurePolymorphic(maps, transitioned_maps, handlers); | 582 nexus->ConfigurePolymorphic(maps, transitioned_maps, handlers); |
582 | 583 |
583 vector_set_ = true; | 584 vector_set_ = true; |
584 OnTypeFeedbackChanged(isolate(), get_host()); | 585 OnTypeFeedbackChanged(isolate(), get_host()); |
585 } | 586 } |
586 | 587 |
587 | 588 |
588 MaybeHandle<Object> LoadIC::Load(Handle<Object> object, Handle<Name> name) { | 589 MaybeHandle<Object> LoadIC::Load(Handle<Object> object, Handle<Name> name) { |
589 // If the object is undefined or null it's illegal to try to get any | 590 // If the object is undefined or null it's illegal to try to get any |
590 // of its properties; throw a TypeError in that case. | 591 // of its properties; throw a TypeError in that case. |
591 if (object->IsUndefined() || object->IsNull()) { | 592 if (object->IsUndefined(isolate()) || object->IsNull()) { |
592 return TypeError(MessageTemplate::kNonObjectPropertyLoad, object, name); | 593 return TypeError(MessageTemplate::kNonObjectPropertyLoad, object, name); |
593 } | 594 } |
594 | 595 |
595 // Check if the name is trivially convertible to an index and get | 596 // Check if the name is trivially convertible to an index and get |
596 // the element or char if so. | 597 // the element or char if so. |
597 uint32_t index; | 598 uint32_t index; |
598 if (kind() == Code::KEYED_LOAD_IC && name->AsArrayIndex(&index)) { | 599 if (kind() == Code::KEYED_LOAD_IC && name->AsArrayIndex(&index)) { |
599 // Rewrite to the generic keyed load stub. | 600 // Rewrite to the generic keyed load stub. |
600 if (FLAG_use_ic) { | 601 if (FLAG_use_ic) { |
601 DCHECK(UseVector()); | 602 DCHECK(UseVector()); |
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1257 if (key->IsHeapNumber()) { | 1258 if (key->IsHeapNumber()) { |
1258 double value = Handle<HeapNumber>::cast(key)->value(); | 1259 double value = Handle<HeapNumber>::cast(key)->value(); |
1259 if (std::isnan(value)) { | 1260 if (std::isnan(value)) { |
1260 key = isolate->factory()->nan_string(); | 1261 key = isolate->factory()->nan_string(); |
1261 } else { | 1262 } else { |
1262 int int_value = FastD2I(value); | 1263 int int_value = FastD2I(value); |
1263 if (value == int_value && Smi::IsValid(int_value)) { | 1264 if (value == int_value && Smi::IsValid(int_value)) { |
1264 key = handle(Smi::FromInt(int_value), isolate); | 1265 key = handle(Smi::FromInt(int_value), isolate); |
1265 } | 1266 } |
1266 } | 1267 } |
1267 } else if (key->IsUndefined()) { | 1268 } else if (key->IsUndefined(isolate)) { |
1268 key = isolate->factory()->undefined_string(); | 1269 key = isolate->factory()->undefined_string(); |
1269 } | 1270 } |
1270 return key; | 1271 return key; |
1271 } | 1272 } |
1272 | 1273 |
1273 void KeyedLoadIC::UpdateLoadElement(Handle<HeapObject> receiver) { | 1274 void KeyedLoadIC::UpdateLoadElement(Handle<HeapObject> receiver) { |
1274 Handle<Map> receiver_map(receiver->map(), isolate()); | 1275 Handle<Map> receiver_map(receiver->map(), isolate()); |
1275 DCHECK(receiver_map->instance_type() != JS_VALUE_TYPE && | 1276 DCHECK(receiver_map->instance_type() != JS_VALUE_TYPE && |
1276 receiver_map->instance_type() != JS_PROXY_TYPE); // Checked by caller. | 1277 receiver_map->instance_type() != JS_PROXY_TYPE); // Checked by caller. |
1277 MapHandleList target_receiver_maps; | 1278 MapHandleList target_receiver_maps; |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1397 case LookupIterator::NOT_FOUND: | 1398 case LookupIterator::NOT_FOUND: |
1398 case LookupIterator::TRANSITION: | 1399 case LookupIterator::TRANSITION: |
1399 UNREACHABLE(); | 1400 UNREACHABLE(); |
1400 case LookupIterator::JSPROXY: | 1401 case LookupIterator::JSPROXY: |
1401 return false; | 1402 return false; |
1402 case LookupIterator::INTERCEPTOR: { | 1403 case LookupIterator::INTERCEPTOR: { |
1403 Handle<JSObject> holder = it->GetHolder<JSObject>(); | 1404 Handle<JSObject> holder = it->GetHolder<JSObject>(); |
1404 InterceptorInfo* info = holder->GetNamedInterceptor(); | 1405 InterceptorInfo* info = holder->GetNamedInterceptor(); |
1405 if (it->HolderIsReceiverOrHiddenPrototype()) { | 1406 if (it->HolderIsReceiverOrHiddenPrototype()) { |
1406 return !info->non_masking() && receiver.is_identical_to(holder) && | 1407 return !info->non_masking() && receiver.is_identical_to(holder) && |
1407 !info->setter()->IsUndefined(); | 1408 !info->setter()->IsUndefined(it->isolate()); |
1408 } else if (!info->getter()->IsUndefined() || | 1409 } else if (!info->getter()->IsUndefined(it->isolate()) || |
1409 !info->query()->IsUndefined()) { | 1410 !info->query()->IsUndefined(it->isolate())) { |
1410 return false; | 1411 return false; |
1411 } | 1412 } |
1412 break; | 1413 break; |
1413 } | 1414 } |
1414 case LookupIterator::ACCESS_CHECK: | 1415 case LookupIterator::ACCESS_CHECK: |
1415 if (it->GetHolder<JSObject>()->IsAccessCheckNeeded()) return false; | 1416 if (it->GetHolder<JSObject>()->IsAccessCheckNeeded()) return false; |
1416 break; | 1417 break; |
1417 case LookupIterator::ACCESSOR: | 1418 case LookupIterator::ACCESSOR: |
1418 return !it->IsReadOnly(); | 1419 return !it->IsReadOnly(); |
1419 case LookupIterator::INTEGER_INDEXED_EXOTIC: | 1420 case LookupIterator::INTEGER_INDEXED_EXOTIC: |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1514 if (MigrateDeprecated(object) || object->IsJSProxy()) { | 1515 if (MigrateDeprecated(object) || object->IsJSProxy()) { |
1515 Handle<Object> result; | 1516 Handle<Object> result; |
1516 ASSIGN_RETURN_ON_EXCEPTION( | 1517 ASSIGN_RETURN_ON_EXCEPTION( |
1517 isolate(), result, | 1518 isolate(), result, |
1518 Object::SetProperty(object, name, value, language_mode()), Object); | 1519 Object::SetProperty(object, name, value, language_mode()), Object); |
1519 return result; | 1520 return result; |
1520 } | 1521 } |
1521 | 1522 |
1522 // If the object is undefined or null it's illegal to try to set any | 1523 // If the object is undefined or null it's illegal to try to set any |
1523 // properties on it; throw a TypeError in that case. | 1524 // properties on it; throw a TypeError in that case. |
1524 if (object->IsUndefined() || object->IsNull()) { | 1525 if (object->IsUndefined(isolate()) || object->IsNull()) { |
1525 return TypeError(MessageTemplate::kNonObjectPropertyStore, object, name); | 1526 return TypeError(MessageTemplate::kNonObjectPropertyStore, object, name); |
1526 } | 1527 } |
1527 | 1528 |
1528 LookupIterator it(object, name); | 1529 LookupIterator it(object, name); |
1529 if (FLAG_use_ic) UpdateCaches(&it, value, store_mode); | 1530 if (FLAG_use_ic) UpdateCaches(&it, value, store_mode); |
1530 | 1531 |
1531 MAYBE_RETURN_NULL( | 1532 MAYBE_RETURN_NULL( |
1532 Object::SetProperty(&it, value, language_mode(), store_mode)); | 1533 Object::SetProperty(&it, value, language_mode(), store_mode)); |
1533 return value; | 1534 return value; |
1534 } | 1535 } |
(...skipping 1398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2933 DCHECK_EQ(FeedbackVectorSlotKind::KEYED_LOAD_IC, | 2934 DCHECK_EQ(FeedbackVectorSlotKind::KEYED_LOAD_IC, |
2934 vector->GetKind(vector_slot)); | 2935 vector->GetKind(vector_slot)); |
2935 KeyedLoadICNexus nexus(vector, vector_slot); | 2936 KeyedLoadICNexus nexus(vector, vector_slot); |
2936 KeyedLoadIC ic(IC::EXTRA_CALL_FRAME, isolate, &nexus); | 2937 KeyedLoadIC ic(IC::EXTRA_CALL_FRAME, isolate, &nexus); |
2937 ic.UpdateState(receiver, key); | 2938 ic.UpdateState(receiver, key); |
2938 RETURN_RESULT_OR_FAILURE(isolate, ic.Load(receiver, key)); | 2939 RETURN_RESULT_OR_FAILURE(isolate, ic.Load(receiver, key)); |
2939 } | 2940 } |
2940 } | 2941 } |
2941 } // namespace internal | 2942 } // namespace internal |
2942 } // namespace v8 | 2943 } // namespace v8 |
OLD | NEW |