Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(178)

Side by Side Diff: src/heap/spaces.cc

Issue 1316183004: [heap] Throw OOM upon failing to expand a PagedSpace above old gen limits. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Compilation error: size_t vs int Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/heap/spaces.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1064 matching lines...) Expand 10 before | Expand all | Expand 10 after
1075 Address cur = obj->address(); 1075 Address cur = obj->address();
1076 Address next = cur + obj->Size(); 1076 Address next = cur + obj->Size();
1077 if ((cur <= addr) && (addr < next)) return obj; 1077 if ((cur <= addr) && (addr < next)) return obj;
1078 } 1078 }
1079 1079
1080 UNREACHABLE(); 1080 UNREACHABLE();
1081 return Smi::FromInt(0); 1081 return Smi::FromInt(0);
1082 } 1082 }
1083 1083
1084 1084
1085 bool PagedSpace::CanExpand() { 1085 bool PagedSpace::CanExpand(size_t size) {
1086 DCHECK(heap()->mark_compact_collector()->is_compacting() || 1086 DCHECK(heap()->mark_compact_collector()->is_compacting() ||
1087 Capacity() <= heap()->MaxOldGenerationSize()); 1087 Capacity() <= heap()->MaxOldGenerationSize());
1088 DCHECK(heap()->CommittedOldGenerationMemory() <=
1089 heap()->MaxOldGenerationSize() +
1090 PagedSpace::MaxEmergencyMemoryAllocated());
1091 1088
1092 // Are we going to exceed capacity for this space? 1089 // Are we going to exceed capacity for this space? At this point we can be
1093 if (!heap()->CanExpandOldGeneration(Page::kPageSize)) return false; 1090 // way over the maximum size because of AlwaysAllocate scopes and large
1091 // objects.
1092 if (!heap()->CanExpandOldGeneration(static_cast<int>(size))) return false;
1094 1093
1095 return true; 1094 return true;
1096 } 1095 }
1097 1096
1098 1097
1099 bool PagedSpace::Expand() { 1098 bool PagedSpace::Expand() {
1100 if (!CanExpand()) return false;
1101
1102 intptr_t size = AreaSize(); 1099 intptr_t size = AreaSize();
1103 if (snapshotable() && !HasPages()) { 1100 if (snapshotable() && !HasPages()) {
1104 size = Snapshot::SizeOfFirstPage(heap()->isolate(), identity()); 1101 size = Snapshot::SizeOfFirstPage(heap()->isolate(), identity());
1105 } 1102 }
1106 1103
1104 if (!CanExpand(size)) return false;
1105
1107 Page* p = heap()->isolate()->memory_allocator()->AllocatePage(size, this, 1106 Page* p = heap()->isolate()->memory_allocator()->AllocatePage(size, this,
1108 executable()); 1107 executable());
1109 if (p == NULL) return false; 1108 if (p == NULL) return false;
1110 1109
1111 // Pages created during bootstrapping may contain immortal immovable objects. 1110 // Pages created during bootstrapping may contain immortal immovable objects.
1112 if (!heap()->deserialization_complete()) p->MarkNeverEvacuate(); 1111 if (!heap()->deserialization_complete()) p->MarkNeverEvacuate();
1113 1112
1114 DCHECK(Capacity() <= heap()->MaxOldGenerationSize()); 1113 DCHECK(Capacity() <= heap()->MaxOldGenerationSize());
1115 DCHECK(heap()->CommittedOldGenerationMemory() <= 1114 DCHECK(heap()->CommittedOldGenerationMemory() <=
1116 heap()->MaxOldGenerationSize() + 1115 heap()->MaxOldGenerationSize() +
(...skipping 2069 matching lines...) Expand 10 before | Expand all | Expand 10 after
3186 object->ShortPrint(); 3185 object->ShortPrint();
3187 PrintF("\n"); 3186 PrintF("\n");
3188 } 3187 }
3189 printf(" --------------------------------------\n"); 3188 printf(" --------------------------------------\n");
3190 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); 3189 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes());
3191 } 3190 }
3192 3191
3193 #endif // DEBUG 3192 #endif // DEBUG
3194 } // namespace internal 3193 } // namespace internal
3195 } // namespace v8 3194 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/spaces.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698