Disconnects Store state fields from Compiler#1761
Conversation
Subscribe to Label Actioncc @peterhuene DetailsThis issue or pull request has been labeled: "wasmtime:api"Thus the following users have been cc'd because of the following labels:
To subscribe or unsubscribe from this label, edit the |
1e94ec4 to
c9da8fb
Compare
Subscribe to Label Actioncc @peterhuene DetailsThis issue or pull request has been labeled: "wasmtime:c-api"Thus the following users have been cc'd because of the following labels:
To subscribe or unsubscribe from this label, edit the |
c9da8fb to
d4e4ade
Compare
b54ba6b to
2e73c4a
Compare
alexcrichton
left a comment
There was a problem hiding this comment.
Nice!
This is looking really promising I think. I've left some various comments about organization below.
Also, would you be up for adding some more tests about using threads? I think it'd be good to try to start adding various tests here and there that try to stress the multithreaded aspects.
Subscribe to Label Actioncc @fitzgen DetailsThis issue or pull request has been labeled: "fuzzing", "wasmtime:docs"Thus the following users have been cc'd because of the following labels:
To subscribe or unsubscribe from this label, edit the |
alexcrichton
left a comment
There was a problem hiding this comment.
Looking great, thanks! Some other remaining points I can think of:
- Can the documentation be updated that
Moduleis threadsafe and safe to share across threads? - Can a test be specifically added that
ModuleisSendandSync? - I think we may want some form of checks when we instantiate a module into a store. I'm a bit worried about, for example you compile it with one engine that conflicts with configuration within another engine. For example you could compile it in one engine with interrupts disabled, and then instantiate it in another with interrupts enabled, and then interrupts wouldn't work.
|
|
||
| impl Default for Engine { | ||
| fn default() -> Engine { | ||
| Engine::new(&Config::default()) |
There was a problem hiding this comment.
Could Default for Store delegate to this now that it exists?
There was a problem hiding this comment.
Not sure how to do it: Engine::new and Store::new have some additional logic that needs to be run.
alexcrichton
left a comment
There was a problem hiding this comment.
FWIW this is a relatively major API change for all users since Module::new and Instance::new are changing. I think the Instance::new change is fine to sweep under the rug because it's largely supplanted by Linker, but Module::new is somewhat serious and you can see the effect it has on all the examples here.
The only way I could see of how to improve things is to implement AsRef<Engine> for Store and then take impl AsRef<Engine> in the constructor for Module. That way folks still wouldn't need to deal with Engine in general.
I don't think it's necessary to do that in this PR, however. I think it's fine to leave this for a later date if truly necessary.
| pub fn module_ref(&self) -> &Module { | ||
| &self.module | ||
| pub fn module_mut(&mut self) -> &mut Module { | ||
| Arc::get_mut(&mut self.module).unwrap() |
There was a problem hiding this comment.
Instead of embedding the .unwrap() here, could this return Option<&mut Module>? It's only used in one location right now which is fine, but I'd prefer to avoid proliferating users of this API
| module: Arc<Module>, | ||
|
|
||
| /// The module's JIT code (if exists). | ||
| code: Arc<dyn Any>, |
There was a problem hiding this comment.
Long-term it feels weird to have two dyn Any in this Instance, instead ideally we'd just have one Box<dyn Any> and shove everything in there. I don't want to iterate too much on this, it's pretty unimportant at this time. Just something to keep in mind for the future, this is more than ok for now.
|
Please add a note to the RELEASES.md describing this change 😄 |
To make wasmtime more threads friendly, this PR:
CodeMemory,VMInterruptsandSignatureRegistryfromCompilerCompiledModuleholdsCodeMemoryandGdbJitImageRegistrationStorekeeps track of its JIT codeSend+Sync