Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(786)

Side by Side Diff: src/mark-compact.cc

Issue 310783003: Visit encountered JSWeakCollection list during scavenging. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/mark-compact.h ('k') | src/objects-visiting-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 marking_parity_(ODD_MARKING_PARITY), 44 marking_parity_(ODD_MARKING_PARITY),
45 compacting_(false), 45 compacting_(false),
46 was_marked_incrementally_(false), 46 was_marked_incrementally_(false),
47 sweeping_pending_(false), 47 sweeping_pending_(false),
48 pending_sweeper_jobs_semaphore_(0), 48 pending_sweeper_jobs_semaphore_(0),
49 sequential_sweeping_(false), 49 sequential_sweeping_(false),
50 tracer_(NULL), 50 tracer_(NULL),
51 migration_slots_buffer_(NULL), 51 migration_slots_buffer_(NULL),
52 heap_(heap), 52 heap_(heap),
53 code_flusher_(NULL), 53 code_flusher_(NULL),
54 encountered_weak_collections_(NULL),
55 have_code_to_deoptimize_(false) { } 54 have_code_to_deoptimize_(false) { }
56 55
57 #ifdef VERIFY_HEAP 56 #ifdef VERIFY_HEAP
58 class VerifyMarkingVisitor: public ObjectVisitor { 57 class VerifyMarkingVisitor: public ObjectVisitor {
59 public: 58 public:
60 explicit VerifyMarkingVisitor(Heap* heap) : heap_(heap) {} 59 explicit VerifyMarkingVisitor(Heap* heap) : heap_(heap) {}
61 60
62 void VisitPointers(Object** start, Object** end) { 61 void VisitPointers(Object** start, Object** end) {
63 for (Object** current = start; current < end; current++) { 62 for (Object** current = start; current < end; current++) {
64 if ((*current)->IsHeapObject()) { 63 if ((*current)->IsHeapObject()) {
(...skipping 2666 matching lines...) Expand 10 before | Expand all | Expand 10 after
2731 new_number_of_entries += survived; 2730 new_number_of_entries += survived;
2732 } 2731 }
2733 for (int i = new_number_of_entries; i < number_of_entries; i++) { 2732 for (int i = new_number_of_entries; i < number_of_entries; i++) {
2734 entries->clear_at(i); 2733 entries->clear_at(i);
2735 } 2734 }
2736 } 2735 }
2737 2736
2738 2737
2739 void MarkCompactCollector::ProcessWeakCollections() { 2738 void MarkCompactCollector::ProcessWeakCollections() {
2740 GCTracer::Scope gc_scope(tracer_, GCTracer::Scope::MC_WEAKCOLLECTION_PROCESS); 2739 GCTracer::Scope gc_scope(tracer_, GCTracer::Scope::MC_WEAKCOLLECTION_PROCESS);
2741 Object* weak_collection_obj = encountered_weak_collections(); 2740 Object* weak_collection_obj = heap()->encountered_weak_collections();
2742 while (weak_collection_obj != Smi::FromInt(0)) { 2741 while (weak_collection_obj != Smi::FromInt(0)) {
2743 JSWeakCollection* weak_collection = 2742 JSWeakCollection* weak_collection =
2744 reinterpret_cast<JSWeakCollection*>(weak_collection_obj); 2743 reinterpret_cast<JSWeakCollection*>(weak_collection_obj);
2745 ASSERT(MarkCompactCollector::IsMarked(weak_collection)); 2744 ASSERT(MarkCompactCollector::IsMarked(weak_collection));
2746 if (weak_collection->table()->IsHashTable()) { 2745 if (weak_collection->table()->IsHashTable()) {
2747 ObjectHashTable* table = ObjectHashTable::cast(weak_collection->table()); 2746 ObjectHashTable* table = ObjectHashTable::cast(weak_collection->table());
2748 Object** anchor = reinterpret_cast<Object**>(table->address()); 2747 Object** anchor = reinterpret_cast<Object**>(table->address());
2749 for (int i = 0; i < table->Capacity(); i++) { 2748 for (int i = 0; i < table->Capacity(); i++) {
2750 if (MarkCompactCollector::IsMarked(HeapObject::cast(table->KeyAt(i)))) { 2749 if (MarkCompactCollector::IsMarked(HeapObject::cast(table->KeyAt(i)))) {
2751 Object** key_slot = 2750 Object** key_slot =
2752 table->RawFieldOfElementAt(ObjectHashTable::EntryToIndex(i)); 2751 table->RawFieldOfElementAt(ObjectHashTable::EntryToIndex(i));
2753 RecordSlot(anchor, key_slot, *key_slot); 2752 RecordSlot(anchor, key_slot, *key_slot);
2754 Object** value_slot = 2753 Object** value_slot =
2755 table->RawFieldOfElementAt(ObjectHashTable::EntryToValueIndex(i)); 2754 table->RawFieldOfElementAt(ObjectHashTable::EntryToValueIndex(i));
2756 MarkCompactMarkingVisitor::MarkObjectByPointer( 2755 MarkCompactMarkingVisitor::MarkObjectByPointer(
2757 this, anchor, value_slot); 2756 this, anchor, value_slot);
2758 } 2757 }
2759 } 2758 }
2760 } 2759 }
2761 weak_collection_obj = weak_collection->next(); 2760 weak_collection_obj = weak_collection->next();
2762 } 2761 }
2763 } 2762 }
2764 2763
2765 2764
2766 void MarkCompactCollector::ClearWeakCollections() { 2765 void MarkCompactCollector::ClearWeakCollections() {
2767 GCTracer::Scope gc_scope(tracer_, GCTracer::Scope::MC_WEAKCOLLECTION_CLEAR); 2766 GCTracer::Scope gc_scope(tracer_, GCTracer::Scope::MC_WEAKCOLLECTION_CLEAR);
2768 Object* weak_collection_obj = encountered_weak_collections(); 2767 Object* weak_collection_obj = heap()->encountered_weak_collections();
2769 while (weak_collection_obj != Smi::FromInt(0)) { 2768 while (weak_collection_obj != Smi::FromInt(0)) {
2770 JSWeakCollection* weak_collection = 2769 JSWeakCollection* weak_collection =
2771 reinterpret_cast<JSWeakCollection*>(weak_collection_obj); 2770 reinterpret_cast<JSWeakCollection*>(weak_collection_obj);
2772 ASSERT(MarkCompactCollector::IsMarked(weak_collection)); 2771 ASSERT(MarkCompactCollector::IsMarked(weak_collection));
2773 if (weak_collection->table()->IsHashTable()) { 2772 if (weak_collection->table()->IsHashTable()) {
2774 ObjectHashTable* table = ObjectHashTable::cast(weak_collection->table()); 2773 ObjectHashTable* table = ObjectHashTable::cast(weak_collection->table());
2775 for (int i = 0; i < table->Capacity(); i++) { 2774 for (int i = 0; i < table->Capacity(); i++) {
2776 HeapObject* key = HeapObject::cast(table->KeyAt(i)); 2775 HeapObject* key = HeapObject::cast(table->KeyAt(i));
2777 if (!MarkCompactCollector::IsMarked(key)) { 2776 if (!MarkCompactCollector::IsMarked(key)) {
2778 table->RemoveEntry(i); 2777 table->RemoveEntry(i);
2779 } 2778 }
2780 } 2779 }
2781 } 2780 }
2782 weak_collection_obj = weak_collection->next(); 2781 weak_collection_obj = weak_collection->next();
2783 weak_collection->set_next(heap()->undefined_value()); 2782 weak_collection->set_next(heap()->undefined_value());
2784 } 2783 }
2785 set_encountered_weak_collections(Smi::FromInt(0)); 2784 heap()->set_encountered_weak_collections(Smi::FromInt(0));
2786 } 2785 }
2787 2786
2788 2787
2789 // We scavange new space simultaneously with sweeping. This is done in two 2788 // We scavange new space simultaneously with sweeping. This is done in two
2790 // passes. 2789 // passes.
2791 // 2790 //
2792 // The first pass migrates all alive objects from one semispace to another or 2791 // The first pass migrates all alive objects from one semispace to another or
2793 // promotes them to old space. Forwarding address is written directly into 2792 // promotes them to old space. Forwarding address is written directly into
2794 // first word of object without any encoding. If object is dead we write 2793 // first word of object without any encoding. If object is dead we write
2795 // NULL as a forwarding address. 2794 // NULL as a forwarding address.
(...skipping 1669 matching lines...) Expand 10 before | Expand all | Expand 10 after
4465 while (buffer != NULL) { 4464 while (buffer != NULL) {
4466 SlotsBuffer* next_buffer = buffer->next(); 4465 SlotsBuffer* next_buffer = buffer->next();
4467 DeallocateBuffer(buffer); 4466 DeallocateBuffer(buffer);
4468 buffer = next_buffer; 4467 buffer = next_buffer;
4469 } 4468 }
4470 *buffer_address = NULL; 4469 *buffer_address = NULL;
4471 } 4470 }
4472 4471
4473 4472
4474 } } // namespace v8::internal 4473 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/mark-compact.h ('k') | src/objects-visiting-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698