Add zygote space as its own space type.
Helps prevent errors caused from doing invalid operations on the
old alloc space.
Removed some duplicated code in mark_sweep.cc and semi_space.cc.
Change-Id: I67a772cab30d698744c918aad581053f282a4a99
diff --git a/runtime/gc/space/space_test.cc b/runtime/gc/space/space_test.cc
index b1be9d8..427d547 100644
--- a/runtime/gc/space/space_test.cc
+++ b/runtime/gc/space/space_test.cc
@@ -16,6 +16,7 @@
#include "dlmalloc_space.h"
#include "large_object_space.h"
+#include "zygote_space.h"
#include "common_test.h"
#include "globals.h"
@@ -179,7 +180,16 @@
// Make sure that the zygote space isn't directly at the start of the space.
space->Alloc(self, 1U * MB, &dummy);
- space = space->CreateZygoteSpace("alloc space", Runtime::Current()->GetHeap()->IsLowMemoryMode());
+
+ gc::Heap* heap = Runtime::Current()->GetHeap();
+ space::Space* old_space = space;
+ heap->RemoveSpace(old_space);
+ space::ZygoteSpace* zygote_space = space->CreateZygoteSpace("alloc space",
+ heap->IsLowMemoryMode(),
+ &space);
+ delete old_space;
+ // Add the zygote space.
+ AddSpace(zygote_space);
// Make space findable to the heap, will also delete space when runtime is cleaned up
AddSpace(space);