Skip to content

Commit 99edb4a

Browse files
author
Vladimir Kozlov
committedAug 12, 2024
8337702: Use new ForwardExceptionNode to call StubRoutines::forward_exception_entry()
Reviewed-by: thartmann
1 parent 8d08314 commit 99edb4a

File tree

15 files changed

+153
-25
lines changed

15 files changed

+153
-25
lines changed
 

‎src/hotspot/cpu/aarch64/aarch64.ad

+13
Original file line numberDiff line numberDiff line change
@@ -16184,6 +16184,19 @@ instruct TailjmpInd(iRegPNoSpNoRfp jump_target, iRegP_R0 ex_oop)
1618416184
ins_pipe(pipe_class_call);
1618516185
%}
1618616186

16187+
// Forward exception.
16188+
instruct ForwardExceptionjmp()
16189+
%{
16190+
match(ForwardException);
16191+
ins_cost(CALL_COST);
16192+
16193+
format %{ "b forward_exception_stub" %}
16194+
ins_encode %{
16195+
__ far_jump(RuntimeAddress(StubRoutines::forward_exception_entry()));
16196+
%}
16197+
ins_pipe(pipe_class_call);
16198+
%}
16199+
1618716200
// Create exception oop: created by stack-crawling runtime code.
1618816201
// Created exception is now available to this handler, and is setup
1618916202
// just prior to jumping to this handler. No code emitted.

‎src/hotspot/cpu/arm/arm.ad

+14
Original file line numberDiff line numberDiff line change
@@ -8953,6 +8953,20 @@ instruct tailjmpInd(IPRegP jump_target, RExceptionRegP ex_oop) %{
89538953
ins_pipe(tail_call);
89548954
%}
89558955

8956+
// Forward exception.
8957+
instruct ForwardExceptionjmp()
8958+
%{
8959+
match(ForwardException);
8960+
ins_cost(CALL_COST);
8961+
8962+
format %{ "b forward_exception_stub" %}
8963+
ins_encode %{
8964+
// OK to trash Rtemp, because Rtemp is used by stub
8965+
__ jump(StubRoutines::forward_exception_entry(), relocInfo::runtime_call_type, Rtemp);
8966+
%}
8967+
ins_pipe(tail_call);
8968+
%}
8969+
89568970
// Create exception oop: created by stack-crawling runtime code.
89578971
// Created exception is now available to this handler, and is setup
89588972
// just prior to jumping to this handler. No code emitted.

‎src/hotspot/cpu/ppc/ppc.ad

+15
Original file line numberDiff line numberDiff line change
@@ -14534,6 +14534,21 @@ instruct tailjmpInd(iRegPdstNoScratch jump_target, rarg1RegP ex_oop) %{
1453414534
ins_pipe(pipe_class_call);
1453514535
%}
1453614536

14537+
// Forward exception.
14538+
instruct ForwardExceptionjmp()
14539+
%{
14540+
match(ForwardException);
14541+
ins_cost(CALL_COST);
14542+
14543+
format %{ "Jmp forward_exception_stub" %}
14544+
ins_encode %{
14545+
__ set_inst_mark();
14546+
__ b64_patchable(StubRoutines::forward_exception_entry(), relocInfo::runtime_call_type);
14547+
__ clear_inst_mark();
14548+
%}
14549+
ins_pipe(pipe_class_call);
14550+
%}
14551+
1453714552
// Create exception oop: created by stack-crawling runtime code.
1453814553
// Created exception is now available to this handler, and is setup
1453914554
// just prior to jumping to this handler. No code emitted.

‎src/hotspot/cpu/riscv/riscv.ad

+16
Original file line numberDiff line numberDiff line change
@@ -10617,6 +10617,22 @@ instruct TailjmpInd(iRegPNoSpNoFp jump_target, iRegP_R10 ex_oop)
1061710617
ins_pipe(pipe_class_call);
1061810618
%}
1061910619

