JNI: Fast-path for decoding returned jobject.
Results for the timeGetBytesAscii#EMPTY benchmark from the
libcore's StringToBytesBenchmark suite on blueline-userdebug
with the cpu frequencies fixed at 1420800 (cpus 0-3; little)
and 1459200 (cpus 4-7; big):
32-bit little: ~415 -> ~390
64-bit little: ~415 -> ~390
32-bit big: ~180 -> ~170
64-bit big: ~180 -> ~170
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing --debug --ndebug
Test: run-gtests.sh
Test: testrunner.py --target --optimizing --debug --ndebug
Bug: 172332525
Change-Id: I0e19d583e5141e99a8b8c6fd9ae125fe7c9e02e7
diff --git a/compiler/jni/jni_compiler_test.cc b/compiler/jni/jni_compiler_test.cc
index d1d3190..397db25 100644
--- a/compiler/jni/jni_compiler_test.cc
+++ b/compiler/jni/jni_compiler_test.cc
@@ -28,6 +28,7 @@
#include "common_compiler_test.h"
#include "compiler.h"
#include "dex/dex_file.h"
+#include "driver/compiler_options.h"
#include "entrypoints/entrypoint_utils-inl.h"
#include "gtest/gtest.h"
#include "indirect_reference_table.h"
@@ -1553,6 +1554,10 @@
}
void JniCompilerTest::UpcallReturnTypeChecking_InstanceImpl() {
+ // Set debuggable so that the JNI compiler does not emit a fast-path that would skip the
+ // runtime call where we do these checks. Note that while normal gtests use the debug build
+ // which disables the fast path, `art_standalone_compiler_tests` run in the release build.
+ compiler_options_->SetDebuggable(true);
SetUpForTest(false, "instanceMethodThatShouldReturnClass", "()Ljava/lang/Class;",
CURRENT_JNI_WRAPPER(Java_MyClassNatives_instanceMethodThatShouldReturnClass));
@@ -1580,6 +1585,10 @@
JNI_TEST(UpcallReturnTypeChecking_Instance)
void JniCompilerTest::UpcallReturnTypeChecking_StaticImpl() {
+ // Set debuggable so that the JNI compiler does not emit a fast-path that would skip the
+ // runtime call where we do these checks. Note that while normal gtests use the debug build
+ // which disables the fast path, `art_standalone_compiler_tests` run in the release build.
+ compiler_options_->SetDebuggable(true);
SetUpForTest(true, "staticMethodThatShouldReturnClass", "()Ljava/lang/Class;",
CURRENT_JNI_WRAPPER(Java_MyClassNatives_staticMethodThatShouldReturnClass));