[lworld] RFR: 8235753: [lworld] Handle deoptimization when buffering scalarized inline type args in C1

Tobias Hartmann thartmann at openjdk.java.net
Fri Mar 27 13:48:59 UTC 2020


When calling from C2 to C1 compiled code (i.e., no adapter in between) we need to buffer scalarized value type
arguments in the C1 compiled entry point of the method (because C1 requires an oop). To do that, we might need to call
into the runtime and that call might trigger deoptimization of the C1 compiled caller. That's a problem because the
arguments are still scalarized and neither the deopt code nor the interpreter know how to handle that state. It's not a
problem for all the other cases where buffering is necessary because it's either in the c2i adapter or C2 compiled code
where we can handle this already.

After trying all my ideas listed in JBS, I've ended up with the following solution:
When deoptimization of a C1 frame that is currently in a runtime call to buffer_value_args_xxx is performed, don't
patch the return address but only set the orig_pc in the frame (see changes to frame::deoptimize). This delays
deoptimization until we enter the method body where a new runtime check added in LIRGenerator::do_Base will detect the
pending deoptimization by checking the original_pc and jump to a deopt stub. This requires initializing the original_pc
to zero at the beginning of the method entry (because it usually contains garbage).

The patch also fixes the following problems:
- Stack banging code is accidentally skipped when entering the C1 method through a scalarized entry
- A clinit_barrier is never needed if the method is non-static
- Refactoring, conversion of some checks to asserts, better comments

Thanks,
Tobias

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

Commit messages:
 - 8235753: [lworld] Handle deoptimization when buffering scalarized inline type args in C1

Changes: https://git.openjdk.java.net/valhalla/pull/6/files
 Webrev: https://webrevs.openjdk.java.net/valhalla/6/webrev.00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8235753
  Stats: 215 lines in 13 files changed: 110 ins; 41 del; 64 mod
  Patch: https://git.openjdk.java.net/valhalla/pull/6.diff
  Fetch: git fetch https://git.openjdk.java.net/valhalla pull/6/head:pull/6

PR: https://git.openjdk.java.net/valhalla/pull/6


More information about the valhalla-dev mailing list