Use u64 to track file offsets instead of usize#2573
Conversation
This replaces usize in a lot of places. Besides being a technically breaking change, this should not impact functionality. Solves a TODO left long ago in the entry code of parse.
45e1141 to
2a6f9db
Compare
|
A lot of consumers seem to hold the entire wasm input in memory, hence these need some ergonomics to convert their offsets back to |
0f2d5de to
018d1e9
Compare
|
I have not removed |
alexcrichton
left a comment
There was a problem hiding this comment.
Personally I still feel that InMemData and MemOffset aren't worth it. This is already a very large change due to how many places it has to touch, and in my mind it's a consequence of the change at all that as casts are going to be needed when in-memory data is indexed with the offsets coming out of wasmparser. While I've no doubt that certain abstractions could cut down on the number of resulting as casts I'm not sure if the benefit of such abstractions outweighs their costs (e.g. new primitives to learn).
I can see that for
One oddity for example is that since In any case, conversion was much easier with |
|
In the course of adding docs to |
This replaces usize in a lot of places. Besides being a breaking change, this should not impact functionality for most users. Tracking file offset with
u64is the more principled choice.Fixes #838
Solves a TODO left long ago in the entry code of parse. Most of the places used
usizeto pass it along to other functions, sinking into Error code for nice error messages, and are thus not sensitive to the data type used. I found two cases that usedusize::MAXas a dummy index in a path that calledexpect()on the eventual error.There is a small abstraction in
offsets.rsexposed asInMemDatathat allows conversion fromRange<u64>to byte slices in case the whole data input fits in memory.