OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/base/atomicops.h" | 7 #include "src/base/atomicops.h" |
8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
9 #include "src/compilation-cache.h" | 9 #include "src/compilation-cache.h" |
10 #include "src/cpu-profiler.h" | 10 #include "src/cpu-profiler.h" |
(...skipping 4080 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4091 p->set_parallel_sweeping(MemoryChunk::SWEEPING_FINALIZE); | 4091 p->set_parallel_sweeping(MemoryChunk::SWEEPING_FINALIZE); |
4092 } else { | 4092 } else { |
4093 p->MarkSweptConservatively(); | 4093 p->MarkSweptConservatively(); |
4094 } | 4094 } |
4095 return FreeList::GuaranteedAllocatable(static_cast<int>(max_freed_bytes)); | 4095 return FreeList::GuaranteedAllocatable(static_cast<int>(max_freed_bytes)); |
4096 } | 4096 } |
4097 | 4097 |
4098 | 4098 |
4099 int MarkCompactCollector::SweepInParallel(PagedSpace* space, | 4099 int MarkCompactCollector::SweepInParallel(PagedSpace* space, |
4100 int required_freed_bytes) { | 4100 int required_freed_bytes) { |
4101 PageIterator it(space); | |
4102 FreeList* free_list = space == heap()->old_pointer_space() | |
4103 ? free_list_old_pointer_space_.get() | |
4104 : free_list_old_data_space_.get(); | |
4105 FreeList private_free_list(space); | |
4106 int max_freed = 0; | 4101 int max_freed = 0; |
4107 int max_freed_overall = 0; | 4102 int max_freed_overall = 0; |
| 4103 PageIterator it(space); |
4108 while (it.has_next()) { | 4104 while (it.has_next()) { |
4109 Page* p = it.next(); | 4105 Page* p = it.next(); |
4110 if (p->TryParallelSweeping()) { | 4106 max_freed = SweepInParallel(p, space); |
4111 if (space->swept_precisely()) { | 4107 ASSERT(max_freed >= 0); |
4112 max_freed = SweepPrecisely<SWEEP_ONLY, | 4108 if (required_freed_bytes > 0 && max_freed >= required_freed_bytes) { |
4113 SWEEP_IN_PARALLEL, | 4109 return max_freed; |
4114 IGNORE_SKIP_LIST, | |
4115 IGNORE_FREE_SPACE>( | |
4116 space, &private_free_list, p, NULL); | |
4117 } else { | |
4118 max_freed = SweepConservatively<SWEEP_IN_PARALLEL>( | |
4119 space, &private_free_list, p); | |
4120 } | |
4121 ASSERT(max_freed >= 0); | |
4122 free_list->Concatenate(&private_free_list); | |
4123 if (required_freed_bytes > 0 && max_freed >= required_freed_bytes) { | |
4124 return max_freed; | |
4125 } | |
4126 max_freed_overall = Max(max_freed, max_freed_overall); | |
4127 } | 4110 } |
| 4111 max_freed_overall = Max(max_freed, max_freed_overall); |
4128 if (p == space->end_of_unswept_pages()) break; | 4112 if (p == space->end_of_unswept_pages()) break; |
4129 } | 4113 } |
4130 return max_freed_overall; | 4114 return max_freed_overall; |
4131 } | 4115 } |
4132 | 4116 |
4133 | 4117 |
| 4118 int MarkCompactCollector::SweepInParallel(Page* page, PagedSpace* space) { |
| 4119 int max_freed = 0; |
| 4120 if (page->TryParallelSweeping()) { |
| 4121 FreeList* free_list = space == heap()->old_pointer_space() |
| 4122 ? free_list_old_pointer_space_.get() |
| 4123 : free_list_old_data_space_.get(); |
| 4124 FreeList private_free_list(space); |
| 4125 if (space->swept_precisely()) { |
| 4126 max_freed = SweepPrecisely<SWEEP_ONLY, SWEEP_IN_PARALLEL, |
| 4127 IGNORE_SKIP_LIST, IGNORE_FREE_SPACE>( |
| 4128 space, &private_free_list, page, NULL); |
| 4129 } else { |
| 4130 max_freed = SweepConservatively<SWEEP_IN_PARALLEL>( |
| 4131 space, &private_free_list, page); |
| 4132 } |
| 4133 free_list->Concatenate(&private_free_list); |
| 4134 } |
| 4135 return max_freed; |
| 4136 } |
| 4137 |
| 4138 |
4134 void MarkCompactCollector::SweepSpace(PagedSpace* space, SweeperType sweeper) { | 4139 void MarkCompactCollector::SweepSpace(PagedSpace* space, SweeperType sweeper) { |
4135 space->set_swept_precisely(sweeper == PRECISE || | 4140 space->set_swept_precisely(sweeper == PRECISE || |
4136 sweeper == CONCURRENT_PRECISE || | 4141 sweeper == CONCURRENT_PRECISE || |
4137 sweeper == PARALLEL_PRECISE); | 4142 sweeper == PARALLEL_PRECISE); |
4138 space->ClearStats(); | 4143 space->ClearStats(); |
4139 | 4144 |
4140 // We defensively initialize end_of_unswept_pages_ here with the first page | 4145 // We defensively initialize end_of_unswept_pages_ here with the first page |
4141 // of the pages list. | 4146 // of the pages list. |
4142 space->set_end_of_unswept_pages(space->FirstPage()); | 4147 space->set_end_of_unswept_pages(space->FirstPage()); |
4143 | 4148 |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4584 while (buffer != NULL) { | 4589 while (buffer != NULL) { |
4585 SlotsBuffer* next_buffer = buffer->next(); | 4590 SlotsBuffer* next_buffer = buffer->next(); |
4586 DeallocateBuffer(buffer); | 4591 DeallocateBuffer(buffer); |
4587 buffer = next_buffer; | 4592 buffer = next_buffer; |
4588 } | 4593 } |
4589 *buffer_address = NULL; | 4594 *buffer_address = NULL; |
4590 } | 4595 } |
4591 | 4596 |
4592 | 4597 |
4593 } } // namespace v8::internal | 4598 } } // namespace v8::internal |
OLD | NEW |