Stream: git-wasmtime

Topic: wasmtime / issue #4844 Implement `value` imports/exports ...


view this post on Zulip Wasmtime GitHub notifications bot (Sep 01 2022 at 21:33):

alexcrichton opened issue #4844:

The current implementation of the component model traked in https://github.com/bytecodealliance/wasmtime/issues/4185 is fairly complete with the current state of the spec but a major gap is the implementation of value imports, value exports, and the start function. Currently Wasmtime will panic if any of these constructs are encountered.

@dicej, @jameysharp, @elliottt, and I just had a chat about how we might go about implementing these and we think we have a promising set of ideas which could serve as the basis for implementing all of these features.

Simple case first

One thing we concluded was that tackling the simplest case first is probably the best where there's only one start function in a component and it takes all the imports as parameters. The start function in this case is also the last initializer within the component itself.

To implement this, some rough ideas we had were:

Whatever trait U implements is one that we could add a custom derive for. Something like:

#[derive(ValueImports)]
struct MyCustomName {
    #[component(import = "bar")]
    foo: String,
    #[component(import = "foo.bar")] // e.g. an instance import `foo` where the instance exports a value named `bar`
    baz: String,
}

#[derive(ValueExports)]
struct MyCustomName2 {
    #[component(import = "bar")]
    foo: String,
    #[component(import = "foo.bar")] // e.g. an instance export `foo` where the instance exports a value named `bar`
    baz: String,
}

(ok as I write this out I realize that the one U I mentioned above should probably be separate type parameters for both imports and exports)

Inter-component start functions

The next level of cases to handle after the above is implemented would be inter-component start functions where values from one start function flow into values of a different start function within the component graph. This sort of value transfer needs to be entirely handled by the precompiled artifact since the embedder is not even aware of the types involved here.

For this the rough assumption is that the usage of fact should be somewhat easy to do here. Ideally this could leverage most of what fact already implements but at least to me it's not immediately obvious how this would be done. @jameysharp's idea was that we could model the start functions as a combination of the primitives that fact implements already today, although I don't think we came to a conclusion on exactly what these primitives are or what the combinations look like.

Open questions

view this post on Zulip Wasmtime GitHub notifications bot (Sep 01 2022 at 21:33):

alexcrichton labeled issue #4844:

The current implementation of the component model traked in https://github.com/bytecodealliance/wasmtime/issues/4185 is fairly complete with the current state of the spec but a major gap is the implementation of value imports, value exports, and the start function. Currently Wasmtime will panic if any of these constructs are encountered.

@dicej, @jameysharp, @elliottt, and I just had a chat about how we might go about implementing these and we think we have a promising set of ideas which could serve as the basis for implementing all of these features.

Simple case first

One thing we concluded was that tackling the simplest case first is probably the best where there's only one start function in a component and it takes all the imports as parameters. The start function in this case is also the last initializer within the component itself.

To implement this, some rough ideas we had were:

Whatever trait U implements is one that we could add a custom derive for. Something like:

#[derive(ValueImports)]
struct MyCustomName {
    #[component(import = "bar")]
    foo: String,
    #[component(import = "foo.bar")] // e.g. an instance import `foo` where the instance exports a value named `bar`
    baz: String,
}

#[derive(ValueExports)]
struct MyCustomName2 {
    #[component(import = "bar")]
    foo: String,
    #[component(import = "foo.bar")] // e.g. an instance export `foo` where the instance exports a value named `bar`
    baz: String,
}

(ok as I write this out I realize that the one U I mentioned above should probably be separate type parameters for both imports and exports)

Inter-component start functions

The next level of cases to handle after the above is implemented would be inter-component start functions where values from one start function flow into values of a different start function within the component graph. This sort of value transfer needs to be entirely handled by the precompiled artifact since the embedder is not even aware of the types involved here.

For this the rough assumption is that the usage of fact should be somewhat easy to do here. Ideally this could leverage most of what fact already implements but at least to me it's not immediately obvious how this would be done. @jameysharp's idea was that we could model the start functions as a combination of the primitives that fact implements already today, although I don't think we came to a conclusion on exactly what these primitives are or what the combinations look like.

Open questions


Last updated: Dec 23 2024 at 12:05 UTC