summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathieu Chartier <mathieuc@google.com>2013-07-19 09:55:14 -0700
committerMathieu Chartier <mathieuc@google.com>2013-07-19 09:55:14 -0700
commitbbf8a09601f5379293b498b7d181ffc2a1f93b6a (patch)
tree88ffc1d3de2b367154c4413d0471e7d96ede73b7
parent1359a18a4b9b7c9442afcbb1bf7eec1398b85ae6 (diff)
parent3da08f4d2cef02bd0a3cc45ae3b7555fc547d29a (diff)
downloadart-bbf8a09601f5379293b498b7d181ffc2a1f93b6a.zip
art-bbf8a09601f5379293b498b7d181ffc2a1f93b6a.tar.gz
art-bbf8a09601f5379293b498b7d181ffc2a1f93b6a.tar.bz2
resolved conflicts for merge of 3da08f4d to dalvik-dev
Change-Id: Ia237450dac762602bb159904a1032e6fccb2d7fd
-rw-r--r--runtime/gc/heap.cc7
-rw-r--r--runtime/gc/heap.h24
-rw-r--r--runtime/native/dalvik_system_VMRuntime.cc7
3 files changed, 36 insertions, 2 deletions
diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc
index 021d8e7..ce253bc 100644
--- a/runtime/gc/heap.cc
+++ b/runtime/gc/heap.cc
@@ -58,7 +58,7 @@ namespace gc {
// When to create a log message about a slow GC, 100ms.
static const uint64_t kSlowGcThreshold = MsToNs(100);
-// When to create a log message about a slow pause, 5ms.
+// When to create a log message about a long pause, 5ms.
static const uint64_t kLongGcPauseThreshold = MsToNs(5);
static const bool kDumpGcPerformanceOnShutdown = false;
// Minimum amount of remaining bytes before a concurrent GC is triggered.
@@ -88,6 +88,7 @@ Heap::Heap(size_t initial_size, size_t growth_limit, size_t min_free, size_t max
large_object_threshold_(3 * kPageSize),
num_bytes_allocated_(0),
native_bytes_allocated_(0),
+ process_state_(PROCESS_STATE_TOP),
verify_missing_card_marks_(false),
verify_system_weaks_(false),
verify_pre_gc_heap_(false),
@@ -237,6 +238,10 @@ struct ContinuousSpaceSorter {
}
};
+void Heap::UpdateProcessState(ProcessState process_state) {
+ process_state_ = process_state;
+}
+
void Heap::AddContinuousSpace(space::ContinuousSpace* space) {
WriterMutexLock mu(Thread::Current(), *Locks::heap_bitmap_lock_);
DCHECK(space != NULL);
diff --git a/runtime/gc/heap.h b/runtime/gc/heap.h
index feccba3..b51e187 100644
--- a/runtime/gc/heap.h
+++ b/runtime/gc/heap.h
@@ -100,6 +100,24 @@ enum HeapVerificationMode {
};
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;
@@ -363,6 +381,9 @@ class Heap {
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;
@@ -528,6 +549,9 @@ class Heap {
// Bytes which are allocated and managed by native code but still need to be accounted for.
AtomicInteger native_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_;
diff --git a/runtime/native/dalvik_system_VMRuntime.cc b/runtime/native/dalvik_system_VMRuntime.cc
index baae8a3..b352d08 100644
--- a/runtime/native/dalvik_system_VMRuntime.cc
+++ b/runtime/native/dalvik_system_VMRuntime.cc
@@ -21,6 +21,7 @@
#include "debugger.h"
#include "dex_file-inl.h"
#include "gc/allocator/dlmalloc.h"
+#include "gc/heap.h"
#include "gc/space/dlmalloc_space.h"
#include "jni_internal.h"
#include "mirror/class-inl.h"
@@ -215,6 +216,10 @@ static void VMRuntime_concurrentGC(JNIEnv* env, jobject) {
Runtime::Current()->GetHeap()->ConcurrentGC(self);
}
+static void VMRuntime_updateProcessState(JNIEnv* env, jobject, jint processState) {
+ Runtime::Current()->GetHeap()->UpdateProcessState(static_cast<gc::ProcessState>(processState));
+}
+
static JNINativeMethod gMethods[] = {
NATIVE_METHOD(VMRuntime, addressOf, "(Ljava/lang/Object;)J"),
NATIVE_METHOD(VMRuntime, bootClassPath, "()Ljava/lang/String;"),
@@ -234,7 +239,7 @@ static JNINativeMethod gMethods[] = {
NATIVE_METHOD(VMRuntime, trimHeap, "()V"),
NATIVE_METHOD(VMRuntime, vmVersion, "()Ljava/lang/String;"),
NATIVE_METHOD(VMRuntime, vmLibrary, "()Ljava/lang/String;"),
-
+ NATIVE_METHOD(VMRuntime, updateProcessState, "(I)V"),
};
void register_dalvik_system_VMRuntime(JNIEnv* env) {