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 936 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
947 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::CODE_SPACE) == | 947 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::CODE_SPACE) == |
948 ObjectSpace::kObjectSpaceCodeSpace); | 948 ObjectSpace::kObjectSpaceCodeSpace); |
949 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::MAP_SPACE) == | 949 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::MAP_SPACE) == |
950 ObjectSpace::kObjectSpaceMapSpace); | 950 ObjectSpace::kObjectSpaceMapSpace); |
951 | 951 |
952 | 952 |
953 PagedSpace::PagedSpace(Heap* heap, AllocationSpace space, | 953 PagedSpace::PagedSpace(Heap* heap, AllocationSpace space, |
954 Executability executable) | 954 Executability executable) |
955 : Space(heap, space, executable), | 955 : Space(heap, space, executable), |
956 free_list_(this), | 956 free_list_(this), |
957 end_of_unswept_pages_(NULL) { | 957 end_of_unswept_pages_(NULL), |
958 force_oom_(false) { | |
958 area_size_ = MemoryAllocator::PageAreaSize(space); | 959 area_size_ = MemoryAllocator::PageAreaSize(space); |
959 accounting_stats_.Clear(); | 960 accounting_stats_.Clear(); |
960 | 961 |
961 allocation_info_.set_top(NULL); | 962 allocation_info_.set_top(NULL); |
962 allocation_info_.set_limit(NULL); | 963 allocation_info_.set_limit(NULL); |
963 | 964 |
964 anchor_.InitializeAsAnchor(this); | 965 anchor_.InitializeAsAnchor(this); |
965 } | 966 } |
966 | 967 |
967 | 968 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1070 while (refilled < kCompactionMemoryWanted) { | 1071 while (refilled < kCompactionMemoryWanted) { |
1071 FreeSpace* node = | 1072 FreeSpace* node = |
1072 free_list->TryRemoveMemory(kCompactionMemoryWanted - refilled); | 1073 free_list->TryRemoveMemory(kCompactionMemoryWanted - refilled); |
1073 if (node == nullptr) return; | 1074 if (node == nullptr) return; |
1074 refilled += node->size(); | 1075 refilled += node->size(); |
1075 AddMemory(node->address(), node->size()); | 1076 AddMemory(node->address(), node->size()); |
1076 } | 1077 } |
1077 } | 1078 } |
1078 | 1079 |
1079 | 1080 |
1081 bool CompactionSpace::ShouldForceOOM() { | |
1082 return heap()->paged_space(identity())->ShouldForceOOM(); | |
1083 } | |
1084 | |
1085 | |
1080 void PagedSpace::MoveOverFreeMemory(PagedSpace* other) { | 1086 void PagedSpace::MoveOverFreeMemory(PagedSpace* other) { |
1081 DCHECK(identity() == other->identity()); | 1087 DCHECK(identity() == other->identity()); |
1082 // Destroy the linear allocation space of {other}. This is needed to | 1088 // Destroy the linear allocation space of {other}. This is needed to |
1083 // (a) not waste the memory and | 1089 // (a) not waste the memory and |
1084 // (b) keep the rest of the chunk in an iterable state (filler is needed). | 1090 // (b) keep the rest of the chunk in an iterable state (filler is needed). |
1085 other->EmptyAllocationInfo(); | 1091 other->EmptyAllocationInfo(); |
1086 | 1092 |
1087 // Move over the free list. Concatenate makes sure that the source free list | 1093 // Move over the free list. Concatenate makes sure that the source free list |
1088 // gets properly reset after moving over all nodes. | 1094 // gets properly reset after moving over all nodes. |
1089 intptr_t added = free_list_.Concatenate(other->free_list()); | 1095 intptr_t added = free_list_.Concatenate(other->free_list()); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1161 Address next = cur + obj->Size(); | 1167 Address next = cur + obj->Size(); |
1162 if ((cur <= addr) && (addr < next)) return obj; | 1168 if ((cur <= addr) && (addr < next)) return obj; |
1163 } | 1169 } |
1164 | 1170 |
1165 UNREACHABLE(); | 1171 UNREACHABLE(); |
1166 return Smi::FromInt(0); | 1172 return Smi::FromInt(0); |
1167 } | 1173 } |
1168 | 1174 |
1169 | 1175 |
1170 bool PagedSpace::CanExpand(size_t size) { | 1176 bool PagedSpace::CanExpand(size_t size) { |
1177 if (ShouldForceOOM()) return false; | |
1178 | |
1171 DCHECK(heap()->mark_compact_collector()->is_compacting() || | 1179 DCHECK(heap()->mark_compact_collector()->is_compacting() || |
1172 Capacity() <= heap()->MaxOldGenerationSize()); | 1180 Capacity() <= heap()->MaxOldGenerationSize()); |
1173 | 1181 |
1174 // Are we going to exceed capacity for this space? At this point we can be | 1182 // Are we going to exceed capacity for this space? At this point we can be |
1175 // way over the maximum size because of AlwaysAllocate scopes and large | 1183 // way over the maximum size because of AlwaysAllocate scopes and large |
1176 // objects. | 1184 // objects. |
1177 if (!heap()->CanExpandOldGeneration(static_cast<int>(size))) return false; | 1185 if (!heap()->CanExpandOldGeneration(static_cast<int>(size))) return false; |
Hannes Payer (out of office)
2015/12/10 15:18:14
I think that ShouldForeOOM should be a property of
Michael Lippautz
2015/12/10 17:42:44
Done. It's still called force_oom().
| |
1178 | 1186 |
1179 return true; | 1187 return true; |
1180 } | 1188 } |
1181 | 1189 |
1182 | 1190 |
1183 bool PagedSpace::Expand() { | 1191 bool PagedSpace::Expand() { |
1184 intptr_t size = AreaSize(); | 1192 intptr_t size = AreaSize(); |
1185 if (snapshotable() && !HasPages()) { | 1193 if (snapshotable() && !HasPages()) { |
1186 size = Snapshot::SizeOfFirstPage(heap()->isolate(), identity()); | 1194 size = Snapshot::SizeOfFirstPage(heap()->isolate(), identity()); |
1187 } | 1195 } |
(...skipping 2136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3324 object->ShortPrint(); | 3332 object->ShortPrint(); |
3325 PrintF("\n"); | 3333 PrintF("\n"); |
3326 } | 3334 } |
3327 printf(" --------------------------------------\n"); | 3335 printf(" --------------------------------------\n"); |
3328 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3336 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
3329 } | 3337 } |
3330 | 3338 |
3331 #endif // DEBUG | 3339 #endif // DEBUG |
3332 } // namespace internal | 3340 } // namespace internal |
3333 } // namespace v8 | 3341 } // namespace v8 |
OLD | NEW |