Expose run_jit to allow for custom behaviour in JIT flow #1551
+480
−443
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi, I'm making this PR primarily to let you know I'm working on a project that uses the JIT in a slightly weird way, I'm making a language that is JITted with Rust as an intermediate language, or at least for its parts that are linked to Rust crate dependencies.
To understand the JIT better, and to give myself a point to start thinking on what else I need I started by splitting out the JIT driver into smaller functions. I'm not sure if this is desirable, it just helped me understand it better.
My next step I've described in this thoughts:
I need some way to make the lazy jit state publicly accessible. It should only be accessible from the rustc thread. This is achieved by using the message channel to send requests to the rustc thread for the regular JIT flow. I need it to be publicly accessible so I can add new functions to the jit_module, and it has to be in the rustc_thread because I assume it
is
thread_local
for good reason.I want to enable arbitrary code to invoke the JIT runtime to compile new functions, so I need to expose a way to send messages to the rustc thread.
So I should add a new message type that requests a function to be JIT to the UnsafeMessage enum. And then I should add a new message handler argument to the
run_jit
function that will be called when a new message is received.I would love your thoughts on if I'm going in a right direction, and if you think this has a chance of getting merged or if I should just continue in my fork without worrying about upstreaming.
Thanks!