Skip to content

Commit

Permalink
art: Implement SetTargetMinHeapFree, SetTargetHeapConcurrentStart
Browse files Browse the repository at this point in the history
* Commit: GC triggering performance optimizations
  ID: 7646e2eb41024d152d76b269653c2321e2cfbd23

  introduced additional functions that needed to be implemented.

Change-Id: I5ec4ae74dc70f1859db2bae8588e697b147a2682
  • Loading branch information
martincz authored and intervigilium committed Apr 28, 2014
1 parent bd81f3b commit 1ca6a11
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
8 changes: 8 additions & 0 deletions runtime/gc/heap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<space::ContinuousSpace*>::const_iterator It;
Expand Down
18 changes: 18 additions & 0 deletions runtime/gc/heap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
14 changes: 14 additions & 0 deletions runtime/native/dalvik_system_VMRuntime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
}

Expand Down Expand Up @@ -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"),
Expand Down

0 comments on commit 1ca6a11

Please sign in to comment.