From 1ca6a11a61b57edea370adf4454876ccf869d92e Mon Sep 17 00:00:00 2001 From: martincz Date: Fri, 4 Apr 2014 00:21:19 +0800 Subject: art: Implement SetTargetMinHeapFree, SetTargetHeapConcurrentStart * Commit: GC triggering performance optimizations ID: 7646e2eb41024d152d76b269653c2321e2cfbd23 introduced additional functions that needed to be implemented. Change-Id: I5ec4ae74dc70f1859db2bae8588e697b147a2682 --- runtime/gc/heap.cc | 8 ++++++++ runtime/gc/heap.h | 18 ++++++++++++++++++ runtime/native/dalvik_system_VMRuntime.cc | 14 ++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc index 1b46257c08..a9b91333f3 100644 --- a/runtime/gc/heap.cc +++ b/runtime/gc/heap.cc @@ -940,6 +940,14 @@ void Heap::SetTargetHeapUtilization(float target) { target_utilization_ = target; } +void Heap::SetTargetHeapMinFree(size_t bytes) { + min_free_ = bytes; +} + +void Heap::SetTargetHeapConcurrentStart(size_t bytes) { + concurrent_start_bytes_ = bytes; +} + size_t Heap::GetObjectsAllocated() const { size_t total = 0; typedef std::vector::const_iterator It; diff --git a/runtime/gc/heap.h b/runtime/gc/heap.h index 0b64261fa1..530118bb23 100644 --- a/runtime/gc/heap.h +++ b/runtime/gc/heap.h @@ -203,6 +203,24 @@ class Heap { // dalvik.system.VMRuntime.setTargetHeapUtilization. void SetTargetHeapUtilization(float target); + // Sets HEAP_MIN_FREE, implements + // dalvik.system.VMRuntime.SetTargetHeapMinFree. + void SetTargetHeapMinFree(size_t bytes); + + // Gets HEAP_MIN_FREE + int GetTargetHeapMinFree() const { + return min_free_; + } + + // Sets HEAP_CONCURRENT_START, implements + // dalvik.system.VMRuntime.SetTargetHeapConcurrentStart. + void SetTargetHeapConcurrentStart(size_t bytes); + + // Gets HEAP_CONCURRENT_START + int GetTargetHeapConcurrentStart() const { + return concurrent_start_bytes_; + } + // For the alloc space, sets the maximum number of bytes that the heap is allowed to allocate // from the system. Doesn't allow the space to exceed its growth limit. void SetIdealFootprint(size_t max_allowed_footprint); diff --git a/runtime/native/dalvik_system_VMRuntime.cc b/runtime/native/dalvik_system_VMRuntime.cc index 5fc8bd5a48..0a652b6d5f 100644 --- a/runtime/native/dalvik_system_VMRuntime.cc +++ b/runtime/native/dalvik_system_VMRuntime.cc @@ -43,6 +43,18 @@ static void VMRuntime_nativeSetTargetHeapUtilization(JNIEnv*, jobject, jfloat ta Runtime::Current()->GetHeap()->SetTargetHeapUtilization(target); } +static jint VMRuntime_nativeSetTargetHeapMinFree(JNIEnv*, jobject, jint bytes) { + Runtime::Current()->GetHeap()->SetTargetHeapMinFree(bytes); + + return Runtime::Current()->GetHeap()->GetTargetHeapMinFree(); +} + +static jint VMRuntime_nativeSetTargetHeapConcurrentStart(JNIEnv*, jobject, jint bytes) { + Runtime::Current()->GetHeap()->SetTargetHeapConcurrentStart(bytes); + + return Runtime::Current()->GetHeap()->GetTargetHeapConcurrentStart(); +} + static void VMRuntime_startJitCompilation(JNIEnv*, jobject) { } @@ -206,6 +218,8 @@ static JNINativeMethod gMethods[] = { NATIVE_METHOD(VMRuntime, getTargetHeapUtilization, "()F"), NATIVE_METHOD(VMRuntime, isDebuggerActive, "()Z"), NATIVE_METHOD(VMRuntime, nativeSetTargetHeapUtilization, "(F)V"), + NATIVE_METHOD(VMRuntime, nativeSetTargetHeapMinFree, "(I)I"), + NATIVE_METHOD(VMRuntime, nativeSetTargetHeapConcurrentStart, "(I)I"), NATIVE_METHOD(VMRuntime, newNonMovableArray, "(Ljava/lang/Class;I)Ljava/lang/Object;"), NATIVE_METHOD(VMRuntime, properties, "()[Ljava/lang/String;"), NATIVE_METHOD(VMRuntime, setTargetSdkVersion, "(I)V"), -- cgit v1.2.3