From 17491ac89fffc79452c4a88b39a9b74f342508d3 Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Tue, 1 Dec 2020 12:02:29 +0000 Subject: JNI: Faster jobject decoding by avoiding checks. Avoid costly runtime checks in Thread::DecodeJObject() and IndirectReferenceTable::Get() that it calls and replace them with DCHECK()s and checks in CheckJNI. This improves the performance of JNI interface in release mode for processes that do not use CheckJNI (default for non-debuggable apps). The results for StringToBytesBenchmark on blueline little cores running at fixed frequency 1420800 are approximately (medians from 3 runs) before after timeGetBytesAscii EMPTY 477.70 408.18 timeGetBytesIso88591 EMPTY 473.00 412.15 timeGetBytesUtf8 EMPTY 468.96 402.78 Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Test: blueline-userdebug boots. Bug: 172332525 Change-Id: Ibea788bb54879d1fca0608c30fde008063aaafcc --- runtime/jni/java_vm_ext.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'runtime/jni/java_vm_ext.h') diff --git a/runtime/jni/java_vm_ext.h b/runtime/jni/java_vm_ext.h index 6f7e546de5..015f85cba9 100644 --- a/runtime/jni/java_vm_ext.h +++ b/runtime/jni/java_vm_ext.h @@ -37,6 +37,7 @@ class Libraries; class ParsedOptions; class Runtime; struct RuntimeArgumentMap; +class ScopedObjectAccess; class JavaVMExt; // Hook definition for runtime plugins. @@ -263,6 +264,9 @@ class JavaVMExt : public JavaVM { std::atomic allocation_tracking_enabled_; std::atomic old_allocation_tracking_state_; + friend IndirectReferenceTable* GetIndirectReferenceTable(ScopedObjectAccess& soa, + IndirectRefKind kind); + DISALLOW_COPY_AND_ASSIGN(JavaVMExt); }; -- cgit v1.2.3-59-g8ed1b