code generation of a switch on an enum
Andrew Haley
aph at redhat.com
Sat Sep 13 07:31:08 UTC 2014
On 12/09/14 20:57, Vitaly Davidovich wrote:
> Sorry, I think I wasn't clear. I'm asking why the JIT decided to do a
> decision tree rather than a jump table. Naively, this example seems like a
> classic jump table approach. If there's no strong profile indicating that
> a given value is always used and the value range is dense, the jump table
> should be preferred as (a) the JIT already loads the switch table I
> believe, so there's a memory access already and (b) this becomes an
> unconditional jump rather than a mess of branches.
You have to measure it. A mess of branches can play much better with
branch predictors than an indirect jump.
Andrew.
More information about the hotspot-compiler-dev
mailing list