Modernize implementation of interface types #1013
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This commit is the start of the modernization of the implementation of
interface types in wasmtime. This has a long way to go, and like the
previous iteration, chunks of it are already destined to get thrown
away.
The current state of affairs is that the implementation of interface
types in wasmtime feels very "bolted on" because, well, it was! The
wasmtime-interface-typescrate is not well integrated with thewasmtimeAPI crate. Additionally it implements an older version of theinterface types proposal dating back to when it was still based on
WebIDL bindings. The goals of this PR are to integrate interface types
into the
wasmtimeAPI crate as well as update the implementation tothe current proposal, which is more instruction/adapter based.
Support here is built on top of the tools in the wasm-interface-types
repository which contain various pieces of functionality like parsing
the text format, parsing the binary format, stringifying the binary
format, and validating the binary format. These tools are intended to be
developed standalone from Wasmtime itself to encourage other users (like
wasm-bindgen, a generator for interface types).This should also fix a number of integration issues around the interface
types demos we have (eventually) since wasm-bindgen is targeting the
wasm-interface-types family of crates rather than the older WebIDL
bindings proposals.
The current status of this commit/PR is that it is a step in the right
direction but incomplete. I started this work a few months ago when I
had some more time and have been occasionally rebasing it on the current
wasmtimemaster branch. Only a few simple instructions are supported(and it's all via an interpreter, nothing compiled), and "hard" things
like strings have yet to be done.
What is implemented, however, falls into categories like:
wasmtimecrate is sorted outValTypetype is enhanced with interface types.Valtype is enhanced with interface types values.Configtype has a gate for the interface types proposal likeit does all other proposals.
wasmtime-interface-typescrate is deleted and all users aremigrated to the
wasmtimecrate exclusively.*.wastsyntax tocover interface types. I basically add things like
s8.const fooaswell as updated the parser to be able to parse
@interfacedirectives. Again this is sort of an invented format, but the
intention is that we can easily write
*.wasttests the same way forinterface types how we do for the core spec.
I don't think we want to land this as-is because of how little of
interface types it implements. Additionally there's parallel work that's
been happening in Cranelift to jit interface types stubs which we may
wish to sync up with as well. In any case the main purpose of this
commit is to add fuel to the interface types discussion and hopefully
give us something concrete to work with as well.