First steps towards Read trait parser (BrTable)#216
First steps towards Read trait parser (BrTable)#216Robbepop wants to merge 9 commits intobytecodealliance:masterfrom
Conversation
|
It is a good start, though I don't think we want How about we will start with generalizing the enum WasmOperator<B: OperatorBuilder> { Unreachable, ..., BrTable { table: B::BrTable }, ... };
type Operator<'a> = WasmOperator<DefaultOperatorBuilder<'a>>;
impl<'a> OperatorBuilder for DefaultOperatorBuilder<'a> {
type BrTable = BrTable<'a>;
fn read_table(&self) -> Self::BrTable { ... }
}(I did not play with the above idea yet, so I'll consider the alternative approaches) |
Well the is basically what I proposed above as a follow-up PR. Why exactly is a Also we do not necessarily have to provide a default To elaborate on the problem with Another solution for a non-allocating default |
Correct. The We can add |
Right. I don't think only BrTable will be an issue. We need a specific plan to remove/generalize |
|
Yep, the best solution I can currently think of is shift all hard problems (allocation) to user side which is exactly what we will be able to do with the help of those new traits. In the long run we do not even want to provide a default |
|
This repository has now moved to a subfolder within https://github.com/bytecodealliance/wasm-tools. This current repository will be marked as archived in the future after we've sorted out active PRs, so if you'd like to still merge this then it will need to be opened as a new PR against the new repository. If you have any trouble in doing so, though, please let me know and I can try to help out. now |
|
Thanks @alexcrichton for letting me know. |
Sorry for the bump but have you made up your mind about this @yurydelendik ? |
I tried to find time to experiment with other side of this puzzle by myself -- got occupied with other stuff. What you are proposing makes sense, since we already had this in the code base few years ago. I like the idea of a |
Wow this is interesting to know. Can you point me to some commit where and why this way changed to what it currently is?
Currently this is the initial PR and work I did for this. I have not yet looked into what else is going to be needed to make I currently have time to experiment a little bit more with this idea and will probably look into what else is needed in order to get Another funny idea I had for the |
|
Moved to bytecodealliance/wasm-tools#22. Closed. |
First step towards implementing https://github.com/bytecodealliance/wasmparser/issues/90.
This refactoring of
BrTableis required in order to drop the explicit lifetime from theOperatorenum. We introduce theWasmBrTableandWasmBrTableBuildertraits so that we can later makeOperatorgeneric over user provided types forBrTableand maybe other custom Wasm operators and types in the future.We separated
BrTableandBrTableBuilderin order to make the more importantBrTableless constraint regarding incremental building. At the moment we do not provide users with a way to customize theOperatorenum so we might experience slight performance regressions since aBrTablenow is eagerly constructed instead of deferring its construction.In the long run this procedure should even improve performance since we no longer need to parse the
br_tabletargets twice. Also in some cases we needed to construct an internalbr_tableand users would then construct their own custombr_tableon their side. With this (and follow-up) changes we simply directly construct the user definedbr_tabledirectly.Next Steps
After merging of this PR the next steps to make the parser work on
T: Readinstead of working on a slice of[u8]are:Result<Self::BrTable>inWasmBrTableBuildertrait to allow for use cases where a user doesn't want to supportbr_tableat all.Operatorand replace it with similar technique.BrTablebut this design is scalable for future additions.T: Read.Benchmarks
Sadly I cannot test the performance implications since the benchmark harness seems to be broken on
master. At least I get the following output oncargo benchwithRUST_BACKTRACE=1:Doc Screenshots