10620+
// Forward exception.
10621+
instruct ForwardExceptionjmp()
10622+
%{
10623+
match(ForwardException);
10624+
10625+
ins_cost(BRANCH_COST);
10626+
10627+
format %{ "j forward_exception_stub\t#@ForwardException" %}
10628+
10629+
ins_encode %{
10630+
__ far_jump(RuntimeAddress(StubRoutines::forward_exception_entry()));
10631+
%}
10632+
10633+
ins_pipe(pipe_class_call);
10634+
%}
10635+
1062010636
// Create exception oop: created by stack-crawling runtime code.
1062110637
// Created exception is now available to this handler, and is setup
1062210638
// just prior to jumping to this handler. No code emitted.

‎src/hotspot/cpu/s390/s390.ad

+14
Original file line numberDiff line numberDiff line change
@@ -9517,6 +9517,20 @@ instruct tailjmpInd(iRegP jump_target, rarg1RegP ex_oop) %{
95179517
ins_pipe(pipe_class_dummy);
95189518
%}
95199519

9520+
// Forward exception.
9521+
instruct ForwardExceptionjmp() %{
9522+
match(ForwardException);
9523+
ins_cost(CALL_COST);
9524+
format %{ "Jmp forward_exception_stub" %}
9525+
ins_encode %{
9526+
__ set_inst_mark();
9527+
__ load_const_optimized(Z_R1_scratch, (address)StubRoutines::forward_exception_entry());
9528+
__ z_br(Z_R1_scratch);
9529+
__ clear_inst_mark();
9530+
%}
9531+
ins_pipe(pipe_class_dummy);
9532+
%}
9533+
95209534
// Create exception oop: created by stack-crawling runtime code.
95219535
// Created exception is now available to this handler, and is setup
95229536
// just prior to jumping to this handler. No code emitted.

‎src/hotspot/cpu/x86/x86_32.ad

+12
Original file line numberDiff line numberDiff line change
@@ -13583,6 +13583,18 @@ instruct tailjmpInd(eRegP_no_EBP jump_target, eAXRegP ex_oop) %{
1358313583
ins_pipe( pipe_jmp );
1358413584
%}
1358513585

13586+
// Forward exception.
13587+
instruct ForwardExceptionjmp()
13588+
%{
13589+
match(ForwardException);
13590+
13591+
format %{ "JMP forward_exception_stub" %}
13592+
ins_encode %{
13593+
__ jump(RuntimeAddress(StubRoutines::forward_exception_entry()), noreg);
13594+
%}
13595+
ins_pipe(pipe_jmp);
13596+
%}
13597+
1358613598
// Create exception oop: created by stack-crawling runtime code.
1358713599
// Created exception is now available to this handler, and is setup
1358813600
// just prior to jumping to this handler. No code emitted.

‎src/hotspot/cpu/x86/x86_64.ad

+12
Original file line numberDiff line numberDiff line change
@@ -12592,6 +12592,18 @@ instruct tailjmpInd(no_rbp_RegP jump_target, rax_RegP ex_oop)
1259212592
ins_pipe(pipe_jmp);
1259312593
%}
1259412594

12595+
// Forward exception.
12596+
instruct ForwardExceptionjmp()
12597+
%{
12598+
match(ForwardException);
12599+
12600+
format %{ "jmp forward_exception_stub" %}
12601+
ins_encode %{
12602+
__ jump(RuntimeAddress(StubRoutines::forward_exception_entry()), noreg);
12603+
%}
12604+
ins_pipe(pipe_jmp);
12605+
%}
12606+
1259512607
// Create exception oop: created by stack-crawling runtime code.
1259612608
// Created exception is now available to this handler, and is setup
1259712609
// just prior to jumping to this handler. No code emitted.

‎src/hotspot/share/adlc/formssel.cpp

