OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 2716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2727 // if requested. | 2727 // if requested. |
2728 template<SweepingMode sweeping_mode, SkipListRebuildingMode skip_list_mode> | 2728 template<SweepingMode sweeping_mode, SkipListRebuildingMode skip_list_mode> |
2729 static void SweepPrecisely(PagedSpace* space, | 2729 static void SweepPrecisely(PagedSpace* space, |
2730 Page* p, | 2730 Page* p, |
2731 ObjectVisitor* v) { | 2731 ObjectVisitor* v) { |
2732 ASSERT(!p->IsEvacuationCandidate() && !p->WasSwept()); | 2732 ASSERT(!p->IsEvacuationCandidate() && !p->WasSwept()); |
2733 ASSERT_EQ(skip_list_mode == REBUILD_SKIP_LIST, | 2733 ASSERT_EQ(skip_list_mode == REBUILD_SKIP_LIST, |
2734 space->identity() == CODE_SPACE); | 2734 space->identity() == CODE_SPACE); |
2735 ASSERT((p->skip_list() == NULL) || (skip_list_mode == REBUILD_SKIP_LIST)); | 2735 ASSERT((p->skip_list() == NULL) || (skip_list_mode == REBUILD_SKIP_LIST)); |
2736 | 2736 |
| 2737 double start_time = 0.0; |
| 2738 if (FLAG_print_cumulative_gc_stat) { |
| 2739 start_time = OS::TimeCurrentMillis(); |
| 2740 } |
| 2741 |
2737 MarkBit::CellType* cells = p->markbits()->cells(); | 2742 MarkBit::CellType* cells = p->markbits()->cells(); |
2738 p->MarkSweptPrecisely(); | 2743 p->MarkSweptPrecisely(); |
2739 | 2744 |
2740 int last_cell_index = | 2745 int last_cell_index = |
2741 Bitmap::IndexToCell( | 2746 Bitmap::IndexToCell( |
2742 Bitmap::CellAlignIndex( | 2747 Bitmap::CellAlignIndex( |
2743 p->AddressToMarkbitIndex(p->area_end()))); | 2748 p->AddressToMarkbitIndex(p->area_end()))); |
2744 | 2749 |
2745 Address free_start = p->area_start(); | 2750 Address free_start = p->area_start(); |
2746 int cell_index = | 2751 int cell_index = |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2792 } | 2797 } |
2793 free_start = free_end + size; | 2798 free_start = free_end + size; |
2794 } | 2799 } |
2795 // Clear marking bits for current cell. | 2800 // Clear marking bits for current cell. |
2796 cells[cell_index] = 0; | 2801 cells[cell_index] = 0; |
2797 } | 2802 } |
2798 if (free_start != p->area_end()) { | 2803 if (free_start != p->area_end()) { |
2799 space->Free(free_start, static_cast<int>(p->area_end() - free_start)); | 2804 space->Free(free_start, static_cast<int>(p->area_end() - free_start)); |
2800 } | 2805 } |
2801 p->ResetLiveBytes(); | 2806 p->ResetLiveBytes(); |
| 2807 if (FLAG_print_cumulative_gc_stat) { |
| 2808 space->heap()->AddSweepingTime(OS::TimeCurrentMillis() - start_time); |
| 2809 } |
2802 } | 2810 } |
2803 | 2811 |
2804 | 2812 |
2805 static bool SetMarkBitsUnderInvalidatedCode(Code* code, bool value) { | 2813 static bool SetMarkBitsUnderInvalidatedCode(Code* code, bool value) { |
2806 Page* p = Page::FromAddress(code->address()); | 2814 Page* p = Page::FromAddress(code->address()); |
2807 | 2815 |
2808 if (p->IsEvacuationCandidate() || | 2816 if (p->IsEvacuationCandidate() || |
2809 p->IsFlagSet(Page::RESCAN_ON_EVACUATION)) { | 2817 p->IsFlagSet(Page::RESCAN_ON_EVACUATION)) { |
2810 return false; | 2818 return false; |
2811 } | 2819 } |
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3387 | 3395 |
3388 // Sweeps a space conservatively. After this has been done the larger free | 3396 // Sweeps a space conservatively. After this has been done the larger free |
3389 // spaces have been put on the free list and the smaller ones have been | 3397 // spaces have been put on the free list and the smaller ones have been |
3390 // ignored and left untouched. A free space is always either ignored or put | 3398 // ignored and left untouched. A free space is always either ignored or put |
3391 // on the free list, never split up into two parts. This is important | 3399 // on the free list, never split up into two parts. This is important |
3392 // because it means that any FreeSpace maps left actually describe a region of | 3400 // because it means that any FreeSpace maps left actually describe a region of |
3393 // memory that can be ignored when scanning. Dead objects other than free | 3401 // memory that can be ignored when scanning. Dead objects other than free |
3394 // spaces will not contain the free space map. | 3402 // spaces will not contain the free space map. |
3395 intptr_t MarkCompactCollector::SweepConservatively(PagedSpace* space, Page* p) { | 3403 intptr_t MarkCompactCollector::SweepConservatively(PagedSpace* space, Page* p) { |
3396 ASSERT(!p->IsEvacuationCandidate() && !p->WasSwept()); | 3404 ASSERT(!p->IsEvacuationCandidate() && !p->WasSwept()); |
| 3405 double start_time = 0.0; |
| 3406 if (FLAG_print_cumulative_gc_stat) { |
| 3407 start_time = OS::TimeCurrentMillis(); |
| 3408 } |
| 3409 |
3397 MarkBit::CellType* cells = p->markbits()->cells(); | 3410 MarkBit::CellType* cells = p->markbits()->cells(); |
3398 p->MarkSweptConservatively(); | 3411 p->MarkSweptConservatively(); |
3399 | 3412 |
3400 int last_cell_index = | 3413 int last_cell_index = |
3401 Bitmap::IndexToCell( | 3414 Bitmap::IndexToCell( |
3402 Bitmap::CellAlignIndex( | 3415 Bitmap::CellAlignIndex( |
3403 p->AddressToMarkbitIndex(p->area_end()))); | 3416 p->AddressToMarkbitIndex(p->area_end()))); |
3404 | 3417 |
3405 int cell_index = | 3418 int cell_index = |
3406 Bitmap::IndexToCell( | 3419 Bitmap::IndexToCell( |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3473 } | 3486 } |
3474 | 3487 |
3475 // Handle the free space at the end of the page. | 3488 // Handle the free space at the end of the page. |
3476 if (block_address - free_start > 32 * kPointerSize) { | 3489 if (block_address - free_start > 32 * kPointerSize) { |
3477 free_start = DigestFreeStart(free_start, free_start_cell); | 3490 free_start = DigestFreeStart(free_start, free_start_cell); |
3478 freed_bytes += space->Free(free_start, | 3491 freed_bytes += space->Free(free_start, |
3479 static_cast<int>(block_address - free_start)); | 3492 static_cast<int>(block_address - free_start)); |
3480 } | 3493 } |
3481 | 3494 |
3482 p->ResetLiveBytes(); | 3495 p->ResetLiveBytes(); |
| 3496 |
| 3497 if (FLAG_print_cumulative_gc_stat) { |
| 3498 space->heap()->AddSweepingTime(OS::TimeCurrentMillis() - start_time); |
| 3499 } |
3483 return freed_bytes; | 3500 return freed_bytes; |
3484 } | 3501 } |
3485 | 3502 |
3486 | 3503 |
3487 void MarkCompactCollector::SweepSpace(PagedSpace* space, SweeperType sweeper) { | 3504 void MarkCompactCollector::SweepSpace(PagedSpace* space, SweeperType sweeper) { |
3488 space->set_was_swept_conservatively(sweeper == CONSERVATIVE || | 3505 space->set_was_swept_conservatively(sweeper == CONSERVATIVE || |
3489 sweeper == LAZY_CONSERVATIVE); | 3506 sweeper == LAZY_CONSERVATIVE); |
3490 | 3507 |
3491 space->ClearStats(); | 3508 space->ClearStats(); |
3492 | 3509 |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3814 while (buffer != NULL) { | 3831 while (buffer != NULL) { |
3815 SlotsBuffer* next_buffer = buffer->next(); | 3832 SlotsBuffer* next_buffer = buffer->next(); |
3816 DeallocateBuffer(buffer); | 3833 DeallocateBuffer(buffer); |
3817 buffer = next_buffer; | 3834 buffer = next_buffer; |
3818 } | 3835 } |
3819 *buffer_address = NULL; | 3836 *buffer_address = NULL; |
3820 } | 3837 } |
3821 | 3838 |
3822 | 3839 |
3823 } } // namespace v8::internal | 3840 } } // namespace v8::internal |
OLD | NEW |