Why there is no RJUMPV
The EIP-615 proposes new jump instruction
JUMPV which looks up the jump destination in the adjusted array using the index value taken from the stack. For good reason similar control-flow instructions exist in most if not all IRs.
However, I have not found any common use-case in contracts development justifying relatively high complexity of the instruction (e.g. encoding of the array in bytecode, handling invalid index values). Furthermore, nothing prevents adding such instruction in future if it turns out to be needed.
Such instruction can help with implementing switch statements, but only if case constants are continuous or at least dense.
The most used “switch” in every solidity contract is the external function dispatch. But
JUMPV will not help here as the functions ids are “hashed” values (sparse). You would first need to the index of a function id but then you don’t need
JUMPV any more as a static jump will do.
I also wanted search solidity source codes on GitHub to check for interesting usages of
switch. Just to realize solidity does not support
switch statement at all.
JUMPV indeed matches the semantics of
br_table from WebAssembly. However, the LLVM IR has extended variant of such control flow instruction called
switch. There instead of a table of indexes we have “an array of pairs of comparison value constants and [jump destinations]”. This would handle function dispatch use-case, but it complicates the instruction even more.
If I’m mistaken and there are valid use-cases for
JUMPV please let me know.