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 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 } | 307 } |
308 | 308 |
309 return true; | 309 return true; |
310 } | 310 } |
311 | 311 |
312 | 312 |
313 void IC::UpdateState(Handle<Object> receiver, Handle<Object> name) { | 313 void IC::UpdateState(Handle<Object> receiver, Handle<Object> name) { |
314 update_receiver_map(receiver); | 314 update_receiver_map(receiver); |
315 if (!name->IsString()) return; | 315 if (!name->IsString()) return; |
316 if (state() != MONOMORPHIC && state() != POLYMORPHIC) return; | 316 if (state() != MONOMORPHIC && state() != POLYMORPHIC) return; |
317 if (receiver->IsUndefined(isolate()) || receiver->IsNull()) return; | 317 if (receiver->IsUndefined(isolate()) || receiver->IsNull(isolate())) return; |
318 | 318 |
319 // Remove the target from the code cache if it became invalid | 319 // Remove the target from the code cache if it became invalid |
320 // because of changes in the prototype chain to avoid hitting it | 320 // because of changes in the prototype chain to avoid hitting it |
321 // again. | 321 // again. |
322 if (ShouldRecomputeHandler(receiver, Handle<String>::cast(name))) { | 322 if (ShouldRecomputeHandler(receiver, Handle<String>::cast(name))) { |
323 MarkRecomputeHandler(name); | 323 MarkRecomputeHandler(name); |
324 } | 324 } |
325 } | 325 } |
326 | 326 |
327 | 327 |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
590 nexus->ConfigurePolymorphic(maps, transitioned_maps, handlers); | 590 nexus->ConfigurePolymorphic(maps, transitioned_maps, handlers); |
591 | 591 |
592 vector_set_ = true; | 592 vector_set_ = true; |
593 OnTypeFeedbackChanged(isolate(), get_host()); | 593 OnTypeFeedbackChanged(isolate(), get_host()); |
594 } | 594 } |
595 | 595 |
596 | 596 |
597 MaybeHandle<Object> LoadIC::Load(Handle<Object> object, Handle<Name> name) { | 597 MaybeHandle<Object> LoadIC::Load(Handle<Object> object, Handle<Name> name) { |
598 // If the object is undefined or null it's illegal to try to get any | 598 // If the object is undefined or null it's illegal to try to get any |
599 // of its properties; throw a TypeError in that case. | 599 // of its properties; throw a TypeError in that case. |
600 if (object->IsUndefined(isolate()) || object->IsNull()) { | 600 if (object->IsUndefined(isolate()) || object->IsNull(isolate())) { |
601 return TypeError(MessageTemplate::kNonObjectPropertyLoad, object, name); | 601 return TypeError(MessageTemplate::kNonObjectPropertyLoad, object, name); |
602 } | 602 } |
603 | 603 |
604 // Check if the name is trivially convertible to an index and get | 604 // Check if the name is trivially convertible to an index and get |
605 // the element or char if so. | 605 // the element or char if so. |
606 uint32_t index; | 606 uint32_t index; |
607 if (kind() == Code::KEYED_LOAD_IC && name->AsArrayIndex(&index)) { | 607 if (kind() == Code::KEYED_LOAD_IC && name->AsArrayIndex(&index)) { |
608 // Rewrite to the generic keyed load stub. | 608 // Rewrite to the generic keyed load stub. |
609 if (FLAG_use_ic) { | 609 if (FLAG_use_ic) { |
610 DCHECK(UseVector()); | 610 DCHECK(UseVector()); |
(...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1529 if (MigrateDeprecated(object) || object->IsJSProxy()) { | 1529 if (MigrateDeprecated(object) || object->IsJSProxy()) { |
1530 Handle<Object> result; | 1530 Handle<Object> result; |
1531 ASSIGN_RETURN_ON_EXCEPTION( | 1531 ASSIGN_RETURN_ON_EXCEPTION( |
1532 isolate(), result, | 1532 isolate(), result, |
1533 Object::SetProperty(object, name, value, language_mode()), Object); | 1533 Object::SetProperty(object, name, value, language_mode()), Object); |
1534 return result; | 1534 return result; |
1535 } | 1535 } |
1536 | 1536 |
1537 // If the object is undefined or null it's illegal to try to set any | 1537 // If the object is undefined or null it's illegal to try to set any |
1538 // properties on it; throw a TypeError in that case. | 1538 // properties on it; throw a TypeError in that case. |
1539 if (object->IsUndefined(isolate()) || object->IsNull()) { | 1539 if (object->IsUndefined(isolate()) || object->IsNull(isolate())) { |
1540 return TypeError(MessageTemplate::kNonObjectPropertyStore, object, name); | 1540 return TypeError(MessageTemplate::kNonObjectPropertyStore, object, name); |
1541 } | 1541 } |
1542 | 1542 |
1543 if (state() != UNINITIALIZED) { | 1543 if (state() != UNINITIALIZED) { |
1544 JSObject::MakePrototypesFast(object, kStartAtPrototype, isolate()); | 1544 JSObject::MakePrototypesFast(object, kStartAtPrototype, isolate()); |
1545 } | 1545 } |
1546 LookupIterator it(object, name); | 1546 LookupIterator it(object, name); |
1547 if (FLAG_use_ic) UpdateCaches(&it, value, store_mode); | 1547 if (FLAG_use_ic) UpdateCaches(&it, value, store_mode); |
1548 | 1548 |
1549 MAYBE_RETURN_NULL( | 1549 MAYBE_RETURN_NULL( |
(...skipping 1401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2951 DCHECK_EQ(FeedbackVectorSlotKind::KEYED_LOAD_IC, | 2951 DCHECK_EQ(FeedbackVectorSlotKind::KEYED_LOAD_IC, |
2952 vector->GetKind(vector_slot)); | 2952 vector->GetKind(vector_slot)); |
2953 KeyedLoadICNexus nexus(vector, vector_slot); | 2953 KeyedLoadICNexus nexus(vector, vector_slot); |
2954 KeyedLoadIC ic(IC::EXTRA_CALL_FRAME, isolate, &nexus); | 2954 KeyedLoadIC ic(IC::EXTRA_CALL_FRAME, isolate, &nexus); |
2955 ic.UpdateState(receiver, key); | 2955 ic.UpdateState(receiver, key); |
2956 RETURN_RESULT_OR_FAILURE(isolate, ic.Load(receiver, key)); | 2956 RETURN_RESULT_OR_FAILURE(isolate, ic.Load(receiver, key)); |
2957 } | 2957 } |
2958 } | 2958 } |
2959 } // namespace internal | 2959 } // namespace internal |
2960 } // namespace v8 | 2960 } // namespace v8 |
OLD | NEW |