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

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

Issue 27133: - Pass the knowledge whether the old GC is compacting to the GC prologue and ... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 9 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
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 // collection. 51 // collection.
52 int MarkCompactCollector::live_bytes_ = 0; 52 int MarkCompactCollector::live_bytes_ = 0;
53 int MarkCompactCollector::live_young_objects_ = 0; 53 int MarkCompactCollector::live_young_objects_ = 0;
54 int MarkCompactCollector::live_old_data_objects_ = 0; 54 int MarkCompactCollector::live_old_data_objects_ = 0;
55 int MarkCompactCollector::live_old_pointer_objects_ = 0; 55 int MarkCompactCollector::live_old_pointer_objects_ = 0;
56 int MarkCompactCollector::live_code_objects_ = 0; 56 int MarkCompactCollector::live_code_objects_ = 0;
57 int MarkCompactCollector::live_map_objects_ = 0; 57 int MarkCompactCollector::live_map_objects_ = 0;
58 int MarkCompactCollector::live_lo_objects_ = 0; 58 int MarkCompactCollector::live_lo_objects_ = 0;
59 #endif 59 #endif
60 60
61 void MarkCompactCollector::CollectGarbage(GCTracer* tracer) { 61 void MarkCompactCollector::CollectGarbage() {
62 // Rather than passing the tracer around we stash it in a static member 62 // Make sure that Prepare() has been called. The individual steps below will
63 // variable. 63 // update the state as they proceed.
64 tracer_ = tracer; 64 ASSERT(state_ == PREPARE_GC);
65 Prepare(); 65
66 // Prepare has selected whether to compact the old generation or not. 66 // Prepare has selected whether to compact the old generation or not.
67 // Tell the tracer. 67 // Tell the tracer.
68 if (IsCompacting()) tracer_->set_is_compacting(); 68 if (IsCompacting()) tracer_->set_is_compacting();
69 69
70 MarkLiveObjects(); 70 MarkLiveObjects();
71 71
72 if (FLAG_collect_maps) ClearNonLiveTransitions(); 72 if (FLAG_collect_maps) ClearNonLiveTransitions();
73 73
74 SweepLargeObjectSpace(); 74 SweepLargeObjectSpace();
75 75
(...skipping 13 matching lines...) Expand all
89 Finish(); 89 Finish();
90 90
91 // Save the count of marked objects remaining after the collection and 91 // Save the count of marked objects remaining after the collection and
92 // null out the GC tracer. 92 // null out the GC tracer.
93 previous_marked_count_ = tracer_->marked_count(); 93 previous_marked_count_ = tracer_->marked_count();
94 ASSERT(previous_marked_count_ == 0); 94 ASSERT(previous_marked_count_ == 0);
95 tracer_ = NULL; 95 tracer_ = NULL;
96 } 96 }
97 97
98 98
99 void MarkCompactCollector::Prepare() { 99 void MarkCompactCollector::Prepare(GCTracer* tracer) {
100 // Rather than passing the tracer around we stash it in a static member
101 // variable.
102 tracer_ = tracer;
103
100 static const int kFragmentationLimit = 50; // Percent. 104 static const int kFragmentationLimit = 50; // Percent.
101 #ifdef DEBUG 105 #ifdef DEBUG
102 ASSERT(state_ == IDLE); 106 ASSERT(state_ == IDLE);
103 state_ = PREPARE_GC; 107 state_ = PREPARE_GC;
104 #endif 108 #endif
105 ASSERT(!FLAG_always_compact || !FLAG_never_compact); 109 ASSERT(!FLAG_always_compact || !FLAG_never_compact);
106 110
107 compacting_collection_ = FLAG_always_compact; 111 compacting_collection_ = FLAG_always_compact;
108 112
109 // We compact the old generation if it gets too fragmented (ie, we could 113 // We compact the old generation if it gets too fragmented (ie, we could
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 if (!Heap::InNewSpace(object) && Heap::InNewSpace(first)) return object; 238 if (!Heap::InNewSpace(object) && Heap::InNewSpace(first)) return object;
235 239
236 *p = first; 240 *p = first;
237 return HeapObject::cast(first); 241 return HeapObject::cast(first);
238 } 242 }
239 243
240 244
241 // Helper class for marking pointers in HeapObjects. 245 // Helper class for marking pointers in HeapObjects.
242 class MarkingVisitor : public ObjectVisitor { 246 class MarkingVisitor : public ObjectVisitor {
243 public: 247 public:
244
245 void VisitPointer(Object** p) { 248 void VisitPointer(Object** p) {
246 MarkObjectByPointer(p); 249 MarkObjectByPointer(p);
247 } 250 }
248 251
249 void VisitPointers(Object** start, Object** end) { 252 void VisitPointers(Object** start, Object** end) {
250 // Mark all objects pointed to in [start, end). 253 // Mark all objects pointed to in [start, end).
251 const int kMinRangeForMarkingRecursion = 64; 254 const int kMinRangeForMarkingRecursion = 64;
252 if (end - start >= kMinRangeForMarkingRecursion) { 255 if (end - start >= kMinRangeForMarkingRecursion) {
253 if (VisitUnmarkedObjects(start, end)) return; 256 if (VisitUnmarkedObjects(start, end)) return;
254 // We are close to a stack overflow, so just mark the objects. 257 // We are close to a stack overflow, so just mark the objects.
(...skipping 1500 matching lines...) Expand 10 before | Expand all | Expand 10 after
1755 1758
1756 void MarkCompactCollector::RebuildRSets() { 1759 void MarkCompactCollector::RebuildRSets() {
1757 #ifdef DEBUG 1760 #ifdef DEBUG
1758 ASSERT(state_ == RELOCATE_OBJECTS); 1761 ASSERT(state_ == RELOCATE_OBJECTS);
1759 state_ = REBUILD_RSETS; 1762 state_ = REBUILD_RSETS;
1760 #endif 1763 #endif
1761 Heap::RebuildRSets(); 1764 Heap::RebuildRSets();
1762 } 1765 }
1763 1766
1764 } } // namespace v8::internal 1767 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698