Chromium Code Reviews| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 // MarkCompactCollector | 56 // MarkCompactCollector |
| 57 | 57 |
| 58 MarkCompactCollector::MarkCompactCollector() : // NOLINT | 58 MarkCompactCollector::MarkCompactCollector() : // NOLINT |
| 59 #ifdef DEBUG | 59 #ifdef DEBUG |
| 60 state_(IDLE), | 60 state_(IDLE), |
| 61 #endif | 61 #endif |
| 62 sweep_precisely_(false), | 62 sweep_precisely_(false), |
| 63 compacting_(false), | 63 compacting_(false), |
| 64 was_marked_incrementally_(false), | 64 was_marked_incrementally_(false), |
| 65 collect_maps_(FLAG_collect_maps), | 65 collect_maps_(FLAG_collect_maps), |
| 66 markbits_are_tainted_(false), | |
| 66 tracer_(NULL), | 67 tracer_(NULL), |
| 67 migration_slots_buffer_(NULL), | 68 migration_slots_buffer_(NULL), |
| 68 #ifdef DEBUG | 69 #ifdef DEBUG |
| 69 live_young_objects_size_(0), | 70 live_young_objects_size_(0), |
| 70 live_old_pointer_objects_size_(0), | 71 live_old_pointer_objects_size_(0), |
| 71 live_old_data_objects_size_(0), | 72 live_old_data_objects_size_(0), |
| 72 live_code_objects_size_(0), | 73 live_code_objects_size_(0), |
| 73 live_map_objects_size_(0), | 74 live_map_objects_size_(0), |
| 74 live_cell_objects_size_(0), | 75 live_cell_objects_size_(0), |
| 75 live_lo_objects_size_(0), | 76 live_lo_objects_size_(0), |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 323 | 324 |
| 324 LargeObjectIterator it(heap_->lo_space()); | 325 LargeObjectIterator it(heap_->lo_space()); |
| 325 for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) { | 326 for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) { |
| 326 MarkBit mark_bit = Marking::MarkBitFrom(obj); | 327 MarkBit mark_bit = Marking::MarkBitFrom(obj); |
| 327 ASSERT(Marking::IsWhite(mark_bit)); | 328 ASSERT(Marking::IsWhite(mark_bit)); |
| 328 } | 329 } |
| 329 } | 330 } |
| 330 #endif | 331 #endif |
| 331 | 332 |
| 332 | 333 |
| 333 static void ClearMarkbits(PagedSpace* space) { | 334 static void ClearMarkbitsInPagedSpace(PagedSpace* space) { |
| 334 PageIterator it(space); | 335 PageIterator it(space); |
| 335 | 336 |
| 336 while (it.has_next()) { | 337 while (it.has_next()) { |
| 337 Bitmap::Clear(it.next()); | 338 Bitmap::Clear(it.next()); |
| 338 } | 339 } |
| 339 } | 340 } |
| 340 | 341 |
| 341 | 342 |
| 342 static void ClearMarkbits(NewSpace* space) { | 343 static void ClearMarkbitsInNewSpace(NewSpace* space) { |
| 343 NewSpacePageIterator it(space->ToSpaceStart(), space->ToSpaceEnd()); | 344 NewSpacePageIterator it(space->ToSpaceStart(), space->ToSpaceEnd()); |
| 344 | 345 |
| 345 while (it.has_next()) { | 346 while (it.has_next()) { |
| 346 Bitmap::Clear(it.next()); | 347 Bitmap::Clear(it.next()); |
| 347 } | 348 } |
| 348 } | 349 } |
| 349 | 350 |
| 350 | 351 |
| 351 static void ClearMarkbits(Heap* heap) { | 352 void MarkCompactCollector::ClearMarkbits() { |
| 352 ClearMarkbits(heap->code_space()); | 353 if (!markbits_are_tainted_) return; |
| 353 ClearMarkbits(heap->map_space()); | |
| 354 ClearMarkbits(heap->old_pointer_space()); | |
| 355 ClearMarkbits(heap->old_data_space()); | |
| 356 ClearMarkbits(heap->cell_space()); | |
| 357 ClearMarkbits(heap->new_space()); | |
| 358 | 354 |
| 359 LargeObjectIterator it(heap->lo_space()); | 355 ClearMarkbitsInPagedSpace(heap()->code_space()); |
| 356 ClearMarkbitsInPagedSpace(heap()->map_space()); | |
| 357 ClearMarkbitsInPagedSpace(heap()->old_pointer_space()); | |
| 358 ClearMarkbitsInPagedSpace(heap()->old_data_space()); | |
| 359 ClearMarkbitsInPagedSpace(heap()->cell_space()); | |
| 360 ClearMarkbitsInNewSpace(heap()->new_space()); | |
| 361 | |
| 362 LargeObjectIterator it(heap()->lo_space()); | |
| 360 for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) { | 363 for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) { |
| 361 MarkBit mark_bit = Marking::MarkBitFrom(obj); | 364 MarkBit mark_bit = Marking::MarkBitFrom(obj); |
| 362 mark_bit.Clear(); | 365 mark_bit.Clear(); |
| 363 mark_bit.Next().Clear(); | 366 mark_bit.Next().Clear(); |
| 364 } | 367 } |
| 368 | |
| 369 markbits_are_tainted_ = false; | |
|
Erik Corry
2011/10/19 17:56:07
Here you could use SetMarkbitsTainted(false)
| |
| 365 } | 370 } |
| 366 | 371 |
| 367 | 372 |
| 368 bool Marking::TransferMark(Address old_start, Address new_start) { | 373 bool Marking::TransferMark(Address old_start, Address new_start) { |
| 369 // This is only used when resizing an object. | 374 // This is only used when resizing an object. |
| 370 ASSERT(MemoryChunk::FromAddress(old_start) == | 375 ASSERT(MemoryChunk::FromAddress(old_start) == |
| 371 MemoryChunk::FromAddress(new_start)); | 376 MemoryChunk::FromAddress(new_start)); |
| 372 | 377 |
| 373 // If the mark doesn't move, we don't check the color of the object. | 378 // If the mark doesn't move, we don't check the color of the object. |
| 374 // It doesn't matter whether the object is black, since it hasn't changed | 379 // It doesn't matter whether the object is black, since it hasn't changed |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 497 #ifdef ENABLE_GDB_JIT_INTERFACE | 502 #ifdef ENABLE_GDB_JIT_INTERFACE |
| 498 if (FLAG_gdbjit) { | 503 if (FLAG_gdbjit) { |
| 499 // If GDBJIT interface is active disable compaction. | 504 // If GDBJIT interface is active disable compaction. |
| 500 compacting_collection_ = false; | 505 compacting_collection_ = false; |
| 501 } | 506 } |
| 502 #endif | 507 #endif |
| 503 | 508 |
| 504 // Clear marking bits for precise sweeping to collect all garbage. | 509 // Clear marking bits for precise sweeping to collect all garbage. |
| 505 if (was_marked_incrementally_ && PreciseSweepingRequired()) { | 510 if (was_marked_incrementally_ && PreciseSweepingRequired()) { |
| 506 heap()->incremental_marking()->Abort(); | 511 heap()->incremental_marking()->Abort(); |
| 507 ClearMarkbits(heap_); | |
| 508 AbortCompaction(); | 512 AbortCompaction(); |
| 509 was_marked_incrementally_ = false; | 513 was_marked_incrementally_ = false; |
| 514 TaintMarkbits(); | |
| 510 } | 515 } |
| 511 | 516 |
| 512 // Don't start compaction if we are in the middle of incremental | 517 // Don't start compaction if we are in the middle of incremental |
| 513 // marking cycle. We did not collect any slots. | 518 // marking cycle. We did not collect any slots. |
| 514 if (!FLAG_never_compact && !was_marked_incrementally_) { | 519 if (!FLAG_never_compact && !was_marked_incrementally_) { |
| 515 StartCompaction(); | 520 StartCompaction(); |
| 516 } | 521 } |
| 517 | 522 |
| 523 ClearMarkbits(); | |
| 524 | |
| 518 PagedSpaces spaces; | 525 PagedSpaces spaces; |
| 519 for (PagedSpace* space = spaces.next(); | 526 for (PagedSpace* space = spaces.next(); |
| 520 space != NULL; | 527 space != NULL; |
| 521 space = spaces.next()) { | 528 space = spaces.next()) { |
| 522 space->PrepareForMarkCompact(); | 529 space->PrepareForMarkCompact(); |
| 523 } | 530 } |
| 524 | 531 |
| 525 #ifdef DEBUG | 532 #ifdef DEBUG |
| 526 if (!was_marked_incrementally_) { | 533 if (!was_marked_incrementally_) { |
| 527 VerifyMarkbitsAreClean(); | 534 VerifyMarkbitsAreClean(); |
| (...skipping 3295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3823 while (buffer != NULL) { | 3830 while (buffer != NULL) { |
| 3824 SlotsBuffer* next_buffer = buffer->next(); | 3831 SlotsBuffer* next_buffer = buffer->next(); |
| 3825 DeallocateBuffer(buffer); | 3832 DeallocateBuffer(buffer); |
| 3826 buffer = next_buffer; | 3833 buffer = next_buffer; |
| 3827 } | 3834 } |
| 3828 *buffer_address = NULL; | 3835 *buffer_address = NULL; |
| 3829 } | 3836 } |
| 3830 | 3837 |
| 3831 | 3838 |
| 3832 } } // namespace v8::internal | 3839 } } // namespace v8::internal |
| OLD | NEW |