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/v8.h" | 5 #include "src/v8.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/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/compilation-cache.h" | 10 #include "src/compilation-cache.h" |
(...skipping 2569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2580 | 2580 |
2581 // Note that we never eliminate a transition array, though we might right-trim | 2581 // Note that we never eliminate a transition array, though we might right-trim |
2582 // such that number_of_transitions() == 0. If this assumption changes, | 2582 // such that number_of_transitions() == 0. If this assumption changes, |
2583 // TransitionArray::Insert() will need to deal with the case that a transition | 2583 // TransitionArray::Insert() will need to deal with the case that a transition |
2584 // array disappeared during GC. | 2584 // array disappeared during GC. |
2585 int trim = TransitionArray::Capacity(transitions) - transition_index; | 2585 int trim = TransitionArray::Capacity(transitions) - transition_index; |
2586 if (trim > 0) { | 2586 if (trim > 0) { |
2587 // Non-full-TransitionArray cases can never reach this point. | 2587 // Non-full-TransitionArray cases can never reach this point. |
2588 DCHECK(TransitionArray::IsFullTransitionArray(transitions)); | 2588 DCHECK(TransitionArray::IsFullTransitionArray(transitions)); |
2589 TransitionArray* t = TransitionArray::cast(transitions); | 2589 TransitionArray* t = TransitionArray::cast(transitions); |
2590 heap_->RightTrimFixedArray<Heap::FROM_GC>( | 2590 heap_->RightTrimFixedArray<Heap::SWEEPING_IS_OFF>( |
2591 t, trim * TransitionArray::kTransitionSize); | 2591 t, trim * TransitionArray::kTransitionSize); |
2592 t->SetNumberOfTransitions(transition_index); | 2592 t->SetNumberOfTransitions(transition_index); |
2593 // The map still has a full transition array. | 2593 // The map still has a full transition array. |
2594 DCHECK(TransitionArray::IsFullTransitionArray(map->raw_transitions())); | 2594 DCHECK(TransitionArray::IsFullTransitionArray(map->raw_transitions())); |
2595 } | 2595 } |
2596 } | 2596 } |
2597 | 2597 |
2598 | 2598 |
2599 void MarkCompactCollector::TrimDescriptorArray(Map* map, | 2599 void MarkCompactCollector::TrimDescriptorArray(Map* map, |
2600 DescriptorArray* descriptors, | 2600 DescriptorArray* descriptors, |
2601 int number_of_own_descriptors) { | 2601 int number_of_own_descriptors) { |
2602 int number_of_descriptors = descriptors->number_of_descriptors_storage(); | 2602 int number_of_descriptors = descriptors->number_of_descriptors_storage(); |
2603 int to_trim = number_of_descriptors - number_of_own_descriptors; | 2603 int to_trim = number_of_descriptors - number_of_own_descriptors; |
2604 if (to_trim == 0) return; | 2604 if (to_trim == 0) return; |
2605 | 2605 |
2606 heap_->RightTrimFixedArray<Heap::FROM_GC>( | 2606 heap_->RightTrimFixedArray<Heap::SWEEPING_IS_OFF>( |
2607 descriptors, to_trim * DescriptorArray::kDescriptorSize); | 2607 descriptors, to_trim * DescriptorArray::kDescriptorSize); |
2608 descriptors->SetNumberOfDescriptors(number_of_own_descriptors); | 2608 descriptors->SetNumberOfDescriptors(number_of_own_descriptors); |
2609 | 2609 |
2610 if (descriptors->HasEnumCache()) TrimEnumCache(map, descriptors); | 2610 if (descriptors->HasEnumCache()) TrimEnumCache(map, descriptors); |
2611 descriptors->Sort(); | 2611 descriptors->Sort(); |
2612 } | 2612 } |
2613 | 2613 |
2614 | 2614 |
2615 void MarkCompactCollector::TrimEnumCache(Map* map, | 2615 void MarkCompactCollector::TrimEnumCache(Map* map, |
2616 DescriptorArray* descriptors) { | 2616 DescriptorArray* descriptors) { |
2617 int live_enum = map->EnumLength(); | 2617 int live_enum = map->EnumLength(); |
2618 if (live_enum == kInvalidEnumCacheSentinel) { | 2618 if (live_enum == kInvalidEnumCacheSentinel) { |
2619 live_enum = map->NumberOfDescribedProperties(OWN_DESCRIPTORS, DONT_ENUM); | 2619 live_enum = map->NumberOfDescribedProperties(OWN_DESCRIPTORS, DONT_ENUM); |
2620 } | 2620 } |
2621 if (live_enum == 0) return descriptors->ClearEnumCache(); | 2621 if (live_enum == 0) return descriptors->ClearEnumCache(); |
2622 | 2622 |
2623 FixedArray* enum_cache = descriptors->GetEnumCache(); | 2623 FixedArray* enum_cache = descriptors->GetEnumCache(); |
2624 | 2624 |
2625 int to_trim = enum_cache->length() - live_enum; | 2625 int to_trim = enum_cache->length() - live_enum; |
2626 if (to_trim <= 0) return; | 2626 if (to_trim <= 0) return; |
2627 heap_->RightTrimFixedArray<Heap::FROM_GC>(descriptors->GetEnumCache(), | 2627 heap_->RightTrimFixedArray<Heap::SWEEPING_IS_OFF>(descriptors->GetEnumCache(), |
2628 to_trim); | 2628 to_trim); |
2629 | 2629 |
2630 if (!descriptors->HasEnumIndicesCache()) return; | 2630 if (!descriptors->HasEnumIndicesCache()) return; |
2631 FixedArray* enum_indices_cache = descriptors->GetEnumIndicesCache(); | 2631 FixedArray* enum_indices_cache = descriptors->GetEnumIndicesCache(); |
2632 heap_->RightTrimFixedArray<Heap::FROM_GC>(enum_indices_cache, to_trim); | 2632 heap_->RightTrimFixedArray<Heap::SWEEPING_IS_OFF>(enum_indices_cache, |
| 2633 to_trim); |
2633 } | 2634 } |
2634 | 2635 |
2635 | 2636 |
2636 void MarkCompactCollector::ProcessWeakCollections() { | 2637 void MarkCompactCollector::ProcessWeakCollections() { |
2637 GCTracer::Scope gc_scope(heap()->tracer(), | 2638 GCTracer::Scope gc_scope(heap()->tracer(), |
2638 GCTracer::Scope::MC_WEAKCOLLECTION_PROCESS); | 2639 GCTracer::Scope::MC_WEAKCOLLECTION_PROCESS); |
2639 Object* weak_collection_obj = heap()->encountered_weak_collections(); | 2640 Object* weak_collection_obj = heap()->encountered_weak_collections(); |
2640 while (weak_collection_obj != Smi::FromInt(0)) { | 2641 while (weak_collection_obj != Smi::FromInt(0)) { |
2641 JSWeakCollection* weak_collection = | 2642 JSWeakCollection* weak_collection = |
2642 reinterpret_cast<JSWeakCollection*>(weak_collection_obj); | 2643 reinterpret_cast<JSWeakCollection*>(weak_collection_obj); |
(...skipping 2107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4750 SlotsBuffer* buffer = *buffer_address; | 4751 SlotsBuffer* buffer = *buffer_address; |
4751 while (buffer != NULL) { | 4752 while (buffer != NULL) { |
4752 SlotsBuffer* next_buffer = buffer->next(); | 4753 SlotsBuffer* next_buffer = buffer->next(); |
4753 DeallocateBuffer(buffer); | 4754 DeallocateBuffer(buffer); |
4754 buffer = next_buffer; | 4755 buffer = next_buffer; |
4755 } | 4756 } |
4756 *buffer_address = NULL; | 4757 *buffer_address = NULL; |
4757 } | 4758 } |
4758 } | 4759 } |
4759 } // namespace v8::internal | 4760 } // namespace v8::internal |
OLD | NEW |