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 4134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4145 SweepConservatively<SWEEP_IN_PARALLEL>(space, &private_free_list, p); | 4145 SweepConservatively<SWEEP_IN_PARALLEL>(space, &private_free_list, p); |
4146 free_list->Concatenate(&private_free_list); | 4146 free_list->Concatenate(&private_free_list); |
4147 p->set_parallel_sweeping(MemoryChunk::PARALLEL_SWEEPING_FINALIZE); | 4147 p->set_parallel_sweeping(MemoryChunk::PARALLEL_SWEEPING_FINALIZE); |
4148 } | 4148 } |
4149 } | 4149 } |
4150 } | 4150 } |
4151 | 4151 |
4152 | 4152 |
4153 void MarkCompactCollector::SweepSpace(PagedSpace* space, SweeperType sweeper) { | 4153 void MarkCompactCollector::SweepSpace(PagedSpace* space, SweeperType sweeper) { |
4154 space->set_was_swept_conservatively(sweeper == CONSERVATIVE || | 4154 space->set_was_swept_conservatively(sweeper == CONSERVATIVE || |
4155 sweeper == LAZY_CONSERVATIVE || | |
4156 sweeper == PARALLEL_CONSERVATIVE || | 4155 sweeper == PARALLEL_CONSERVATIVE || |
4157 sweeper == CONCURRENT_CONSERVATIVE); | 4156 sweeper == CONCURRENT_CONSERVATIVE); |
4158 space->ClearStats(); | 4157 space->ClearStats(); |
4159 | 4158 |
4160 PageIterator it(space); | 4159 PageIterator it(space); |
4161 | 4160 |
4162 int pages_swept = 0; | 4161 int pages_swept = 0; |
4163 bool lazy_sweeping_active = false; | |
4164 bool unused_page_present = false; | 4162 bool unused_page_present = false; |
4165 bool parallel_sweeping_active = false; | 4163 bool parallel_sweeping_active = false; |
4166 | 4164 |
4167 while (it.has_next()) { | 4165 while (it.has_next()) { |
4168 Page* p = it.next(); | 4166 Page* p = it.next(); |
4169 | 4167 |
4170 ASSERT(p->parallel_sweeping() == MemoryChunk::PARALLEL_SWEEPING_DONE); | 4168 ASSERT(p->parallel_sweeping() == MemoryChunk::PARALLEL_SWEEPING_DONE); |
4171 ASSERT(!p->IsEvacuationCandidate()); | 4169 ASSERT(!p->IsEvacuationCandidate()); |
4172 | 4170 |
4173 // Clear sweeping flags indicating that marking bits are still intact. | 4171 // Clear sweeping flags indicating that marking bits are still intact. |
(...skipping 25 matching lines...) Expand all Loading... |
4199 switch (sweeper) { | 4197 switch (sweeper) { |
4200 case CONSERVATIVE: { | 4198 case CONSERVATIVE: { |
4201 if (FLAG_gc_verbose) { | 4199 if (FLAG_gc_verbose) { |
4202 PrintF("Sweeping 0x%" V8PRIxPTR " conservatively.\n", | 4200 PrintF("Sweeping 0x%" V8PRIxPTR " conservatively.\n", |
4203 reinterpret_cast<intptr_t>(p)); | 4201 reinterpret_cast<intptr_t>(p)); |
4204 } | 4202 } |
4205 SweepConservatively<SWEEP_SEQUENTIALLY>(space, NULL, p); | 4203 SweepConservatively<SWEEP_SEQUENTIALLY>(space, NULL, p); |
4206 pages_swept++; | 4204 pages_swept++; |
4207 break; | 4205 break; |
4208 } | 4206 } |
4209 case LAZY_CONSERVATIVE: { | |
4210 if (lazy_sweeping_active) { | |
4211 if (FLAG_gc_verbose) { | |
4212 PrintF("Sweeping 0x%" V8PRIxPTR " lazily postponed.\n", | |
4213 reinterpret_cast<intptr_t>(p)); | |
4214 } | |
4215 space->IncreaseUnsweptFreeBytes(p); | |
4216 } else { | |
4217 if (FLAG_gc_verbose) { | |
4218 PrintF("Sweeping 0x%" V8PRIxPTR " conservatively.\n", | |
4219 reinterpret_cast<intptr_t>(p)); | |
4220 } | |
4221 SweepConservatively<SWEEP_SEQUENTIALLY>(space, NULL, p); | |
4222 pages_swept++; | |
4223 space->SetPagesToSweep(p->next_page()); | |
4224 lazy_sweeping_active = true; | |
4225 } | |
4226 break; | |
4227 } | |
4228 case CONCURRENT_CONSERVATIVE: | 4207 case CONCURRENT_CONSERVATIVE: |
4229 case PARALLEL_CONSERVATIVE: { | 4208 case PARALLEL_CONSERVATIVE: { |
4230 if (!parallel_sweeping_active) { | 4209 if (!parallel_sweeping_active) { |
4231 if (FLAG_gc_verbose) { | 4210 if (FLAG_gc_verbose) { |
4232 PrintF("Sweeping 0x%" V8PRIxPTR " conservatively.\n", | 4211 PrintF("Sweeping 0x%" V8PRIxPTR " conservatively.\n", |
4233 reinterpret_cast<intptr_t>(p)); | 4212 reinterpret_cast<intptr_t>(p)); |
4234 } | 4213 } |
4235 SweepConservatively<SWEEP_SEQUENTIALLY>(space, NULL, p); | 4214 SweepConservatively<SWEEP_SEQUENTIALLY>(space, NULL, p); |
4236 pages_swept++; | 4215 pages_swept++; |
4237 parallel_sweeping_active = true; | 4216 parallel_sweeping_active = true; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4278 // Give pages that are queued to be freed back to the OS. | 4257 // Give pages that are queued to be freed back to the OS. |
4279 heap()->FreeQueuedChunks(); | 4258 heap()->FreeQueuedChunks(); |
4280 } | 4259 } |
4281 | 4260 |
4282 | 4261 |
4283 void MarkCompactCollector::SweepSpaces() { | 4262 void MarkCompactCollector::SweepSpaces() { |
4284 GCTracer::Scope gc_scope(tracer_, GCTracer::Scope::MC_SWEEP); | 4263 GCTracer::Scope gc_scope(tracer_, GCTracer::Scope::MC_SWEEP); |
4285 #ifdef DEBUG | 4264 #ifdef DEBUG |
4286 state_ = SWEEP_SPACES; | 4265 state_ = SWEEP_SPACES; |
4287 #endif | 4266 #endif |
4288 SweeperType how_to_sweep = | 4267 SweeperType how_to_sweep = CONSERVATIVE; |
4289 FLAG_lazy_sweeping ? LAZY_CONSERVATIVE : CONSERVATIVE; | |
4290 if (AreSweeperThreadsActivated()) { | 4268 if (AreSweeperThreadsActivated()) { |
4291 if (FLAG_parallel_sweeping) how_to_sweep = PARALLEL_CONSERVATIVE; | 4269 if (FLAG_parallel_sweeping) how_to_sweep = PARALLEL_CONSERVATIVE; |
4292 if (FLAG_concurrent_sweeping) how_to_sweep = CONCURRENT_CONSERVATIVE; | 4270 if (FLAG_concurrent_sweeping) how_to_sweep = CONCURRENT_CONSERVATIVE; |
4293 } | 4271 } |
4294 if (sweep_precisely_) how_to_sweep = PRECISE; | 4272 if (sweep_precisely_) how_to_sweep = PRECISE; |
4295 | 4273 |
4296 // Unlink evacuation candidates before sweeper threads access the list of | 4274 // Unlink evacuation candidates before sweeper threads access the list of |
4297 // pages to avoid race condition. | 4275 // pages to avoid race condition. |
4298 UnlinkEvacuationCandidates(); | 4276 UnlinkEvacuationCandidates(); |
4299 | 4277 |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4578 while (buffer != NULL) { | 4556 while (buffer != NULL) { |
4579 SlotsBuffer* next_buffer = buffer->next(); | 4557 SlotsBuffer* next_buffer = buffer->next(); |
4580 DeallocateBuffer(buffer); | 4558 DeallocateBuffer(buffer); |
4581 buffer = next_buffer; | 4559 buffer = next_buffer; |
4582 } | 4560 } |
4583 *buffer_address = NULL; | 4561 *buffer_address = NULL; |
4584 } | 4562 } |
4585 | 4563 |
4586 | 4564 |
4587 } } // namespace v8::internal | 4565 } } // namespace v8::internal |
OLD | NEW |