Nicolas Cellier a écrit :
Eliot Miranda <eliot.miranda <at> gmail.com> writes:
So.... the FFI marshalling machinery really needs to reset the FPU's stack
pointer to zero both before and after making a call. I don't know if the FFI does this but chances are it doesn't.
In my time VisualWorks suffered problems like this, including its machine code
floating point primitives not zeroing the x87 stack pointer on primitive fail. Now it does an fninit (the relevant instruction to intialize the x87 FPU) in relevant places.
Cheers Eliot
As suggested by my above tests, the fninit does not seem to be called in FFI. Would you know how to force such an instruction in a portable way via VMMaker?
Ian just mailed that all parameters are passed in memory, so the right place for fninit is before foreign call, and before ffi return.
However, I see this does reset the whole FPU state. Bad if in the future we want to control hardware trap on FPU...