libffi return value convention bug

Ulrich Weigand Ulrich.Weigand@de.ibm.com
Tue Oct 1 10:08:00 GMT 2002


Hello,

after actually switching on the Java interpreter on s390(x), it appears
that my libffi implementation is still broken :-/

Unfortunately, one particular problem looks like it is not completely
my fault: the question is, how are 32-bit return values to be handled
on 64-bit (big endian) platforms?

In java/lang/reflect/natMethod.cc, it is expected that ints are returned
by ffi_call as a 'ffi_arg' type, which is defined to be an 64-bit integer
type on 64-bit machines.  However, in interpreter.cc, it is expected that
ints are returned by ffi_raw_call / ffi_java_raw_call as 'jint' type,
which is always a 32-bit integer type.

Furthermore, ffi_raw_call / ffi_java_raw_call have a default implementation
in terms of ffi_call which does not in any way convert the return value.

So, I cannot implement ffi_call to satisfy at the same time both
requirements on a 64-bit big endian machine.  Any suggestions?


Related is the question of how ffi_closure expects its target function
to handle return values.  One closure target function used by libjava,
_Jv_JNIMethod::call, simply passes the ret pointer on to ffi_raw_call,
so it would appear that ffi_closure should handle return values just
the same ways as ffi_(raw_)call.

However, the other target function, _Jv_InterpMethod::run, specifically
interprets the ret pointer as 'jint *' when returning 32-bit values.
So, if it turns out that ffi_call is supposed to return 64-bit, then
ffi_closure cannot be implemented correctly ...


(B.t.w. why aren't the return value pointers handled just the same as
the argument pointers, i.e. as void pointers interpreted to point to
exactly the type described by cif->rtype?  That sure would simplify
the issue ...)


Mit freundlichen Gruessen / Best Regards

Ulrich Weigand

--
  Dr. Ulrich Weigand
  Linux for S/390 Design & Development
  IBM Deutschland Entwicklung GmbH, Schoenaicher Str. 220, 71032 Boeblingen
  Phone: +49-7031/16-3727   ---   Email: Ulrich.Weigand@de.ibm.com



More information about the Java mailing list