Skip to content

Commit 8b1d228

Browse files
committed
adding assert and frame extension for exception
1 parent 6817e8c commit 8b1d228

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

src/hotspot/cpu/s390/interp_masm_s390.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -575,11 +575,17 @@ void InterpreterMacroAssembler::store_ptr(int n, Register val) {
575575
void InterpreterMacroAssembler::prepare_to_jump_from_interpreted(Register method) {
576576
// Satisfy interpreter calling convention (see generate_normal_entry()).
577577
z_lgr(Z_R10, Z_SP); // Set sender sp (aka initial caller sp, aka unextended sp).
578-
// Record top_frame_sp, because the callee might modify it, if it's compiled.
579-
assert_different_registers(Z_R1, method);
580-
z_sgrk(Z_R1, Z_SP, Z_fp);
581-
z_srag(Z_R1, Z_R1, Interpreter::logStackElementSize);
582-
z_stg(Z_R1, _z_ijava_state_neg(top_frame_sp), Z_fp);
578+
#ifdef ASSERT
579+
NearLabel ok;
580+
Register tmp = Z_R1;
581+
z_lg(tmp, Address(Z_fp, _z_ijava_state_neg(top_frame_sp)));
582+
z_slag(tmp, tmp, Interpreter::logStackElementSize);
583+
z_agr(tmp, Z_fp);
584+
z_cgr(tmp, Z_SP);
585+
z_bre(ok);
586+
stop("corrupted top_frame_sp");
587+
bind(ok);
588+
#endif
583589
save_bcp();
584590
save_esp();
585591
z_lgr(Z_method, method); // Set Z_method (kills Z_fp!).

src/hotspot/cpu/s390/templateInterpreterGenerator_s390.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2073,6 +2073,14 @@ void TemplateInterpreterGenerator::generate_throw_exception() {
20732073
__ z_lg(Z_fp, _z_abi(callers_sp), Z_SP); // Frame accessors use Z_fp.
20742074
// Z_ARG1 (==Z_tos): exception
20752075
// Z_ARG2 : Return address/pc that threw exception.
2076+
{
2077+
Register top_frame_sp = Z_R1_scratch; // anyway going to load it with correct value
2078+
__ z_lg(top_frame_sp, Address(Z_fp, _z_ijava_state_neg(top_frame_sp)));
2079+
__ z_slag(top_frame_sp, top_frame_sp, Interpreter::logStackElementSize);
2080+
__ z_agr(top_frame_sp, Z_fp);
2081+
2082+
__ resize_frame_absolute(top_frame_sp, /* temp = */ Z_R0, /* load_fp = */ true);
2083+
}
20762084
__ restore_bcp(); // R13 points to call/send.
20772085
__ restore_locals();
20782086

@@ -2180,6 +2188,14 @@ void TemplateInterpreterGenerator::generate_throw_exception() {
21802188
false, // install_monitor_exception
21812189
false); // notify_jvmdi
21822190
__ z_lg(Z_fp, _z_abi(callers_sp), Z_SP); // Restore frame pointer.
2191+
{
2192+
Register top_frame_sp = Z_R1_scratch;
2193+
__ z_lg(top_frame_sp, Address(Z_fp, _z_ijava_state_neg(top_frame_sp)));
2194+
__ z_slag(top_frame_sp, top_frame_sp, Interpreter::logStackElementSize);
2195+
__ z_agr(top_frame_sp, Z_fp);
2196+
2197+
__ resize_frame_absolute(top_frame_sp, /* temp = */ Z_R0, /* load_fp = */ true);
2198+
}
21832199
__ restore_bcp();
21842200
__ restore_locals();
21852201
__ restore_esp();

0 commit comments

Comments
 (0)