diff options
author | Ian Rogers <irogers@google.com> | 2013-10-18 15:42:20 -0700 |
---|---|---|
committer | Ian Rogers <irogers@google.com> | 2013-10-20 14:55:26 -0700 |
commit | 1eb512d33f94d1dd7ea38263307ba0f7a0dfa653 (patch) | |
tree | b4d4d9b16013ab90fb4b40d23013d7ef44bb5852 /runtime/native/dalvik_system_VMRuntime.cc | |
parent | b917ea1a62aa0ab8eca3f689ef64b5be34e11abb (diff) | |
download | art-1eb512d33f94d1dd7ea38263307ba0f7a0dfa653.tar.gz art-1eb512d33f94d1dd7ea38263307ba0f7a0dfa653.tar.bz2 art-1eb512d33f94d1dd7ea38263307ba0f7a0dfa653.zip |
Fast JNI support.
Use a modifier to signal a native method is a fast JNI method. If the
modifier is set then don't perform runnable transitions.
Change-Id: I7835b4d837bfdd1cb8e2d54b919c0d5e6cf90499
Diffstat (limited to 'runtime/native/dalvik_system_VMRuntime.cc')
-rw-r--r-- | runtime/native/dalvik_system_VMRuntime.cc | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/runtime/native/dalvik_system_VMRuntime.cc b/runtime/native/dalvik_system_VMRuntime.cc index dad6eff354..9ad2585bc5 100644 --- a/runtime/native/dalvik_system_VMRuntime.cc +++ b/runtime/native/dalvik_system_VMRuntime.cc @@ -28,6 +28,7 @@ #include "mirror/object.h" #include "mirror/object-inl.h" #include "object_utils.h" +#include "scoped_fast_native_object_access.h" #include "scoped_thread_state_change.h" #include "thread.h" #include "thread_list.h" @@ -50,7 +51,7 @@ static void VMRuntime_disableJitCompilation(JNIEnv*, jobject) { } static jobject VMRuntime_newNonMovableArray(JNIEnv* env, jobject, jclass javaElementClass, jint length) { - ScopedObjectAccess soa(env); + ScopedFastNativeObjectAccess soa(env); #ifdef MOVING_GARBAGE_COLLECTOR // TODO: right now, we don't have a copying collector, so there's no need // to do anything special here, but we ought to pass the non-movability @@ -81,7 +82,7 @@ static jlong VMRuntime_addressOf(JNIEnv* env, jobject, jobject javaArray) { if (javaArray == NULL) { // Most likely allocation failed return 0; } - ScopedObjectAccess soa(env); + ScopedFastNativeObjectAccess soa(env); mirror::Array* array = soa.Decode<mirror::Array*>(javaArray); if (!array->IsArrayInstance()) { ThrowIllegalArgumentException(NULL, "not an array"); @@ -147,21 +148,21 @@ static void VMRuntime_setTargetSdkVersion(JNIEnv* env, jobject, jint targetSdkVe } static void VMRuntime_registerNativeAllocation(JNIEnv* env, jobject, jint bytes) { - ScopedObjectAccess soa(env); - if (bytes < 0) { + if (UNLIKELY(bytes < 0)) { + ScopedObjectAccess soa(env); ThrowRuntimeException("allocation size negative %d", bytes); return; } - Runtime::Current()->GetHeap()->RegisterNativeAllocation(bytes); + Runtime::Current()->GetHeap()->RegisterNativeAllocation(env, bytes); } static void VMRuntime_registerNativeFree(JNIEnv* env, jobject, jint bytes) { - ScopedObjectAccess soa(env); - if (bytes < 0) { + if (UNLIKELY(bytes < 0)) { + ScopedObjectAccess soa(env); ThrowRuntimeException("allocation size negative %d", bytes); return; } - Runtime::Current()->GetHeap()->RegisterNativeFree(bytes); + Runtime::Current()->GetHeap()->RegisterNativeFree(env, bytes); } static void VMRuntime_trimHeap(JNIEnv*, jobject) { @@ -189,12 +190,12 @@ static void VMRuntime_trimHeap(JNIEnv*, jobject) { } static void VMRuntime_concurrentGC(JNIEnv* env, jobject) { - Thread* self = static_cast<JNIEnvExt*>(env)->self; + Thread* self = ThreadForEnv(env); Runtime::Current()->GetHeap()->ConcurrentGC(self); } static JNINativeMethod gMethods[] = { - NATIVE_METHOD(VMRuntime, addressOf, "(Ljava/lang/Object;)J"), + NATIVE_METHOD(VMRuntime, addressOf, "!(Ljava/lang/Object;)J"), NATIVE_METHOD(VMRuntime, bootClassPath, "()Ljava/lang/String;"), NATIVE_METHOD(VMRuntime, classPath, "()Ljava/lang/String;"), NATIVE_METHOD(VMRuntime, clearGrowthLimit, "()V"), @@ -203,7 +204,7 @@ static JNINativeMethod gMethods[] = { NATIVE_METHOD(VMRuntime, getTargetHeapUtilization, "()F"), NATIVE_METHOD(VMRuntime, isDebuggerActive, "()Z"), NATIVE_METHOD(VMRuntime, nativeSetTargetHeapUtilization, "(F)V"), - NATIVE_METHOD(VMRuntime, newNonMovableArray, "(Ljava/lang/Class;I)Ljava/lang/Object;"), + NATIVE_METHOD(VMRuntime, newNonMovableArray, "!(Ljava/lang/Class;I)Ljava/lang/Object;"), NATIVE_METHOD(VMRuntime, properties, "()[Ljava/lang/String;"), NATIVE_METHOD(VMRuntime, setTargetSdkVersion, "(I)V"), NATIVE_METHOD(VMRuntime, registerNativeAllocation, "(I)V"), |