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

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

Issue 12580005: Fail with fatal error instead of segmentation fault if virtual memory allocation fails. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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 | « no previous file | runtime/vm/virtual_memory.cc » ('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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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/scavenger.h" 5 #include "vm/scavenger.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 : heap_(heap), 312 : heap_(heap),
313 object_alignment_(object_alignment), 313 object_alignment_(object_alignment),
314 scavenging_(false) { 314 scavenging_(false) {
315 // Verify assumptions about the first word in objects which the scavenger is 315 // Verify assumptions about the first word in objects which the scavenger is
316 // going to use for forwarding pointers. 316 // going to use for forwarding pointers.
317 ASSERT(Object::tags_offset() == 0); 317 ASSERT(Object::tags_offset() == 0);
318 ASSERT(kForwardingMask == (1 << RawObject::kFreeBit)); 318 ASSERT(kForwardingMask == (1 << RawObject::kFreeBit));
319 319
320 // Allocate the virtual memory for this scavenge heap. 320 // Allocate the virtual memory for this scavenge heap.
321 space_ = VirtualMemory::Reserve(max_capacity); 321 space_ = VirtualMemory::Reserve(max_capacity);
322 ASSERT(space_ != NULL); 322 if (space_ == NULL) {
323 FATAL("Out of memory.\n");
324 }
323 325
324 // Allocate the entire space at the beginning. 326 // Allocate the entire space at the beginning.
325 space_->Commit(false); 327 space_->Commit(false);
326 328
327 // Setup the semi spaces. 329 // Setup the semi spaces.
328 uword semi_space_size = space_->size() / 2; 330 uword semi_space_size = space_->size() / 2;
329 ASSERT((semi_space_size & (VirtualMemory::PageSize() - 1)) == 0); 331 ASSERT((semi_space_size & (VirtualMemory::PageSize() - 1)) == 0);
330 to_ = new MemoryRegion(space_->address(), semi_space_size); 332 to_ = new MemoryRegion(space_->address(), semi_space_size);
331 uword middle = space_->start() + semi_space_size; 333 uword middle = space_->start() + semi_space_size;
332 from_ = new MemoryRegion(reinterpret_cast<void*>(middle), semi_space_size); 334 from_ = new MemoryRegion(reinterpret_cast<void*>(middle), semi_space_size);
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 PeerTable::iterator it = peer_table_.find(raw_obj); 712 PeerTable::iterator it = peer_table_.find(raw_obj);
711 return (it == peer_table_.end()) ? NULL : it->second; 713 return (it == peer_table_.end()) ? NULL : it->second;
712 } 714 }
713 715
714 716
715 int64_t Scavenger::PeerCount() const { 717 int64_t Scavenger::PeerCount() const {
716 return static_cast<int64_t>(peer_table_.size()); 718 return static_cast<int64_t>(peer_table_.size());
717 } 719 }
718 720
719 } // namespace dart 721 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/virtual_memory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698