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

Side by Side Diff: src/incremental-marking.cc

Issue 6713075: Create an abstraction (MarkBit) object to hold the location of the... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: '' Created 9 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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 MarkObjectByPointer(p); 45 MarkObjectByPointer(p);
46 } 46 }
47 47
48 void VisitPointers(Object** start, Object** end) { 48 void VisitPointers(Object** start, Object** end) {
49 for (Object** p = start; p < end; p++) MarkObjectByPointer(p); 49 for (Object** p = start; p < end; p++) MarkObjectByPointer(p);
50 } 50 }
51 51
52 private: 52 private:
53 // Mark object pointed to by p. 53 // Mark object pointed to by p.
54 INLINE(static void MarkObjectByPointer(Object** p)) { 54 INLINE(static void MarkObjectByPointer(Object** p)) {
55 if ((*p)->IsHeapObject()) { 55 Object* obj = *p;
56 HeapObject* object = HeapObject::cast(*p); 56 if (obj->IsHeapObject()) {
57 if (IncrementalMarking::IsWhite(object)) { 57 HeapObject* heap_object = HeapObject::cast(obj);
58 IncrementalMarking::WhiteToGrey(object); 58 MarkBit mark_bit = Marking::MarkBitFrom(heap_object);
59 if (IncrementalMarking::IsWhite(mark_bit)) {
60 IncrementalMarking::WhiteToGrey(heap_object, mark_bit);
59 } 61 }
60 } 62 }
61 } 63 }
62 }; 64 };
63 65
64 66
65 static IncrementalMarkingMarkingVisitor marking_visitor; 67 static IncrementalMarkingMarkingVisitor marking_visitor;
66 68
67 class IncrementalMarkingRootMarkingVisitor : public ObjectVisitor { 69 class IncrementalMarkingRootMarkingVisitor : public ObjectVisitor {
68 public: 70 public:
69 void VisitPointer(Object** p) { 71 void VisitPointer(Object** p) {
70 MarkObjectByPointer(p); 72 MarkObjectByPointer(p);
71 } 73 }
72 74
73 void VisitPointers(Object** start, Object** end) { 75 void VisitPointers(Object** start, Object** end) {
74 for (Object** p = start; p < end; p++) MarkObjectByPointer(p); 76 for (Object** p = start; p < end; p++) MarkObjectByPointer(p);
75 } 77 }
76 78
77 private: 79 private:
78 void MarkObjectByPointer(Object** p) { 80 void MarkObjectByPointer(Object** p) {
79 if (!(*p)->IsHeapObject()) return; 81 Object* obj = *p;
82 if (!obj->IsHeapObject()) return;
80 83
81 HeapObject* object = HeapObject::cast(*p); 84 HeapObject* heap_object = HeapObject::cast(obj);
82 if (IncrementalMarking::IsWhite(object)) { 85 MarkBit mark_bit = Marking::MarkBitFrom(heap_object);
83 IncrementalMarking::WhiteToGrey(object); 86 if (IncrementalMarking::IsWhite(mark_bit)) {
87 IncrementalMarking::WhiteToGrey(heap_object, mark_bit);
84 } 88 }
85 } 89 }
86 }; 90 };
87 91
88 92
89 static void ClearMarkbits(PagedSpace* space) { 93 static void ClearMarkbits(PagedSpace* space) {
90 PageIterator it(space); 94 PageIterator it(space);
91 95
92 while (it.has_next()) { 96 while (it.has_next()) {
93 Page* p = it.next(); 97 Page* p = it.next();
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 174
171 PatchIncrementalMarkingRecordWriteStubs(true); 175 PatchIncrementalMarkingRecordWriteStubs(true);
172 176
173 Heap::EnsureFromSpaceIsCommitted(); 177 Heap::EnsureFromSpaceIsCommitted();
174 178
175 // Initialize marking stack. 179 // Initialize marking stack.
176 marking_stack_.Initialize(Heap::new_space()->FromSpaceLow(), 180 marking_stack_.Initialize(Heap::new_space()->FromSpaceLow(),
177 Heap::new_space()->FromSpaceHigh()); 181 Heap::new_space()->FromSpaceHigh());
178 182
179 // Clear markbits. 183 // Clear markbits.
180 Address new_space_top = Heap::new_space()->top();
181 Address new_space_bottom = Heap::new_space()->bottom(); 184 Address new_space_bottom = Heap::new_space()->bottom();
185 uintptr_t new_space_size =
186 RoundUp(Heap::new_space()->top() - new_space_bottom, 32 * kPointerSize);
182 187
183 Marking::ClearRange(new_space_bottom, 188 Marking::ClearRange(new_space_bottom, new_space_size);
184 static_cast<int>(new_space_top - new_space_bottom));
185 189
186 ClearMarkbits(); 190 ClearMarkbits();
187 191
188 #ifdef DEBUG 192 #ifdef DEBUG
189 VerifyMarkbitsAreClean(); 193 VerifyMarkbitsAreClean();
190 #endif 194 #endif
191 195
192 // Mark strong roots grey. 196 // Mark strong roots grey.
193 IncrementalMarkingRootMarkingVisitor visitor; 197 IncrementalMarkingRootMarkingVisitor visitor;
194 Heap::IterateStrongRoots(&visitor, VISIT_ONLY_STRONG); 198 Heap::IterateStrongRoots(&visitor, VISIT_ONLY_STRONG);
(...skipping 15 matching lines...) Expand all
210 // TODO(gc) hurry can mark objects it encounters black as mutator 214 // TODO(gc) hurry can mark objects it encounters black as mutator
211 // was stopped. 215 // was stopped.
212 Map* filler_map = Heap::one_pointer_filler_map(); 216 Map* filler_map = Heap::one_pointer_filler_map();
213 while (!marking_stack_.is_empty()) { 217 while (!marking_stack_.is_empty()) {
214 HeapObject* obj = marking_stack_.Pop(); 218 HeapObject* obj = marking_stack_.Pop();
215 219
216 // Explicitly skip one word fillers. Incremental markbit patterns are 220 // Explicitly skip one word fillers. Incremental markbit patterns are
217 // correct only for objects that occupy at least two words. 221 // correct only for objects that occupy at least two words.
218 if (obj->map() != filler_map) { 222 if (obj->map() != filler_map) {
219 obj->Iterate(&marking_visitor); 223 obj->Iterate(&marking_visitor);
220 MarkBlack(obj); } 224 MarkBit mark_bit = Marking::MarkBitFrom(obj);
225 MarkBlack(mark_bit);
226 }
221 } 227 }
222 state_ = COMPLETE; 228 state_ = COMPLETE;
223 if (FLAG_trace_incremental_marking) { 229 if (FLAG_trace_incremental_marking) {
224 double end = OS::TimeCurrentMillis(); 230 double end = OS::TimeCurrentMillis();
225 PrintF("[IncrementalMarking] Complete (hurry), spent %d ms\n", 231 PrintF("[IncrementalMarking] Complete (hurry), spent %d ms\n",
226 static_cast<int>(end - start)); 232 static_cast<int>(end - start));
227 } 233 }
228 } 234 }
229 } 235 }
230 236
(...skipping 29 matching lines...) Expand all
260 start = OS::TimeCurrentMillis(); 266 start = OS::TimeCurrentMillis();
261 } 267 }
262 268
263 Map* filler_map = Heap::one_pointer_filler_map(); 269 Map* filler_map = Heap::one_pointer_filler_map();
264 while (!marking_stack_.is_empty() && bytes_to_process > 0) { 270 while (!marking_stack_.is_empty() && bytes_to_process > 0) {
265 HeapObject* obj = marking_stack_.Pop(); 271 HeapObject* obj = marking_stack_.Pop();
266 272
267 // Explicitly skip one word fillers. Incremental markbit patterns are 273 // Explicitly skip one word fillers. Incremental markbit patterns are
268 // correct only for objects that occupy at least two words. 274 // correct only for objects that occupy at least two words.
269 if (obj->map() != filler_map) { 275 if (obj->map() != filler_map) {
270 ASSERT(IsGrey(obj)); 276 ASSERT(IsGrey(Marking::MarkBitFrom(obj)));
271 Map* map = obj->map(); 277 Map* map = obj->map();
272 int size = obj->SizeFromMap(map); 278 int size = obj->SizeFromMap(map);
273 bytes_to_process -= size; 279 bytes_to_process -= size;
274 if (IsWhite(map)) WhiteToGrey(map); 280 MarkBit map_mark_bit = Marking::MarkBitFrom(map);
281 if (IsWhite(map_mark_bit)) WhiteToGrey(map, map_mark_bit);
275 obj->IterateBody(map->instance_type(), size, &marking_visitor); 282 obj->IterateBody(map->instance_type(), size, &marking_visitor);
276 MarkBlack(obj); 283 MarkBit obj_mark_bit = Marking::MarkBitFrom(obj);
284 MarkBlack(obj_mark_bit);
277 } 285 }
278 count++; 286 count++;
279 } 287 }
280 if (FLAG_trace_incremental_marking) { 288 if (FLAG_trace_incremental_marking) {
281 double end = OS::TimeCurrentMillis(); 289 double end = OS::TimeCurrentMillis();
282 PrintF("[IncrementalMarking] %d objects marked, spent %d ms\n", 290 PrintF("[IncrementalMarking] %d objects marked, spent %d ms\n",
283 count, 291 count,
284 static_cast<int>(end - start)); 292 static_cast<int>(end - start));
285 } 293 }
286 allocated = 0; 294 allocated = 0;
287 if (marking_stack_.is_empty()) MarkingComplete(); 295 if (marking_stack_.is_empty()) MarkingComplete();
288 } 296 }
289 } 297 }
290 } 298 }
291 299
292 300
293 } } // namespace v8::internal 301 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698