From de300b8737dc84562ce760bca2037f0cd11cc6f6 Mon Sep 17 00:00:00 2001 From: Dhruv Chopra Date: Tue, 15 Nov 2022 00:59:31 -0500 Subject: [PATCH] Increment counter correctly in FFI Upcall on Z When getArgPointer is invoked while an upcall is performed the gprIndex must be incremented if hidden parameters have to be accounted for. This commit implements the suggested change. Fixes: #16214 Signed-off-by: Dhruv Chopra --- runtime/vm/xz64/UpcallThunkGen.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/runtime/vm/xz64/UpcallThunkGen.cpp b/runtime/vm/xz64/UpcallThunkGen.cpp index 8098dd8e1c0..be57c6a33c8 100644 --- a/runtime/vm/xz64/UpcallThunkGen.cpp +++ b/runtime/vm/xz64/UpcallThunkGen.cpp @@ -752,6 +752,10 @@ getArgPointer(J9UpcallNativeSignature *nativeSig, void *argListPtr, I_32 argIdx) // where the struct must be stored when we return to native caller. So we must skip over that // "hiddenParameter" when trying to identify arguments in getArgPointer. calleeFrameIndex++; + // When the return type is a struct, the buffer where the struct must be populated is initially + // provided in GPR2 by the caller. So we must increment the GPR index as well in order to correctly + // find the position of the current argument pointer. + gprIndex++; } I_32 structOffset = 0;