-
Notifications
You must be signed in to change notification settings - Fork 245
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for resources to
wit-component
(#1084)
* Add support for resources to `wit-component` This commit fully integrates resource types in the component model with the `wit-component` crate, implementing features such as: * A WIT package using `resource` types can now be round-tripped through its WebAssembly encoding. This enables use cases such as `wit-bindgen` which embed type information in custom sections of core wasm binaries produced by native compilers. * Core modules can be lifted into components and the component can use resources. This provides a target for `wit-bindgen` and other code generators to use when generating guest code. Resource intrinsics and destructors are all available to the core wasm as desired. * WIT can be inferred from components using resources, where functions are represented as `resource`-related functions in WIT. * The `roundtrip-wit` fuzzer is extended with resources support meaning all of the above support will be fuzzed on OSS-Fuzz. This required a number of refactorings in `wit-component` especially around how type information was handled. Previous processing was a bit fast-and-loose because where exactly a type was defined didn't really matter since everything was nominal. With resource types, however, definition locations are significant and this required some fixes to previous processing. One example of this is that WebAssembly/component-model#208 was discovered through this work and the fixes required were implemented previously and further handled here in `wit-component`. Overall this PR has been almost exclusively fuzz-driven in its development. I started out with the bare bones of getting simple components working with resources being imported and exported, then added fuzzing support to `wit-smith`, then let the fuzzer go wild. Quite a few issues were discovered which led to all of the refactorings and processing here in this PR. I definitely won't claim that this is a simplification at all to `wit-component` by any measure. Rather it's taking a complicated codebase and making it more complicated. In my mind though the "saving grace" is that I'm pretty confident in the testing/fuzzing story here. It's relatively easy to isolate issues and add test cases for the various things that can crop up and the fuzzer has quite good coverage of all the various paths through `wit-component`. All that's to say that this is surely not the "best" or easiest to understand implementation of resources, but it's intended to be sufficient for now. * add basic ABI/bindgen support for resources These additions are needed for `wit-bindgen` guest binding generation. Signed-off-by: Joel Dice <[email protected]> * Update expected fuzz error message --------- Signed-off-by: Joel Dice <[email protected]> Co-authored-by: Joel Dice <[email protected]>
- Loading branch information
1 parent
d4be472
commit 65395c8
Showing
82 changed files
with
2,809 additions
and
533 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.