RFR: JDK-8264899: C1: -XX:AbortVMOnException does not work if all methods in the call stack are compiled with C1 and there are no exception handlers [v5]

Fei Yang fyang at openjdk.org
Fri Jun 16 11:12:07 UTC 2023


On Thu, 15 Jun 2023 11:23:52 GMT, Damon Fenacci <duke at openjdk.org> wrote:

>> # Problem
>> The `AbortVMOnException` flag prints the stack trace instead of aborting when the code gets compiled with C1.
>> This only happens when the exception gets unwound, all methods in the call stack are compiled with C1 and there are no exception handlers for that exception.
>> This happens here (for x86. Other platform's implementations are similar):
>> 
>> https://github.com/openjdk/jdk/blob/4d4706967d44b6908406818bb135f94130f373a0/src/hotspot/cpu/x86/c1_Runtime1_x86.cpp#L1209-L1215
>> 
>> # Solution
>> To catch this situation, if `AbortVMOnException` is set, a call to check if there is a match is added when unwinding the exception. This is done in the `void Runtime1::generate_unwind_exception` which is the sole call of the `unwind_exception_id` case.
>> 
>> On a few architectures a *move* instruction is needed (e.g. `__ mov(rscratch1, exception_oop)`) to copy the exception oop into a different register that doesn't conflict with the argument of the C calling convention. This is checked with asserts in most architectures but not for *aarch64* (new enhancement issue: [JDK-8310020](https://bugs.openjdk.org/browse/JDK-8310020)).
>> 
>> A regression test is added as well.
>> 
>> # Testing
>> This fix includes changes for x86_32/64 and aarch64, which I could test thoroughly but also for **arm**, **ppc**, **riscv**, and **s390** for which I would **need some help with testing**.
>
> Damon Fenacci has updated the pull request incrementally with one additional commit since the last revision:
> 
>   JDK-8264899: fix exception oop register for s390

Changes requested by fyang (Reviewer).

src/hotspot/cpu/riscv/c1_Runtime1_riscv.cpp line 509:

> 507:     __ leave();
> 508:   }
> 509: 

Hi, the newly-added test case passed on linux-riscv64 with this fix.
But seems that this could still be improved? Something like:

diff --git a/src/hotspot/cpu/riscv/c1_Runtime1_riscv.cpp b/src/hotspot/cpu/riscv/c1_Runtime1_riscv.cpp
index 24b97875910..ea086d46bda 100644
--- a/src/hotspot/cpu/riscv/c1_Runtime1_riscv.cpp
+++ b/src/hotspot/cpu/riscv/c1_Runtime1_riscv.cpp
@@ -499,10 +499,9 @@ void Runtime1::generate_unwind_exception(StubAssembler *sasm) {
   const Register handler_addr = x11;

   if (AbortVMOnException) {
-    __ mv(x15, x10);
     __ enter();
     save_live_registers(sasm);
-    __ call_VM_leaf(CAST_FROM_FN_PTR(address, check_abort_on_vm_exception), x15);
+    __ call_VM_leaf(CAST_FROM_FN_PTR(address, check_abort_on_vm_exception), x10);
     restore_live_registers(sasm);
     __ leave();
   }

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

PR Review: https://git.openjdk.org/jdk/pull/14240#pullrequestreview-1483233924
PR Review Comment: https://git.openjdk.org/jdk/pull/14240#discussion_r1232109606


More information about the hotspot-dev mailing list