Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation of orc2 based jit engine. #477

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

JCBurnside
Copy link

Description

It supports creating the LLJIT engine off a module (consuming said module), adding global mappings off name and global values.
Documentation needs a bit of work (thus starting this as a draft pr) but rather simple implementation and tried to mirror JITExecutionEngine though it is constructed differently.

Related Issue

#476

How This Has Been Tested

I have tested with a local project referencing the local fork and the samples attached to LLJITExecutionEngine::get_function and LLJITExecutionEngine::add_global_mapping

Checklist

@JCBurnside JCBurnside marked this pull request as ready for review February 22, 2024 15:40
@JCBurnside
Copy link
Author

alright I feel I have commented everything. Feel free to let me know anything i missed.

@JCBurnside
Copy link
Author

hmmm sees i need to find out what llvm version LLJIT was added. And then rebase to master. I'll get right on that!

Comment on lines +80 to +81
/// execution engine it came from, but adding functions after calling this
/// method *may* invalidate the function pointer.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is probably a cool hack to avoid this: accept &mut self in add_* methods and store &self in LLJITFunction. In theory, this should prevent from calling mutable methods, while there is an immutable reference

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just like you can't store references to Vec elements and push into it

@@ -184,6 +186,7 @@ impl<'ctx> Module<'ctx> {
Module {
module: Cell::new(module),
owned_by_ee: RefCell::new(None),
owned_by_lljit : RefCell::new(None),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should just have one owned by field with an enum in the option?

self.add_global_mappings_impl(mappings.iter().map(|(name,addr)| (to_c_str(name),*addr)))
}

fn add_global_mapping_impl(&self,name:Cow<'_,CStr>, addr:usize) -> Result<(),LLVMString> {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please format these changes

@TheDan64 TheDan64 force-pushed the master branch 3 times, most recently from b7ef5f6 to 7684346 Compare May 18, 2024 05:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants