RFR: 8337702: Use new ForwardExceptionNode to call StubRoutines::forward_exception_entry() [v2]

Tobias Hartmann thartmann at openjdk.org
Fri Aug 9 08:39:37 UTC 2024


On Fri, 2 Aug 2024 15:28:04 GMT, Vladimir Kozlov <kvn at openjdk.org> wrote:

>> Currently C2 uses `TailCall` node when it generates code to forward exception in C2 runtime stubs.
>> `StubRoutines::forward_exception_entry()` address is passed as constant and  method pointer is `NULL`: 
>> [generateOptoStub.cpp#L258](https://github.com/openjdk/jdk/blob/master/src/hotspot/share/opto/generateOptoStub.cpp#L258)
>> 
>> On other hand TailCall mach node uses 2 registers as parameter which is hardcoded in `Matcher`: [matcher.cpp#L828](https://github.com/openjdk/jdk/blob/master/src/hotspot/share/opto/matcher.cpp#L828)
>> As result we waste two registers to pass constant and NULL.
>> 
>> Also incorrect relocation is used for such call because the address of `forward_exception` stub passed in register in mach node. When it is converted to `Address` for `jmp` instruction the default `external_word_type` relocation is used when `runtime_call_type` should be used. See discussion in PR [JDK-8337396](https://github.com/openjdk/jdk/pull/20412)
>> 
>> I added new ideal node `ForwardExceptionNode` to solve these issues. It is similar to `Rethrow` node (which mach node definition I used as template) but I kept it based on `Return` node similar to `TailCall` node.
>> 
>> Tested tier1-3,stress,xcomp
>
> Vladimir Kozlov has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Fix arm (32 bits) build

Nice enhancement. 

I noticed that `TailJump` is in vmStructs.cpp, should `ForwardException` be added as well?

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

> 16186: 
> 16187: // Forward exception.
> 16188: instruct ForwardExceptionjmp()

Suggestion:

instruct ForwardException()


Same for other AD files.

src/hotspot/share/opto/callnode.hpp line 160:

> 158: public:
> 159:   ForwardExceptionNode( Node *cntrl, Node *i_o, Node *memory, Node *frameptr, Node *retadr)
> 160:     : ReturnNode( TypeFunc::Parms, cntrl, i_o, memory, frameptr, retadr ) {

Suggestion:

  ForwardExceptionNode(Node* cntrl, Node* i_o, Node* memory, Node* frameptr, Node* retadr)
    : ReturnNode(TypeFunc::Parms, cntrl, i_o, memory, frameptr, retadr) {

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

Marked as reviewed by thartmann (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/20437#pullrequestreview-2229654576
PR Review Comment: https://git.openjdk.org/jdk/pull/20437#discussion_r1711050995
PR Review Comment: https://git.openjdk.org/jdk/pull/20437#discussion_r1711043275


More information about the hotspot-compiler-dev mailing list