+19-15
Original file line numberDiff line numberDiff line change
@@ -210,15 +210,16 @@ bool InstructForm::is_pinned(FormDict &globals) {
210210
if ( ! _matrule) return false;
211211

212212
int index = 0;
213-
if (_matrule->find_type("Goto", index)) return true;
214-
if (_matrule->find_type("If", index)) return true;
215-
if (_matrule->find_type("CountedLoopEnd",index)) return true;
216-
if (_matrule->find_type("Return", index)) return true;
217-
if (_matrule->find_type("Rethrow", index)) return true;
218-
if (_matrule->find_type("TailCall", index)) return true;
219-
if (_matrule->find_type("TailJump", index)) return true;
220-
if (_matrule->find_type("Halt", index)) return true;
221-
if (_matrule->find_type("Jump", index)) return true;
213+
if (_matrule->find_type("Goto", index)) return true;
214+
if (_matrule->find_type("If", index)) return true;
215+
if (_matrule->find_type("CountedLoopEnd", index)) return true;
216+
if (_matrule->find_type("Return", index)) return true;
217+
if (_matrule->find_type("Rethrow", index)) return true;
218+
if (_matrule->find_type("TailCall", index)) return true;
219+
if (_matrule->find_type("TailJump", index)) return true;
220+
if (_matrule->find_type("ForwardException", index)) return true;
221+
if (_matrule->find_type("Halt", index)) return true;
222+
if (_matrule->find_type("Jump", index)) return true;
222223

223224
return is_parm(globals);
224225
}
@@ -228,12 +229,13 @@ bool InstructForm::is_projection(FormDict &globals) {
228229
if ( ! _matrule) return false;
229230

230231
int index = 0;
231-
if (_matrule->find_type("Goto", index)) return true;
232-
if (_matrule->find_type("Return", index)) return true;
233-
if (_matrule->find_type("Rethrow", index)) return true;
234-
if (_matrule->find_type("TailCall",index)) return true;
235-
if (_matrule->find_type("TailJump",index)) return true;
236-
if (_matrule->find_type("Halt", index)) return true;
232+
if (_matrule->find_type("Goto", index)) return true;
233+
if (_matrule->find_type("Return", index)) return true;
234+
if (_matrule->find_type("Rethrow", index)) return true;
235+
if (_matrule->find_type("TailCall", index)) return true;
236+
if (_matrule->find_type("TailJump", index)) return true;
237+
if (_matrule->find_type("ForwardException", index)) return true;
238+
if (_matrule->find_type("Halt", index)) return true;
237239

238240
return false;
239241
}
@@ -376,6 +378,7 @@ bool InstructForm::is_ideal_return() const {
376378
if (_matrule->find_type("Rethrow",index)) return true;
377379
if (_matrule->find_type("TailCall",index)) return true;
378380
if (_matrule->find_type("TailJump",index)) return true;
381+
if (_matrule->find_type("ForwardException", index)) return true;
379382

380383
return false;
381384
}
@@ -894,6 +897,7 @@ uint InstructForm::oper_input_base(FormDict &globals) {
894897
strcmp(_matrule->_opType,"Rethrow" )==0 ||
895898
strcmp(_matrule->_opType,"TailCall" )==0 ||
896899
strcmp(_matrule->_opType,"TailJump" )==0 ||
900+
strcmp(_matrule->_opType,"ForwardException")==0 ||
897901
strcmp(_matrule->_opType,"SafePoint" )==0 ||
898902
strcmp(_matrule->_opType,"Halt" )==0 )
899903
return AdlcVMDeps::Parms; // Skip the machine-state edges

‎src/hotspot/share/opto/callnode.hpp

+11
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,17 @@ class RethrowNode : public Node {
152152
};
153153

154154

