Skip to content

Commit 68a2d93

Browse files
zifeihanRealFYang
authored andcommitted
8330094: RISC-V: Save and restore FRM in the call stub
Reviewed-by: fyang Backport-of: b0496096dc8d7dc7acf28aa006141a3ecea446de
1 parent 32bf1f4 commit 68a2d93

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

src/hotspot/cpu/riscv/frame_riscv.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@
133133
// Entry frames
134134
// n.b. these values are determined by the layout defined in
135135
// stubGenerator for the Java call stub
136-
entry_frame_after_call_words = 34,
136+
entry_frame_after_call_words = 35,
137137
entry_frame_call_wrapper_offset = -10,
138138

139139
// we don't need a save area

src/hotspot/cpu/riscv/stubGenerator_riscv.cpp

+24-3
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,9 @@ class StubGenerator: public StubCodeGenerator {
127127
// [ return_from_Java ] <--- sp
128128
// [ argument word n ]
129129
// ...
130-
// -34 [ argument word 1 ]
131-
// -33 [ saved f27 ] <--- sp_after_call
130+
// -35 [ argument word 1 ]
131+
// -34 [ saved FRM in Floating-point Control and Status Register ] <--- sp_after_call
132+
// -33 [ saved f27 ]
132133
// -32 [ saved f26 ]
133134
// -31 [ saved f25 ]
134135
// -30 [ saved f24 ]
@@ -165,8 +166,9 @@ class StubGenerator: public StubCodeGenerator {
165166

166167
// Call stub stack layout word offsets from fp
167168
enum call_stub_layout {
168-
sp_after_call_off = -33,
169+
sp_after_call_off = -34,
169170

171+
frm_off = sp_after_call_off,
170172
f27_off = -33,
171173
f26_off = -32,
172174
f25_off = -31,
@@ -214,6 +216,7 @@ class StubGenerator: public StubCodeGenerator {
214216

215217
const Address sp_after_call (fp, sp_after_call_off * wordSize);
216218

219+
const Address frm_save (fp, frm_off * wordSize);
217220
const Address call_wrapper (fp, call_wrapper_off * wordSize);
218221
const Address result (fp, result_off * wordSize);
219222
const Address result_type (fp, result_type_off * wordSize);
@@ -296,6 +299,16 @@ class StubGenerator: public StubCodeGenerator {
296299
__ fsd(f26, f26_save);
297300
__ fsd(f27, f27_save);
298301

302+
__ frrm(t0);
303+
__ sd(t0, frm_save);
304+
// Set frm to the state we need. We do want Round to Nearest. We
305+
// don't want non-IEEE rounding modes.
306+
Label skip_fsrmi;
307+
guarantee(__ RoundingMode::rne == 0, "must be");
308+
__ beqz(t0, skip_fsrmi);
309+
__ fsrmi(__ RoundingMode::rne);
310+
__ bind(skip_fsrmi);
311+
299312
// install Java thread in global register now we have saved
300313
// whatever value it held
301314
__ mv(xthread, c_rarg7);
@@ -413,6 +426,14 @@ class StubGenerator: public StubCodeGenerator {
413426

414427
__ ld(x9, x9_save);
415428

429+
// restore frm
430+
Label skip_fsrm;
431+
__ ld(t0, frm_save);
432+
__ frrm(t1);
433+
__ beq(t0, t1, skip_fsrm);
434+
__ fsrm(t0);
435+
__ bind(skip_fsrm);
436+
416437
__ ld(c_rarg0, call_wrapper);
417438
__ ld(c_rarg1, result);
418439
__ ld(c_rarg2, result_type);

0 commit comments

Comments
 (0)