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

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

Issue 1024823002: Fix OOM bug 3976. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix signed/unsigned comparison Created 5 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « src/heap/spaces.h ('k') | test/mjsunit/mjsunit.status » ('j') | 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/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 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after
1012 1012
1013 UNREACHABLE(); 1013 UNREACHABLE();
1014 return Smi::FromInt(0); 1014 return Smi::FromInt(0);
1015 } 1015 }
1016 1016
1017 1017
1018 bool PagedSpace::CanExpand() { 1018 bool PagedSpace::CanExpand() {
1019 DCHECK(max_capacity_ % AreaSize() == 0); 1019 DCHECK(max_capacity_ % AreaSize() == 0);
1020 DCHECK(Capacity() <= heap()->MaxOldGenerationSize()); 1020 DCHECK(Capacity() <= heap()->MaxOldGenerationSize());
1021 DCHECK(heap()->CommittedOldGenerationMemory() <= 1021 DCHECK(heap()->CommittedOldGenerationMemory() <=
1022 heap()->MaxOldGenerationSize()); 1022 heap()->MaxOldGenerationSize() +
1023 PagedSpace::MaxEmergencyMemoryAllocated());
1023 1024
1024 // Are we going to exceed capacity for this space? 1025 // Are we going to exceed capacity for this space?
1025 if (!heap()->CanExpandOldGeneration(Page::kPageSize)) return false; 1026 if (!heap()->CanExpandOldGeneration(Page::kPageSize)) return false;
1026 1027
1027 return true; 1028 return true;
1028 } 1029 }
1029 1030
1030 1031
1031 bool PagedSpace::Expand() { 1032 bool PagedSpace::Expand() {
1032 if (!CanExpand()) return false; 1033 if (!CanExpand()) return false;
1033 1034
1034 intptr_t size = AreaSize(); 1035 intptr_t size = AreaSize();
1035 1036
1036 if (anchor_.next_page() == &anchor_) { 1037 if (anchor_.next_page() == &anchor_) {
1037 size = Snapshot::SizeOfFirstPage(heap()->isolate(), identity()); 1038 size = Snapshot::SizeOfFirstPage(heap()->isolate(), identity());
1038 } 1039 }
1039 1040
1040 Page* p = heap()->isolate()->memory_allocator()->AllocatePage(size, this, 1041 Page* p = heap()->isolate()->memory_allocator()->AllocatePage(size, this,
1041 executable()); 1042 executable());
1042 if (p == NULL) return false; 1043 if (p == NULL) return false;
1043 1044
1044 // Pages created during bootstrapping may contain immortal immovable objects. 1045 // Pages created during bootstrapping may contain immortal immovable objects.
1045 if (!heap()->deserialization_complete()) p->MarkNeverEvacuate(); 1046 if (!heap()->deserialization_complete()) p->MarkNeverEvacuate();
1046 1047
1047 DCHECK(Capacity() <= heap()->MaxOldGenerationSize()); 1048 DCHECK(Capacity() <= heap()->MaxOldGenerationSize());
1048 DCHECK(heap()->CommittedOldGenerationMemory() <= 1049 DCHECK(heap()->CommittedOldGenerationMemory() <=
1049 heap()->MaxOldGenerationSize()); 1050 heap()->MaxOldGenerationSize() +
1051 PagedSpace::MaxEmergencyMemoryAllocated());
1050 1052
1051 p->InsertAfter(anchor_.prev_page()); 1053 p->InsertAfter(anchor_.prev_page());
1052 1054
1053 return true; 1055 return true;
1054 } 1056 }
1055 1057
1056 1058
1057 int PagedSpace::CountTotalPages() { 1059 int PagedSpace::CountTotalPages() {
1058 PageIterator it(this); 1060 PageIterator it(this);
1059 int count = 0; 1061 int count = 0;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1121 heap()->isolate()->memory_allocator()->Free(page); 1123 heap()->isolate()->memory_allocator()->Free(page);
1122 } else { 1124 } else {
1123 heap()->QueueMemoryChunkForFree(page); 1125 heap()->QueueMemoryChunkForFree(page);
1124 } 1126 }
1125 1127
1126 DCHECK(Capacity() > 0); 1128 DCHECK(Capacity() > 0);
1127 accounting_stats_.ShrinkSpace(AreaSize()); 1129 accounting_stats_.ShrinkSpace(AreaSize());
1128 } 1130 }
1129 1131
1130 1132
1133 intptr_t PagedSpace::MaxEmergencyMemoryAllocated() {
1134 // New space and large object space.
1135 static const int spaces_without_emergency_memory = 2;
1136 static const int spaces_with_emergency_memory =
1137 LAST_SPACE - FIRST_SPACE + 1 - spaces_without_emergency_memory;
1138 return Page::kPageSize * spaces_with_emergency_memory;
1139 }
1140
1141
1131 void PagedSpace::CreateEmergencyMemory() { 1142 void PagedSpace::CreateEmergencyMemory() {
1132 if (identity() == CODE_SPACE) { 1143 if (identity() == CODE_SPACE) {
1133 // Make the emergency block available to the allocator. 1144 // Make the emergency block available to the allocator.
1134 CodeRange* code_range = heap()->isolate()->code_range(); 1145 CodeRange* code_range = heap()->isolate()->code_range();
1135 if (code_range != NULL && code_range->valid()) { 1146 if (code_range != NULL && code_range->valid()) {
1136 code_range->ReleaseEmergencyBlock(); 1147 code_range->ReleaseEmergencyBlock();
1137 } 1148 }
1138 DCHECK(MemoryAllocator::CodePageAreaSize() == AreaSize()); 1149 DCHECK(MemoryAllocator::CodePageAreaSize() == AreaSize());
1139 } 1150 }
1140 emergency_memory_ = heap()->isolate()->memory_allocator()->AllocateChunk( 1151 emergency_memory_ = heap()->isolate()->memory_allocator()->AllocateChunk(
(...skipping 1990 matching lines...) Expand 10 before | Expand all | Expand 10 after
3131 object->ShortPrint(); 3142 object->ShortPrint();
3132 PrintF("\n"); 3143 PrintF("\n");
3133 } 3144 }
3134 printf(" --------------------------------------\n"); 3145 printf(" --------------------------------------\n");
3135 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); 3146 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes());
3136 } 3147 }
3137 3148
3138 #endif // DEBUG 3149 #endif // DEBUG
3139 } 3150 }
3140 } // namespace v8::internal 3151 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap/spaces.h ('k') | test/mjsunit/mjsunit.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698