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

Serialize and deserialize compilation artifacts. #2020

Merged
merged 9 commits into from
Jul 21, 2020

Conversation

yurydelendik
Copy link
Collaborator

Fixes #1779

This is final patch in series to allow direct access to the compiled code.

  • Added compile_and_serialize API function that allows to save CompilationArtifacts object in binary format (+target/config fingerprint)
  • Added unsafe Module::deserialize API function that allows to read the above data and create Module object. Marked unsafe since it does not provide any guarantees for safety of the ingested code.
  • Portability limitation is that producer and consumer'sConfigs must have the same host triple, codegen flags, and Tunables. (Can we ignore CompilerStrategy?)

PR opened for feedback.

@github-actions github-actions bot added cranelift Issues related to the Cranelift code generator wasmtime:api Related to the API of the `wasmtime` crate itself labels Jul 14, 2020
@github-actions
Copy link

Subscribe to Label Action

cc @bnjbvr, @peterhuene

This issue or pull request has been labeled: "cranelift", "wasmtime:api"

Thus the following users have been cc'd because of the following labels:

  • bnjbvr: cranelift
  • peterhuene: wasmtime:api

To subscribe or unsubscribe from this label, edit the .github/subscribe-to-label.json configuration file.

Learn more.

@github-actions github-actions bot added the wasmtime:c-api Issues pertaining to the C API. label Jul 15, 2020
@yurydelendik yurydelendik marked this pull request as ready for review July 15, 2020 19:16
@github-actions
Copy link

Subscribe to Label Action

cc @peterhuene

This issue or pull request has been labeled: "wasmtime:c-api"

Thus the following users have been cc'd because of the following labels:

  • peterhuene: wasmtime:c-api

To subscribe or unsubscribe from this label, edit the .github/subscribe-to-label.json configuration file.

Learn more.

Copy link
Member

@alexcrichton alexcrichton left a comment

Choose a reason for hiding this comment

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

Nice!

I think that we'll want to expand the documentation on these functions as well. I'd probably pick one of serialize/deserialize and add a bunch of docs there, referencing these docs from the other function instead of duplication as well.

In terms of documentation contents I think we'll want to document how the bytes are intended to be used, for example they're only usable by one version of the wasmtime crate, they're not intended to be long-lived artifacts. Also we'll probably want a small example in the documentation of serializing/deserializing.

Can you be sure to add some Rust tests as well?

crates/wasmtime/src/module.rs Outdated Show resolved Hide resolved
crates/wasmtime/src/runtime.rs Show resolved Hide resolved
crates/wasmtime/src/runtime.rs Outdated Show resolved Hide resolved
crates/wasmtime/src/module.rs Outdated Show resolved Hide resolved
crates/c-api/src/module.rs Outdated Show resolved Hide resolved
Copy link
Member

@alexcrichton alexcrichton left a comment

Choose a reason for hiding this comment

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

Sorry missed the updates here but this all looks good to me now!

@yurydelendik yurydelendik merged commit 399ee0a into bytecodealliance:main Jul 21, 2020
@yurydelendik yurydelendik deleted the serde-module-example branch July 21, 2020 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cranelift Issues related to the Cranelift code generator wasmtime:api Related to the API of the `wasmtime` crate itself wasmtime:c-api Issues pertaining to the C API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ability to get and load compilation result bytes
3 participants