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

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

Issue 9295047: Revert 10542 (boot time memory reduction) due to map alignment (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 8 years, 10 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 | « src/incremental-marking.cc ('k') | src/serialize.cc » ('j') | 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 // 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 2901 matching lines...) Expand 10 before | Expand all | Expand 10 after
2912 cell_index++, object_address += 32 * kPointerSize) { 2912 cell_index++, object_address += 32 * kPointerSize) {
2913 ASSERT((unsigned)cell_index == 2913 ASSERT((unsigned)cell_index ==
2914 Bitmap::IndexToCell( 2914 Bitmap::IndexToCell(
2915 Bitmap::CellAlignIndex( 2915 Bitmap::CellAlignIndex(
2916 p->AddressToMarkbitIndex(object_address)))); 2916 p->AddressToMarkbitIndex(object_address))));
2917 int live_objects = MarkWordToObjectStarts(cells[cell_index], offsets); 2917 int live_objects = MarkWordToObjectStarts(cells[cell_index], offsets);
2918 int live_index = 0; 2918 int live_index = 0;
2919 for ( ; live_objects != 0; live_objects--) { 2919 for ( ; live_objects != 0; live_objects--) {
2920 Address free_end = object_address + offsets[live_index++] * kPointerSize; 2920 Address free_end = object_address + offsets[live_index++] * kPointerSize;
2921 if (free_end != free_start) { 2921 if (free_end != free_start) {
2922 space->AddToFreeLists(free_start, 2922 space->Free(free_start, static_cast<int>(free_end - free_start));
2923 static_cast<int>(free_end - free_start));
2924 } 2923 }
2925 HeapObject* live_object = HeapObject::FromAddress(free_end); 2924 HeapObject* live_object = HeapObject::FromAddress(free_end);
2926 ASSERT(Marking::IsBlack(Marking::MarkBitFrom(live_object))); 2925 ASSERT(Marking::IsBlack(Marking::MarkBitFrom(live_object)));
2927 Map* map = live_object->map(); 2926 Map* map = live_object->map();
2928 int size = live_object->SizeFromMap(map); 2927 int size = live_object->SizeFromMap(map);
2929 if (sweeping_mode == SWEEP_AND_VISIT_LIVE_OBJECTS) { 2928 if (sweeping_mode == SWEEP_AND_VISIT_LIVE_OBJECTS) {
2930 live_object->IterateBody(map->instance_type(), size, v); 2929 live_object->IterateBody(map->instance_type(), size, v);
2931 } 2930 }
2932 if ((skip_list_mode == REBUILD_SKIP_LIST) && skip_list != NULL) { 2931 if ((skip_list_mode == REBUILD_SKIP_LIST) && skip_list != NULL) {
2933 int new_region_start = 2932 int new_region_start =
2934 SkipList::RegionNumber(free_end); 2933 SkipList::RegionNumber(free_end);
2935 int new_region_end = 2934 int new_region_end =
2936 SkipList::RegionNumber(free_end + size - kPointerSize); 2935 SkipList::RegionNumber(free_end + size - kPointerSize);
2937 if (new_region_start != curr_region || 2936 if (new_region_start != curr_region ||
2938 new_region_end != curr_region) { 2937 new_region_end != curr_region) {
2939 skip_list->AddObject(free_end, size); 2938 skip_list->AddObject(free_end, size);
2940 curr_region = new_region_end; 2939 curr_region = new_region_end;
2941 } 2940 }
2942 } 2941 }
2943 free_start = free_end + size; 2942 free_start = free_end + size;
2944 } 2943 }
2945 // Clear marking bits for current cell. 2944 // Clear marking bits for current cell.
2946 cells[cell_index] = 0; 2945 cells[cell_index] = 0;
2947 } 2946 }
2948 if (free_start != p->ObjectAreaEnd()) { 2947 if (free_start != p->ObjectAreaEnd()) {
2949 space->AddToFreeLists(free_start, 2948 space->Free(free_start, static_cast<int>(p->ObjectAreaEnd() - free_start));
2950 static_cast<int>(p->ObjectAreaEnd() - free_start));
2951 } 2949 }
2952 p->ResetLiveBytes(); 2950 p->ResetLiveBytes();
2953 } 2951 }
2954 2952
2955 2953
2956 static bool SetMarkBitsUnderInvalidatedCode(Code* code, bool value) { 2954 static bool SetMarkBitsUnderInvalidatedCode(Code* code, bool value) {
2957 Page* p = Page::FromAddress(code->address()); 2955 Page* p = Page::FromAddress(code->address());
2958 2956
2959 if (p->IsEvacuationCandidate() || 2957 if (p->IsEvacuationCandidate() ||
2960 p->IsFlagSet(Page::RESCAN_ON_EVACUATION)) { 2958 p->IsFlagSet(Page::RESCAN_ON_EVACUATION)) {
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
3233 VerifyEvacuation(heap_); 3231 VerifyEvacuation(heap_);
3234 } 3232 }
3235 #endif 3233 #endif
3236 3234
3237 slots_buffer_allocator_.DeallocateChain(&migration_slots_buffer_); 3235 slots_buffer_allocator_.DeallocateChain(&migration_slots_buffer_);
3238 ASSERT(migration_slots_buffer_ == NULL); 3236 ASSERT(migration_slots_buffer_ == NULL);
3239 for (int i = 0; i < npages; i++) { 3237 for (int i = 0; i < npages; i++) {
3240 Page* p = evacuation_candidates_[i]; 3238 Page* p = evacuation_candidates_[i];
3241 if (!p->IsEvacuationCandidate()) continue; 3239 if (!p->IsEvacuationCandidate()) continue;
3242 PagedSpace* space = static_cast<PagedSpace*>(p->owner()); 3240 PagedSpace* space = static_cast<PagedSpace*>(p->owner());
3243 space->AddToFreeLists( 3241 space->Free(p->ObjectAreaStart(), Page::kObjectAreaSize);
3244 p->ObjectAreaStart(),
3245 static_cast<int>(p->ObjectAreaEnd() - p->ObjectAreaStart()));
3246 p->set_scan_on_scavenge(false); 3242 p->set_scan_on_scavenge(false);
3247 slots_buffer_allocator_.DeallocateChain(p->slots_buffer_address()); 3243 slots_buffer_allocator_.DeallocateChain(p->slots_buffer_address());
3248 p->ClearEvacuationCandidate(); 3244 p->ClearEvacuationCandidate();
3249 } 3245 }
3250 evacuation_candidates_.Rewind(0); 3246 evacuation_candidates_.Rewind(0);
3251 compacting_ = false; 3247 compacting_ = false;
3252 } 3248 }
3253 3249
3254 3250
3255 static const int kStartTableEntriesPerLine = 5; 3251 static const int kStartTableEntriesPerLine = 5;
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
3552 Address block_address = p->ObjectAreaStart(); 3548 Address block_address = p->ObjectAreaStart();
3553 3549
3554 // Skip over all the dead objects at the start of the page and mark them free. 3550 // Skip over all the dead objects at the start of the page and mark them free.
3555 for (cell_index = Page::kFirstUsedCell; 3551 for (cell_index = Page::kFirstUsedCell;
3556 cell_index < last_cell_index; 3552 cell_index < last_cell_index;
3557 cell_index++, block_address += 32 * kPointerSize) { 3553 cell_index++, block_address += 32 * kPointerSize) {
3558 if (cells[cell_index] != 0) break; 3554 if (cells[cell_index] != 0) break;
3559 } 3555 }
3560 size_t size = block_address - p->ObjectAreaStart(); 3556 size_t size = block_address - p->ObjectAreaStart();
3561 if (cell_index == last_cell_index) { 3557 if (cell_index == last_cell_index) {
3562 freed_bytes += static_cast<int>(space->AddToFreeLists( 3558 freed_bytes += static_cast<int>(space->Free(p->ObjectAreaStart(),
3563 p->ObjectAreaStart(), static_cast<int>(size))); 3559 static_cast<int>(size)));
3564 ASSERT_EQ(0, p->LiveBytes()); 3560 ASSERT_EQ(0, p->LiveBytes());
3565 return freed_bytes; 3561 return freed_bytes;
3566 } 3562 }
3567 // Grow the size of the start-of-page free space a little to get up to the 3563 // Grow the size of the start-of-page free space a little to get up to the
3568 // first live object. 3564 // first live object.
3569 Address free_end = StartOfLiveObject(block_address, cells[cell_index]); 3565 Address free_end = StartOfLiveObject(block_address, cells[cell_index]);
3570 // Free the first free space. 3566 // Free the first free space.
3571 size = free_end - p->ObjectAreaStart(); 3567 size = free_end - p->ObjectAreaStart();
3572 freed_bytes += space->AddToFreeLists(p->ObjectAreaStart(), 3568 freed_bytes += space->Free(p->ObjectAreaStart(),
3573 static_cast<int>(size)); 3569 static_cast<int>(size));
3574 // The start of the current free area is represented in undigested form by 3570 // The start of the current free area is represented in undigested form by
3575 // the address of the last 32-word section that contained a live object and 3571 // the address of the last 32-word section that contained a live object and
3576 // the marking bitmap for that cell, which describes where the live object 3572 // the marking bitmap for that cell, which describes where the live object
3577 // started. Unless we find a large free space in the bitmap we will not 3573 // started. Unless we find a large free space in the bitmap we will not
3578 // digest this pair into a real address. We start the iteration here at the 3574 // digest this pair into a real address. We start the iteration here at the
3579 // first word in the marking bit map that indicates a live object. 3575 // first word in the marking bit map that indicates a live object.
3580 Address free_start = block_address; 3576 Address free_start = block_address;
3581 uint32_t free_start_cell = cells[cell_index]; 3577 uint32_t free_start_cell = cells[cell_index];
3582 3578
3583 for ( ; 3579 for ( ;
3584 cell_index < last_cell_index; 3580 cell_index < last_cell_index;
3585 cell_index++, block_address += 32 * kPointerSize) { 3581 cell_index++, block_address += 32 * kPointerSize) {
3586 ASSERT((unsigned)cell_index == 3582 ASSERT((unsigned)cell_index ==
3587 Bitmap::IndexToCell( 3583 Bitmap::IndexToCell(
3588 Bitmap::CellAlignIndex( 3584 Bitmap::CellAlignIndex(
3589 p->AddressToMarkbitIndex(block_address)))); 3585 p->AddressToMarkbitIndex(block_address))));
3590 uint32_t cell = cells[cell_index]; 3586 uint32_t cell = cells[cell_index];
3591 if (cell != 0) { 3587 if (cell != 0) {
3592 // We have a live object. Check approximately whether it is more than 32 3588 // We have a live object. Check approximately whether it is more than 32
3593 // words since the last live object. 3589 // words since the last live object.
3594 if (block_address - free_start > 32 * kPointerSize) { 3590 if (block_address - free_start > 32 * kPointerSize) {
3595 free_start = DigestFreeStart(free_start, free_start_cell); 3591 free_start = DigestFreeStart(free_start, free_start_cell);
3596 if (block_address - free_start > 32 * kPointerSize) { 3592 if (block_address - free_start > 32 * kPointerSize) {
3597 // Now that we know the exact start of the free space it still looks 3593 // Now that we know the exact start of the free space it still looks
3598 // like we have a large enough free space to be worth bothering with. 3594 // like we have a large enough free space to be worth bothering with.
3599 // so now we need to find the start of the first live object at the 3595 // so now we need to find the start of the first live object at the
3600 // end of the free space. 3596 // end of the free space.
3601 free_end = StartOfLiveObject(block_address, cell); 3597 free_end = StartOfLiveObject(block_address, cell);
3602 freed_bytes += space->AddToFreeLists( 3598 freed_bytes += space->Free(free_start,
3603 free_start, static_cast<int>(free_end - free_start)); 3599 static_cast<int>(free_end - free_start));
3604 } 3600 }
3605 } 3601 }
3606 // Update our undigested record of where the current free area started. 3602 // Update our undigested record of where the current free area started.
3607 free_start = block_address; 3603 free_start = block_address;
3608 free_start_cell = cell; 3604 free_start_cell = cell;
3609 // Clear marking bits for current cell. 3605 // Clear marking bits for current cell.
3610 cells[cell_index] = 0; 3606 cells[cell_index] = 0;
3611 } 3607 }
3612 } 3608 }
3613 3609
3614 // Handle the free space at the end of the page. 3610 // Handle the free space at the end of the page.
3615 if (block_address - free_start > 32 * kPointerSize) { 3611 if (block_address - free_start > 32 * kPointerSize) {
3616 free_start = DigestFreeStart(free_start, free_start_cell); 3612 free_start = DigestFreeStart(free_start, free_start_cell);
3617 freed_bytes += space->AddToFreeLists( 3613 freed_bytes += space->Free(free_start,
3618 free_start, static_cast<int>(block_address - free_start)); 3614 static_cast<int>(block_address - free_start));
3619 } 3615 }
3620 3616
3621 p->ResetLiveBytes(); 3617 p->ResetLiveBytes();
3622 return freed_bytes; 3618 return freed_bytes;
3623 } 3619 }
3624 3620
3625 3621
3626 void MarkCompactCollector::SweepSpace(PagedSpace* space, SweeperType sweeper) { 3622 void MarkCompactCollector::SweepSpace(PagedSpace* space, SweeperType sweeper) {
3627 space->set_was_swept_conservatively(sweeper == CONSERVATIVE || 3623 space->set_was_swept_conservatively(sweeper == CONSERVATIVE ||
3628 sweeper == LAZY_CONSERVATIVE); 3624 sweeper == LAZY_CONSERVATIVE);
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
3943 while (buffer != NULL) { 3939 while (buffer != NULL) {
3944 SlotsBuffer* next_buffer = buffer->next(); 3940 SlotsBuffer* next_buffer = buffer->next();
3945 DeallocateBuffer(buffer); 3941 DeallocateBuffer(buffer);
3946 buffer = next_buffer; 3942 buffer = next_buffer;
3947 } 3943 }
3948 *buffer_address = NULL; 3944 *buffer_address = NULL;
3949 } 3945 }
3950 3946
3951 3947
3952 } } // namespace v8::internal 3948 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/incremental-marking.cc ('k') | src/serialize.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698