OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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/heap/spaces.h" | 5 #include "src/heap/spaces.h" |
6 | 6 |
7 #include "src/base/bits.h" | 7 #include "src/base/bits.h" |
8 #include "src/base/platform/platform.h" | 8 #include "src/base/platform/platform.h" |
9 #include "src/full-codegen/full-codegen.h" | 9 #include "src/full-codegen/full-codegen.h" |
10 #include "src/heap/slots-buffer.h" | 10 #include "src/heap/slots-buffer.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 } | 28 } |
29 | 29 |
30 | 30 |
31 HeapObjectIterator::HeapObjectIterator(Page* page) { | 31 HeapObjectIterator::HeapObjectIterator(Page* page) { |
32 Space* owner = page->owner(); | 32 Space* owner = page->owner(); |
33 DCHECK(owner == page->heap()->old_space() || | 33 DCHECK(owner == page->heap()->old_space() || |
34 owner == page->heap()->map_space() || | 34 owner == page->heap()->map_space() || |
35 owner == page->heap()->code_space()); | 35 owner == page->heap()->code_space()); |
36 Initialize(reinterpret_cast<PagedSpace*>(owner), page->area_start(), | 36 Initialize(reinterpret_cast<PagedSpace*>(owner), page->area_start(), |
37 page->area_end(), kOnePageOnly); | 37 page->area_end(), kOnePageOnly); |
38 DCHECK(page->WasSwept() || page->SweepingCompleted()); | 38 DCHECK(page->SweepingDone()); |
39 } | 39 } |
40 | 40 |
41 | 41 |
42 void HeapObjectIterator::Initialize(PagedSpace* space, Address cur, Address end, | 42 void HeapObjectIterator::Initialize(PagedSpace* space, Address cur, Address end, |
43 HeapObjectIterator::PageMode mode) { | 43 HeapObjectIterator::PageMode mode) { |
44 space_ = space; | 44 space_ = space; |
45 cur_addr_ = cur; | 45 cur_addr_ = cur; |
46 cur_end_ = end; | 46 cur_end_ = end; |
47 page_mode_ = mode; | 47 page_mode_ = mode; |
48 } | 48 } |
(...skipping 10 matching lines...) Expand all Loading... |
59 } else { | 59 } else { |
60 cur_page = Page::FromAddress(cur_addr_ - 1); | 60 cur_page = Page::FromAddress(cur_addr_ - 1); |
61 DCHECK(cur_addr_ == cur_page->area_end()); | 61 DCHECK(cur_addr_ == cur_page->area_end()); |
62 } | 62 } |
63 cur_page = cur_page->next_page(); | 63 cur_page = cur_page->next_page(); |
64 if (cur_page == space_->anchor()) return false; | 64 if (cur_page == space_->anchor()) return false; |
65 cur_page->heap()->mark_compact_collector()->SweepOrWaitUntilSweepingCompleted( | 65 cur_page->heap()->mark_compact_collector()->SweepOrWaitUntilSweepingCompleted( |
66 cur_page); | 66 cur_page); |
67 cur_addr_ = cur_page->area_start(); | 67 cur_addr_ = cur_page->area_start(); |
68 cur_end_ = cur_page->area_end(); | 68 cur_end_ = cur_page->area_end(); |
69 DCHECK(cur_page->WasSwept() || cur_page->SweepingCompleted()); | 69 DCHECK(cur_page->SweepingDone()); |
70 return true; | 70 return true; |
71 } | 71 } |
72 | 72 |
73 | 73 |
74 // ----------------------------------------------------------------------------- | 74 // ----------------------------------------------------------------------------- |
75 // CodeRange | 75 // CodeRange |
76 | 76 |
77 | 77 |
78 CodeRange::CodeRange(Isolate* isolate) | 78 CodeRange::CodeRange(Isolate* isolate) |
79 : isolate_(isolate), | 79 : isolate_(isolate), |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 chunk->area_start_ = area_start; | 462 chunk->area_start_ = area_start; |
463 chunk->area_end_ = area_end; | 463 chunk->area_end_ = area_end; |
464 chunk->flags_ = 0; | 464 chunk->flags_ = 0; |
465 chunk->set_owner(owner); | 465 chunk->set_owner(owner); |
466 chunk->InitializeReservedMemory(); | 466 chunk->InitializeReservedMemory(); |
467 chunk->slots_buffer_ = NULL; | 467 chunk->slots_buffer_ = NULL; |
468 chunk->skip_list_ = NULL; | 468 chunk->skip_list_ = NULL; |
469 chunk->write_barrier_counter_ = kWriteBarrierCounterGranularity; | 469 chunk->write_barrier_counter_ = kWriteBarrierCounterGranularity; |
470 chunk->progress_bar_ = 0; | 470 chunk->progress_bar_ = 0; |
471 chunk->high_water_mark_.SetValue(static_cast<intptr_t>(area_start - base)); | 471 chunk->high_water_mark_.SetValue(static_cast<intptr_t>(area_start - base)); |
472 chunk->parallel_sweeping_state().SetValue(kSweepingDone); | 472 chunk->concurrent_sweeping_state().SetValue(kSweepingDone); |
473 chunk->parallel_compaction_state().SetValue(kCompactingDone); | 473 chunk->parallel_compaction_state().SetValue(kCompactingDone); |
474 chunk->mutex_ = NULL; | 474 chunk->mutex_ = NULL; |
475 chunk->available_in_small_free_list_ = 0; | 475 chunk->available_in_small_free_list_ = 0; |
476 chunk->available_in_medium_free_list_ = 0; | 476 chunk->available_in_medium_free_list_ = 0; |
477 chunk->available_in_large_free_list_ = 0; | 477 chunk->available_in_large_free_list_ = 0; |
478 chunk->available_in_huge_free_list_ = 0; | 478 chunk->available_in_huge_free_list_ = 0; |
479 chunk->non_available_small_blocks_ = 0; | 479 chunk->non_available_small_blocks_ = 0; |
480 chunk->ResetLiveBytes(); | 480 chunk->ResetLiveBytes(); |
481 Bitmap::Clear(chunk); | 481 Bitmap::Clear(chunk); |
482 chunk->initialize_scan_on_scavenge(false); | 482 chunk->initialize_scan_on_scavenge(false); |
483 chunk->SetFlag(WAS_SWEPT); | |
484 chunk->set_next_chunk(nullptr); | 483 chunk->set_next_chunk(nullptr); |
485 chunk->set_prev_chunk(nullptr); | 484 chunk->set_prev_chunk(nullptr); |
486 | 485 |
487 DCHECK(OFFSET_OF(MemoryChunk, flags_) == kFlagsOffset); | 486 DCHECK(OFFSET_OF(MemoryChunk, flags_) == kFlagsOffset); |
488 DCHECK(OFFSET_OF(MemoryChunk, live_byte_count_) == kLiveBytesOffset); | 487 DCHECK(OFFSET_OF(MemoryChunk, live_byte_count_) == kLiveBytesOffset); |
489 | 488 |
490 if (executable == EXECUTABLE) { | 489 if (executable == EXECUTABLE) { |
491 chunk->SetFlag(IS_EXECUTABLE); | 490 chunk->SetFlag(IS_EXECUTABLE); |
492 } | 491 } |
493 | 492 |
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
916 } | 915 } |
917 return false; | 916 return false; |
918 } | 917 } |
919 | 918 |
920 | 919 |
921 // ----------------------------------------------------------------------------- | 920 // ----------------------------------------------------------------------------- |
922 // MemoryChunk implementation | 921 // MemoryChunk implementation |
923 | 922 |
924 void MemoryChunk::IncrementLiveBytesFromMutator(HeapObject* object, int by) { | 923 void MemoryChunk::IncrementLiveBytesFromMutator(HeapObject* object, int by) { |
925 MemoryChunk* chunk = MemoryChunk::FromAddress(object->address()); | 924 MemoryChunk* chunk = MemoryChunk::FromAddress(object->address()); |
926 if (!chunk->InNewSpace() && !static_cast<Page*>(chunk)->WasSwept()) { | 925 if (!chunk->InNewSpace() && !static_cast<Page*>(chunk)->SweepingDone()) { |
927 static_cast<PagedSpace*>(chunk->owner())->Allocate(by); | 926 static_cast<PagedSpace*>(chunk->owner())->Allocate(by); |
928 } | 927 } |
929 chunk->IncrementLiveBytes(by); | 928 chunk->IncrementLiveBytes(by); |
930 } | 929 } |
931 | 930 |
932 | 931 |
933 void MemoryChunk::ReleaseAllocatedMemory() { | 932 void MemoryChunk::ReleaseAllocatedMemory() { |
934 delete slots_buffer_; | 933 delete slots_buffer_; |
935 delete skip_list_; | 934 delete skip_list_; |
936 delete mutex_; | 935 delete mutex_; |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1218 page->ResetFreeListStatistics(); | 1217 page->ResetFreeListStatistics(); |
1219 } | 1218 } |
1220 } | 1219 } |
1221 | 1220 |
1222 | 1221 |
1223 void PagedSpace::IncreaseCapacity(int size) { | 1222 void PagedSpace::IncreaseCapacity(int size) { |
1224 accounting_stats_.ExpandSpace(size); | 1223 accounting_stats_.ExpandSpace(size); |
1225 } | 1224 } |
1226 | 1225 |
1227 | 1226 |
1228 void PagedSpace::ReleasePage(Page* page) { | 1227 void PagedSpace::ReleasePage(Page* page, bool evict_free_list_items) { |
1229 DCHECK(page->LiveBytes() == 0); | 1228 DCHECK(page->LiveBytes() == 0); |
1230 DCHECK(AreaSize() == page->area_size()); | 1229 DCHECK(AreaSize() == page->area_size()); |
1231 | 1230 |
1232 if (page->WasSwept()) { | 1231 if (evict_free_list_items) { |
1233 intptr_t size = free_list_.EvictFreeListItems(page); | 1232 intptr_t size = free_list_.EvictFreeListItems(page); |
1234 accounting_stats_.AllocateBytes(size); | 1233 accounting_stats_.AllocateBytes(size); |
1235 DCHECK_EQ(AreaSize(), static_cast<int>(size)); | 1234 DCHECK_EQ(AreaSize(), static_cast<int>(size)); |
1236 } | 1235 } |
1237 | 1236 |
1238 if (page->IsFlagSet(MemoryChunk::SCAN_ON_SCAVENGE)) { | 1237 if (page->IsFlagSet(MemoryChunk::SCAN_ON_SCAVENGE)) { |
1239 heap()->decrement_scan_on_scavenge_pages(); | 1238 heap()->decrement_scan_on_scavenge_pages(); |
1240 page->ClearFlag(MemoryChunk::SCAN_ON_SCAVENGE); | 1239 page->ClearFlag(MemoryChunk::SCAN_ON_SCAVENGE); |
1241 } | 1240 } |
1242 | 1241 |
(...skipping 25 matching lines...) Expand all Loading... |
1268 void PagedSpace::Verify(ObjectVisitor* visitor) { | 1267 void PagedSpace::Verify(ObjectVisitor* visitor) { |
1269 bool allocation_pointer_found_in_space = | 1268 bool allocation_pointer_found_in_space = |
1270 (allocation_info_.top() == allocation_info_.limit()); | 1269 (allocation_info_.top() == allocation_info_.limit()); |
1271 PageIterator page_iterator(this); | 1270 PageIterator page_iterator(this); |
1272 while (page_iterator.has_next()) { | 1271 while (page_iterator.has_next()) { |
1273 Page* page = page_iterator.next(); | 1272 Page* page = page_iterator.next(); |
1274 CHECK(page->owner() == this); | 1273 CHECK(page->owner() == this); |
1275 if (page == Page::FromAllocationTop(allocation_info_.top())) { | 1274 if (page == Page::FromAllocationTop(allocation_info_.top())) { |
1276 allocation_pointer_found_in_space = true; | 1275 allocation_pointer_found_in_space = true; |
1277 } | 1276 } |
1278 CHECK(page->WasSwept()); | 1277 CHECK(page->SweepingDone()); |
1279 HeapObjectIterator it(page); | 1278 HeapObjectIterator it(page); |
1280 Address end_of_previous_object = page->area_start(); | 1279 Address end_of_previous_object = page->area_start(); |
1281 Address top = page->area_end(); | 1280 Address top = page->area_end(); |
1282 int black_size = 0; | 1281 int black_size = 0; |
1283 for (HeapObject* object = it.Next(); object != NULL; object = it.Next()) { | 1282 for (HeapObject* object = it.Next(); object != NULL; object = it.Next()) { |
1284 CHECK(end_of_previous_object <= object->address()); | 1283 CHECK(end_of_previous_object <= object->address()); |
1285 | 1284 |
1286 // The first word should be a map, and we expect all map pointers to | 1285 // The first word should be a map, and we expect all map pointers to |
1287 // be in map space. | 1286 // be in map space. |
1288 Map* map = object->map(); | 1287 Map* map = object->map(); |
(...skipping 2075 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3364 object->ShortPrint(); | 3363 object->ShortPrint(); |
3365 PrintF("\n"); | 3364 PrintF("\n"); |
3366 } | 3365 } |
3367 printf(" --------------------------------------\n"); | 3366 printf(" --------------------------------------\n"); |
3368 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3367 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
3369 } | 3368 } |
3370 | 3369 |
3371 #endif // DEBUG | 3370 #endif // DEBUG |
3372 } // namespace internal | 3371 } // namespace internal |
3373 } // namespace v8 | 3372 } // namespace v8 |
OLD | NEW |