OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/objects.h" | 5 #include "src/objects.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <iomanip> | 8 #include <iomanip> |
9 #include <sstream> | 9 #include <sstream> |
10 | 10 |
(...skipping 2779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2790 } | 2790 } |
2791 // Otherwise, properties will need to be moved to the backing store. | 2791 // Otherwise, properties will need to be moved to the backing store. |
2792 return true; | 2792 return true; |
2793 } | 2793 } |
2794 | 2794 |
2795 | 2795 |
2796 // static | 2796 // static |
2797 void JSObject::UpdatePrototypeUserRegistration(Handle<Map> old_map, | 2797 void JSObject::UpdatePrototypeUserRegistration(Handle<Map> old_map, |
2798 Handle<Map> new_map, | 2798 Handle<Map> new_map, |
2799 Isolate* isolate) { | 2799 Isolate* isolate) { |
2800 if (!FLAG_track_prototype_users) return; | |
2801 if (!old_map->is_prototype_map()) return; | 2800 if (!old_map->is_prototype_map()) return; |
2802 DCHECK(new_map->is_prototype_map()); | 2801 DCHECK(new_map->is_prototype_map()); |
2803 bool was_registered = JSObject::UnregisterPrototypeUser(old_map, isolate); | 2802 bool was_registered = JSObject::UnregisterPrototypeUser(old_map, isolate); |
2804 new_map->set_prototype_info(old_map->prototype_info()); | 2803 new_map->set_prototype_info(old_map->prototype_info()); |
2805 old_map->set_prototype_info(Smi::FromInt(0)); | 2804 old_map->set_prototype_info(Smi::FromInt(0)); |
2806 if (FLAG_trace_prototype_users) { | 2805 if (FLAG_trace_prototype_users) { |
2807 PrintF("Moving prototype_info %p from map %p to map %p.\n", | 2806 PrintF("Moving prototype_info %p from map %p to map %p.\n", |
2808 reinterpret_cast<void*>(new_map->prototype_info()), | 2807 reinterpret_cast<void*>(new_map->prototype_info()), |
2809 reinterpret_cast<void*>(*old_map), | 2808 reinterpret_cast<void*>(*old_map), |
2810 reinterpret_cast<void*>(*new_map)); | 2809 reinterpret_cast<void*>(*new_map)); |
(...skipping 8780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11591 | 11590 |
11592 // static | 11591 // static |
11593 void JSObject::ReoptimizeIfPrototype(Handle<JSObject> object) { | 11592 void JSObject::ReoptimizeIfPrototype(Handle<JSObject> object) { |
11594 if (!object->map()->is_prototype_map()) return; | 11593 if (!object->map()->is_prototype_map()) return; |
11595 OptimizeAsPrototype(object, FAST_PROTOTYPE); | 11594 OptimizeAsPrototype(object, FAST_PROTOTYPE); |
11596 } | 11595 } |
11597 | 11596 |
11598 | 11597 |
11599 // static | 11598 // static |
11600 void JSObject::LazyRegisterPrototypeUser(Handle<Map> user, Isolate* isolate) { | 11599 void JSObject::LazyRegisterPrototypeUser(Handle<Map> user, Isolate* isolate) { |
11601 DCHECK(FLAG_track_prototype_users); | |
11602 // Contract: In line with InvalidatePrototypeChains()'s requirements, | 11600 // Contract: In line with InvalidatePrototypeChains()'s requirements, |
11603 // leaf maps don't need to register as users, only prototypes do. | 11601 // leaf maps don't need to register as users, only prototypes do. |
11604 DCHECK(user->is_prototype_map()); | 11602 DCHECK(user->is_prototype_map()); |
11605 | 11603 |
11606 Handle<Map> current_user = user; | 11604 Handle<Map> current_user = user; |
11607 Handle<PrototypeInfo> current_user_info = | 11605 Handle<PrototypeInfo> current_user_info = |
11608 Map::GetOrCreatePrototypeInfo(user, isolate); | 11606 Map::GetOrCreatePrototypeInfo(user, isolate); |
11609 for (PrototypeIterator iter(user); !iter.IsAtEnd(); iter.Advance()) { | 11607 for (PrototypeIterator iter(user); !iter.IsAtEnd(); iter.Advance()) { |
11610 // Walk up the prototype chain as far as links haven't been registered yet. | 11608 // Walk up the prototype chain as far as links haven't been registered yet. |
11611 if (current_user_info->registry_slot() != PrototypeInfo::UNREGISTERED) { | 11609 if (current_user_info->registry_slot() != PrototypeInfo::UNREGISTERED) { |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11697 Map* user; | 11695 Map* user; |
11698 while ((user = iterator.Next<Map>())) { | 11696 while ((user = iterator.Next<Map>())) { |
11699 // Walk the prototype chain (backwards, towards leaf objects) if necessary. | 11697 // Walk the prototype chain (backwards, towards leaf objects) if necessary. |
11700 InvalidatePrototypeChainsInternal(user); | 11698 InvalidatePrototypeChainsInternal(user); |
11701 } | 11699 } |
11702 } | 11700 } |
11703 | 11701 |
11704 | 11702 |
11705 // static | 11703 // static |
11706 void JSObject::InvalidatePrototypeChains(Map* map) { | 11704 void JSObject::InvalidatePrototypeChains(Map* map) { |
11707 if (!FLAG_eliminate_prototype_chain_checks) return; | |
11708 DisallowHeapAllocation no_gc; | 11705 DisallowHeapAllocation no_gc; |
11709 InvalidatePrototypeChainsInternal(map); | 11706 InvalidatePrototypeChainsInternal(map); |
11710 } | 11707 } |
11711 | 11708 |
11712 | 11709 |
11713 // static | 11710 // static |
11714 Handle<PrototypeInfo> Map::GetOrCreatePrototypeInfo(Handle<JSObject> prototype, | 11711 Handle<PrototypeInfo> Map::GetOrCreatePrototypeInfo(Handle<JSObject> prototype, |
11715 Isolate* isolate) { | 11712 Isolate* isolate) { |
11716 Object* maybe_proto_info = prototype->map()->prototype_info(); | 11713 Object* maybe_proto_info = prototype->map()->prototype_info(); |
11717 if (maybe_proto_info->IsPrototypeInfo()) { | 11714 if (maybe_proto_info->IsPrototypeInfo()) { |
(...skipping 6675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
18393 if (cell->value() != *new_value) { | 18390 if (cell->value() != *new_value) { |
18394 cell->set_value(*new_value); | 18391 cell->set_value(*new_value); |
18395 Isolate* isolate = cell->GetIsolate(); | 18392 Isolate* isolate = cell->GetIsolate(); |
18396 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 18393 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
18397 isolate, DependentCode::kPropertyCellChangedGroup); | 18394 isolate, DependentCode::kPropertyCellChangedGroup); |
18398 } | 18395 } |
18399 } | 18396 } |
18400 | 18397 |
18401 } // namespace internal | 18398 } // namespace internal |
18402 } // namespace v8 | 18399 } // namespace v8 |
OLD | NEW |