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

Unified Diff: runtime/vm/scavenger.cc

Issue 259483002: Zero-sized new-space for VM isolate. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: runtime/vm/scavenger.cc
===================================================================
--- runtime/vm/scavenger.cc (revision 35335)
+++ runtime/vm/scavenger.cc (working copy)
@@ -317,21 +317,27 @@
// going to use for forwarding pointers.
ASSERT(Object::tags_offset() == 0);
- // Allocate the virtual memory for this scavenge heap.
- space_ = VirtualMemory::Reserve(max_capacity_in_words << kWordSizeLog2);
- if (space_ == NULL) {
- FATAL("Out of memory.\n");
- }
+ if (max_capacity_in_words == 0) {
+ space_ = NULL;
+ to_ = new MemoryRegion(NULL, 0);
+ from_ = new MemoryRegion(NULL, 0);
+ } else {
+ // Allocate the virtual memory for this scavenge heap.
+ space_ = VirtualMemory::Reserve(max_capacity_in_words << kWordSizeLog2);
+ if (space_ == NULL) {
+ FATAL("Out of memory.\n");
+ }
- // Allocate the entire space at the beginning.
- space_->Commit(false);
+ // Allocate the entire space at the beginning.
+ space_->Commit(false);
- // Setup the semi spaces.
- uword semi_space_size = space_->size() / 2;
- ASSERT((semi_space_size & (VirtualMemory::PageSize() - 1)) == 0);
- to_ = new MemoryRegion(space_->address(), semi_space_size);
- uword middle = space_->start() + semi_space_size;
- from_ = new MemoryRegion(reinterpret_cast<void*>(middle), semi_space_size);
+ // Setup the semi spaces.
+ uword semi_space_size = space_->size() / 2;
+ ASSERT((semi_space_size & (VirtualMemory::PageSize() - 1)) == 0);
+ to_ = new MemoryRegion(space_->address(), semi_space_size);
+ uword middle = space_->start() + semi_space_size;
+ from_ = new MemoryRegion(reinterpret_cast<void*>(middle), semi_space_size);
+ }
// Make sure that the two semi-spaces are aligned properly.
ASSERT(Utils::IsAligned(to_->start(), kObjectAlignment));
@@ -733,8 +739,10 @@
void Scavenger::WriteProtect(bool read_only) {
- space_->Protect(
- read_only ? VirtualMemory::kReadOnly : VirtualMemory::kReadWrite);
+ if (space_ != NULL) {
+ space_->Protect(
+ read_only ? VirtualMemory::kReadOnly : VirtualMemory::kReadWrite);
+ }
}

Powered by Google App Engine
This is Rietveld 408576698