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

feat: Implement wasmer_module_serialize and wasmer_module_deserialize functions in runtime-c-api #271

Merged
merged 17 commits into from
Mar 19, 2019

Conversation

Hywan
Copy link
Contributor

@Hywan Hywan commented Mar 15, 2019

This PR implements 5 new functions in the runtime-c-api crate:

  1. wasmer_module_serialize to serialize a module into a wasmer_serialized_module_t type,
  2. wasmer_module_deserialize to deserialize a serialized module,
  3. wasmer_serialized_module_bytes to read the bytes in the wasmer_serialized_module_t type into a wasmer_byte_array,
  4. wasmer_serialized_module_from_bytes to transform a wasmer_byte_array into a wasmer_serialized_module_t,
  5. wasmer_serialized_module_destroy to destroy a wasmer_serialized_module_t.

Documentation and a test suite have been added.

We need to change the visibility of the wasmer_runtime::default_compiler function to public, since it is used in runtime-c-api.

The new test suite test-module-serialize does a full roundtrip: A module is compiled, then serialized, then deserialized, to finally be instantiated and a function is called on it.

Thoughts?

Hywan added 7 commits March 15, 2019 12:04
This is required to be able to deserialize a serialized module in
`runtime-c-api`.
`std::slice` is already imported. This patch then rewrites `::std::slice::` into `slice::`.
…tions.

This patch implements 2 functions:

  1. `wasmer_module_serialize`, and
  2. `wasmer_module_deserialize`.
…ions.

This test suite compiles a module, then serializes it, deserializes
it, and continues by creating an instance and calling a function on
it. It allows to test the entire roundtrip.
Copy link
Contributor

@bjfish bjfish left a comment

Choose a reason for hiding this comment

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

LGTM, @lachlansneff please review the caching part of this?

lib/runtime-c-api/src/lib.rs Show resolved Hide resolved
lib/runtime-c-api/src/lib.rs Show resolved Hide resolved
Copy link
Contributor

@xmclark xmclark left a comment

Choose a reason for hiding this comment

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

Well done!

lib/runtime-c-api/src/lib.rs Show resolved Hide resolved
lib/runtime-c-api/src/lib.rs Outdated Show resolved Hide resolved
Hywan added 2 commits March 18, 2019 16:09
When the value goes out-of-scope, `drop` is called utomatically.
… type.

The `wasmer_module_serialize` function now computes a
`wasmer_serialized_module_t` value. The `wasmer_module_deserialize`
function takes this value as an input. Same for
`wasmer_serialized_module_destroy`.

The new function `wasmer_serialized_module_bytes` allows to read the
bytes inside the `wasmer_serialized_mdule_t` structure.
…ction.

This function is required to transform a `wasmer_byte_array` into a
`wasmer_serialized_module_t`. This is the complementary function of
`wasmer_serialized_module_bytes`.
@Hywan
Copy link
Contributor Author

Hywan commented Mar 19, 2019

I've added the wasmer_serialized_module_from_bytes function. The PR description has been updated accordingly. This function is required to transform a wasmer_byte_array into a wasmer_serialized_module_t. Indeed, when storing the serialized module bytes into a file for instance, one gets the same bytes when reading the file and has to transform them into a wasmer_serialized_module_t so that it can be passed to the wasmer_module_deserialize function.

lib/runtime-c-api/wasmer.h Outdated Show resolved Hide resolved
Copy link
Contributor

@bjfish bjfish left a comment

Choose a reason for hiding this comment

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

Please see the comments I made.

@Hywan
Copy link
Contributor Author

Hywan commented Mar 19, 2019

bors r+

bors bot added a commit that referenced this pull request Mar 19, 2019
271: feat: Implement `wasmer_module_serialize` and `wasmer_module_deserialize` functions in `runtime-c-api` r=Hywan a=Hywan

This PR implements 5 new functions in the `runtime-c-api` crate:

  1. `wasmer_module_serialize` to serialize a module into a `wasmer_serialized_module_t` type,
  2. `wasmer_module_deserialize` to deserialize a serialized module,
  3. `wasmer_serialized_module_bytes` to read the bytes in the `wasmer_serialized_module_t` type into a `wasmer_byte_array`,
  4. `wasmer_serialized_module_from_bytes` to transform a `wasmer_byte_array` into a `wasmer_serialized_module_t`,
  4. `wasmer_serialized_module_destroy` to destroy a `wasmer_serialized_module_t`.

Documentation and a test suite have been added.

We need to change the visibility of the `wasmer_runtime::default_compiler` function to public, since it is used in `runtime-c-api`.