155+
//------------------------------ForwardExceptionNode---------------------------
156+
// Pop stack frame and jump to StubRoutines::forward_exception_entry()
157+
class ForwardExceptionNode : public ReturnNode {
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) {
161+
}
162+
163+
virtual int Opcode() const;
164+
};
165+
155166
//------------------------------TailCallNode-----------------------------------
156167
// Pop stack frame and jump indirect
157168
class TailCallNode : public ReturnNode {

‎src/hotspot/share/opto/classes.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ macro(FastLock)
184184
macro(FastUnlock)
185185
macro(FmaD)
186186
macro(FmaF)
187+
macro(ForwardException)
187188
macro(Goto)
188189
macro(Halt)
189190
macro(CountPositives)

‎src/hotspot/share/opto/domgraph.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ uint Block_Stack::most_frequent_successor( Block *b ) {
239239
break;
240240
case Op_TailCall:
241241
case Op_TailJump:
242+
case Op_ForwardException:
242243
case Op_Return:
243244
case Op_Halt:
244245
case Op_Rethrow:

‎src/hotspot/share/opto/gcm.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -2031,6 +2031,7 @@ float Block::succ_prob(uint i) {
20312031

20322032
case Op_TailCall:
20332033
case Op_TailJump:
2034+
case Op_ForwardException:
20342035
case Op_Return:
20352036
case Op_Halt:
20362037
case Op_Rethrow:
@@ -2084,6 +2085,7 @@ int Block::num_fall_throughs() {
20842085
case Op_NeverBranch:
20852086
case Op_TailCall:
20862087
case Op_TailJump:
2088+
case Op_ForwardException:
20872089
case Op_Return:
20882090
case Op_Halt:
20892091
case Op_Rethrow:
@@ -2129,6 +2131,7 @@ bool Block::succ_fall_through(uint i) {
21292131
case Op_NeverBranch:
21302132
case Op_TailCall:
21312133
case Op_TailJump:
2134+
case Op_ForwardException:
21322135
case Op_Return:
21332136
case Op_Halt:
21342137
case Op_Rethrow:

‎src/hotspot/share/opto/generateOptoStub.cpp

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -255,13 +255,11 @@ void GraphKit::gen_stub(address C_function,
255255
Node* if_not_null = _gvn.transform( new IfTrueNode(iff) );
256256

257257
assert (StubRoutines::forward_exception_entry() != nullptr, "must be generated before");
258-
Node *exc_target = makecon(TypeRawPtr::make( StubRoutines::forward_exception_entry() ));
259-
Node *to_exc = new TailCallNode(if_not_null,
260-
i_o(),
261-
exit_memory,
262-
frameptr(),
263-
returnadr(),
264-
exc_target, null());
258+
Node *to_exc = new ForwardExceptionNode(if_not_null,
259+
i_o(),
260+
exit_memory,
261+
frameptr(),
262+
returnadr());
265263
root()->add_req(_gvn.transform(to_exc)); // bind to root to keep live
266264
C->init_start(start);
267265

‎src/hotspot/share/opto/matcher.cpp

+14-1
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,10 @@ void Matcher::Fixup_Save_On_Entry( ) {
804804
if (ret_edge_cnt > TypeFunc::Parms)
805805
ret_rms[TypeFunc::Parms+0] = _return_value_mask;
806806

807+
// Input RegMask array shared by all ForwardExceptions
808+
uint forw_exc_edge_cnt = TypeFunc::Parms;
809+
RegMask* forw_exc_rms = init_input_masks( forw_exc_edge_cnt + soe_cnt, _return_addr_mask, c_frame_ptr_mask );
810+
807811
// Input RegMask array shared by all Rethrows.
808812
uint reth_edge_cnt = TypeFunc::Parms+1;
809813
RegMask *reth_rms = init_input_masks( reth_edge_cnt + soe_cnt, _return_addr_mask, c_frame_ptr_mask );
@@ -863,6 +867,7 @@ void Matcher::Fixup_Save_On_Entry( ) {
863867
case Op_Rethrow : exit->_in_rms = reth_rms; break;
864868
case Op_TailCall : exit->_in_rms = tail_call_rms; break;
865869
case Op_TailJump : exit->_in_rms = tail_jump_rms; break;
870+
case Op_ForwardException: exit->_in_rms = forw_exc_rms; break;
866871
case Op_Halt : exit->_in_rms = halt_rms; break;
867872
default : ShouldNotReachHere();
868873
}
@@ -882,6 +887,7 @@ void Matcher::Fixup_Save_On_Entry( ) {
882887
reth_rms [ reth_edge_cnt] = mreg2regmask[i];
883888
tail_call_rms[tail_call_edge_cnt] = mreg2regmask[i];
884889
tail_jump_rms[tail_jump_edge_cnt] = mreg2regmask[i];
890+
forw_exc_rms [ forw_exc_edge_cnt] = mreg2regmask[i];
885891
// Halts need the SOE registers, but only in the stack as debug info.
886892
// A just-prior uncommon-trap or deoptimization will use the SOE regs.
887893
halt_rms [ halt_edge_cnt] = *idealreg2spillmask[_register_save_type[i]];
@@ -899,6 +905,7 @@ void Matcher::Fixup_Save_On_Entry( ) {
899905
reth_rms [ reth_edge_cnt].Insert(OptoReg::Name(i+1));
900906
tail_call_rms[tail_call_edge_cnt].Insert(OptoReg::Name(i+1));
901907
tail_jump_rms[tail_jump_edge_cnt].Insert(OptoReg::Name(i+1));
908+
forw_exc_rms [ forw_exc_edge_cnt].Insert(OptoReg::Name(i+1));
902909
halt_rms [ halt_edge_cnt].Insert(OptoReg::Name(i+1));
903910
mproj = new MachProjNode( start, proj_cnt, ret_rms[ret_edge_cnt], Op_RegD );
904911
proj_cnt += 2; // Skip 2 for doubles
@@ -911,6 +918,7 @@ void Matcher::Fixup_Save_On_Entry( ) {
911918
reth_rms [ reth_edge_cnt] = RegMask::Empty;
912919
tail_call_rms[tail_call_edge_cnt] = RegMask::Empty;
913920
tail_jump_rms[tail_jump_edge_cnt] = RegMask::Empty;
921+
forw_exc_rms [ forw_exc_edge_cnt] = RegMask::Empty;
914922
halt_rms [ halt_edge_cnt] = RegMask::Empty;
915923
mproj = C->top();
916924
}
@@ -925,6 +933,7 @@ void Matcher::Fixup_Save_On_Entry( ) {
925933
reth_rms [ reth_edge_cnt].Insert(OptoReg::Name(i+1));
926934
tail_call_rms[tail_call_edge_cnt].Insert(OptoReg::Name(i+1));
927935
tail_jump_rms[tail_jump_edge_cnt].Insert(OptoReg::Name(i+1));
936+
forw_exc_rms [ forw_exc_edge_cnt].Insert(OptoReg::Name(i+1));
928937
halt_rms [ halt_edge_cnt].Insert(OptoReg::Name(i+1));
929938
mproj = new MachProjNode( start, proj_cnt, ret_rms[ret_edge_cnt], Op_RegL );
930939
proj_cnt += 2; // Skip 2 for longs
@@ -937,6 +946,7 @@ void Matcher::Fixup_Save_On_Entry( ) {
937946
reth_rms [ reth_edge_cnt] = RegMask::Empty;
938947
tail_call_rms[tail_call_edge_cnt] = RegMask::Empty;
939948
tail_jump_rms[tail_jump_edge_cnt] = RegMask::Empty;
949+
forw_exc_rms [ forw_exc_edge_cnt] = RegMask::Empty;
940950
halt_rms [ halt_edge_cnt] = RegMask::Empty;
941951
mproj = C->top();
942952
} else {
@@ -948,11 +958,13 @@ void Matcher::Fixup_Save_On_Entry( ) {
948958
reth_edge_cnt ++;
949959
tail_call_edge_cnt ++;
950960
tail_jump_edge_cnt ++;
961+
forw_exc_edge_cnt++;
951962
halt_edge_cnt ++;
952963

953964
// Add a use of the SOE register to all exit paths
954-
for( uint j=1; j < root->req(); j++ )
965+
for (uint j=1; j < root->req(); j++) {
955966
root->in(j)->add_req(mproj);
967+
}
956968
} // End of if a save-on-entry register
957969
} // End of for all machine registers
958970
}
@@ -1070,6 +1082,7 @@ static void match_alias_type(Compile* C, Node* n, Node* m) {
10701082
case Op_Halt:
10711083
case Op_TailCall:
10721084
case Op_TailJump:
1085+
case Op_ForwardException:
10731086
nidx = Compile::AliasIdxBot;
10741087
nat = TypePtr::BOTTOM;
10751088
break;

‎src/hotspot/share/runtime/vmStructs.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1422,6 +1422,7 @@
14221422
declare_c2_type(RethrowNode, Node) \
14231423
declare_c2_type(TailCallNode, ReturnNode) \
14241424
declare_c2_type(TailJumpNode, ReturnNode) \
1425+
declare_c2_type(ForwardExceptionNode, ReturnNode) \
14251426
declare_c2_type(SafePointNode, MultiNode) \
14261427
declare_c2_type(CallNode, SafePointNode) \
14271428
declare_c2_type(CallJavaNode, CallNode) \

1 commit comments

Comments
 (1)

openjdk-notifier[bot] commented on Aug 12, 2024

@openjdk-notifier[bot]
Please sign in to comment.