-
Notifications
You must be signed in to change notification settings - Fork 253
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
Add support for resources to wit-component
#1084
Merged
alexcrichton
merged 3 commits into
bytecodealliance:main
from
alexcrichton:wit-component-full
Jul 5, 2023
Merged
Add support for resources to wit-component
#1084
alexcrichton
merged 3 commits into
bytecodealliance:main
from
alexcrichton:wit-component-full
Jul 5, 2023
Conversation
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
cc @silesmo as you're likely interested in this as well |
alexcrichton
force-pushed
the
wit-component-full
branch
from
June 23, 2023 02:06
61c81d2
to
e2485b8
Compare
9 tasks
sunfishcode
reviewed
Jun 30, 2023
alexcrichton
force-pushed
the
wit-component-full
branch
from
July 5, 2023 14:29
b60aa26
to
04b20d4
Compare
sunfishcode
approved these changes
Jul 5, 2023
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.
These additions are needed for `wit-bindgen` guest binding generation. Signed-off-by: Joel Dice <joel.dice@fermyon.com>
alexcrichton
force-pushed
the
wit-component-full
branch
from
July 5, 2023 23:11
04b20d4
to
5bd69b8
Compare
alexcrichton
added a commit
to alexcrichton/wasm-tools
that referenced
this pull request
Jul 11, 2023
Releases recent changes such as: * More support for the gc proposal. bytecodealliance#1045 bytecodealliance#1059 * Support for resources throughout most tooling. bytecodealliance#1053 bytecodealliance#1068 bytecodealliance#1070 bytecodealliance#1082 bytecodealliance#1079 bytecodealliance#1083 bytecodealliance#1084 bytecodealliance#1105 bytecodealliance#1113 bytecodealliance#1116 * Support for `include` in WIT files. bytecodealliance#1054 bytecodealliance#1085 bytecodealliance#1088 * WIT worlds may now be rejected if the same interface can be "reached" as both an import and an export simultaneously. bytecodealliance#1081 bytecodealliance#1107 * Support for registry metadata in `wasm-tools metadata`. bytecodealliance#1060 * A new subcommand `wasm-tools component targets`. bytecodealliance#1089 * An `--out-dir` argument is supported on `wasm-tools component wit` to print the entire `Resolve` instead of just one package. bytecodealliance#1108 * Miscellaneous bug fixes and improvements. bytecodealliance#1061 bytecodealliance#1065 bytecodealliance#1074 bytecodealliance#1073 bytecodealliance#1078 bytecodealliance#1077 bytecodealliance#1072 bytecodealliance#1086 bytecodealliance#1091 bytecodealliance#1094 bytecodealliance#1114 bytecodealliance#1106
alexcrichton
added a commit
to alexcrichton/wasm-tools
that referenced
this pull request
Jul 11, 2023
Releases recent changes such as: * More support for the gc proposal. [bytecodealliance#1045](bytecodealliance#1045) [bytecodealliance#1059](bytecodealliance#1059) * Support for resources throughout most tooling. [bytecodealliance#1053](bytecodealliance#1053) [bytecodealliance#1068](bytecodealliance#1068) [bytecodealliance#1070](bytecodealliance#1070) [bytecodealliance#1082](bytecodealliance#1082) [bytecodealliance#1079](bytecodealliance#1079) [bytecodealliance#1083](bytecodealliance#1083) [bytecodealliance#1084](bytecodealliance#1084) [bytecodealliance#1105](bytecodealliance#1105) [bytecodealliance#1113](bytecodealliance#1113) [bytecodealliance#1116](bytecodealliance#1116) * Support for `include` in WIT files. [bytecodealliance#1054](bytecodealliance#1054) [bytecodealliance#1085](bytecodealliance#1085) [bytecodealliance#1088](bytecodealliance#1088) * WIT worlds may now be rejected if the same interface can be "reached" as both an import and an export simultaneously. [bytecodealliance#1081](bytecodealliance#1081) [bytecodealliance#1107](bytecodealliance#1107) * Support for registry metadata in `wasm-tools metadata`. [bytecodealliance#1060](bytecodealliance#1060) * A new subcommand `wasm-tools component targets`. [bytecodealliance#1089](bytecodealliance#1089) * An `--out-dir` argument is supported on `wasm-tools component wit` to print the entire `Resolve` instead of just one package. [bytecodealliance#1108](bytecodealliance#1108) * Miscellaneous bug fixes and improvements. [bytecodealliance#1061](bytecodealliance#1061) [bytecodealliance#1065](bytecodealliance#1065) [bytecodealliance#1074](bytecodealliance#1074) [bytecodealliance#1073](bytecodealliance#1073) [bytecodealliance#1078](bytecodealliance#1078) [bytecodealliance#1077](bytecodealliance#1077) [bytecodealliance#1072](bytecodealliance#1072) [bytecodealliance#1086](bytecodealliance#1086) [bytecodealliance#1091](bytecodealliance#1091) [bytecodealliance#1094](bytecodealliance#1094) [bytecodealliance#1114](bytecodealliance#1114) [bytecodealliance#1106](bytecodealliance#1106)
Merged
alexcrichton
added a commit
that referenced
this pull request
Jul 11, 2023
Releases recent changes such as: * More support for the gc proposal. [#1045](#1045) [#1059](#1059) * Support for resources throughout most tooling. [#1053](#1053) [#1068](#1068) [#1070](#1070) [#1082](#1082) [#1079](#1079) [#1083](#1083) [#1084](#1084) [#1105](#1105) [#1113](#1113) [#1116](#1116) * Support for `include` in WIT files. [#1054](#1054) [#1085](#1085) [#1088](#1088) * WIT worlds may now be rejected if the same interface can be "reached" as both an import and an export simultaneously. [#1081](#1081) [#1107](#1107) * Support for registry metadata in `wasm-tools metadata`. [#1060](#1060) * A new subcommand `wasm-tools component targets`. [#1089](#1089) * An `--out-dir` argument is supported on `wasm-tools component wit` to print the entire `Resolve` instead of just one package. [#1108](#1108) * Miscellaneous bug fixes and improvements. [#1061](#1061) [#1065](#1065) [#1074](#1074) [#1073](#1073) [#1078](#1078) [#1077](#1077) [#1072](#1072) [#1086](#1086) [#1091](#1091) [#1094](#1094) [#1114](#1114) [#1106](#1106)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 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 throughits 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 codegenerators 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 meaningall of the above support will be fuzzed on OSS-Fuzz.
This required a number of refactorings in
wit-component
especiallyaround 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. Quitea 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'staking 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" oreasiest to understand implementation of resources, but it's intended to
be sufficient for now.