-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Allow serializing all cranelift-module data structures #6172
Allow serializing all cranelift-module data structures #6172
Conversation
6a5811e
to
436ffb8
Compare
|
||
struct ModuleDeclarationsFieldVisitor; | ||
|
||
impl<'de> serde::de::Visitor<'de> for ModuleDeclarationsFieldVisitor { |
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.
The Deserialize impl is based on serde-derive's macro expansion, but it has been cleaned up a lot and modified to run get_names
instead of expecting a names
field. This should be license technically, right?
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.
Any chance you can use one of the facilities provided by serde, e.g. #[serde(serialize_with = ...)]
on the names
field, instead?
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.
When applied to the names field that doesn't give access to the functions and data_objects fields to reconstruct the names field from from what I can tell.
Redirecting review to @bnjbvr who has touched these files recently (I've never messed with |
436ffb8
to
0f1fbe2
Compare
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 really just happened to touch this file, but I'm really not a code owner of it, sorry. Just a few small comments while skimming the code.
|
||
struct ModuleDeclarationsFieldVisitor; | ||
|
||
impl<'de> serde::de::Visitor<'de> for ModuleDeclarationsFieldVisitor { |
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.
Any chance you can use one of the facilities provided by serde, e.g. #[serde(serialize_with = ...)]
on the names
field, instead?
3760b5f
to
6784ad9
Compare
This is ready for review again. |
The same information can be retrieved using ctx.compiled_code().unwrap().code_info().total_size In addition for Module implementations that don't immediately compile the given function there is no correct value that can be returned.
This internal name can conflict if a module is serialized and then deserialized into another module. It also wasn't used by any of the Module implementations anyway.
This allows a Module implementation to serialize it's internal state and deserialize it in another compilation session. For example to implement LTO or to load the module into cranelift-interpreter.
6784ad9
to
32580fb
Compare
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.
Lgtm!
…nce#6172) * Remove ModuleCompiledFunction The same information can be retrieved using ctx.compiled_code().unwrap().code_info().total_size In addition for Module implementations that don't immediately compile the given function there is no correct value that can be returned. * Don't give anonymous functions and data objects an internal name This internal name can conflict if a module is serialized and then deserialized into another module. It also wasn't used by any of the Module implementations anyway. * Allow serializing all cranelift-module data structures This allows a Module implementation to serialize it's internal state and deserialize it in another compilation session. For example to implement LTO or to load the module into cranelift-interpreter. * Use expect
…nce#6172) * Remove ModuleCompiledFunction The same information can be retrieved using ctx.compiled_code().unwrap().code_info().total_size In addition for Module implementations that don't immediately compile the given function there is no correct value that can be returned. * Don't give anonymous functions and data objects an internal name This internal name can conflict if a module is serialized and then deserialized into another module. It also wasn't used by any of the Module implementations anyway. * Allow serializing all cranelift-module data structures This allows a Module implementation to serialize it's internal state and deserialize it in another compilation session. For example to implement LTO or to load the module into cranelift-interpreter. * Use expect
This allows a Module implementation to serialize it's internal state and deserialize it in another compilation session. For example to implement LTO or to load the module into cranelift-interpreter.
This is the last PR in the series for now. The actual implementation of a module that can be serialized is in cg_clif. I may extract it in the future, but for now these are almost all the changes that need to be made on the cranelift side. The previous PR's in this series are #6169 and #6170.