RFR: 8339299: C1 will miss type profile when inline final method

Dean Long dlong at openjdk.org
Fri Aug 30 21:41:24 UTC 2024


On Fri, 30 Aug 2024 07:25:59 GMT, kuaiwei <duke at openjdk.org> wrote:

> I found sometimes C1 will miss type profile and I tried to write a test to demonstrate it.
> It will happen with these conditions
> 1 It's a virtual call and the callee is a final method. So c1 will think it's static bound.
> 2 The interpreter never touch the callsite, so interpreter does not add type profile.
> 3 In c1 compilation, it will be inlined based on CHA.
> 4 In c2 compilation, the CHA is broken, but type profile is missing, so c2 can not inline it.

src/hotspot/share/c1/c1_LIR.hpp line 2037:

> 2035:     bool callee_is_static = _profiled_callee->is_loaded() && _profiled_callee->is_static();
> 2036:     Bytecodes::Code bc = _profiled_method->java_code_at_bci(_profiled_bci);
> 2037:     bool call_is_virtual = (bc == Bytecodes::_invokevirtual && (UseCHA || !_profiled_callee->can_be_statically_bound())) || bc == Bytecodes::_invokeinterface;

UseCHA is on by default, so this effectively always turns on profiling.  I think it would be better if we set a flag that says if CHA was used or not.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/20786#discussion_r1739431991


More information about the hotspot-compiler-dev mailing list