The new test suite `test-module-serialize` does a full roundtrip: A module is compiled, then serialized, then deserialized, to finally be instantiated and a function is called on it.

Thoughts?

Co-authored-by: Ivan Enderlin <ivan.enderlin@hoa-project.net>
@bors
Copy link
Contributor

bors bot commented Mar 19, 2019

Canceled

@Hywan
Copy link
Contributor Author

Hywan commented Mar 19, 2019

bors r+

bors bot added a commit that referenced this pull request Mar 19, 2019
271: feat: Implement `wasmer_module_serialize` and `wasmer_module_deserialize` functions in `runtime-c-api` r=Hywan a=Hywan

This PR implements 5 new functions in the `runtime-c-api` crate:

  1. `wasmer_module_serialize` to serialize a module into a `wasmer_serialized_module_t` type,
  2. `wasmer_module_deserialize` to deserialize a serialized module,
  3. `wasmer_serialized_module_bytes` to read the bytes in the `wasmer_serialized_module_t` type into a `wasmer_byte_array`,
  4. `wasmer_serialized_module_from_bytes` to transform a `wasmer_byte_array` into a `wasmer_serialized_module_t`,
  4. `wasmer_serialized_module_destroy` to destroy a `wasmer_serialized_module_t`.

Documentation and a test suite have been added.

We need to change the visibility of the `wasmer_runtime::default_compiler` function to public, since it is used in `runtime-c-api`.

The new test suite `test-module-serialize` does a full roundtrip: A module is compiled, then serialized, then deserialized, to finally be instantiated and a function is called on it.

Thoughts?

Co-authored-by: Ivan Enderlin <ivan.enderlin@hoa-project.net>
@bors
Copy link
Contributor

bors bot commented Mar 19, 2019

@bors bors bot merged commit c0f4b6a into wasmerio:master Mar 19, 2019
bors bot added a commit that referenced this pull request Oct 14, 2019
876: Bump structopt from 0.3.2 to 0.3.3 r=Hywan a=dependabot-preview[bot]

Bumps [structopt](https://github.com/TeXitoi/structopt) from 0.3.2 to 0.3.3.
<details>
<summary>Changelog</summary>

*Sourced from [structopt's changelog](https://github.com/TeXitoi/structopt/blob/master/CHANGELOG.md).*

> # v0.3.3 (2019-10-10)
> 
> * Add `from_flag` custom parser to create flags from non-bool types.
>   Fixes [#185](https://github-redirect.dependabot.com/TeXitoi/structopt/issues/185)
</details>
<details>
<summary>Commits</summary>

- [`2cb1fbf`](TeXitoi/structopt@2cb1fbf) v0.3.3
- [`fd2cc62`](TeXitoi/structopt@fd2cc62) Add from_flag parser ([#271](https://github-redirect.dependabot.com/TeXitoi/structopt/issues/271))
- [`6a3fc8b`](TeXitoi/structopt@6a3fc8b) Run ui tests only on stable
- [`8d86616`](TeXitoi/structopt@8d86616) Fix code formatting
- [`cf61ff1`](TeXitoi/structopt@cf61ff1) Fix nightly tests
- [`0c888e9`](TeXitoi/structopt@0c888e9) Fix clippy warnings
- [`1cae9fa`](TeXitoi/structopt@1cae9fa) Suppress all clippy warnings
- [`c228c23`](TeXitoi/structopt@c228c23) Fix version in docs (AGAIN)
- See full diff in [compare view](TeXitoi/structopt@v0.3.2...v0.3.3)
</details>
<br />

[![Dependabot compatibility score](https://api.dependabot.com/badges/compatibility_score?dependency-name=structopt&package-manager=cargo&previous-version=0.3.2&new-version=0.3.3)](https://dependabot.com/compatibility-score.html?dependency-name=structopt&package-manager=cargo&previous-version=0.3.2&new-version=0.3.3)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
- `@dependabot use these labels` will set the current labels as the default for future PRs for this repo and language
- `@dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language
- `@dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language
- `@dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language
- `@dependabot badge me` will comment on this PR with code to add a "Dependabot enabled" badge to your readme

Additionally, you can set the following in your Dependabot [dashboard](https://app.dependabot.com):
- Update frequency (including time of day and day of week)
- Pull request limits (per update run and/or open at any time)
- Automerge options (never/patch/minor, and dev/runtime dependencies)
- Out-of-range updates (receive only lockfile updates, if desired)
- Security updates (receive only security updates, if desired)



</details>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📚 documentation Do you like to read? 🎉 enhancement New feature! 📦 lib-c-api About wasmer-c-api 🧪 tests I love tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants