Inlining methods with large switch statements

Vitaly Davidovich vitalyd at
Fri Jun 5 17:08:23 UTC 2015

Thanks John.

A switch should not be measured by the raw size of the instruction.
> If several adjacent keys branch to the same successor, surely that should
> count as a single test and branch.

Although the adjacent keys branching to same successor is yet another case,
it seems like any switch (whether it has adjacent keys or not) that gets
lowered to a jump table should be *heavily* discounted by whatever
heuristic is used.  If the JIT were to incorporate profile info and detect
common targets, then even better :).

Thanks guys.

On Fri, Jun 5, 2015 at 1:02 PM, John Rose <john.r.rose at> wrote:

> Bug updated; thanks!
> On Jun 5, 2015, at 9:04 AM, Vitaly Davidovich <vitalyd at> wrote:
> Right, I didn't see FreqInlineSize on there, and the large jump table
> scenario seemed like one worth calling out as well?
> On Fri, Jun 5, 2015 at 12:03 PM, Roland Westrelin <
> roland.westrelin at> wrote:
>> > By "handled better" I mean for the JIT to not get scared about the
>> bytecode size since machine code is rather compact and quick to execute
>> (especially if the indirect jump via the jump table is predicted well).
>> This is somewhat analogous to the JIT being spooked by methods >
>> MaxInlineSize where the actual bytecode size isn't representative of the
>> real cost (e.g. dead code, asserts, etc), but for FreqInlineSize.
>> John suggested a way to improve our heuristics:
>> Roland.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the hotspot-compiler-dev mailing list