| 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 2539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2550 | 2550 |
| 2551 // Note that we never eliminate a transition array, though we might right-trim | 2551 // Note that we never eliminate a transition array, though we might right-trim |
| 2552 // such that number_of_transitions() == 0. If this assumption changes, | 2552 // such that number_of_transitions() == 0. If this assumption changes, |
| 2553 // TransitionArray::Insert() will need to deal with the case that a transition | 2553 // TransitionArray::Insert() will need to deal with the case that a transition |
| 2554 // array disappeared during GC. | 2554 // array disappeared during GC. |
| 2555 int trim = TransitionArray::Capacity(transitions) - transition_index; | 2555 int trim = TransitionArray::Capacity(transitions) - transition_index; |
| 2556 if (trim > 0) { | 2556 if (trim > 0) { |
| 2557 // Non-full-TransitionArray cases can never reach this point. | 2557 // Non-full-TransitionArray cases can never reach this point. |
| 2558 DCHECK(TransitionArray::IsFullTransitionArray(transitions)); | 2558 DCHECK(TransitionArray::IsFullTransitionArray(transitions)); |
| 2559 TransitionArray* t = TransitionArray::cast(transitions); | 2559 TransitionArray* t = TransitionArray::cast(transitions); |
| 2560 heap_->RightTrimFixedArray<Heap::FROM_GC>( | 2560 heap_->RightTrimFixedArray<Heap::SEQUENTIAL_TO_SWEEPER>( |
| 2561 t, trim * TransitionArray::kTransitionSize); | 2561 t, trim * TransitionArray::kTransitionSize); |
| 2562 t->SetNumberOfTransitions(transition_index); | 2562 t->SetNumberOfTransitions(transition_index); |
| 2563 // The map still has a full transition array. | 2563 // The map still has a full transition array. |
| 2564 DCHECK(TransitionArray::IsFullTransitionArray(map->raw_transitions())); | 2564 DCHECK(TransitionArray::IsFullTransitionArray(map->raw_transitions())); |
| 2565 } | 2565 } |
| 2566 } | 2566 } |
| 2567 | 2567 |
| 2568 | 2568 |
| 2569 void MarkCompactCollector::TrimDescriptorArray(Map* map, | 2569 void MarkCompactCollector::TrimDescriptorArray(Map* map, |
| 2570 DescriptorArray* descriptors, | 2570 DescriptorArray* descriptors, |
| 2571 int number_of_own_descriptors) { | 2571 int number_of_own_descriptors) { |
| 2572 int number_of_descriptors = descriptors->number_of_descriptors_storage(); | 2572 int number_of_descriptors = descriptors->number_of_descriptors_storage(); |
| 2573 int to_trim = number_of_descriptors - number_of_own_descriptors; | 2573 int to_trim = number_of_descriptors - number_of_own_descriptors; |
| 2574 if (to_trim == 0) return; | 2574 if (to_trim == 0) return; |
| 2575 | 2575 |
| 2576 heap_->RightTrimFixedArray<Heap::FROM_GC>( | 2576 heap_->RightTrimFixedArray<Heap::SEQUENTIAL_TO_SWEEPER>( |
| 2577 descriptors, to_trim * DescriptorArray::kDescriptorSize); | 2577 descriptors, to_trim * DescriptorArray::kDescriptorSize); |
| 2578 descriptors->SetNumberOfDescriptors(number_of_own_descriptors); | 2578 descriptors->SetNumberOfDescriptors(number_of_own_descriptors); |
| 2579 | 2579 |
| 2580 if (descriptors->HasEnumCache()) TrimEnumCache(map, descriptors); | 2580 if (descriptors->HasEnumCache()) TrimEnumCache(map, descriptors); |
| 2581 descriptors->Sort(); | 2581 descriptors->Sort(); |
| 2582 | 2582 |
| 2583 if (FLAG_unbox_double_fields) { | 2583 if (FLAG_unbox_double_fields) { |
| 2584 LayoutDescriptor* layout_descriptor = map->layout_descriptor(); | 2584 LayoutDescriptor* layout_descriptor = map->layout_descriptor(); |
| 2585 layout_descriptor = layout_descriptor->Trim(heap_, map, descriptors, | 2585 layout_descriptor = layout_descriptor->Trim(heap_, map, descriptors, |
| 2586 number_of_own_descriptors); | 2586 number_of_own_descriptors); |
| 2587 SLOW_DCHECK(layout_descriptor->IsConsistentWithMap(map, true)); | 2587 SLOW_DCHECK(layout_descriptor->IsConsistentWithMap(map, true)); |
| 2588 } | 2588 } |
| 2589 } | 2589 } |
| 2590 | 2590 |
| 2591 | 2591 |
| 2592 void MarkCompactCollector::TrimEnumCache(Map* map, | 2592 void MarkCompactCollector::TrimEnumCache(Map* map, |
| 2593 DescriptorArray* descriptors) { | 2593 DescriptorArray* descriptors) { |
| 2594 int live_enum = map->EnumLength(); | 2594 int live_enum = map->EnumLength(); |
| 2595 if (live_enum == kInvalidEnumCacheSentinel) { | 2595 if (live_enum == kInvalidEnumCacheSentinel) { |
| 2596 live_enum = map->NumberOfDescribedProperties(OWN_DESCRIPTORS, DONT_ENUM); | 2596 live_enum = map->NumberOfDescribedProperties(OWN_DESCRIPTORS, DONT_ENUM); |
| 2597 } | 2597 } |
| 2598 if (live_enum == 0) return descriptors->ClearEnumCache(); | 2598 if (live_enum == 0) return descriptors->ClearEnumCache(); |
| 2599 | 2599 |
| 2600 FixedArray* enum_cache = descriptors->GetEnumCache(); | 2600 FixedArray* enum_cache = descriptors->GetEnumCache(); |
| 2601 | 2601 |
| 2602 int to_trim = enum_cache->length() - live_enum; | 2602 int to_trim = enum_cache->length() - live_enum; |
| 2603 if (to_trim <= 0) return; | 2603 if (to_trim <= 0) return; |
| 2604 heap_->RightTrimFixedArray<Heap::FROM_GC>(descriptors->GetEnumCache(), | 2604 heap_->RightTrimFixedArray<Heap::SEQUENTIAL_TO_SWEEPER>( |
| 2605 to_trim); | 2605 descriptors->GetEnumCache(), to_trim); |
| 2606 | 2606 |
| 2607 if (!descriptors->HasEnumIndicesCache()) return; | 2607 if (!descriptors->HasEnumIndicesCache()) return; |
| 2608 FixedArray* enum_indices_cache = descriptors->GetEnumIndicesCache(); | 2608 FixedArray* enum_indices_cache = descriptors->GetEnumIndicesCache(); |
| 2609 heap_->RightTrimFixedArray<Heap::FROM_GC>(enum_indices_cache, to_trim); | 2609 heap_->RightTrimFixedArray<Heap::SEQUENTIAL_TO_SWEEPER>(enum_indices_cache, |
| 2610 to_trim); |
| 2610 } | 2611 } |
| 2611 | 2612 |
| 2612 | 2613 |
| 2613 void MarkCompactCollector::ProcessWeakCollections() { | 2614 void MarkCompactCollector::ProcessWeakCollections() { |
| 2614 GCTracer::Scope gc_scope(heap()->tracer(), | 2615 GCTracer::Scope gc_scope(heap()->tracer(), |
| 2615 GCTracer::Scope::MC_WEAKCOLLECTION_PROCESS); | 2616 GCTracer::Scope::MC_WEAKCOLLECTION_PROCESS); |
| 2616 Object* weak_collection_obj = heap()->encountered_weak_collections(); | 2617 Object* weak_collection_obj = heap()->encountered_weak_collections(); |
| 2617 while (weak_collection_obj != Smi::FromInt(0)) { | 2618 while (weak_collection_obj != Smi::FromInt(0)) { |
| 2618 JSWeakCollection* weak_collection = | 2619 JSWeakCollection* weak_collection = |
| 2619 reinterpret_cast<JSWeakCollection*>(weak_collection_obj); | 2620 reinterpret_cast<JSWeakCollection*>(weak_collection_obj); |
| (...skipping 2111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4731 SlotsBuffer* buffer = *buffer_address; | 4732 SlotsBuffer* buffer = *buffer_address; |
| 4732 while (buffer != NULL) { | 4733 while (buffer != NULL) { |
| 4733 SlotsBuffer* next_buffer = buffer->next(); | 4734 SlotsBuffer* next_buffer = buffer->next(); |
| 4734 DeallocateBuffer(buffer); | 4735 DeallocateBuffer(buffer); |
| 4735 buffer = next_buffer; | 4736 buffer = next_buffer; |
| 4736 } | 4737 } |
| 4737 *buffer_address = NULL; | 4738 *buffer_address = NULL; |
| 4738 } | 4739 } |
| 4739 } | 4740 } |
| 4740 } // namespace v8::internal | 4741 } // namespace v8::internal |
| OLD | NEW |