OLD | NEW |
---|---|
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 <iomanip> | 5 #include <iomanip> |
6 #include <sstream> | 6 #include <sstream> |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/accessors.h" | 10 #include "src/accessors.h" |
(...skipping 4626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4637 int index = Smi::cast(iteration_order->get(i))->value(); | 4637 int index = Smi::cast(iteration_order->get(i))->value(); |
4638 DCHECK(dictionary->IsKey(dictionary->KeyAt(index))); | 4638 DCHECK(dictionary->IsKey(dictionary->KeyAt(index))); |
4639 | 4639 |
4640 Object* value = dictionary->ValueAt(index); | 4640 Object* value = dictionary->ValueAt(index); |
4641 PropertyType type = dictionary->DetailsAt(index).type(); | 4641 PropertyType type = dictionary->DetailsAt(index).type(); |
4642 if (type == DATA && !value->IsJSFunction()) { | 4642 if (type == DATA && !value->IsJSFunction()) { |
4643 number_of_fields += 1; | 4643 number_of_fields += 1; |
4644 } | 4644 } |
4645 } | 4645 } |
4646 | 4646 |
4647 int inobject_props = object->map()->inobject_properties(); | 4647 Handle<Map> old_map(object->map(), isolate); |
4648 | |
4649 int inobject_props = old_map->inobject_properties(); | |
4648 | 4650 |
4649 // Allocate new map. | 4651 // Allocate new map. |
4650 Handle<Map> new_map = Map::CopyDropDescriptors(handle(object->map())); | 4652 Handle<Map> new_map = Map::CopyDropDescriptors(old_map); |
4651 new_map->set_dictionary_map(false); | 4653 new_map->set_dictionary_map(false); |
4652 | 4654 |
4653 if (object->map()->is_prototype_map()) { | 4655 if (old_map->is_prototype_map() && FLAG_track_prototype_users) { |
4654 DCHECK(new_map->is_prototype_map()); | 4656 DCHECK(new_map->is_prototype_map()); |
4655 new_map->set_prototype_info(object->map()->prototype_info()); | 4657 |
4656 object->map()->set_prototype_info(Smi::FromInt(0)); | 4658 Object* maybe_old_prototype = old_map->prototype(); |
4659 if (maybe_old_prototype->IsJSObject()) { | |
Jakob Kummerow
2015/07/28 15:14:19
This if-block is new; the other changes are just r
| |
4660 Handle<JSObject> old_prototype(JSObject::cast(maybe_old_prototype)); | |
4661 bool was_registered = | |
4662 JSObject::UnregisterPrototypeUser(old_prototype, old_map); | |
4663 if (was_registered) { | |
4664 JSObject::LazyRegisterPrototypeUser(new_map, isolate); | |
4665 } | |
4666 } | |
4667 new_map->set_prototype_info(old_map->prototype_info()); | |
4668 old_map->set_prototype_info(Smi::FromInt(0)); | |
4657 if (FLAG_trace_prototype_users) { | 4669 if (FLAG_trace_prototype_users) { |
4658 PrintF("Moving prototype_info %p from map %p to map %p.\n", | 4670 PrintF("Moving prototype_info %p from map %p to map %p.\n", |
4659 reinterpret_cast<void*>(new_map->prototype_info()), | 4671 reinterpret_cast<void*>(new_map->prototype_info()), |
4660 reinterpret_cast<void*>(object->map()), | 4672 reinterpret_cast<void*>(*old_map), |
4661 reinterpret_cast<void*>(*new_map)); | 4673 reinterpret_cast<void*>(*new_map)); |
4662 } | 4674 } |
4663 } | 4675 } |
4664 | 4676 |
4665 #if TRACE_MAPS | 4677 #if TRACE_MAPS |
4666 if (FLAG_trace_maps) { | 4678 if (FLAG_trace_maps) { |
4667 PrintF("[TraceMaps: SlowToFast from= %p to= %p reason= %s ]\n", | 4679 PrintF("[TraceMaps: SlowToFast from= %p to= %p reason= %s ]\n", |
4668 reinterpret_cast<void*>(object->map()), | 4680 reinterpret_cast<void*>(*old_map), reinterpret_cast<void*>(*new_map), |
4669 reinterpret_cast<void*>(*new_map), reason); | 4681 reason); |
4670 } | 4682 } |
4671 #endif | 4683 #endif |
4672 | 4684 |
4673 if (instance_descriptor_length == 0) { | 4685 if (instance_descriptor_length == 0) { |
4674 DisallowHeapAllocation no_gc; | 4686 DisallowHeapAllocation no_gc; |
4675 DCHECK_LE(unused_property_fields, inobject_props); | 4687 DCHECK_LE(unused_property_fields, inobject_props); |
4676 // Transform the object. | 4688 // Transform the object. |
4677 new_map->set_unused_property_fields(inobject_props); | 4689 new_map->set_unused_property_fields(inobject_props); |
4678 object->synchronized_set_map(*new_map); | 4690 object->synchronized_set_map(*new_map); |
4679 object->set_properties(isolate->heap()->empty_fixed_array()); | 4691 object->set_properties(isolate->heap()->empty_fixed_array()); |
(...skipping 11080 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
15760 if (cell->value() != *new_value) { | 15772 if (cell->value() != *new_value) { |
15761 cell->set_value(*new_value); | 15773 cell->set_value(*new_value); |
15762 Isolate* isolate = cell->GetIsolate(); | 15774 Isolate* isolate = cell->GetIsolate(); |
15763 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 15775 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
15764 isolate, DependentCode::kPropertyCellChangedGroup); | 15776 isolate, DependentCode::kPropertyCellChangedGroup); |
15765 } | 15777 } |
15766 } | 15778 } |
15767 | 15779 |
15768 } // namespace internal | 15780 } // namespace internal |
15769 } // namespace v8 | 15781 } // namespace v8 |
OLD | NEW |