-
Notifications
You must be signed in to change notification settings - Fork 49
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
base: main
Are you sure you want to change the base?
Conversation
let cache = cache.clone(); | ||
|
||
move || { | ||
let context = Box::leak(Box::new(revmc::llvm::Context::create())); |
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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") }; |
There was a problem hiding this comment.
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?
Closes #25
Will add more of a description later