Add interface for updating the heap's process state
In the future, the heap's process state will be used
to determine GC behavior.
Change-Id: Iba4f038d28dbf483b6573d8feb25e4246ead1d50
diff --git a/runtime/gc/heap.h b/runtime/gc/heap.h
index 630d063..9e9c2b3 100644
--- a/runtime/gc/heap.h
+++ b/runtime/gc/heap.h
@@ -100,6 +100,24 @@
};
const HeapVerificationMode kDesiredHeapVerification = kNoHeapVerification;
+// This comes from ActivityManager and needs to be kept in sync.
+enum ProcessState {
+ PROCESS_STATE_PERSISTENT = 0,
+ PROCESS_STATE_PERSISTENT_UI = 1,
+ PROCESS_STATE_TOP = 2,
+ PROCESS_STATE_IMPORTANT_FOREGROUND = 3,
+ PROCESS_STATE_IMPORTANT_BACKGROUND = 4,
+ PROCESS_STATE_BACKUP = 5,
+ PROCESS_STATE_HEAVY_WEIGHT = 6,
+ PROCESS_STATE_SERVICE = 7,
+ PROCESS_STATE_RECEIVER = 8,
+ PROCESS_STATE_HOME = 9,
+ PROCESS_STATE_LAST_ACTIVITY = 10,
+ PROCESS_STATE_CACHED_ACTIVITY = 11,
+ PROCESS_STATE_CACHED_ACTIVITY_CLIENT = 12,
+ PROCESS_STATE_CACHED_EMPTY = 13,
+};
+
class Heap {
public:
static const size_t kDefaultInitialSize = 2 * MB;
@@ -359,6 +377,9 @@
collector::GcType gc_type)
EXCLUSIVE_LOCKS_REQUIRED(Locks::heap_bitmap_lock_);
+ // Update process state to let the heap know which type of GC to do.
+ void UpdateProcessState(ProcessState process_state);
+
// DEPRECATED: Should remove in "near" future when support for multiple image spaces is added.
// Assumes there is only one image space.
space::ImageSpace* GetImageSpace() const;
@@ -512,6 +533,9 @@
// Number of bytes allocated. Adjusted after each allocation and free.
AtomicInteger num_bytes_allocated_;
+ // Current process state, updated by activity manager.
+ ProcessState process_state_;
+
// Heap verification flags.
const bool verify_missing_card_marks_;
const bool verify_system_weaks_;