Clean-up heap spaces.
We now use the CMS collector instead of the semispace collector when
the phone is booting. We still perform compaction during the zygote
space creation. This reduces time spent in GC by ~2s during boot
and doesn't affect zygote space size.
Changed the space creation logic to create the temp space when a
background transition occurs.
Added a flag to each space which is true if you are allowed to
move objects that are within this space.
Removed SwapSemiSpaces call from the semi space collector, it is now
the job of the caller to do this with threads suspended. This
simplifies the logic in the zygote compaction / heap transition code
since these do not copy from one semispace to another.
Added Space::Clear to RosAllocSpace and DlMallocSpace. This greatly
simplifies the code used for collector transitions.
Time spent in GC creating zygote space:
Before: 3.4s, After: 1.28s
No change in zygote space size.
Bug: 13878055
Change-Id: I700348ab7d5bf3aa537c0cd70c0fed09aa4b0623
diff --git a/runtime/gc/space/malloc_space.cc b/runtime/gc/space/malloc_space.cc
index dac043e..c3ca096 100644
--- a/runtime/gc/space/malloc_space.cc
+++ b/runtime/gc/space/malloc_space.cc
@@ -37,10 +37,12 @@
MallocSpace::MallocSpace(const std::string& name, MemMap* mem_map,
byte* begin, byte* end, byte* limit, size_t growth_limit,
- bool create_bitmaps)
+ bool create_bitmaps, bool can_move_objects, size_t starting_size,
+ size_t initial_size)
: ContinuousMemMapAllocSpace(name, mem_map, begin, end, limit, kGcRetentionPolicyAlwaysCollect),
recent_free_pos_(0), lock_("allocation space lock", kAllocSpaceLock),
- growth_limit_(growth_limit) {
+ growth_limit_(growth_limit), can_move_objects_(can_move_objects),
+ starting_size_(starting_size), initial_size_(initial_size) {
if (create_bitmaps) {
size_t bitmap_index = bitmap_index_++;
static const uintptr_t kGcCardSize = static_cast<uintptr_t>(accounting::CardTable::kCardSize);
@@ -201,7 +203,7 @@
CHECK_MEMORY_CALL(mprotect, (end, capacity - initial_size, PROT_NONE), alloc_space_name);
}
*out_malloc_space = CreateInstance(alloc_space_name, mem_map.release(), allocator, end_, end,
- limit_, growth_limit);
+ limit_, growth_limit, CanMoveObjects());
SetLimit(End());
live_bitmap_->SetHeapLimit(reinterpret_cast<uintptr_t>(End()));
CHECK_EQ(live_bitmap_->HeapLimit(), reinterpret_cast<uintptr_t>(End()));