Skip to content

Commit 1a6a7d2

Browse files
authored
Merge pull request #19998 from ChengJin01/ffi_revert_heap_changes_interpreter_v3
[FFI] Restore the original check on argument values on the java stack
2 parents 1cac505 + c17c644 commit 1a6a7d2

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

runtime/vm/BytecodeInterpreter.hpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5297,7 +5297,9 @@ class INTERPRETER_CLASS
52975297
for (U_8 i = 0; i < ffiArgCount; i++) {
52985298
U_8 argType = LayoutFFITypeHelpers::getJ9NativeTypeCodeFromFFIType(cif->arg_types[i]);
52995299

5300-
if (J9NtcPointer == argType) {
5300+
if ((0 == ffiArgs[i]) && (J9NtcPointer != argType)) {
5301+
values[i] = &(ffiArgs[i]);
5302+
} else if (J9NtcPointer == argType) {
53015303
/* ffi_call expects the address of the pointer is the address of the stackslot. */
53025304
pointerValues[i] = (U_64)ffiArgs[i];
53035305
#if JAVA_SPEC_VERSION >= 22
@@ -5348,15 +5350,13 @@ class INTERPRETER_CLASS
53485350
} else {
53495351
values[i] = &(ffiArgs[i]);
53505352
#if !defined(J9VM_ENV_LITTLE_ENDIAN)
5351-
if (0 != ffiArgs[i]) {
5352-
/* Note: A float number is converted to int by Float.floatToIntBits() in InternalDowncallHandler. */
5353-
if ((J9NtcInt == argType) || (J9NtcFloat == argType)) {
5354-
values[i] = (void *)((U_64)values[i] + extraBytesOfInt);
5355-
} else if ((J9NtcShort == argType) || (J9NtcChar == argType)) {
5356-
values[i] = (void *)((U_64)values[i] + extraBytesOfShortAndChar);
5357-
} else if ((J9NtcBoolean == argType) || (J9NtcByte == argType)) {
5358-
values[i] = (void *)((U_64)values[i] + extraBytesOfBoolAndByte);
5359-
}
5353+
/* Note: A float number is converted to int by Float.floatToIntBits() in InternalDowncallHandler. */
5354+
if ((J9NtcInt == argType) || (J9NtcFloat == argType)) {
5355+
values[i] = (void *)((U_64)values[i] + extraBytesOfInt);
5356+
} else if ((J9NtcShort == argType) || (J9NtcChar == argType)) {
5357+
values[i] = (void *)((U_64)values[i] + extraBytesOfShortAndChar);
5358+
} else if ((J9NtcBoolean == argType) || (J9NtcByte == argType)) {
5359+
values[i] = (void *)((U_64)values[i] + extraBytesOfBoolAndByte);
53605360
}
53615361
#endif /*J9VM_ENV_LITTLE_ENDIAN */
53625362
}

0 commit comments

Comments
 (0)