-
Notifications
You must be signed in to change notification settings - Fork 313
feat(wit): add map type support #2356
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
feat(wit): add map type support #2356
Conversation
|
Thanks for this! Are you looking to get this merged ASAP? Or is this more of a proof-of-concept to support the development of the PR on the spec itself? If you're looking to get this merged sooner-rather-than-later, do you have plans to work on other parts of the stack such as wit-bindgen or Wasmtime? |
|
@alexcrichton no rush at all in my end. I want to learn how to do the whole thing if possible if that is ok with you |
cd02439 to
2487714
Compare
|
Note for self: |
alexcrichton
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok looked over things, and thanks for this!
In terms of implementing this, adding a new type is a relatively major endeavor that takes awhile as there are a lot of integration points. Given that we'll want to make sure that this work is properly "gated" from external users to avoid, in theory, accidentally hitting unimplemented parts of the type system. The primary way this is done is via WasmFeatures in the wasmparser crate. What I'd recommend is adding a new cm_map feature similar to cm_fixed_size_lists. Effectively you'll want to add a bunch of tests/checks/etc in the same manner as fixed-size-lists, also an unstable feature at this time.
Additionally you'll want to add tests in tests/cli/component-model/*.wast for this new type as well. You should be able to find tests for fixed-size-lists around there and you can structure tests in a similar way.
Other than that though I think this would be reasonable to land. After landing here would come integration work into wasmtime/wit-bindgen/etc.
alexcrichton
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, thanks! The remaining things I can think of are:
- This needs a new feature gate in wasmparser's validation to ensure that this isn't accidentally usable-by-default.
- This needs
*.wasttests for the component-model side of things to ensure that the type works in the text format, validation, etc. There should also be tests ensuring that if the feature gate is disabled that usage of the type is an error (you can copy fixed-size-list tests for example) - Tests are currently not passing in CI, so that'll need to be green
1e65742 to
2ea4fec
Compare
2ea4fec to
f1a8786
Compare
|
@yordis it looks like the feature gating still isn't implemented? |
|
@alexcrichton 🤦🏻 sorry ... I completely forgot focusing on making CI to pass again resolving the comments ... let me work on that |
@alexcrichton when I ran |
8698f34 to
51b1558
Compare
|
Sorry I'm not sure what you're referring to? If you run |
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
…ib smoke test output
Map keys must be primitive types only. Add validation to reject non-primitive types (floats, user-defined types, etc.) as map keys.
…ent model Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
f70170f to
4f3e386
Compare
Yeah, just wondering why the |
alexcrichton
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
crates/wasmparser/src/features.rs
Outdated
| /// | ||
| /// Corresponds to the 🗺️ character in | ||
| /// <https://github.com/WebAssembly/component-model/blob/main/design/mvp/Explainer.md>. | ||
| pub cm_map: CM_MAP(1 << 37) = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the 37 here conflicts with compact_imports below now. I think it's reasonable to leave this adjacent to cm_gc, but feel free to renumber the below bits to ensure the biggest number is last
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It scares me that my tests passed 😭 I do not like things no breaking with these type of changes.
Could this use a enum thou?
| /// | ||
| /// Corresponds to the 🗺️ character in | ||
| /// <https://github.com/WebAssembly/component-model/blob/main/design/mvp/Explainer.md>. | ||
| pub cm_map: CM_MAP(1 << 38) = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I rather keep it based on the flag value than grouping things ... I think that caused the issue to begin with
Related Add a 'map<K,V>' type