RFR: 8365047: Remove exception handler stub code in C2 [v4]

Andrew Dinn adinn at openjdk.org
Mon Sep 15 09:26:21 UTC 2025


On Fri, 12 Sep 2025 16:36:56 GMT, Ruben <duke at openjdk.org> wrote:

>> The C2 exception handler stub code is only a trampoline to the generated exception handler blob. This change removes the extra step on the way to the generated blob.
>> 
>> According to some comments in the source code, the exception handler stub code used to be patched upon deoptimization, however presumably these comments are outdated as the patching upon deoptimization happens for post-call NOPs only.
>
> Ruben has updated the pull request incrementally with two additional commits since the last revision:
> 
>  - Offset the deoptimization handler entry point
>    
>    Change-Id: I596317ec6a364b341e4642636fa5cf08f87ed722
>  - Revert "Ensure stub code is not adjacent to a call"

This is a nice, uniform fix that makes the way the deopt entry interacts with the frame code check much clearer. I think we would benefit from a comment in each generator to explain the indirect order of entry and call.

src/hotspot/cpu/aarch64/aarch64.ad line 2276:

> 2274:   __ far_call(RuntimeAddress(SharedRuntime::deopt_blob()->unpack()));
> 2275: 
> 2276:   int entry_point = __ offset();

I feel we ought to have a comment somewhere that explains why this backward jump exists so that no one subsequently tries to 'optimize' it away. It would be most helpful right here in the code -- even though that means repeating it in every port's generator file

Suggestion:

  // the entry point is placed immediately after the unpack call so we can test for
  // it as a return PC marking the nmethod being in deopt
  int entry_point = __ offset();

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

Marked as reviewed by adinn (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/26678#pullrequestreview-3223645152
PR Review Comment: https://git.openjdk.org/jdk/pull/26678#discussion_r2348370056


More information about the hotspot-dev mailing list