| 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/v8.h" | 5 #include "src/v8.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.h" | 9 #include "src/full-codegen.h" |
| 10 #include "src/heap/mark-compact.h" | 10 #include "src/heap/mark-compact.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 // just an anchor for the double linked page list. Initialize the current | 34 // just an anchor for the double linked page list. Initialize the current |
| 35 // address and end as NULL, then the first iteration will move on | 35 // address and end as NULL, then the first iteration will move on |
| 36 // to the first page. | 36 // to the first page. |
| 37 Initialize(space, NULL, NULL, kAllPagesInSpace, size_func); | 37 Initialize(space, NULL, NULL, kAllPagesInSpace, size_func); |
| 38 } | 38 } |
| 39 | 39 |
| 40 | 40 |
| 41 HeapObjectIterator::HeapObjectIterator(Page* page, | 41 HeapObjectIterator::HeapObjectIterator(Page* page, |
| 42 HeapObjectCallback size_func) { | 42 HeapObjectCallback size_func) { |
| 43 Space* owner = page->owner(); | 43 Space* owner = page->owner(); |
| 44 DCHECK(owner == page->heap()->old_space() || | 44 DCHECK(owner == page->heap()->old_pointer_space() || |
| 45 owner == page->heap()->old_data_space() || |
| 45 owner == page->heap()->map_space() || | 46 owner == page->heap()->map_space() || |
| 46 owner == page->heap()->cell_space() || | 47 owner == page->heap()->cell_space() || |
| 47 owner == page->heap()->code_space()); | 48 owner == page->heap()->code_space()); |
| 48 Initialize(reinterpret_cast<PagedSpace*>(owner), page->area_start(), | 49 Initialize(reinterpret_cast<PagedSpace*>(owner), page->area_start(), |
| 49 page->area_end(), kOnePageOnly, size_func); | 50 page->area_end(), kOnePageOnly, size_func); |
| 50 DCHECK(page->WasSwept() || page->SweepingCompleted()); | 51 DCHECK(page->WasSwept() || page->SweepingCompleted()); |
| 51 } | 52 } |
| 52 | 53 |
| 53 | 54 |
| 54 void HeapObjectIterator::Initialize(PagedSpace* space, Address cur, Address end, | 55 void HeapObjectIterator::Initialize(PagedSpace* space, Address cur, Address end, |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 chunk->initialize_scan_on_scavenge(false); | 503 chunk->initialize_scan_on_scavenge(false); |
| 503 chunk->SetFlag(WAS_SWEPT); | 504 chunk->SetFlag(WAS_SWEPT); |
| 504 | 505 |
| 505 DCHECK(OFFSET_OF(MemoryChunk, flags_) == kFlagsOffset); | 506 DCHECK(OFFSET_OF(MemoryChunk, flags_) == kFlagsOffset); |
| 506 DCHECK(OFFSET_OF(MemoryChunk, live_byte_count_) == kLiveBytesOffset); | 507 DCHECK(OFFSET_OF(MemoryChunk, live_byte_count_) == kLiveBytesOffset); |
| 507 | 508 |
| 508 if (executable == EXECUTABLE) { | 509 if (executable == EXECUTABLE) { |
| 509 chunk->SetFlag(IS_EXECUTABLE); | 510 chunk->SetFlag(IS_EXECUTABLE); |
| 510 } | 511 } |
| 511 | 512 |
| 513 if (owner == heap->old_data_space()) { |
| 514 chunk->SetFlag(CONTAINS_ONLY_DATA); |
| 515 } |
| 516 |
| 512 return chunk; | 517 return chunk; |
| 513 } | 518 } |
| 514 | 519 |
| 515 | 520 |
| 516 // Commit MemoryChunk area to the requested size. | 521 // Commit MemoryChunk area to the requested size. |
| 517 bool MemoryChunk::CommitArea(size_t requested) { | 522 bool MemoryChunk::CommitArea(size_t requested) { |
| 518 size_t guard_size = | 523 size_t guard_size = |
| 519 IsFlagSet(IS_EXECUTABLE) ? MemoryAllocator::CodePageGuardSize() : 0; | 524 IsFlagSet(IS_EXECUTABLE) ? MemoryAllocator::CodePageGuardSize() : 0; |
| 520 size_t header_size = area_start() - address() - guard_size; | 525 size_t header_size = area_start() - address() - guard_size; |
| 521 size_t commit_size = | 526 size_t commit_size = |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 913 } | 918 } |
| 914 chunk->IncrementLiveBytes(by); | 919 chunk->IncrementLiveBytes(by); |
| 915 } | 920 } |
| 916 | 921 |
| 917 | 922 |
| 918 // ----------------------------------------------------------------------------- | 923 // ----------------------------------------------------------------------------- |
| 919 // PagedSpace implementation | 924 // PagedSpace implementation |
| 920 | 925 |
| 921 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::NEW_SPACE) == | 926 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::NEW_SPACE) == |
| 922 ObjectSpace::kObjectSpaceNewSpace); | 927 ObjectSpace::kObjectSpaceNewSpace); |
| 923 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::OLD_SPACE) == | 928 STATIC_ASSERT(static_cast<ObjectSpace>(1 |
| 924 ObjectSpace::kObjectSpaceOldSpace); | 929 << AllocationSpace::OLD_POINTER_SPACE) == |
| 930 ObjectSpace::kObjectSpaceOldPointerSpace); |
| 931 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::OLD_DATA_SPACE) == |
| 932 ObjectSpace::kObjectSpaceOldDataSpace); |
| 925 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::CODE_SPACE) == | 933 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::CODE_SPACE) == |
| 926 ObjectSpace::kObjectSpaceCodeSpace); | 934 ObjectSpace::kObjectSpaceCodeSpace); |
| 927 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::CELL_SPACE) == | 935 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::CELL_SPACE) == |
| 928 ObjectSpace::kObjectSpaceCellSpace); | 936 ObjectSpace::kObjectSpaceCellSpace); |
| 929 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::MAP_SPACE) == | 937 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::MAP_SPACE) == |
| 930 ObjectSpace::kObjectSpaceMapSpace); | 938 ObjectSpace::kObjectSpaceMapSpace); |
| 931 | 939 |
| 932 | 940 |
| 933 PagedSpace::PagedSpace(Heap* heap, intptr_t max_capacity, AllocationSpace space, | 941 PagedSpace::PagedSpace(Heap* heap, intptr_t max_capacity, AllocationSpace space, |
| 934 Executability executable) | 942 Executability executable) |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1102 allocation_info_.set_top(NULL); | 1110 allocation_info_.set_top(NULL); |
| 1103 allocation_info_.set_limit(NULL); | 1111 allocation_info_.set_limit(NULL); |
| 1104 } | 1112 } |
| 1105 | 1113 |
| 1106 // If page is still in a list, unlink it from that list. | 1114 // If page is still in a list, unlink it from that list. |
| 1107 if (page->next_chunk() != NULL) { | 1115 if (page->next_chunk() != NULL) { |
| 1108 DCHECK(page->prev_chunk() != NULL); | 1116 DCHECK(page->prev_chunk() != NULL); |
| 1109 page->Unlink(); | 1117 page->Unlink(); |
| 1110 } | 1118 } |
| 1111 | 1119 |
| 1112 heap()->QueueMemoryChunkForFree(page); | 1120 if (page->IsFlagSet(MemoryChunk::CONTAINS_ONLY_DATA)) { |
| 1121 heap()->isolate()->memory_allocator()->Free(page); |
| 1122 } else { |
| 1123 heap()->QueueMemoryChunkForFree(page); |
| 1124 } |
| 1113 | 1125 |
| 1114 DCHECK(Capacity() > 0); | 1126 DCHECK(Capacity() > 0); |
| 1115 accounting_stats_.ShrinkSpace(AreaSize()); | 1127 accounting_stats_.ShrinkSpace(AreaSize()); |
| 1116 } | 1128 } |
| 1117 | 1129 |
| 1118 | 1130 |
| 1119 void PagedSpace::CreateEmergencyMemory() { | 1131 void PagedSpace::CreateEmergencyMemory() { |
| 1120 if (identity() == CODE_SPACE) { | 1132 if (identity() == CODE_SPACE) { |
| 1121 // Make the emergency block available to the allocator. | 1133 // Make the emergency block available to the allocator. |
| 1122 CodeRange* code_range = heap()->isolate()->code_range(); | 1134 CodeRange* code_range = heap()->isolate()->code_range(); |
| (...skipping 1996 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3119 object->ShortPrint(); | 3131 object->ShortPrint(); |
| 3120 PrintF("\n"); | 3132 PrintF("\n"); |
| 3121 } | 3133 } |
| 3122 printf(" --------------------------------------\n"); | 3134 printf(" --------------------------------------\n"); |
| 3123 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3135 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
| 3124 } | 3136 } |
| 3125 | 3137 |
| 3126 #endif // DEBUG | 3138 #endif // DEBUG |
| 3127 } | 3139 } |
| 3128 } // namespace v8::internal | 3140 } // namespace v8::internal |
| OLD | NEW |