Calling an exposed Mu function in Mu
This problem has been raised before and discussed, but has not been properly documented. How existing (especially reference implementation) handles it also needs to be documented. This thread shall serve these purposes
Problem Description
RPython allows casting a function pointer to and from an address. A situation can occur when the code loads a function address, cast it back to a function pointer and calls it.
This poses some problem for Mu because the function is of type funcref
, and currently Address
is translated as uptr<void>
. ufuncptr
in Mu is specifically for native interface. A Mu function can be 'exposed' to get a ufuncptr
, but it is expected that it will be called from C rather than from within Mu itself.
What should Mu do in such case? Should the instruction be CALL
or CCALL
?
I do acknowledge that the deeper issue is the mismatch of type system assumptions that's built into RPython compiler. Handling it though can be quite tricky.
In previous discussions, Yi did point out that in the Zebu implementation this is not a problem. But I believe that this is a problem for the current reference implementation.