sparse-switch

Purpose

Jump to a new instruction based on the value in the given register, using an ordered table of value-offset pairs, or fall through to the next instruction if there is no match.

Note: The address of the table is guaranteed to be even (that is, 4-byte aligned). If the code size of the method is otherwise odd, then an extra code unit is inserted between the main code and the table whose value is the same as a nop.

Details

Op & Format Mnemonic / Syntax Arguments
2c 31t sparse-switch vAA, +BBBBBBBB (with supplemental data as specified below in "sparse-switch Format") A: register to test
B: signed "branch" offset to table data (32 bits)

Constraints

Behavior

Exceptions

None.

Notes

The low-to-high ordering of the keys allows the VM to employ binary search for the lookup, resulting in O(log table.size) comparisons.