| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 MemoryChunk* other_next = other->next_chunk(); | 575 MemoryChunk* other_next = other->next_chunk(); |
| 576 | 576 |
| 577 set_next_chunk(other_next); | 577 set_next_chunk(other_next); |
| 578 set_prev_chunk(other); | 578 set_prev_chunk(other); |
| 579 other_next->set_prev_chunk(this); | 579 other_next->set_prev_chunk(this); |
| 580 other->set_next_chunk(this); | 580 other->set_next_chunk(this); |
| 581 } | 581 } |
| 582 | 582 |
| 583 | 583 |
| 584 void MemoryChunk::Unlink() { | 584 void MemoryChunk::Unlink() { |
| 585 if (!InNewSpace() && IsFlagSet(SCAN_ON_SCAVENGE)) { | |
| 586 heap_->decrement_scan_on_scavenge_pages(); | |
| 587 ClearFlag(SCAN_ON_SCAVENGE); | |
| 588 } | |
| 589 MemoryChunk* next_element = next_chunk(); | 585 MemoryChunk* next_element = next_chunk(); |
| 590 MemoryChunk* prev_element = prev_chunk(); | 586 MemoryChunk* prev_element = prev_chunk(); |
| 591 next_element->set_prev_chunk(prev_element); | 587 next_element->set_prev_chunk(prev_element); |
| 592 prev_element->set_next_chunk(next_element); | 588 prev_element->set_next_chunk(next_element); |
| 593 set_prev_chunk(NULL); | 589 set_prev_chunk(NULL); |
| 594 set_next_chunk(NULL); | 590 set_next_chunk(NULL); |
| 595 } | 591 } |
| 596 | 592 |
| 597 | 593 |
| 598 MemoryChunk* MemoryAllocator::AllocateChunk(intptr_t reserve_area_size, | 594 MemoryChunk* MemoryAllocator::AllocateChunk(intptr_t reserve_area_size, |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 946 // ----------------------------------------------------------------------------- | 942 // ----------------------------------------------------------------------------- |
| 947 // PagedSpace implementation | 943 // PagedSpace implementation |
| 948 | 944 |
| 949 PagedSpace::PagedSpace(Heap* heap, | 945 PagedSpace::PagedSpace(Heap* heap, |
| 950 intptr_t max_capacity, | 946 intptr_t max_capacity, |
| 951 AllocationSpace id, | 947 AllocationSpace id, |
| 952 Executability executable) | 948 Executability executable) |
| 953 : Space(heap, id, executable), | 949 : Space(heap, id, executable), |
| 954 free_list_(this), | 950 free_list_(this), |
| 955 was_swept_conservatively_(false), | 951 was_swept_conservatively_(false), |
| 956 unswept_free_bytes_(0) { | 952 unswept_free_bytes_(0), |
| 953 end_of_unswept_pages_(NULL) { |
| 957 if (id == CODE_SPACE) { | 954 if (id == CODE_SPACE) { |
| 958 area_size_ = heap->isolate()->memory_allocator()-> | 955 area_size_ = heap->isolate()->memory_allocator()-> |
| 959 CodePageAreaSize(); | 956 CodePageAreaSize(); |
| 960 } else { | 957 } else { |
| 961 area_size_ = Page::kPageSize - Page::kObjectStartOffset; | 958 area_size_ = Page::kPageSize - Page::kObjectStartOffset; |
| 962 } | 959 } |
| 963 max_capacity_ = (RoundDown(max_capacity, Page::kPageSize) / Page::kPageSize) | 960 max_capacity_ = (RoundDown(max_capacity, Page::kPageSize) / Page::kPageSize) |
| 964 * AreaSize(); | 961 * AreaSize(); |
| 965 accounting_stats_.Clear(); | 962 accounting_stats_.Clear(); |
| 966 | 963 |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1119 page->ResetFreeListStatistics(); | 1116 page->ResetFreeListStatistics(); |
| 1120 } | 1117 } |
| 1121 } | 1118 } |
| 1122 | 1119 |
| 1123 | 1120 |
| 1124 void PagedSpace::IncreaseCapacity(int size) { | 1121 void PagedSpace::IncreaseCapacity(int size) { |
| 1125 accounting_stats_.ExpandSpace(size); | 1122 accounting_stats_.ExpandSpace(size); |
| 1126 } | 1123 } |
| 1127 | 1124 |
| 1128 | 1125 |
| 1129 void PagedSpace::ReleasePage(Page* page, bool unlink) { | 1126 void PagedSpace::ReleasePage(Page* page) { |
| 1130 ASSERT(page->LiveBytes() == 0); | 1127 ASSERT(page->LiveBytes() == 0); |
| 1131 ASSERT(AreaSize() == page->area_size()); | 1128 ASSERT(AreaSize() == page->area_size()); |
| 1132 | 1129 |
| 1133 if (page->WasSwept()) { | 1130 if (page->WasSwept()) { |
| 1134 intptr_t size = free_list_.EvictFreeListItems(page); | 1131 intptr_t size = free_list_.EvictFreeListItems(page); |
| 1135 accounting_stats_.AllocateBytes(size); | 1132 accounting_stats_.AllocateBytes(size); |
| 1136 ASSERT_EQ(AreaSize(), static_cast<int>(size)); | 1133 ASSERT_EQ(AreaSize(), static_cast<int>(size)); |
| 1137 } else { | 1134 } else { |
| 1138 DecreaseUnsweptFreeBytes(page); | 1135 DecreaseUnsweptFreeBytes(page); |
| 1139 } | 1136 } |
| 1140 | 1137 |
| 1141 // TODO(hpayer): This check is just used for debugging purpose and | 1138 if (page->IsFlagSet(MemoryChunk::SCAN_ON_SCAVENGE)) { |
| 1142 // should be removed or turned into an assert after investigating the | 1139 heap()->decrement_scan_on_scavenge_pages(); |
| 1143 // crash in concurrent sweeping. | 1140 page->ClearFlag(MemoryChunk::SCAN_ON_SCAVENGE); |
| 1144 CHECK(!free_list_.ContainsPageFreeListItems(page)); | 1141 } |
| 1142 |
| 1143 ASSERT(!free_list_.ContainsPageFreeListItems(page)); |
| 1145 | 1144 |
| 1146 if (Page::FromAllocationTop(allocation_info_.top()) == page) { | 1145 if (Page::FromAllocationTop(allocation_info_.top()) == page) { |
| 1147 allocation_info_.set_top(NULL); | 1146 allocation_info_.set_top(NULL); |
| 1148 allocation_info_.set_limit(NULL); | 1147 allocation_info_.set_limit(NULL); |
| 1149 } | 1148 } |
| 1150 | 1149 |
| 1151 if (unlink) { | 1150 page->Unlink(); |
| 1152 page->Unlink(); | |
| 1153 } | |
| 1154 if (page->IsFlagSet(MemoryChunk::CONTAINS_ONLY_DATA)) { | 1151 if (page->IsFlagSet(MemoryChunk::CONTAINS_ONLY_DATA)) { |
| 1155 heap()->isolate()->memory_allocator()->Free(page); | 1152 heap()->isolate()->memory_allocator()->Free(page); |
| 1156 } else { | 1153 } else { |
| 1157 heap()->QueueMemoryChunkForFree(page); | 1154 heap()->QueueMemoryChunkForFree(page); |
| 1158 } | 1155 } |
| 1159 | 1156 |
| 1160 ASSERT(Capacity() > 0); | 1157 ASSERT(Capacity() > 0); |
| 1161 accounting_stats_.ShrinkSpace(AreaSize()); | 1158 accounting_stats_.ShrinkSpace(AreaSize()); |
| 1162 } | 1159 } |
| 1163 | 1160 |
| (...skipping 1990 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3154 object->ShortPrint(); | 3151 object->ShortPrint(); |
| 3155 PrintF("\n"); | 3152 PrintF("\n"); |
| 3156 } | 3153 } |
| 3157 printf(" --------------------------------------\n"); | 3154 printf(" --------------------------------------\n"); |
| 3158 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3155 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
| 3159 } | 3156 } |
| 3160 | 3157 |
| 3161 #endif // DEBUG | 3158 #endif // DEBUG |
| 3162 | 3159 |
| 3163 } } // namespace v8::internal | 3160 } } // namespace v8::internal |
| OLD | NEW |