Open florianhartung opened 3 months ago
This issue exists to discuss solutions for matching opcodes and their arguments.
The initial solution was to match just the opcode byte and then read the opcode's arguments:
match wasm.read_u8().unwrap() { MY_OPCODE => { let some_opcode_argument = wasm.read_var_u32()?; ... } }
Then the approach to use slice patterns for matching was suggested:
match &wasm.full_contents[wasm.pc..] { [MY_OPCODE, ..] => { .. } }
Here we could also match some arguments directly:
[MY_OPCODE, some_opcode_argument, ..] => { .. }
However this only works for fixed-size arguments and WASM integers are encoded through a variable-length encoding format (specified here).
[MY_OPCODE_BYTE1, MY_OPCODE_BYTE2, ..] => { .. }
Personally I'd prefer the 3. solution.
Also I'm curious about what your opinion is on this topic @wucke13
This issue exists to discuss solutions for matching opcodes and their arguments.
Summary of the initial discussion (https://github.com/DLR-FT/wasm-interpreter/pull/23#discussion_r1665625248)
The initial solution was to match just the opcode byte and then read the opcode's arguments:
Then the approach to use slice patterns for matching was suggested:
Here we could also match some arguments directly:
However this only works for fixed-size arguments and WASM integers are encoded through a variable-length encoding format (specified here).
Solutions