OLD | NEW |
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 187 matching lines...) Loading... |
198 } | 198 } |
199 | 199 |
200 | 200 |
201 void IncrementalMarking::ClearMarkbits() { | 201 void IncrementalMarking::ClearMarkbits() { |
202 // TODO(gc): Clear the mark bits in the sweeper. | 202 // TODO(gc): Clear the mark bits in the sweeper. |
203 ClearMarkbits(heap_->old_pointer_space()); | 203 ClearMarkbits(heap_->old_pointer_space()); |
204 ClearMarkbits(heap_->old_data_space()); | 204 ClearMarkbits(heap_->old_data_space()); |
205 ClearMarkbits(heap_->cell_space()); | 205 ClearMarkbits(heap_->cell_space()); |
206 ClearMarkbits(heap_->map_space()); | 206 ClearMarkbits(heap_->map_space()); |
207 ClearMarkbits(heap_->code_space()); | 207 ClearMarkbits(heap_->code_space()); |
| 208 heap_->new_space()->ActivePage()->markbits()->Clear(); |
208 | 209 |
209 SetNewSpacePageFlags(heap_->new_space()->ActivePage(), true); | 210 SetNewSpacePageFlags(heap_->new_space()->ActivePage(), true); |
210 | 211 |
211 LargePage* lop = heap_->lo_space()->first_page(); | 212 LargePage* lop = heap_->lo_space()->first_page(); |
212 while (lop->is_valid()) { | 213 while (lop->is_valid()) { |
213 SetOldSpacePageFlags(lop, true); | 214 SetOldSpacePageFlags(lop, true); |
214 lop = lop->next_page(); | 215 lop = lop->next_page(); |
215 } | 216 } |
216 } | 217 } |
217 | 218 |
218 | 219 |
219 #ifdef DEBUG | 220 #ifdef DEBUG |
220 void IncrementalMarking::VerifyMarkbitsAreClean(PagedSpace* space) { | 221 void IncrementalMarking::VerifyMarkbitsAreClean(PagedSpace* space) { |
221 PageIterator it(space); | 222 PageIterator it(space); |
222 | 223 |
223 while (it.has_next()) { | 224 while (it.has_next()) { |
224 Page* p = it.next(); | 225 Page* p = it.next(); |
225 ASSERT(p->markbits()->IsClean()); | 226 ASSERT(p->markbits()->IsClean()); |
226 } | 227 } |
227 } | 228 } |
228 | 229 |
229 | 230 |
230 void IncrementalMarking::VerifyMarkbitsAreClean() { | 231 void IncrementalMarking::VerifyMarkbitsAreClean() { |
231 VerifyMarkbitsAreClean(heap_->old_pointer_space()); | 232 VerifyMarkbitsAreClean(heap_->old_pointer_space()); |
232 VerifyMarkbitsAreClean(heap_->old_data_space()); | 233 VerifyMarkbitsAreClean(heap_->old_data_space()); |
233 VerifyMarkbitsAreClean(heap_->code_space()); | 234 VerifyMarkbitsAreClean(heap_->code_space()); |
234 VerifyMarkbitsAreClean(heap_->cell_space()); | 235 VerifyMarkbitsAreClean(heap_->cell_space()); |
235 VerifyMarkbitsAreClean(heap_->map_space()); | 236 VerifyMarkbitsAreClean(heap_->map_space()); |
| 237 ASSERT(heap_->new_space()->ActivePage()->markbits()->IsClean()); |
236 } | 238 } |
237 #endif | 239 #endif |
238 | 240 |
239 | 241 |
240 bool IncrementalMarking::WorthActivating() { | 242 bool IncrementalMarking::WorthActivating() { |
241 #ifndef DEBUG | 243 #ifndef DEBUG |
242 static const intptr_t kActivationThreshold = 8 * MB; | 244 static const intptr_t kActivationThreshold = 8 * MB; |
243 #else | 245 #else |
244 // TODO(gc) consider setting this to some low level so that some | 246 // TODO(gc) consider setting this to some low level so that some |
245 // debug tests run with incremental marking and some without. | 247 // debug tests run with incremental marking and some without. |
(...skipping 74 matching lines...) Loading... |
320 PatchIncrementalMarkingRecordWriteStubs(true); | 322 PatchIncrementalMarkingRecordWriteStubs(true); |
321 | 323 |
322 EnsureMarkingDequeIsCommitted(); | 324 EnsureMarkingDequeIsCommitted(); |
323 | 325 |
324 // Initialize marking stack. | 326 // Initialize marking stack. |
325 Address addr = static_cast<Address>(marking_deque_memory->address()); | 327 Address addr = static_cast<Address>(marking_deque_memory->address()); |
326 marking_deque_.Initialize(addr, | 328 marking_deque_.Initialize(addr, |
327 addr + marking_deque_memory->size()); | 329 addr + marking_deque_memory->size()); |
328 | 330 |
329 // Clear markbits. | 331 // Clear markbits. |
330 Address new_space_low = heap_->new_space()->ToSpaceLow(); | |
331 Address new_space_high = heap_->new_space()->ToSpaceHigh(); | |
332 heap_->marking()->ClearRange( | |
333 new_space_low, static_cast<int>(new_space_high - new_space_low)); | |
334 | |
335 ClearMarkbits(); | 332 ClearMarkbits(); |
336 | 333 |
337 #ifdef DEBUG | 334 #ifdef DEBUG |
338 VerifyMarkbitsAreClean(); | 335 VerifyMarkbitsAreClean(); |
339 #endif | 336 #endif |
340 | 337 |
341 // Mark strong roots grey. | 338 // Mark strong roots grey. |
342 IncrementalMarkingRootMarkingVisitor visitor(heap_, this); | 339 IncrementalMarkingRootMarkingVisitor visitor(heap_, this); |
343 heap_->IterateStrongRoots(&visitor, VISIT_ONLY_STRONG); | 340 heap_->IterateStrongRoots(&visitor, VISIT_ONLY_STRONG); |
344 | 341 |
345 // Ready to start incremental marking. | 342 // Ready to start incremental marking. |
346 if (FLAG_trace_incremental_marking) { | 343 if (FLAG_trace_incremental_marking) { |
347 PrintF("[IncrementalMarking] Running\n"); | 344 PrintF("[IncrementalMarking] Running\n"); |
348 } | 345 } |
349 } | 346 } |
350 | 347 |
351 | 348 |
352 void IncrementalMarking::PrepareForScavenge() { | 349 void IncrementalMarking::PrepareForScavenge() { |
353 if (!IsMarking()) return; | 350 if (!IsMarking()) return; |
354 | 351 heap_->new_space()->InactivePage()->markbits()->Clear(); |
355 Address new_space_low = heap_->new_space()->FromSpaceLow(); | |
356 Address new_space_high = heap_->new_space()->FromSpaceHigh(); | |
357 heap_->marking()->ClearRange( | |
358 new_space_low, static_cast<int>(new_space_high - new_space_low)); | |
359 } | 352 } |
360 | 353 |
361 | 354 |
362 void IncrementalMarking::UpdateMarkingDequeAfterScavenge() { | 355 void IncrementalMarking::UpdateMarkingDequeAfterScavenge() { |
363 if (!IsMarking()) return; | 356 if (!IsMarking()) return; |
364 | 357 |
365 intptr_t current = marking_deque_.bottom(); | 358 intptr_t current = marking_deque_.bottom(); |
366 intptr_t mask = marking_deque_.mask(); | 359 intptr_t mask = marking_deque_.mask(); |
367 intptr_t limit = marking_deque_.top(); | 360 intptr_t limit = marking_deque_.top(); |
368 HeapObject** array = marking_deque_.array(); | 361 HeapObject** array = marking_deque_.array(); |
(...skipping 126 matching lines...) Loading... |
495 while (!marking_deque_.IsEmpty() && bytes_to_process > 0) { | 488 while (!marking_deque_.IsEmpty() && bytes_to_process > 0) { |
496 HeapObject* obj = marking_deque_.Pop(); | 489 HeapObject* obj = marking_deque_.Pop(); |
497 | 490 |
498 // Explicitly skip one word fillers. Incremental markbit patterns are | 491 // Explicitly skip one word fillers. Incremental markbit patterns are |
499 // correct only for objects that occupy at least two words. | 492 // correct only for objects that occupy at least two words. |
500 Map* map = obj->map(); | 493 Map* map = obj->map(); |
501 if (map != filler_map) { | 494 if (map != filler_map) { |
502 ASSERT(IsGrey(marking->MarkBitFrom(obj))); | 495 ASSERT(IsGrey(marking->MarkBitFrom(obj))); |
503 int size = obj->SizeFromMap(map); | 496 int size = obj->SizeFromMap(map); |
504 bytes_to_process -= size; | 497 bytes_to_process -= size; |
505 MarkBit map_mark_bit = marking->MarkBitFromOldSpace(map); | 498 MarkBit map_mark_bit = marking->MarkBitFrom(map); |
506 if (IsWhite(map_mark_bit)) WhiteToGreyAndPush(map, map_mark_bit); | 499 if (IsWhite(map_mark_bit)) WhiteToGreyAndPush(map, map_mark_bit); |
507 // TODO(gc) switch to static visitor instead of normal visitor. | 500 // TODO(gc) switch to static visitor instead of normal visitor. |
508 obj->IterateBody(map->instance_type(), size, &marking_visitor); | 501 obj->IterateBody(map->instance_type(), size, &marking_visitor); |
509 MarkBit obj_mark_bit = marking->MarkBitFrom(obj); | 502 MarkBit obj_mark_bit = marking->MarkBitFrom(obj); |
510 MarkBlack(obj_mark_bit); | 503 MarkBlack(obj_mark_bit); |
511 } | 504 } |
512 } | 505 } |
513 if (marking_deque_.IsEmpty()) MarkingComplete(); | 506 if (marking_deque_.IsEmpty()) MarkingComplete(); |
514 } | 507 } |
515 | 508 |
(...skipping 10 matching lines...) Loading... |
526 } | 519 } |
527 | 520 |
528 if (FLAG_trace_incremental_marking || FLAG_trace_gc) { | 521 if (FLAG_trace_incremental_marking || FLAG_trace_gc) { |
529 double end = OS::TimeCurrentMillis(); | 522 double end = OS::TimeCurrentMillis(); |
530 steps_took_ += (end - start); | 523 steps_took_ += (end - start); |
531 } | 524 } |
532 } | 525 } |
533 | 526 |
534 | 527 |
535 } } // namespace v8::internal | 528 } } // namespace v8::internal |
OLD | NEW |