Considering most JIT compilers for JavaScript are written in C++, I can't conceive of a reason you couldn't implement one in Rust.
Is part of your requirement that unsafe
doesn't get used anywhere in the dependency tree? If so you'd have to take away most of the Rust std
library since many implementations in there have small strategic uses of unsafe
under the hood.
In my entire software engineering career, which spans embedded systems to CAD applications, I've never encountered a case where GOTO
is actually needed (but maybe some places where it can be used as a dirty shortcut to save you some lines of code).
As for arbitrary function pointers, if those function pointers are written in Rust then they'll come with all the safety assurances afforded to Rust code. I suppose if you're worried about the danger of running ussr-code with unsafe
in it, you could probably have your JIT refuse to compile the unsafe
keyword specifically.