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/mark-compact.h" | 5 #include "src/heap/mark-compact.h" |
6 | 6 |
7 #include "src/base/atomicops.h" | 7 #include "src/base/atomicops.h" |
8 #include "src/base/bits.h" | 8 #include "src/base/bits.h" |
9 #include "src/base/sys-info.h" | 9 #include "src/base/sys-info.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 2560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2571 if (transition_index == num_transitions) { | 2571 if (transition_index == num_transitions) { |
2572 DCHECK(!descriptors_owner_died); | 2572 DCHECK(!descriptors_owner_died); |
2573 return false; | 2573 return false; |
2574 } | 2574 } |
2575 // Note that we never eliminate a transition array, though we might right-trim | 2575 // Note that we never eliminate a transition array, though we might right-trim |
2576 // such that number_of_transitions() == 0. If this assumption changes, | 2576 // such that number_of_transitions() == 0. If this assumption changes, |
2577 // TransitionArray::Insert() will need to deal with the case that a transition | 2577 // TransitionArray::Insert() will need to deal with the case that a transition |
2578 // array disappeared during GC. | 2578 // array disappeared during GC. |
2579 int trim = TransitionArray::Capacity(transitions) - transition_index; | 2579 int trim = TransitionArray::Capacity(transitions) - transition_index; |
2580 if (trim > 0) { | 2580 if (trim > 0) { |
2581 heap_->RightTrimFixedArray<Heap::SEQUENTIAL_TO_SWEEPER>( | 2581 heap_->RightTrimFixedArray(transitions, |
2582 transitions, trim * TransitionArray::kTransitionSize); | 2582 trim * TransitionArray::kTransitionSize); |
2583 transitions->SetNumberOfTransitions(transition_index); | 2583 transitions->SetNumberOfTransitions(transition_index); |
2584 } | 2584 } |
2585 return descriptors_owner_died; | 2585 return descriptors_owner_died; |
2586 } | 2586 } |
2587 | 2587 |
2588 | 2588 |
2589 void MarkCompactCollector::TrimDescriptorArray(Map* map, | 2589 void MarkCompactCollector::TrimDescriptorArray(Map* map, |
2590 DescriptorArray* descriptors) { | 2590 DescriptorArray* descriptors) { |
2591 int number_of_own_descriptors = map->NumberOfOwnDescriptors(); | 2591 int number_of_own_descriptors = map->NumberOfOwnDescriptors(); |
2592 if (number_of_own_descriptors == 0) { | 2592 if (number_of_own_descriptors == 0) { |
2593 DCHECK(descriptors == heap_->empty_descriptor_array()); | 2593 DCHECK(descriptors == heap_->empty_descriptor_array()); |
2594 return; | 2594 return; |
2595 } | 2595 } |
2596 | 2596 |
2597 int number_of_descriptors = descriptors->number_of_descriptors_storage(); | 2597 int number_of_descriptors = descriptors->number_of_descriptors_storage(); |
2598 int to_trim = number_of_descriptors - number_of_own_descriptors; | 2598 int to_trim = number_of_descriptors - number_of_own_descriptors; |
2599 if (to_trim > 0) { | 2599 if (to_trim > 0) { |
2600 heap_->RightTrimFixedArray<Heap::SEQUENTIAL_TO_SWEEPER>( | 2600 heap_->RightTrimFixedArray(descriptors, |
2601 descriptors, to_trim * DescriptorArray::kDescriptorSize); | 2601 to_trim * DescriptorArray::kDescriptorSize); |
2602 descriptors->SetNumberOfDescriptors(number_of_own_descriptors); | 2602 descriptors->SetNumberOfDescriptors(number_of_own_descriptors); |
2603 | 2603 |
2604 if (descriptors->HasEnumCache()) TrimEnumCache(map, descriptors); | 2604 if (descriptors->HasEnumCache()) TrimEnumCache(map, descriptors); |
2605 descriptors->Sort(); | 2605 descriptors->Sort(); |
2606 | 2606 |
2607 if (FLAG_unbox_double_fields) { | 2607 if (FLAG_unbox_double_fields) { |
2608 LayoutDescriptor* layout_descriptor = map->layout_descriptor(); | 2608 LayoutDescriptor* layout_descriptor = map->layout_descriptor(); |
2609 layout_descriptor = layout_descriptor->Trim(heap_, map, descriptors, | 2609 layout_descriptor = layout_descriptor->Trim(heap_, map, descriptors, |
2610 number_of_own_descriptors); | 2610 number_of_own_descriptors); |
2611 SLOW_DCHECK(layout_descriptor->IsConsistentWithMap(map, true)); | 2611 SLOW_DCHECK(layout_descriptor->IsConsistentWithMap(map, true)); |
(...skipping 10 matching lines...) Expand all Loading... |
2622 if (live_enum == kInvalidEnumCacheSentinel) { | 2622 if (live_enum == kInvalidEnumCacheSentinel) { |
2623 live_enum = | 2623 live_enum = |
2624 map->NumberOfDescribedProperties(OWN_DESCRIPTORS, ENUMERABLE_STRINGS); | 2624 map->NumberOfDescribedProperties(OWN_DESCRIPTORS, ENUMERABLE_STRINGS); |
2625 } | 2625 } |
2626 if (live_enum == 0) return descriptors->ClearEnumCache(); | 2626 if (live_enum == 0) return descriptors->ClearEnumCache(); |
2627 | 2627 |
2628 FixedArray* enum_cache = descriptors->GetEnumCache(); | 2628 FixedArray* enum_cache = descriptors->GetEnumCache(); |
2629 | 2629 |
2630 int to_trim = enum_cache->length() - live_enum; | 2630 int to_trim = enum_cache->length() - live_enum; |
2631 if (to_trim <= 0) return; | 2631 if (to_trim <= 0) return; |
2632 heap_->RightTrimFixedArray<Heap::SEQUENTIAL_TO_SWEEPER>( | 2632 heap_->RightTrimFixedArray(descriptors->GetEnumCache(), to_trim); |
2633 descriptors->GetEnumCache(), to_trim); | |
2634 | 2633 |
2635 if (!descriptors->HasEnumIndicesCache()) return; | 2634 if (!descriptors->HasEnumIndicesCache()) return; |
2636 FixedArray* enum_indices_cache = descriptors->GetEnumIndicesCache(); | 2635 FixedArray* enum_indices_cache = descriptors->GetEnumIndicesCache(); |
2637 heap_->RightTrimFixedArray<Heap::SEQUENTIAL_TO_SWEEPER>(enum_indices_cache, | 2636 heap_->RightTrimFixedArray(enum_indices_cache, to_trim); |
2638 to_trim); | |
2639 } | 2637 } |
2640 | 2638 |
2641 | 2639 |
2642 void MarkCompactCollector::ProcessWeakCollections() { | 2640 void MarkCompactCollector::ProcessWeakCollections() { |
2643 Object* weak_collection_obj = heap()->encountered_weak_collections(); | 2641 Object* weak_collection_obj = heap()->encountered_weak_collections(); |
2644 while (weak_collection_obj != Smi::kZero) { | 2642 while (weak_collection_obj != Smi::kZero) { |
2645 JSWeakCollection* weak_collection = | 2643 JSWeakCollection* weak_collection = |
2646 reinterpret_cast<JSWeakCollection*>(weak_collection_obj); | 2644 reinterpret_cast<JSWeakCollection*>(weak_collection_obj); |
2647 DCHECK(MarkCompactCollector::IsMarked(weak_collection)); | 2645 DCHECK(MarkCompactCollector::IsMarked(weak_collection)); |
2648 if (weak_collection->table()->IsHashTable()) { | 2646 if (weak_collection->table()->IsHashTable()) { |
(...skipping 1286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3935 // The target is always in old space, we don't have to record the slot in | 3933 // The target is always in old space, we don't have to record the slot in |
3936 // the old-to-new remembered set. | 3934 // the old-to-new remembered set. |
3937 DCHECK(!heap()->InNewSpace(target)); | 3935 DCHECK(!heap()->InNewSpace(target)); |
3938 RecordRelocSlot(host, &rinfo, target); | 3936 RecordRelocSlot(host, &rinfo, target); |
3939 } | 3937 } |
3940 } | 3938 } |
3941 } | 3939 } |
3942 | 3940 |
3943 } // namespace internal | 3941 } // namespace internal |
3944 } // namespace v8 | 3942 } // namespace v8 |
OLD | NEW |