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/mark-compact.h" | 10 #include "src/heap/mark-compact.h" |
(...skipping 985 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
996 PageIterator iterator(this); | 996 PageIterator iterator(this); |
997 while (iterator.has_next()) { | 997 while (iterator.has_next()) { |
998 heap()->isolate()->memory_allocator()->Free(iterator.next()); | 998 heap()->isolate()->memory_allocator()->Free(iterator.next()); |
999 } | 999 } |
1000 anchor_.set_next_page(&anchor_); | 1000 anchor_.set_next_page(&anchor_); |
1001 anchor_.set_prev_page(&anchor_); | 1001 anchor_.set_prev_page(&anchor_); |
1002 accounting_stats_.Clear(); | 1002 accounting_stats_.Clear(); |
1003 } | 1003 } |
1004 | 1004 |
1005 | 1005 |
| 1006 void PagedSpace::MergeCompactionSpace(CompactionSpace* other) { |
| 1007 // Unmerged fields: |
| 1008 // area_size_ |
| 1009 // allocation_info_ |
| 1010 // emergency_memory_ |
| 1011 // end_of_unswept_pages_ |
| 1012 // unswept_free_bytes_ |
| 1013 // anchor_ |
| 1014 |
| 1015 // It only makes sense to merge compatible spaces. |
| 1016 DCHECK(identity() == other->identity()); |
| 1017 |
| 1018 // Destroy the linear allocation space of {other}. This is needed to (a) not |
| 1019 // waste the memory and (b) keep the rest of the chunk in an iterable state |
| 1020 // (filler is needed). |
| 1021 int linear_size = static_cast<int>(other->limit() - other->top()); |
| 1022 other->Free(other->top(), linear_size); |
| 1023 |
| 1024 // Move over the free list. |
| 1025 free_list_.Concatenate(other->free_list()); |
| 1026 |
| 1027 // Update and clear accounting statistics. |
| 1028 accounting_stats_.Merge(other->accounting_stats_); |
| 1029 other->accounting_stats_.Clear(); |
| 1030 |
| 1031 // Move over pages. |
| 1032 PageIterator it(other); |
| 1033 Page* p = nullptr; |
| 1034 while (it.has_next()) { |
| 1035 p = it.next(); |
| 1036 p->set_owner(this); |
| 1037 p->InsertAfter(anchor_.prev_page()); |
| 1038 } |
| 1039 } |
| 1040 |
| 1041 |
1006 size_t PagedSpace::CommittedPhysicalMemory() { | 1042 size_t PagedSpace::CommittedPhysicalMemory() { |
1007 if (!base::VirtualMemory::HasLazyCommits()) return CommittedMemory(); | 1043 if (!base::VirtualMemory::HasLazyCommits()) return CommittedMemory(); |
1008 MemoryChunk::UpdateHighWaterMark(allocation_info_.top()); | 1044 MemoryChunk::UpdateHighWaterMark(allocation_info_.top()); |
1009 size_t size = 0; | 1045 size_t size = 0; |
1010 PageIterator it(this); | 1046 PageIterator it(this); |
1011 while (it.has_next()) { | 1047 while (it.has_next()) { |
1012 size += it.next()->CommittedPhysicalMemory(); | 1048 size += it.next()->CommittedPhysicalMemory(); |
1013 } | 1049 } |
1014 return size; | 1050 return size; |
1015 } | 1051 } |
(...skipping 2133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3149 object->ShortPrint(); | 3185 object->ShortPrint(); |
3150 PrintF("\n"); | 3186 PrintF("\n"); |
3151 } | 3187 } |
3152 printf(" --------------------------------------\n"); | 3188 printf(" --------------------------------------\n"); |
3153 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3189 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
3154 } | 3190 } |
3155 | 3191 |
3156 #endif // DEBUG | 3192 #endif // DEBUG |
3157 } // namespace internal | 3193 } // namespace internal |
3158 } // namespace v8 | 3194 } // namespace v8 |
OLD | NEW |