Use homogeneous space compaction if proper flag is set.
If the flag ART_USE_HSPACE_COMPACT is set then we use
hspace compaction.
Bug: 16401001
Change-Id: I74e1db764f9ff16c007fa3bd16cb2c9b468ec83c
diff --git a/runtime/Android.mk b/runtime/Android.mk
index 09ec004..bdecc7e 100644
--- a/runtime/Android.mk
+++ b/runtime/Android.mk
@@ -325,6 +325,10 @@
LIBART_CFLAGS += -DUSE_JEMALLOC
endif
+ifeq ($(ART_USE_HSPACE_COMPACT),true)
+ LIBART_CFLAGS += -DART_USE_HSPACE_COMPACT
+endif
+
# $(1): target or host
# $(2): ndebug or debug
define build-libart
diff --git a/runtime/parsed_options.cc b/runtime/parsed_options.cc
index 49f6585..36ad56b 100644
--- a/runtime/parsed_options.cc
+++ b/runtime/parsed_options.cc
@@ -205,7 +205,11 @@
// If background_collector_type_ is kCollectorTypeNone, it defaults to the collector_type_ after
// parsing options. If you set this to kCollectorTypeHSpaceCompact then we will do an hspace
// compaction when we transition to background instead of a normal collector transition.
+#ifdef ART_USE_HSPACE_COMPACT
+ background_collector_type_ = gc::kCollectorTypeHomogeneousSpaceCompact;
+#else
background_collector_type_ = gc::kCollectorTypeSS;
+#endif
stack_size_ = 0; // 0 means default.
max_spins_before_thin_lock_inflation_ = Monitor::kDefaultMaxSpinsBeforeThinLockInflation;
low_memory_mode_ = false;
@@ -390,6 +394,10 @@
} else if (option == "-XX:IgnoreMaxFootprint") {
ignore_max_footprint_ = true;
} else if (option == "-XX:LowMemoryMode") {
+ if (background_collector_type_ == gc::kCollectorTypeHomogeneousSpaceCompact) {
+ // Use semispace instead of homogenous space compact for low memory mode.
+ background_collector_type_ = gc::kCollectorTypeSS;
+ }
low_memory_mode_ = true;
// TODO Might want to turn off must_relocate here.
} else if (option == "-XX:UseTLAB") {