| 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_pointer_space() || | 44 DCHECK(owner == page->heap()->old_space() || |
| 45 owner == page->heap()->old_data_space() || | |
| 46 owner == page->heap()->map_space() || | 45 owner == page->heap()->map_space() || |
| 47 owner == page->heap()->cell_space() || | 46 owner == page->heap()->cell_space() || |
| 48 owner == page->heap()->code_space()); | 47 owner == page->heap()->code_space()); |
| 49 Initialize(reinterpret_cast<PagedSpace*>(owner), page->area_start(), | 48 Initialize(reinterpret_cast<PagedSpace*>(owner), page->area_start(), |
| 50 page->area_end(), kOnePageOnly, size_func); | 49 page->area_end(), kOnePageOnly, size_func); |
| 51 DCHECK(page->WasSwept() || page->SweepingCompleted()); | 50 DCHECK(page->WasSwept() || page->SweepingCompleted()); |
| 52 } | 51 } |
| 53 | 52 |
| 54 | 53 |
| 55 void HeapObjectIterator::Initialize(PagedSpace* space, Address cur, Address end, | 54 void HeapObjectIterator::Initialize(PagedSpace* space, Address cur, Address end, |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 chunk->initialize_scan_on_scavenge(false); | 502 chunk->initialize_scan_on_scavenge(false); |
| 504 chunk->SetFlag(WAS_SWEPT); | 503 chunk->SetFlag(WAS_SWEPT); |
| 505 | 504 |
| 506 DCHECK(OFFSET_OF(MemoryChunk, flags_) == kFlagsOffset); | 505 DCHECK(OFFSET_OF(MemoryChunk, flags_) == kFlagsOffset); |
| 507 DCHECK(OFFSET_OF(MemoryChunk, live_byte_count_) == kLiveBytesOffset); | 506 DCHECK(OFFSET_OF(MemoryChunk, live_byte_count_) == kLiveBytesOffset); |
| 508 | 507 |
| 509 if (executable == EXECUTABLE) { | 508 if (executable == EXECUTABLE) { |
| 510 chunk->SetFlag(IS_EXECUTABLE); | 509 chunk->SetFlag(IS_EXECUTABLE); |
| 511 } | 510 } |
| 512 | 511 |
| 513 if (owner == heap->old_data_space()) { | |
| 514 chunk->SetFlag(CONTAINS_ONLY_DATA); | |
| 515 } | |
| 516 | |
| 517 return chunk; | 512 return chunk; |
| 518 } | 513 } |
| 519 | 514 |
| 520 | 515 |
| 521 // Commit MemoryChunk area to the requested size. | 516 // Commit MemoryChunk area to the requested size. |
| 522 bool MemoryChunk::CommitArea(size_t requested) { | 517 bool MemoryChunk::CommitArea(size_t requested) { |
| 523 size_t guard_size = | 518 size_t guard_size = |
| 524 IsFlagSet(IS_EXECUTABLE) ? MemoryAllocator::CodePageGuardSize() : 0; | 519 IsFlagSet(IS_EXECUTABLE) ? MemoryAllocator::CodePageGuardSize() : 0; |
| 525 size_t header_size = area_start() - address() - guard_size; | 520 size_t header_size = area_start() - address() - guard_size; |
| 526 size_t commit_size = | 521 size_t commit_size = |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 918 } | 913 } |
| 919 chunk->IncrementLiveBytes(by); | 914 chunk->IncrementLiveBytes(by); |
| 920 } | 915 } |
| 921 | 916 |
| 922 | 917 |
| 923 // ----------------------------------------------------------------------------- | 918 // ----------------------------------------------------------------------------- |
| 924 // PagedSpace implementation | 919 // PagedSpace implementation |
| 925 | 920 |
| 926 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::NEW_SPACE) == | 921 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::NEW_SPACE) == |
| 927 ObjectSpace::kObjectSpaceNewSpace); | 922 ObjectSpace::kObjectSpaceNewSpace); |
| 928 STATIC_ASSERT(static_cast<ObjectSpace>(1 | 923 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::OLD_SPACE) == |
| 929 << AllocationSpace::OLD_POINTER_SPACE) == | 924 ObjectSpace::kObjectSpaceOldSpace); |
| 930 ObjectSpace::kObjectSpaceOldPointerSpace); | |
| 931 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::OLD_DATA_SPACE) == | |
| 932 ObjectSpace::kObjectSpaceOldDataSpace); | |
| 933 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::CODE_SPACE) == | 925 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::CODE_SPACE) == |
| 934 ObjectSpace::kObjectSpaceCodeSpace); | 926 ObjectSpace::kObjectSpaceCodeSpace); |
| 935 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::CELL_SPACE) == | 927 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::CELL_SPACE) == |
| 936 ObjectSpace::kObjectSpaceCellSpace); | 928 ObjectSpace::kObjectSpaceCellSpace); |
| 937 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::MAP_SPACE) == | 929 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::MAP_SPACE) == |
| 938 ObjectSpace::kObjectSpaceMapSpace); | 930 ObjectSpace::kObjectSpaceMapSpace); |
| 939 | 931 |
| 940 | 932 |
| 941 PagedSpace::PagedSpace(Heap* heap, intptr_t max_capacity, AllocationSpace space, | 933 PagedSpace::PagedSpace(Heap* heap, intptr_t max_capacity, AllocationSpace space, |
| 942 Executability executable) | 934 Executability executable) |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1112 allocation_info_.set_top(NULL); | 1104 allocation_info_.set_top(NULL); |
| 1113 allocation_info_.set_limit(NULL); | 1105 allocation_info_.set_limit(NULL); |
| 1114 } | 1106 } |
| 1115 | 1107 |
| 1116 // If page is still in a list, unlink it from that list. | 1108 // If page is still in a list, unlink it from that list. |
| 1117 if (page->next_chunk() != NULL) { | 1109 if (page->next_chunk() != NULL) { |
| 1118 DCHECK(page->prev_chunk() != NULL); | 1110 DCHECK(page->prev_chunk() != NULL); |
| 1119 page->Unlink(); | 1111 page->Unlink(); |
| 1120 } | 1112 } |
| 1121 | 1113 |
| 1122 if (page->IsFlagSet(MemoryChunk::CONTAINS_ONLY_DATA)) { | 1114 heap()->QueueMemoryChunkForFree(page); |
| 1123 heap()->isolate()->memory_allocator()->Free(page); | |
| 1124 } else { | |
| 1125 heap()->QueueMemoryChunkForFree(page); | |
| 1126 } | |
| 1127 | 1115 |
| 1128 DCHECK(Capacity() > 0); | 1116 DCHECK(Capacity() > 0); |
| 1129 accounting_stats_.ShrinkSpace(AreaSize()); | 1117 accounting_stats_.ShrinkSpace(AreaSize()); |
| 1130 } | 1118 } |
| 1131 | 1119 |
| 1132 | 1120 |
| 1133 intptr_t PagedSpace::MaxEmergencyMemoryAllocated() { | 1121 intptr_t PagedSpace::MaxEmergencyMemoryAllocated() { |
| 1134 // New space and large object space. | 1122 // New space and large object space. |
| 1135 static const int spaces_without_emergency_memory = 2; | 1123 static const int spaces_without_emergency_memory = 2; |
| 1136 static const int spaces_with_emergency_memory = | 1124 static const int spaces_with_emergency_memory = |
| (...skipping 2005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3142 object->ShortPrint(); | 3130 object->ShortPrint(); |
| 3143 PrintF("\n"); | 3131 PrintF("\n"); |
| 3144 } | 3132 } |
| 3145 printf(" --------------------------------------\n"); | 3133 printf(" --------------------------------------\n"); |
| 3146 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3134 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
| 3147 } | 3135 } |
| 3148 | 3136 |
| 3149 #endif // DEBUG | 3137 #endif // DEBUG |
| 3150 } | 3138 } |
| 3151 } // namespace v8::internal | 3139 } // namespace v8::internal |
| OLD | NEW |