Skip to content

Commit

Permalink
Rewrite MN.resolve logic on updating method flags
Browse files Browse the repository at this point in the history
- update MemberName ref kind based on resolved method

Signed-off-by: Jack Lu <[email protected]>
  • Loading branch information
fengxue-IS committed Dec 10, 2021
1 parent 9f6e55d commit 425a1f1
Showing 1 changed file with 42 additions and 3 deletions.
45 changes: 42 additions & 3 deletions runtime/jcl/common/java_lang_invoke_MethodHandleNatives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -881,13 +881,52 @@ Java_java_lang_invoke_MethodHandleNatives_resolve(JNIEnv *env, jclass clazz, job
vmindex = (jlong)(UDATA)methodID;
target = (jlong)(UDATA)method;

J9ROMMethod *romMethod = J9_ROM_METHOD_FROM_RAM_METHOD(methodID->method);
J9UTF8 *methodName = J9ROMMETHOD_NAME(romMethod);
U_32 methodModifiers = romMethod->modifiers;
new_clazz = J9VM_J9CLASS_TO_HEAPCLASS(J9_CLASS_FROM_METHOD(method));
new_flags = methodModifiers & CFR_METHOD_ACCESS_MASK;

J9ROMMethod *romMethod = J9_ROM_METHOD_FROM_RAM_METHOD(methodID->method);
new_flags = flags | (romMethod->modifiers & CFR_METHOD_ACCESS_MASK);
if (J9_ARE_ANY_BITS_SET(romMethod->modifiers, J9AccMethodCallerSensitive)) {
if (J9_ARE_ANY_BITS_SET(methodModifiers, J9AccMethodCallerSensitive)) {
new_flags |= MN_CALLER_SENSITIVE;
}

if (J9_ARE_ALL_BITS_SET(flags, MN_IS_METHOD)) {
new_flags |= MN_IS_METHOD;
if (MH_REF_INVOKEINTERFACE == ref_kind) {
Assert_JCL_true(J9_ARE_NO_BITS_SET(methodModifiers, J9AccStatic));
if (J9_ARE_ALL_BITS_SET(methodID->vTableIndex, J9_JNI_MID_INTERFACE)) {
new_flags |= MH_REF_INVOKEINTERFACE << MN_REFERENCE_KIND_SHIFT;
} else if (!J9ROMMETHOD_HAS_VTABLE(romMethod)) {
new_flags |= MH_REF_INVOKESPECIAL << MN_REFERENCE_KIND_SHIFT;
} else {
new_flags |= MH_REF_INVOKEVIRTUAL << MN_REFERENCE_KIND_SHIFT;
}
} else if (MH_REF_INVOKESPECIAL == ref_kind) {
Assert_JCL_true(J9_ARE_NO_BITS_SET(methodModifiers, J9AccStatic));
new_flags |= MH_REF_INVOKESPECIAL << MN_REFERENCE_KIND_SHIFT;
} else if (MH_REF_INVOKESTATIC == ref_kind) {
Assert_JCL_true(J9_ARE_ALL_BITS_SET(methodModifiers, J9AccStatic));
new_flags |= MH_REF_INVOKESTATIC << MN_REFERENCE_KIND_SHIFT;
} else if (MH_REF_INVOKEVIRTUAL == ref_kind) {
Assert_JCL_true(J9_ARE_NO_BITS_SET(methodModifiers, J9AccStatic));
if (!J9ROMMETHOD_HAS_VTABLE(romMethod)) {
new_flags |= MH_REF_INVOKESPECIAL << MN_REFERENCE_KIND_SHIFT;
} else {
if (J9_ARE_ALL_BITS_SET(methodID->vTableIndex, J9_JNI_MID_INTERFACE)) {
new_clazz = J9VM_J9CLASS_TO_HEAPCLASS(resolvedClass);
}
new_flags |= MH_REF_INVOKEVIRTUAL << MN_REFERENCE_KIND_SHIFT;
}
} else {
Assert_JCL_unreachable();
}
} else if (J9_ARE_NO_BITS_SET(methodModifiers, J9AccStatic) && ('<' == (char)*J9UTF8_DATA(methodName))) {
new_flags |= MN_IS_CONSTRUCTOR;
new_flags |= MH_REF_INVOKESPECIAL << MN_REFERENCE_KIND_SHIFT;
} else {
Assert_JCL_unreachable();
}
}
} if (J9_ARE_ANY_BITS_SET(flags, MN_IS_FIELD)) {
J9Class *declaringClass;
Expand Down

0 comments on commit 425a1f1

Please sign in to comment.