deno icon indicating copy to clipboard operation
deno copied to clipboard

Feature (ext/ffi): Support non-uniform function pointer sizes

Open aapoalas opened this issue 3 years ago • 3 comments

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.

aapoalas avatar Jul 23 '22 19:07 aapoalas

Low priority, This will complicate the FFI code for platforms we only theoretically support.

littledivy avatar Jul 24 '22 04:07 littledivy

Low priority, This will complicate the FFI code for platforms we only theoretically support.

Yup, agreed.

aapoalas avatar Jul 24 '22 05:07 aapoalas

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.

vimirage avatar Jul 24 '22 06:07 vimirage