RFR(S): 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
tobias.hartmann at oracle.com
Tue Oct 27 11:17:18 UTC 2015
please review the following patch.
C2 merges the branches for an If and the dominating If into a single region that branches to the uncommon trap for the dominating If to optimize explicit range checks. The problem is that if the dominating If branches to an uncommon trap with 'Reason_unloaded', the merged uncommon trap will not re-execute the checks but directly execute the branch of the first If. This leads to wrong code being executed. Since we don't know which of the two checks failed, we have to re-execute both.
As Roland pointed out, IfNode::has_only_uncommon_traps() should check if the dominating uncommon trap has 'Reason_unstable_if' to ensure that we re-execute the bytecode after deoptimization. The type of the dominated uncommon trap does not matter in this case.
Regression test and JPRT. I also compared the PrintOptoAssembly output of TestExcplicitRangChecks to the baseline version to make sure that all range checks are still folded.
More information about the hotspot-compiler-dev