From 7917f50f8ce94edf2f1915c265ed7d90c61121fa Mon Sep 17 00:00:00 2001 From: Dan Heidinga Date: Fri, 20 Nov 2020 10:51:56 -0500 Subject: [PATCH] Fetch array length before dropping vm access Rather than dropping access, only to acquire and release it during the `env->GetArrayLength` call, use the macro to avoid the extra in and out of vm access Signed-off-by: Dan Heidinga --- runtime/jcl/common/sun_misc_Unsafe.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/runtime/jcl/common/sun_misc_Unsafe.cpp b/runtime/jcl/common/sun_misc_Unsafe.cpp index 5ec78037a18..78c2b999905 100644 --- a/runtime/jcl/common/sun_misc_Unsafe.cpp +++ b/runtime/jcl/common/sun_misc_Unsafe.cpp @@ -119,12 +119,12 @@ Java_sun_misc_Unsafe_defineAnonymousClass(JNIEnv *env, jobject receiver, jclass } } - vmFuncs->internalExitVMToJNI(currentThread); + jsize length = (jsize)J9INDEXABLEOBJECT_SIZE(currentThread, J9_JNI_UNWRAP_REFERENCE(bytecodes)); - jsize length = env->GetArrayLength(bytecodes); + vmFuncs->internalExitVMToJNI(currentThread); /* acquires access internally */ - jclass anonClass = defineClassCommon(env, hostClassLoaderLocalRef, NULL,bytecodes, 0, length, protectionDomainLocalRef, &defineClassOptions, hostClazz, &cpPatchMap, FALSE); + jclass anonClass = defineClassCommon(env, hostClassLoaderLocalRef, NULL, bytecodes, 0, length, protectionDomainLocalRef, &defineClassOptions, hostClazz, &cpPatchMap, FALSE); if (env->ExceptionCheck()) { return NULL; } else if (NULL == anonClass) {