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

Start compiling module-linking modules #2093

Merged

Conversation

alexcrichton
Copy link
Member

This commit is intended to be the first of many in implementing the
module linking proposal. At this time this builds on #2059 so it
shouldn't land yet. The goal of this commit is to compile bare-bones
modules which use module linking, e.g. those with nested modules.

My hope with module linking is that almost everything in wasmtime only
needs mild refactorings to handle it. The goal is that all per-module
structures are still per-module and at the top level there's just a
Vec containing a bunch of modules. That's implemented currently where
wasmtime::Module contains Arc<[CompiledModule]> and an index of
which one it's pointing to. This should enable
serialization/deserialization of any module in a nested modules
scenario, no matter how you got it.

Tons of features of the module linking proposal are missing from this
commit. For example instantiation flat out doesn't work, nor does
import/export of modules or instances. That'll be coming as future
commits, but the purpose here is to start laying groundwork in Wasmtime
for handling lots of modules in lots of places.

@alexcrichton alexcrichton marked this pull request as draft August 4, 2020 19:16
@github-actions github-actions bot added cranelift Issues related to the Cranelift code generator cranelift:wasm fuzzing Issues related to our fuzzing infrastructure lightbeam Issues related to the Lightbeam compiler wasmtime:api Related to the API of the `wasmtime` crate itself labels Aug 4, 2020
@github-actions
Copy link

github-actions bot commented Aug 4, 2020

Subscribe to Label Action

cc @bnjbvr, @fitzgen, @peterhuene

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

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

  • bnjbvr: cranelift
  • fitzgen: fuzzing
  • peterhuene: wasmtime:api

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

Learn more.

@alexcrichton alexcrichton force-pushed the compile-nested-modules branch 2 times, most recently from b589e70 to 409b962 Compare November 3, 2020 02:11
@alexcrichton alexcrichton marked this pull request as ready for review November 3, 2020 02:31
@alexcrichton
Copy link
Member Author

Ok I've rebased this now and I think it should be ready for review!

@tschneidereit tschneidereit requested a review from fitzgen November 3, 2020 18:25
@@ -847,4 +847,28 @@ pub trait ModuleEnvironment<'data>: TargetEnvironment {
fn wasm_features(&self) -> WasmFeatures {
WasmFeatures::default()
}

/// Indicates that this module will have `amount` submodules.
Copy link
Member

Choose a reason for hiding this comment

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

So this only includes nested submodules, not the top level module? Good to make this explicit in the comment.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah good point, but yes, this only includes the top-level module's modules (or whatever the current module is), basically just "we found the module section in the wasm file"

@alexcrichton alexcrichton force-pushed the compile-nested-modules branch from 409b962 to 104cde1 Compare November 6, 2020 18:56
This commit is intended to be the first of many in implementing the
module linking proposal. At this time this builds on bytecodealliance#2059 so it
shouldn't land yet. The goal of this commit is to compile bare-bones
modules which use module linking, e.g. those with nested modules.

My hope with module linking is that almost everything in wasmtime only
needs mild refactorings to handle it. The goal is that all per-module
structures are still per-module and at the top level there's just a
`Vec` containing a bunch of modules. That's implemented currently where
`wasmtime::Module` contains `Arc<[CompiledModule]>` and an index of
which one it's pointing to. This should enable
serialization/deserialization of any module in a nested modules
scenario, no matter how you got it.

Tons of features of the module linking proposal are missing from this
commit. For example instantiation flat out doesn't work, nor does
import/export of modules or instances. That'll be coming as future
commits, but the purpose here is to start laying groundwork in Wasmtime
for handling lots of modules in lots of places.
@alexcrichton alexcrichton force-pushed the compile-nested-modules branch from 104cde1 to bbc93ad Compare November 6, 2020 18:58
@alexcrichton alexcrichton merged commit 77827a4 into bytecodealliance:main Nov 6, 2020
@alexcrichton alexcrichton deleted the compile-nested-modules branch November 6, 2020 19:32
cfallin pushed a commit that referenced this pull request Nov 30, 2020
This commit is intended to be the first of many in implementing the
module linking proposal. At this time this builds on #2059 so it
shouldn't land yet. The goal of this commit is to compile bare-bones
modules which use module linking, e.g. those with nested modules.

My hope with module linking is that almost everything in wasmtime only
needs mild refactorings to handle it. The goal is that all per-module
structures are still per-module and at the top level there's just a
`Vec` containing a bunch of modules. That's implemented currently where
`wasmtime::Module` contains `Arc<[CompiledModule]>` and an index of
which one it's pointing to. This should enable
serialization/deserialization of any module in a nested modules
scenario, no matter how you got it.

Tons of features of the module linking proposal are missing from this
commit. For example instantiation flat out doesn't work, nor does
import/export of modules or instances. That'll be coming as future
commits, but the purpose here is to start laying groundwork in Wasmtime
for handling lots of modules in lots of places.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cranelift:wasm cranelift Issues related to the Cranelift code generator fuzzing Issues related to our fuzzing infrastructure lightbeam Issues related to the Lightbeam compiler wasmtime:api Related to the API of the `wasmtime` crate itself
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants