Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(173)

Side by Side Diff: src/mark-compact.cc

Issue 408843003: Set the state of a swept page after being done with sweeping. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 3249 matching lines...) Expand 10 before | Expand all | Expand 10 after
3260 space->identity() == CODE_SPACE); 3260 space->identity() == CODE_SPACE);
3261 ASSERT((p->skip_list() == NULL) || (skip_list_mode == REBUILD_SKIP_LIST)); 3261 ASSERT((p->skip_list() == NULL) || (skip_list_mode == REBUILD_SKIP_LIST));
3262 ASSERT(parallelism == MarkCompactCollector::SWEEP_ON_MAIN_THREAD || 3262 ASSERT(parallelism == MarkCompactCollector::SWEEP_ON_MAIN_THREAD ||
3263 sweeping_mode == SWEEP_ONLY); 3263 sweeping_mode == SWEEP_ONLY);
3264 3264
3265 double start_time = 0.0; 3265 double start_time = 0.0;
3266 if (FLAG_print_cumulative_gc_stat) { 3266 if (FLAG_print_cumulative_gc_stat) {
3267 start_time = base::OS::TimeCurrentMillis(); 3267 start_time = base::OS::TimeCurrentMillis();
3268 } 3268 }
3269 3269
3270 if (parallelism == MarkCompactCollector::SWEEP_IN_PARALLEL) {
3271 p->set_parallel_sweeping(MemoryChunk::SWEEPING_FINALIZE);
3272 } else {
3273 p->MarkSweptPrecisely();
3274 }
3275
3276 Address free_start = p->area_start(); 3270 Address free_start = p->area_start();
3277 ASSERT(reinterpret_cast<intptr_t>(free_start) % (32 * kPointerSize) == 0); 3271 ASSERT(reinterpret_cast<intptr_t>(free_start) % (32 * kPointerSize) == 0);
3278 int offsets[16]; 3272 int offsets[16];
3279 3273
3280 SkipList* skip_list = p->skip_list(); 3274 SkipList* skip_list = p->skip_list();
3281 int curr_region = -1; 3275 int curr_region = -1;
3282 if ((skip_list_mode == REBUILD_SKIP_LIST) && skip_list) { 3276 if ((skip_list_mode == REBUILD_SKIP_LIST) && skip_list) {
3283 skip_list->Clear(); 3277 skip_list->Clear();
3284 } 3278 }
3285 3279
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
3339 #ifdef ENABLE_GDB_JIT_INTERFACE 3333 #ifdef ENABLE_GDB_JIT_INTERFACE
3340 if (FLAG_gdbjit && space->identity() == CODE_SPACE) { 3334 if (FLAG_gdbjit && space->identity() == CODE_SPACE) {
3341 GDBJITInterface::RemoveCodeRange(free_start, p->area_end()); 3335 GDBJITInterface::RemoveCodeRange(free_start, p->area_end());
3342 } 3336 }
3343 #endif 3337 #endif
3344 } 3338 }
3345 p->ResetLiveBytes(); 3339 p->ResetLiveBytes();
3346 if (FLAG_print_cumulative_gc_stat) { 3340 if (FLAG_print_cumulative_gc_stat) {
3347 space->heap()->AddSweepingTime(base::OS::TimeCurrentMillis() - start_time); 3341 space->heap()->AddSweepingTime(base::OS::TimeCurrentMillis() - start_time);
3348 } 3342 }
3343
3344 if (parallelism == MarkCompactCollector::SWEEP_IN_PARALLEL) {
3345 // When concurrent sweeping is active, the page will be marked after
3346 // sweeping by the main thread.
3347 p->set_parallel_sweeping(MemoryChunk::SWEEPING_FINALIZE);
3348 } else {
3349 p->MarkSweptPrecisely();
3350 }
3349 return FreeList::GuaranteedAllocatable(static_cast<int>(max_freed_bytes)); 3351 return FreeList::GuaranteedAllocatable(static_cast<int>(max_freed_bytes));
3350 } 3352 }
3351 3353
3352 3354
3353 static bool SetMarkBitsUnderInvalidatedCode(Code* code, bool value) { 3355 static bool SetMarkBitsUnderInvalidatedCode(Code* code, bool value) {
3354 Page* p = Page::FromAddress(code->address()); 3356 Page* p = Page::FromAddress(code->address());
3355 3357
3356 if (p->IsEvacuationCandidate() || 3358 if (p->IsEvacuationCandidate() ||
3357 p->IsFlagSet(Page::RESCAN_ON_EVACUATION)) { 3359 p->IsFlagSet(Page::RESCAN_ON_EVACUATION)) {
3358 return false; 3360 return false;
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after
3992 template<MarkCompactCollector::SweepingParallelism mode> 3994 template<MarkCompactCollector::SweepingParallelism mode>
3993 int MarkCompactCollector::SweepConservatively(PagedSpace* space, 3995 int MarkCompactCollector::SweepConservatively(PagedSpace* space,
3994 FreeList* free_list, 3996 FreeList* free_list,
3995 Page* p) { 3997 Page* p) {
3996 ASSERT(!p->IsEvacuationCandidate() && !p->WasSwept()); 3998 ASSERT(!p->IsEvacuationCandidate() && !p->WasSwept());
3997 ASSERT((mode == MarkCompactCollector::SWEEP_IN_PARALLEL && 3999 ASSERT((mode == MarkCompactCollector::SWEEP_IN_PARALLEL &&
3998 free_list != NULL) || 4000 free_list != NULL) ||
3999 (mode == MarkCompactCollector::SWEEP_ON_MAIN_THREAD && 4001 (mode == MarkCompactCollector::SWEEP_ON_MAIN_THREAD &&
4000 free_list == NULL)); 4002 free_list == NULL));
4001 4003
4002 // When parallel sweeping is active, the page will be marked after
4003 // sweeping by the main thread.
4004 if (mode == MarkCompactCollector::SWEEP_IN_PARALLEL) {
4005 p->set_parallel_sweeping(MemoryChunk::SWEEPING_FINALIZE);
4006 } else {
4007 p->MarkSweptConservatively();
4008 }
4009
4010 intptr_t freed_bytes = 0; 4004 intptr_t freed_bytes = 0;
4011 intptr_t max_freed_bytes = 0; 4005 intptr_t max_freed_bytes = 0;
4012 size_t size = 0; 4006 size_t size = 0;
4013 4007
4014 // Skip over all the dead objects at the start of the page and mark them free. 4008 // Skip over all the dead objects at the start of the page and mark them free.
4015 Address cell_base = 0; 4009 Address cell_base = 0;
4016 MarkBit::CellType* cell = NULL; 4010 MarkBit::CellType* cell = NULL;
4017 MarkBitCellIterator it(p); 4011 MarkBitCellIterator it(p);
4018 for (; !it.Done(); it.Advance()) { 4012 for (; !it.Done(); it.Advance()) {
4019 cell_base = it.CurrentCellBase(); 4013 cell_base = it.CurrentCellBase();
4020 cell = it.CurrentCell(); 4014 cell = it.CurrentCell();
4021 if (*cell != 0) break; 4015 if (*cell != 0) break;
4022 } 4016 }
4023 4017
4024 if (it.Done()) { 4018 if (it.Done()) {
4025 size = p->area_end() - p->area_start(); 4019 size = p->area_end() - p->area_start();
4026 freed_bytes = Free<mode>(space, free_list, p->area_start(), 4020 freed_bytes = Free<mode>(space, free_list, p->area_start(),
4027 static_cast<int>(size)); 4021 static_cast<int>(size));
4028 max_freed_bytes = Max(freed_bytes, max_freed_bytes); 4022 max_freed_bytes = Max(freed_bytes, max_freed_bytes);
4029 ASSERT_EQ(0, p->LiveBytes()); 4023 ASSERT_EQ(0, p->LiveBytes());
4024 if (mode == MarkCompactCollector::SWEEP_IN_PARALLEL) {
4025 // When concurrent sweeping is active, the page will be marked after
4026 // sweeping by the main thread.
4027 p->set_parallel_sweeping(MemoryChunk::SWEEPING_FINALIZE);
4028 } else {
4029 p->MarkSweptConservatively();
4030 }
4030 return FreeList::GuaranteedAllocatable(static_cast<int>(max_freed_bytes)); 4031 return FreeList::GuaranteedAllocatable(static_cast<int>(max_freed_bytes));
4031 } 4032 }
4032 4033
4033 // Grow the size of the start-of-page free space a little to get up to the 4034 // Grow the size of the start-of-page free space a little to get up to the
4034 // first live object. 4035 // first live object.
4035 Address free_end = StartOfLiveObject(cell_base, *cell); 4036 Address free_end = StartOfLiveObject(cell_base, *cell);
4036 // Free the first free space. 4037 // Free the first free space.
4037 size = free_end - p->area_start(); 4038 size = free_end - p->area_start();
4038 freed_bytes = Free<mode>(space, free_list, p->area_start(), 4039 freed_bytes = Free<mode>(space, free_list, p->area_start(),
4039 static_cast<int>(size)); 4040 static_cast<int>(size));
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
4077 4078
4078 // Handle the free space at the end of the page. 4079 // Handle the free space at the end of the page.
4079 if (cell_base - free_start > 32 * kPointerSize) { 4080 if (cell_base - free_start > 32 * kPointerSize) {
4080 free_start = DigestFreeStart(free_start, free_start_cell); 4081 free_start = DigestFreeStart(free_start, free_start_cell);
4081 freed_bytes = Free<mode>(space, free_list, free_start, 4082 freed_bytes = Free<mode>(space, free_list, free_start,
4082 static_cast<int>(p->area_end() - free_start)); 4083 static_cast<int>(p->area_end() - free_start));
4083 max_freed_bytes = Max(freed_bytes, max_freed_bytes); 4084 max_freed_bytes = Max(freed_bytes, max_freed_bytes);
4084 } 4085 }
4085 4086
4086 p->ResetLiveBytes(); 4087 p->ResetLiveBytes();
4088 if (mode == MarkCompactCollector::SWEEP_IN_PARALLEL) {
titzer 2014/07/21 19:19:48 How about we have a subroutine :)
Hannes Payer (out of office) 2014/07/21 19:22:13 The mode will be gone soon, working on it.
4089 // When concurrent sweeping is active, the page will be marked after
4090 // sweeping by the main thread.
4091 p->set_parallel_sweeping(MemoryChunk::SWEEPING_FINALIZE);
4092 } else {
4093 p->MarkSweptConservatively();
4094 }
4087 return FreeList::GuaranteedAllocatable(static_cast<int>(max_freed_bytes)); 4095 return FreeList::GuaranteedAllocatable(static_cast<int>(max_freed_bytes));
4088 } 4096 }
4089 4097
4090 4098
4091 int MarkCompactCollector::SweepInParallel(PagedSpace* space, 4099 int MarkCompactCollector::SweepInParallel(PagedSpace* space,
4092 int required_freed_bytes) { 4100 int required_freed_bytes) {
4093 PageIterator it(space); 4101 PageIterator it(space);
4094 FreeList* free_list = space == heap()->old_pointer_space() 4102 FreeList* free_list = space == heap()->old_pointer_space()
4095 ? free_list_old_pointer_space_.get() 4103 ? free_list_old_pointer_space_.get()
4096 : free_list_old_data_space_.get(); 4104 : free_list_old_data_space_.get();
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
4576 while (buffer != NULL) { 4584 while (buffer != NULL) {
4577 SlotsBuffer* next_buffer = buffer->next(); 4585 SlotsBuffer* next_buffer = buffer->next();
4578 DeallocateBuffer(buffer); 4586 DeallocateBuffer(buffer);
4579 buffer = next_buffer; 4587 buffer = next_buffer;
4580 } 4588 }
4581 *buffer_address = NULL; 4589 *buffer_address = NULL;
4582 } 4590 }
4583 4591
4584 4592
4585 } } // namespace v8::internal 4593 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698