Skip to content

Commit

Permalink
Fetch array length before dropping vm access
Browse files Browse the repository at this point in the history
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 <heidinga@redhat.com>
  • Loading branch information
DanHeidinga committed Nov 20, 2020
1 parent 47d7b92 commit 7917f50
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions runtime/jcl/common/sun_misc_Unsafe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 7917f50

Please sign in to comment.