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

Add Optional JIT compilation #91

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

richardpringle
Copy link

Closes #25

Will add more of a description later

Richard Pringle and others added 4 commits November 19, 2024 14:55
let cache = cache.clone();

move || {
let context = Box::leak(Box::new(revmc::llvm::Context::create()));
Copy link
Author

Choose a reason for hiding this comment

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

Can I leak this, does that make sense? I guess I shouldn't need to since context will live for the whole while loop below.

dbg!("compiled", &name);

let result =
unsafe { compiler.jit(&name, &code, spec_id) }.expect("catastrophe");
Copy link
Author

Choose a reason for hiding this comment

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

I'm a little confused as to the relationship between a compiler, a module, and a contract.
Should I be compiling all the code with the same compiler?


cache.lock().unwrap().insert(hash, result);

unsafe { compiler.clear().expect("could not clear") };
Copy link
Author

Choose a reason for hiding this comment

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

I'm pretty sure this is wrong, as the functions that I'm storing in the hashmap are just linked back to this compiler. When I call clear and try to call the cached function, it's a use-after-free and I segfault.

I'm obviously thinking about using the compiler the wrong way, how should I be thinking about it?

I've read over your code here, but I believe that's for aot compilation instead of jit since you're writing everything out to files.

Should I just be creating a new compiler every time and storing the compiler as well?

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.

Integrate revmc jit
1 participant