wasmparser: Implement no-hash-maps crate feature & support#1521
wasmparser: Implement no-hash-maps crate feature & support#1521alexcrichton merged 73 commits intobytecodealliance:mainfrom
wasmparser: Implement no-hash-maps crate feature & support#1521Conversation
Disabled by default.
This introduced a lot of compile errors in case no-hash-maps is actually enabled since many keys are not Ord.
Some methods are not shared between Hash{Map,Set} and BTree{Map,Set} such as reserve and the Key type has different trait bounds (Eq + Hash) vs (Eq + Ord) which can be confusing when using map and set in wasmparser during development.
Thus we actually do not want to use type aliases but proper types that wraps both Hash{Map,Set} and BTree{Map,Set} and provide a unified API.
The same is true for Index{Map,Set} but we will do this in another commit.
This is just a workaround until the new Map/Set type with unified API is done.
I want to keep the base mod.rs as clean as possible.
Currently it only supports mostly the minimal API needed to make the wasmparser crate work.
Currently it only mostly supports the minimal API needed to make the wasmparser crate work again.
They are used in IndexMap so for symmetry I add them here too.
symmetry: this method is used by both Set and IndexMap
symmetry: used on IndexMap
|
@alexcrichton Today I have time to work on this again. One question still open: In my Wasmi implementation I made |
|
I think it's reasonable to go ahead and add in more API surface area yeah, especially if it's easy enough to implement |
|
@alexcrichton I have now done the following
Testing of the custom One question: |
For the no-hash-maps custom impl.
This is friendlier for maintenance and developers.
|
Technically the methods don't need |
|
@alexcrichton I just added tests for the custom I will do the |
alexcrichton
left a comment
There was a problem hiding this comment.
Looks great to me, thanks again for your work on this!
Forgot to flag this in bytecodealliance#1521 so adding in a follow-up.
Thank you for making wasmparser compatible with Wasmi. I am very happy to contribute this. :) |
Forgot to flag this in #1521 so adding in a follow-up.
Closes #1517 .
This PR tries to implement
Set,MapIndexSetandIndexMapwith as similar APIs as possibleto each other but also to Rust's
HashMap,BTreeMapandindexmap::IndexMap.TODO
wasmparser::mapmodule towasmparser::collections.Settype:hash-setandbtree-set.Maptype:hash-mapandbtree-map.IndexSettype:IndexMap<T, ()>-based custom ImplementationIndexMaptype:btree-based Implementation