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

Side by Side Diff: runtime/vm/pages.cc

Issue 1119403003: Propagate failures from VirtualMemory::Commit. (Closed) Base URL: http://dart.googlecode.com/svn/trunk/dart/
Patch Set: Created 5 years, 7 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 | « runtime/vm/pages.h ('k') | runtime/vm/virtual_memory.h » ('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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/pages.h" 5 #include "vm/pages.h"
6 6
7 #include "platform/assert.h" 7 #include "platform/assert.h"
8 #include "vm/compiler_stats.h" 8 #include "vm/compiler_stats.h"
9 #include "vm/gc_marker.h" 9 #include "vm/gc_marker.h"
10 #include "vm/gc_sweeper.h" 10 #include "vm/gc_sweeper.h"
(...skipping 28 matching lines...) Expand all
39 #if defined(TARGET_ARCH_MIPS) || defined(TARGET_ARCH_ARM64) 39 #if defined(TARGET_ARCH_MIPS) || defined(TARGET_ARCH_ARM64)
40 DEFINE_FLAG(bool, concurrent_sweep, false, 40 DEFINE_FLAG(bool, concurrent_sweep, false,
41 "Concurrent sweep for old generation."); 41 "Concurrent sweep for old generation.");
42 #else // TARGET_ARCH_MIPS || TARGET_ARCH_ARM64 42 #else // TARGET_ARCH_MIPS || TARGET_ARCH_ARM64
43 DEFINE_FLAG(bool, concurrent_sweep, true, 43 DEFINE_FLAG(bool, concurrent_sweep, true,
44 "Concurrent sweep for old generation."); 44 "Concurrent sweep for old generation.");
45 #endif // TARGET_ARCH_MIPS || TARGET_ARCH_ARM64 45 #endif // TARGET_ARCH_MIPS || TARGET_ARCH_ARM64
46 DEFINE_FLAG(bool, log_growth, false, "Log PageSpace growth policy decisions."); 46 DEFINE_FLAG(bool, log_growth, false, "Log PageSpace growth policy decisions.");
47 47
48 HeapPage* HeapPage::Initialize(VirtualMemory* memory, PageType type) { 48 HeapPage* HeapPage::Initialize(VirtualMemory* memory, PageType type) {
49 ASSERT(memory != NULL);
49 ASSERT(memory->size() > VirtualMemory::PageSize()); 50 ASSERT(memory->size() > VirtualMemory::PageSize());
50 bool is_executable = (type == kExecutable); 51 bool is_executable = (type == kExecutable);
51 memory->Commit(is_executable); 52 if (!memory->Commit(is_executable)) {
52 53 return NULL;
54 }
53 HeapPage* result = reinterpret_cast<HeapPage*>(memory->address()); 55 HeapPage* result = reinterpret_cast<HeapPage*>(memory->address());
56 ASSERT(result != NULL);
54 result->memory_ = memory; 57 result->memory_ = memory;
55 result->next_ = NULL; 58 result->next_ = NULL;
56 result->executable_ = is_executable; 59 result->executable_ = is_executable;
57 return result; 60 return result;
58 } 61 }
59 62
60 63
61 HeapPage* HeapPage::Allocate(intptr_t size_in_words, PageType type) { 64 HeapPage* HeapPage::Allocate(intptr_t size_in_words, PageType type) {
62 VirtualMemory* memory = 65 VirtualMemory* memory =
63 VerifiedMemory::Reserve(size_in_words << kWordSizeLog2); 66 VerifiedMemory::Reserve(size_in_words << kWordSizeLog2);
64 if (memory == NULL) { 67 if (memory == NULL) {
65 return NULL; 68 return NULL;
66 } 69 }
67 return Initialize(memory, type); 70 HeapPage* result = Initialize(memory, type);
71 if (result == NULL) {
72 delete memory; // Release reservation to OS.
73 return NULL;
74 }
75 return result;
68 } 76 }
69 77
70 78
71 void HeapPage::Deallocate() { 79 void HeapPage::Deallocate() {
72 // The memory for this object will become unavailable after the delete below. 80 // The memory for this object will become unavailable after the delete below.
73 delete memory_; 81 delete memory_;
74 } 82 }
75 83
76 84
77 void HeapPage::VisitObjects(ObjectVisitor* visitor) const { 85 void HeapPage::VisitObjects(ObjectVisitor* visitor) const {
(...skipping 1039 matching lines...) Expand 10 before | Expand all | Expand 10 after
1117 return 0; 1125 return 0;
1118 } else { 1126 } else {
1119 ASSERT(total_time >= gc_time); 1127 ASSERT(total_time >= gc_time);
1120 int result = static_cast<int>((static_cast<double>(gc_time) / 1128 int result = static_cast<int>((static_cast<double>(gc_time) /
1121 static_cast<double>(total_time)) * 100); 1129 static_cast<double>(total_time)) * 100);
1122 return result; 1130 return result;
1123 } 1131 }
1124 } 1132 }
1125 1133
1126 } // namespace dart 1134 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/pages.h ('k') | runtime/vm/virtual_memory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698