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

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

Issue 805413002: Check for OOM in HeapPage::Allocate. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years 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 | « no previous file | 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 (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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 result->memory_ = memory; 54 result->memory_ = memory;
55 result->next_ = NULL; 55 result->next_ = NULL;
56 result->executable_ = is_executable; 56 result->executable_ = is_executable;
57 return result; 57 return result;
58 } 58 }
59 59
60 60
61 HeapPage* HeapPage::Allocate(intptr_t size_in_words, PageType type) { 61 HeapPage* HeapPage::Allocate(intptr_t size_in_words, PageType type) {
62 VirtualMemory* memory = 62 VirtualMemory* memory =
63 VerifiedMemory::Reserve(size_in_words << kWordSizeLog2); 63 VerifiedMemory::Reserve(size_in_words << kWordSizeLog2);
64 if (memory == NULL) {
65 FATAL1("Out of memory while allocating %" Pd " words.\n",
66 size_in_words);
67 }
64 return Initialize(memory, type); 68 return Initialize(memory, type);
65 } 69 }
66 70
67 71
68 void HeapPage::Deallocate() { 72 void HeapPage::Deallocate() {
69 // The memory for this object will become unavailable after the delete below. 73 // The memory for this object will become unavailable after the delete below.
70 delete memory_; 74 delete memory_;
71 } 75 }
72 76
73 77
(...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after
994 for (int i = 0; i < history_.Size() - 1; i++) { 998 for (int i = 0; i < history_.Size() - 1; i++) {
995 Entry current = history_.Get(i); 999 Entry current = history_.Get(i);
996 Entry previous = history_.Get(i + 1); 1000 Entry previous = history_.Get(i + 1);
997 gc_time += current.end - current.start; 1001 gc_time += current.end - current.start;
998 total_time += current.end - previous.end; 1002 total_time += current.end - previous.end;
999 } 1003 }
1000 if (total_time == 0) { 1004 if (total_time == 0) {
1001 return 0; 1005 return 0;
1002 } else { 1006 } else {
1003 ASSERT(total_time >= gc_time); 1007 ASSERT(total_time >= gc_time);
1004 int result= static_cast<int>((static_cast<double>(gc_time) / 1008 int result = static_cast<int>((static_cast<double>(gc_time) /
1005 static_cast<double>(total_time)) * 100); 1009 static_cast<double>(total_time)) * 100);
1006 return result; 1010 return result;
1007 } 1011 }
1008 } 1012 }
1009 1013
1010 } // namespace dart 1014 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698