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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 } | 298 } |
299 | 299 |
300 return true; | 300 return true; |
301 } | 301 } |
302 | 302 |
303 | 303 |
304 void IC::UpdateState(Handle<Object> receiver, Handle<Object> name) { | 304 void IC::UpdateState(Handle<Object> receiver, Handle<Object> name) { |
305 update_receiver_map(receiver); | 305 update_receiver_map(receiver); |
306 if (!name->IsString()) return; | 306 if (!name->IsString()) return; |
307 if (state() != MONOMORPHIC && state() != POLYMORPHIC) return; | 307 if (state() != MONOMORPHIC && state() != POLYMORPHIC) return; |
308 if (receiver->IsUndefined(isolate()) || receiver->IsNull()) return; | 308 if (receiver->IsUndefined(isolate()) || receiver->IsNull(isolate())) return; |
309 | 309 |
310 // Remove the target from the code cache if it became invalid | 310 // Remove the target from the code cache if it became invalid |
311 // because of changes in the prototype chain to avoid hitting it | 311 // because of changes in the prototype chain to avoid hitting it |
312 // again. | 312 // again. |
313 if (ShouldRecomputeHandler(receiver, Handle<String>::cast(name))) { | 313 if (ShouldRecomputeHandler(receiver, Handle<String>::cast(name))) { |
314 MarkRecomputeHandler(name); | 314 MarkRecomputeHandler(name); |
315 } | 315 } |
316 } | 316 } |
317 | 317 |
318 | 318 |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 nexus->ConfigurePolymorphic(maps, transitioned_maps, handlers); | 582 nexus->ConfigurePolymorphic(maps, transitioned_maps, handlers); |
583 | 583 |
584 vector_set_ = true; | 584 vector_set_ = true; |
585 OnTypeFeedbackChanged(isolate(), get_host()); | 585 OnTypeFeedbackChanged(isolate(), get_host()); |
586 } | 586 } |
587 | 587 |
588 | 588 |
589 MaybeHandle<Object> LoadIC::Load(Handle<Object> object, Handle<Name> name) { | 589 MaybeHandle<Object> LoadIC::Load(Handle<Object> object, Handle<Name> name) { |
590 // 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 |
591 // of its properties; throw a TypeError in that case. | 591 // of its properties; throw a TypeError in that case. |
592 if (object->IsUndefined(isolate()) || object->IsNull()) { | 592 if (object->IsUndefined(isolate()) || object->IsNull(isolate())) { |
593 return TypeError(MessageTemplate::kNonObjectPropertyLoad, object, name); | 593 return TypeError(MessageTemplate::kNonObjectPropertyLoad, object, name); |
594 } | 594 } |
595 | 595 |
596 // 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 |
597 // the element or char if so. | 597 // the element or char if so. |
598 uint32_t index; | 598 uint32_t index; |
599 if (kind() == Code::KEYED_LOAD_IC && name->AsArrayIndex(&index)) { | 599 if (kind() == Code::KEYED_LOAD_IC && name->AsArrayIndex(&index)) { |
600 // Rewrite to the generic keyed load stub. | 600 // Rewrite to the generic keyed load stub. |
601 if (FLAG_use_ic) { | 601 if (FLAG_use_ic) { |
602 DCHECK(UseVector()); | 602 DCHECK(UseVector()); |
(...skipping 916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1519 if (MigrateDeprecated(object) || object->IsJSProxy()) { | 1519 if (MigrateDeprecated(object) || object->IsJSProxy()) { |
1520 Handle<Object> result; | 1520 Handle<Object> result; |
1521 ASSIGN_RETURN_ON_EXCEPTION( | 1521 ASSIGN_RETURN_ON_EXCEPTION( |
1522 isolate(), result, | 1522 isolate(), result, |
1523 Object::SetProperty(object, name, value, language_mode()), Object); | 1523 Object::SetProperty(object, name, value, language_mode()), Object); |
1524 return result; | 1524 return result; |
1525 } | 1525 } |
1526 | 1526 |
1527 // If the object is undefined or null it's illegal to try to set any | 1527 // If the object is undefined or null it's illegal to try to set any |
1528 // properties on it; throw a TypeError in that case. | 1528 // properties on it; throw a TypeError in that case. |
1529 if (object->IsUndefined(isolate()) || object->IsNull()) { | 1529 if (object->IsUndefined(isolate()) || object->IsNull(isolate())) { |
1530 return TypeError(MessageTemplate::kNonObjectPropertyStore, object, name); | 1530 return TypeError(MessageTemplate::kNonObjectPropertyStore, object, name); |
1531 } | 1531 } |
1532 | 1532 |
1533 LookupIterator it(object, name); | 1533 LookupIterator it(object, name); |
1534 if (FLAG_use_ic) UpdateCaches(&it, value, store_mode); | 1534 if (FLAG_use_ic) UpdateCaches(&it, value, store_mode); |
1535 | 1535 |
1536 MAYBE_RETURN_NULL( | 1536 MAYBE_RETURN_NULL( |
1537 Object::SetProperty(&it, value, language_mode(), store_mode)); | 1537 Object::SetProperty(&it, value, language_mode(), store_mode)); |
1538 return value; | 1538 return value; |
1539 } | 1539 } |
(...skipping 1398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2938 DCHECK_EQ(FeedbackVectorSlotKind::KEYED_LOAD_IC, | 2938 DCHECK_EQ(FeedbackVectorSlotKind::KEYED_LOAD_IC, |
2939 vector->GetKind(vector_slot)); | 2939 vector->GetKind(vector_slot)); |
2940 KeyedLoadICNexus nexus(vector, vector_slot); | 2940 KeyedLoadICNexus nexus(vector, vector_slot); |
2941 KeyedLoadIC ic(IC::EXTRA_CALL_FRAME, isolate, &nexus); | 2941 KeyedLoadIC ic(IC::EXTRA_CALL_FRAME, isolate, &nexus); |
2942 ic.UpdateState(receiver, key); | 2942 ic.UpdateState(receiver, key); |
2943 RETURN_RESULT_OR_FAILURE(isolate, ic.Load(receiver, key)); | 2943 RETURN_RESULT_OR_FAILURE(isolate, ic.Load(receiver, key)); |
2944 } | 2944 } |
2945 } | 2945 } |
2946 } // namespace internal | 2946 } // namespace internal |
2947 } // namespace v8 | 2947 } // namespace v8 |
OLD | NEW |