FPCast emulation - alternative methods? #3530
joemarshall
started this conversation in
Ideas
Replies: 1 comment
-
That's tricky, because after LLVM emits wasm we only see the function pointers as integers. We don't know that they refer to indices in the table. So this would require LLVM to support function cast emulation, and usually is a harder case to make. Perhaps the better solution here is to fix Python's use of undefined behavior, as @sbc100 mentioned elsewhere. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've been doing a bunch of work updating pyodide to wasm32 and upstream emscripten.
In doing this, I've been fiddling a bit with the fpcast_emulation stuff. Currently it fails quite often with corner cases such as:
Fixing 1 and 2 breaks anything that causes emcc to output invoke_xxx calls, which requires further fixes, as they need to call the original version not the fpcast_emulation one. I've fixed that also.
.
With those I'm at a point where the only thing that doesn't work is passing static unexported functions from module to module, and then calling invoke_xxx calls on it.
It did occur to me though that maybe the whole method of messing with the table is wrong and bad, because it causes all these complications. Would it not make more sense if rather than messing with the function tables themselves, we instead put code in at any point where the function pointer was stored into a variable the wrapped version was instead stored? At the point of taking a function pointer, we either a) are in the same module as the function, and getting the fpcast wrapped version is trivial, or b) it is an import, and we should either i)automatically export the wrapped versions for all exports, or ii) we should put a wrapper round the import call in this module instead.
I don't know, I'm not a super expert here, so I might be wrong, but I think this is worth discussing, as it would make things a lot less complicated, by removing all the corner cases where I have to do table juggling in emscripten javascript.
Beta Was this translation helpful? Give feedback.
All reactions