Skip to content

Commit

Permalink
Merge pull request #19998 from ChengJin01/ffi_revert_heap_changes_int…
Browse files Browse the repository at this point in the history
…erpreter_v3

[FFI] Restore the original check on argument values on the java stack
  • Loading branch information
pshipton authored Aug 15, 2024
2 parents 1cac505 + c17c644 commit 1a6a7d2
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions runtime/vm/BytecodeInterpreter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5297,7 +5297,9 @@ class INTERPRETER_CLASS
for (U_8 i = 0; i < ffiArgCount; i++) {
U_8 argType = LayoutFFITypeHelpers::getJ9NativeTypeCodeFromFFIType(cif->arg_types[i]);

if (J9NtcPointer == argType) {
if ((0 == ffiArgs[i]) && (J9NtcPointer != argType)) {
values[i] = &(ffiArgs[i]);
} else if (J9NtcPointer == argType) {
/* ffi_call expects the address of the pointer is the address of the stackslot. */
pointerValues[i] = (U_64)ffiArgs[i];
#if JAVA_SPEC_VERSION >= 22
Expand Down Expand Up @@ -5348,15 +5350,13 @@ class INTERPRETER_CLASS
} else {
values[i] = &(ffiArgs[i]);
#if !defined(J9VM_ENV_LITTLE_ENDIAN)
if (0 != ffiArgs[i]) {
/* Note: A float number is converted to int by Float.floatToIntBits() in InternalDowncallHandler. */
if ((J9NtcInt == argType) || (J9NtcFloat == argType)) {
values[i] = (void *)((U_64)values[i] + extraBytesOfInt);
} else if ((J9NtcShort == argType) || (J9NtcChar == argType)) {
values[i] = (void *)((U_64)values[i] + extraBytesOfShortAndChar);
} else if ((J9NtcBoolean == argType) || (J9NtcByte == argType)) {
values[i] = (void *)((U_64)values[i] + extraBytesOfBoolAndByte);
}
/* Note: A float number is converted to int by Float.floatToIntBits() in InternalDowncallHandler. */
if ((J9NtcInt == argType) || (J9NtcFloat == argType)) {
values[i] = (void *)((U_64)values[i] + extraBytesOfInt);
} else if ((J9NtcShort == argType) || (J9NtcChar == argType)) {
values[i] = (void *)((U_64)values[i] + extraBytesOfShortAndChar);
} else if ((J9NtcBoolean == argType) || (J9NtcByte == argType)) {
values[i] = (void *)((U_64)values[i] + extraBytesOfBoolAndByte);
}
#endif /*J9VM_ENV_LITTLE_ENDIAN */
}
Expand Down

0 comments on commit 1a6a7d2

Please sign in to comment.