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 "v8.h" | 5 #include "v8.h" |
6 | 6 |
7 #include "code-stubs.h" | 7 #include "code-stubs.h" |
8 #include "compilation-cache.h" | 8 #include "compilation-cache.h" |
9 #include "cpu-profiler.h" | 9 #include "cpu-profiler.h" |
10 #include "deoptimizer.h" | 10 #include "deoptimizer.h" |
(...skipping 2722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2733 for (int i = new_number_of_entries; i < number_of_entries; i++) { | 2733 for (int i = new_number_of_entries; i < number_of_entries; i++) { |
2734 entries->clear_at(i); | 2734 entries->clear_at(i); |
2735 } | 2735 } |
2736 } | 2736 } |
2737 | 2737 |
2738 | 2738 |
2739 void MarkCompactCollector::ProcessWeakCollections() { | 2739 void MarkCompactCollector::ProcessWeakCollections() { |
2740 GCTracer::Scope gc_scope(tracer_, GCTracer::Scope::MC_WEAKCOLLECTION_PROCESS); | 2740 GCTracer::Scope gc_scope(tracer_, GCTracer::Scope::MC_WEAKCOLLECTION_PROCESS); |
2741 Object* weak_collection_obj = encountered_weak_collections(); | 2741 Object* weak_collection_obj = encountered_weak_collections(); |
2742 while (weak_collection_obj != Smi::FromInt(0)) { | 2742 while (weak_collection_obj != Smi::FromInt(0)) { |
2743 ASSERT(MarkCompactCollector::IsMarked( | |
2744 HeapObject::cast(weak_collection_obj))); | |
2745 JSWeakCollection* weak_collection = | 2743 JSWeakCollection* weak_collection = |
2746 reinterpret_cast<JSWeakCollection*>(weak_collection_obj); | 2744 reinterpret_cast<JSWeakCollection*>(weak_collection_obj); |
2747 ObjectHashTable* table = ObjectHashTable::cast(weak_collection->table()); | 2745 ASSERT(MarkCompactCollector::IsMarked(weak_collection)); |
2748 Object** anchor = reinterpret_cast<Object**>(table->address()); | 2746 if (weak_collection->table()->IsHashTable()) { |
2749 for (int i = 0; i < table->Capacity(); i++) { | 2747 ObjectHashTable* table = ObjectHashTable::cast(weak_collection->table()); |
2750 if (MarkCompactCollector::IsMarked(HeapObject::cast(table->KeyAt(i)))) { | 2748 Object** anchor = reinterpret_cast<Object**>(table->address()); |
2751 Object** key_slot = | 2749 for (int i = 0; i < table->Capacity(); i++) { |
2752 table->RawFieldOfElementAt(ObjectHashTable::EntryToIndex(i)); | 2750 if (MarkCompactCollector::IsMarked(HeapObject::cast(table->KeyAt(i)))) { |
2753 RecordSlot(anchor, key_slot, *key_slot); | 2751 Object** key_slot = |
2754 Object** value_slot = | 2752 table->RawFieldOfElementAt(ObjectHashTable::EntryToIndex(i)); |
2755 table->RawFieldOfElementAt(ObjectHashTable::EntryToValueIndex(i)); | 2753 RecordSlot(anchor, key_slot, *key_slot); |
2756 MarkCompactMarkingVisitor::MarkObjectByPointer( | 2754 Object** value_slot = |
2757 this, anchor, value_slot); | 2755 table->RawFieldOfElementAt(ObjectHashTable::EntryToValueIndex(i)); |
| 2756 MarkCompactMarkingVisitor::MarkObjectByPointer( |
| 2757 this, anchor, value_slot); |
| 2758 } |
2758 } | 2759 } |
2759 } | 2760 } |
2760 weak_collection_obj = weak_collection->next(); | 2761 weak_collection_obj = weak_collection->next(); |
2761 } | 2762 } |
2762 } | 2763 } |
2763 | 2764 |
2764 | 2765 |
2765 void MarkCompactCollector::ClearWeakCollections() { | 2766 void MarkCompactCollector::ClearWeakCollections() { |
2766 GCTracer::Scope gc_scope(tracer_, GCTracer::Scope::MC_WEAKCOLLECTION_CLEAR); | 2767 GCTracer::Scope gc_scope(tracer_, GCTracer::Scope::MC_WEAKCOLLECTION_CLEAR); |
2767 Object* weak_collection_obj = encountered_weak_collections(); | 2768 Object* weak_collection_obj = encountered_weak_collections(); |
2768 while (weak_collection_obj != Smi::FromInt(0)) { | 2769 while (weak_collection_obj != Smi::FromInt(0)) { |
2769 ASSERT(MarkCompactCollector::IsMarked( | |
2770 HeapObject::cast(weak_collection_obj))); | |
2771 JSWeakCollection* weak_collection = | 2770 JSWeakCollection* weak_collection = |
2772 reinterpret_cast<JSWeakCollection*>(weak_collection_obj); | 2771 reinterpret_cast<JSWeakCollection*>(weak_collection_obj); |
2773 ObjectHashTable* table = ObjectHashTable::cast(weak_collection->table()); | 2772 ASSERT(MarkCompactCollector::IsMarked(weak_collection)); |
2774 for (int i = 0; i < table->Capacity(); i++) { | 2773 if (weak_collection->table()->IsHashTable()) { |
2775 if (!MarkCompactCollector::IsMarked(HeapObject::cast(table->KeyAt(i)))) { | 2774 ObjectHashTable* table = ObjectHashTable::cast(weak_collection->table()); |
2776 table->RemoveEntry(i); | 2775 for (int i = 0; i < table->Capacity(); i++) { |
| 2776 HeapObject* key = HeapObject::cast(table->KeyAt(i)); |
| 2777 if (!MarkCompactCollector::IsMarked(key)) { |
| 2778 table->RemoveEntry(i); |
| 2779 } |
2777 } | 2780 } |
2778 } | 2781 } |
2779 weak_collection_obj = weak_collection->next(); | 2782 weak_collection_obj = weak_collection->next(); |
2780 weak_collection->set_next(heap()->undefined_value()); | 2783 weak_collection->set_next(heap()->undefined_value()); |
2781 } | 2784 } |
2782 set_encountered_weak_collections(Smi::FromInt(0)); | 2785 set_encountered_weak_collections(Smi::FromInt(0)); |
2783 } | 2786 } |
2784 | 2787 |
2785 | 2788 |
2786 // We scavange new space simultaneously with sweeping. This is done in two | 2789 // We scavange new space simultaneously with sweeping. This is done in two |
(...skipping 1675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4462 while (buffer != NULL) { | 4465 while (buffer != NULL) { |
4463 SlotsBuffer* next_buffer = buffer->next(); | 4466 SlotsBuffer* next_buffer = buffer->next(); |
4464 DeallocateBuffer(buffer); | 4467 DeallocateBuffer(buffer); |
4465 buffer = next_buffer; | 4468 buffer = next_buffer; |
4466 } | 4469 } |
4467 *buffer_address = NULL; | 4470 *buffer_address = NULL; |
4468 } | 4471 } |
4469 | 4472 |
4470 | 4473 |
4471 } } // namespace v8::internal | 4474 } } // namespace v8::internal |
OLD | NEW |