Add GC mode for stressing testing heap transitions.
The stress testing mode does repeated heap transitions when the heap
gets a process state update. In between each transition, the heap
waits for a specified number of time.
Change-Id: Ie3f43835e539fa8da147f77b4623a432a0d858c2
diff --git a/compiler/jni/quick/arm/calling_convention_arm.cc b/compiler/jni/quick/arm/calling_convention_arm.cc
index 9778293..78f403c 100644
--- a/compiler/jni/quick/arm/calling_convention_arm.cc
+++ b/compiler/jni/quick/arm/calling_convention_arm.cc
@@ -133,7 +133,7 @@
uint32_t ArmJniCallingConvention::CoreSpillMask() const {
// Compute spill mask to agree with callee saves initialized in the constructor
uint32_t result = 0;
- result = 1 << R5 | 1 << R6 | 1 << R7 | 1 << R8 | 1 << R10 | 1 << R11 | 1 << LR;
+ result = 1 << R5 | 1 << R6 | 1 << R7 | 1 << R8 | 1 << R10 | 1 << R11 | 1 << LR;
return result;
}
diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc
index a256b67..7827261 100644
--- a/runtime/gc/heap.cc
+++ b/runtime/gc/heap.cc
@@ -70,6 +70,8 @@
namespace gc {
+static constexpr size_t kCollectorTransitionStressIterations = 0;
+static constexpr size_t kCollectorTransitionStressWait = 10 * 1000; // Microseconds
static constexpr bool kGCALotMode = false;
static constexpr size_t kGcAlotInterval = KB;
// Minimum amount of remaining bytes before a concurrent GC is triggered.
@@ -482,6 +484,13 @@
void Heap::UpdateProcessState(ProcessState process_state) {
if (process_state_ != process_state) {
process_state_ = process_state;
+ for (size_t i = 1; i <= kCollectorTransitionStressIterations; ++i) {
+ // Start at index 1 to avoid "is always false" warning.
+ // Have iteration 1 always transition the collector.
+ TransitionCollector((((i & 1) == 1) == (process_state_ == kProcessStateJankPerceptible))
+ ? post_zygote_collector_type_ : background_collector_type_);
+ usleep(kCollectorTransitionStressWait);
+ }
if (process_state_ == kProcessStateJankPerceptible) {
// Transition back to foreground right away to prevent jank.
RequestCollectorTransition(post_zygote_collector_type_, 0);