deno
deno copied to clipboard
Feature (ext/ffi): Support non-uniform function pointer sizes
As pointed out by @Phosra in this comment, it is not guaranteed that function pointers are always size-wise interchangeable with data pointers.
Currently the FFI layer presumes both function and data pointers to always be usize sized. This presumption also goes deep, the Rust libffi crate does not offer a separate type for function pointers and as such there might be a need to manually convert function pointers into appropriate integer sizes.
In any case, this probably needs a bit of work to support.
Low priority, This will complicate the FFI code for platforms we only theoretically support.
Low priority, This will complicate the FFI code for platforms we only theoretically support.
Yup, agreed.
With an assertion in place for their sizes, shouldn't the appropriate types be intentionally preferred, as compilation would fail if they differ anyways? I.e. use the correct Rust fn() and C void(*)() because it doesn't matter.