diff options
author | 2016-09-22 15:46:29 -0700 | |
---|---|---|
committer | 2016-09-27 10:05:24 -0700 | |
commit | 017efa83f02ce113090753d618554827fbabea4a (patch) | |
tree | 969a261ac7d40207a978c5be6547ca75cb464d0c | |
parent | 48d10ee126838f060aa6dcd304fc161b57bc14af (diff) |
benchmark: Add jni benchmarks for use in golem
Also adds libartbenchmark.so as a build dependency for golem targets
Test: make build-art-host-golem build-art-target-golem
Bug: 31401609
Change-Id: I3f6b11f93684cc8eb3534bb02bf2d3eb05e39dcf
-rw-r--r-- | Android.mk | 11 | ||||
-rw-r--r-- | benchmark/Android.bp | 2 | ||||
-rw-r--r-- | benchmark/jni_loader.cc | 32 | ||||
-rw-r--r-- | benchmark/micro-native/micro_native.cc | 83 |
4 files changed, 128 insertions, 0 deletions
diff --git a/Android.mk b/Android.mk index 3740ed8ea2..8b6f21ec41 100644 --- a/Android.mk +++ b/Android.mk @@ -436,14 +436,25 @@ build-art-target: $(TARGET_OUT_EXECUTABLES)/art $(ART_TARGET_DEPENDENCIES) $(TAR ######################################################################## # Phony target for only building what go/lem requires on target. .PHONY: build-art-target-golem +# Also include libartbenchmark, we always include it when running golem. +ART_TARGET_SHARED_LIBRARY_BENCHMARK := $(TARGET_OUT_SHARED_LIBRARIES)/libartbenchmark.so build-art-target-golem: dex2oat dalvikvm patchoat linker \ $(TARGET_OUT)/etc/public.libraries.txt \ $(ART_TARGET_DEX_DEPENDENCIES) \ $(ART_TARGET_SHARED_LIBRARY_DEPENDENCIES) \ + $(ART_TARGET_SHARED_LIBRARY_BENCHMARK) \ $(TARGET_CORE_IMG_OUT_BASE).art \ $(TARGET_CORE_IMG_OUT_BASE)-interpreter.art ######################################################################## +# Phony target for building what go/lem requires on host. +.PHONY: build-art-host-golem +# Also include libartbenchmark, we always include it when running golem. +ART_HOST_SHARED_LIBRARY_BENCHMARK := $(ART_HOST_OUT_SHARED_LIBRARIES)/libartbenchmark.so +build-art-host-golem: build-art-host \ + $(ART_HOST_SHARED_LIBRARY_BENCHMARK) + +######################################################################## # Rules for building all dependencies for tests. .PHONY: build-art-host-tests diff --git a/benchmark/Android.bp b/benchmark/Android.bp index 617f5b0927..94ad0155ff 100644 --- a/benchmark/Android.bp +++ b/benchmark/Android.bp @@ -19,8 +19,10 @@ art_cc_library { host_supported: true, defaults: ["art_defaults", "art_debug_defaults"], srcs: [ + "jni_loader.cc", "jobject-benchmark/jobject_benchmark.cc", "jni-perf/perf_jni.cc", + "micro-native/micro_native.cc", "scoped-primitive-array/scoped_primitive_array.cc", ], shared_libs: [ diff --git a/benchmark/jni_loader.cc b/benchmark/jni_loader.cc new file mode 100644 index 0000000000..2c9f86e3b3 --- /dev/null +++ b/benchmark/jni_loader.cc @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <jni.h> + +extern void register_micro_native_methods(JNIEnv* env); + +jint JNI_OnLoad(JavaVM* vm, void* /*reserved*/) { + JNIEnv* env; + if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK) { + return -1; + } + + // List of functions to call to register methods explicitly. + // Otherwise we use the regular JNI naming conventions to register implicitly. + register_micro_native_methods(env); + + return JNI_VERSION_1_6; +} diff --git a/benchmark/micro-native/micro_native.cc b/benchmark/micro-native/micro_native.cc new file mode 100644 index 0000000000..43c29e2eea --- /dev/null +++ b/benchmark/micro-native/micro_native.cc @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG "NativeMethods" + +#define CLASS_NAME "benchmarks/MicroNative/java/NativeMethods" + +#include "JNIHelp.h" +#include "JniConstants.h" + +static void NativeMethods_emptyJniStaticSynchronizedMethod0(JNIEnv*, jclass) { } +static void NativeMethods_emptyJniSynchronizedMethod0(JNIEnv*, jclass) { } + +static JNINativeMethod gMethods_NormalOnly[] = { + NATIVE_METHOD(NativeMethods, emptyJniStaticSynchronizedMethod0, "()V"), + NATIVE_METHOD(NativeMethods, emptyJniSynchronizedMethod0, "()V"), +}; + +static void NativeMethods_emptyJniMethod0(JNIEnv*, jobject) { } +static void NativeMethods_emptyJniMethod6(JNIEnv*, jobject, int, int, int, int, int, int) { } +static void NativeMethods_emptyJniMethod6L(JNIEnv*, jobject, jobject, jarray, jarray, jobject, + jarray, jarray) { } +static void NativeMethods_emptyJniStaticMethod6L(JNIEnv*, jclass, jobject, jarray, jarray, jobject, + jarray, jarray) { } + +static void NativeMethods_emptyJniStaticMethod0(JNIEnv*, jclass) { } +static void NativeMethods_emptyJniStaticMethod6(JNIEnv*, jclass, int, int, int, int, int, int) { } + +static JNINativeMethod gMethods[] = { + NATIVE_METHOD(NativeMethods, emptyJniMethod0, "()V"), + NATIVE_METHOD(NativeMethods, emptyJniMethod6, "(IIIIII)V"), + NATIVE_METHOD(NativeMethods, emptyJniMethod6L, "(Ljava/lang/String;[Ljava/lang/String;[[ILjava/lang/Object;[Ljava/lang/Object;[[[[Ljava/lang/Object;)V"), + NATIVE_METHOD(NativeMethods, emptyJniStaticMethod6L, "(Ljava/lang/String;[Ljava/lang/String;[[ILjava/lang/Object;[Ljava/lang/Object;[[[[Ljava/lang/Object;)V"), + NATIVE_METHOD(NativeMethods, emptyJniStaticMethod0, "()V"), + NATIVE_METHOD(NativeMethods, emptyJniStaticMethod6, "(IIIIII)V"), +}; + +static void NativeMethods_emptyJniMethod0_Fast(JNIEnv*, jobject) { } +static void NativeMethods_emptyJniMethod6_Fast(JNIEnv*, jobject, int, int, int, int, int, int) { } +static void NativeMethods_emptyJniMethod6L_Fast(JNIEnv*, jobject, jobject, jarray, jarray, jobject, + jarray, jarray) { } +static void NativeMethods_emptyJniStaticMethod6L_Fast(JNIEnv*, jclass, jobject, jarray, jarray, + jobject, jarray, jarray) { } + +static void NativeMethods_emptyJniStaticMethod0_Fast(JNIEnv*, jclass) { } +static void NativeMethods_emptyJniStaticMethod6_Fast(JNIEnv*, jclass, int, int, int, int, int, int) { } + +static JNINativeMethod gMethods_Fast[] = { + NATIVE_METHOD(NativeMethods, emptyJniMethod0_Fast, "()V"), + NATIVE_METHOD(NativeMethods, emptyJniMethod6_Fast, "(IIIIII)V"), + NATIVE_METHOD(NativeMethods, emptyJniMethod6L_Fast, "(Ljava/lang/String;[Ljava/lang/String;[[ILjava/lang/Object;[Ljava/lang/Object;[[[[Ljava/lang/Object;)V"), + NATIVE_METHOD(NativeMethods, emptyJniStaticMethod6L_Fast, "(Ljava/lang/String;[Ljava/lang/String;[[ILjava/lang/Object;[Ljava/lang/Object;[[[[Ljava/lang/Object;)V"), + NATIVE_METHOD(NativeMethods, emptyJniStaticMethod0_Fast, "()V"), + NATIVE_METHOD(NativeMethods, emptyJniStaticMethod6_Fast, "(IIIIII)V"), +}; + +static void NativeMethods_emptyJniStaticMethod0_Critical() { } +static void NativeMethods_emptyJniStaticMethod6_Critical(int, int, int, int, int, int) { } + +static JNINativeMethod gMethods_Critical[] = { + NATIVE_METHOD(NativeMethods, emptyJniStaticMethod0_Critical, "()V"), + NATIVE_METHOD(NativeMethods, emptyJniStaticMethod6_Critical, "(IIIIII)V"), +}; + +void register_micro_native_methods(JNIEnv* env) { + jniRegisterNativeMethods(env, CLASS_NAME, gMethods_NormalOnly, NELEM(gMethods_NormalOnly)); + jniRegisterNativeMethods(env, CLASS_NAME, gMethods, NELEM(gMethods)); + jniRegisterNativeMethods(env, CLASS_NAME, gMethods_Fast, NELEM(gMethods_Fast)); + jniRegisterNativeMethods(env, CLASS_NAME, gMethods_Critical, NELEM(gMethods_Critical)); +} |