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/heap/heap.h" | 5 #include "src/heap/heap.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/ast/scopeinfo.h" | 9 #include "src/ast/scopeinfo.h" |
10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
(...skipping 5591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5602 DCHECK_EQ(*dep, LookupWeakObjectToCodeDependency(obj)); | 5602 DCHECK_EQ(*dep, LookupWeakObjectToCodeDependency(obj)); |
5603 } | 5603 } |
5604 | 5604 |
5605 | 5605 |
5606 DependentCode* Heap::LookupWeakObjectToCodeDependency(Handle<HeapObject> obj) { | 5606 DependentCode* Heap::LookupWeakObjectToCodeDependency(Handle<HeapObject> obj) { |
5607 Object* dep = weak_object_to_code_table()->Lookup(obj); | 5607 Object* dep = weak_object_to_code_table()->Lookup(obj); |
5608 if (dep->IsDependentCode()) return DependentCode::cast(dep); | 5608 if (dep->IsDependentCode()) return DependentCode::cast(dep); |
5609 return DependentCode::cast(empty_fixed_array()); | 5609 return DependentCode::cast(empty_fixed_array()); |
5610 } | 5610 } |
5611 | 5611 |
| 5612 void Heap::CompactWeakFixedArrays() { |
| 5613 // Find known WeakFixedArrays and compact them. |
| 5614 i::HeapIterator iterator(this); |
| 5615 for (i::HeapObject* o = iterator.next(); o != NULL; o = iterator.next()) { |
| 5616 if (o->IsPrototypeInfo()) { |
| 5617 i::Object* prototype_users = i::PrototypeInfo::cast(o)->prototype_users(); |
| 5618 if (prototype_users->IsWeakFixedArray()) { |
| 5619 i::WeakFixedArray* array = i::WeakFixedArray::cast(prototype_users); |
| 5620 array->Compact<i::JSObject::PrototypeRegistryCompactionCallback>(); |
| 5621 } |
| 5622 } else if (o->IsScript()) { |
| 5623 i::Object* shared_list = i::Script::cast(o)->shared_function_infos(); |
| 5624 if (shared_list->IsWeakFixedArray()) { |
| 5625 i::WeakFixedArray* array = i::WeakFixedArray::cast(shared_list); |
| 5626 array->Compact<i::WeakFixedArray::NullCallback>(); |
| 5627 } |
| 5628 } |
| 5629 } |
| 5630 } |
5612 | 5631 |
5613 void Heap::AddRetainedMap(Handle<Map> map) { | 5632 void Heap::AddRetainedMap(Handle<Map> map) { |
5614 Handle<WeakCell> cell = Map::WeakCellForMap(map); | 5633 Handle<WeakCell> cell = Map::WeakCellForMap(map); |
5615 Handle<ArrayList> array(retained_maps(), isolate()); | 5634 Handle<ArrayList> array(retained_maps(), isolate()); |
5616 if (array->IsFull()) { | 5635 if (array->IsFull()) { |
5617 CompactRetainedMaps(*array); | 5636 CompactRetainedMaps(*array); |
5618 } | 5637 } |
5619 array = ArrayList::Add( | 5638 array = ArrayList::Add( |
5620 array, cell, handle(Smi::FromInt(FLAG_retain_maps_for_n_gc), isolate()), | 5639 array, cell, handle(Smi::FromInt(FLAG_retain_maps_for_n_gc), isolate()), |
5621 ArrayList::kReloadLengthAfterAllocation); | 5640 ArrayList::kReloadLengthAfterAllocation); |
(...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6406 } | 6425 } |
6407 | 6426 |
6408 | 6427 |
6409 // static | 6428 // static |
6410 int Heap::GetStaticVisitorIdForMap(Map* map) { | 6429 int Heap::GetStaticVisitorIdForMap(Map* map) { |
6411 return StaticVisitorBase::GetVisitorId(map); | 6430 return StaticVisitorBase::GetVisitorId(map); |
6412 } | 6431 } |
6413 | 6432 |
6414 } // namespace internal | 6433 } // namespace internal |
6415 } // namespace v8 | 6434 } // namespace v8 |
OLD | NEW |