@@ -127,8 +127,9 @@ class StubGenerator: public StubCodeGenerator {
127
127
// [ return_from_Java ] <--- sp
128
128
// [ argument word n ]
129
129
// ...
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 ]
132
133
// -32 [ saved f26 ]
133
134
// -31 [ saved f25 ]
134
135
// -30 [ saved f24 ]
@@ -165,8 +166,9 @@ class StubGenerator: public StubCodeGenerator {
165
166
166
167
// Call stub stack layout word offsets from fp
167
168
enum call_stub_layout {
168
- sp_after_call_off = -33 ,
169
+ sp_after_call_off = -34 ,
169
170
171
+ frm_off = sp_after_call_off,
170
172
f27_off = -33 ,
171
173
f26_off = -32 ,
172
174
f25_off = -31 ,
@@ -214,6 +216,7 @@ class StubGenerator: public StubCodeGenerator {
214
216
215
217
const Address sp_after_call (fp, sp_after_call_off * wordSize);
216
218
219
+ const Address frm_save (fp, frm_off * wordSize);
217
220
const Address call_wrapper (fp, call_wrapper_off * wordSize);
218
221
const Address result (fp, result_off * wordSize);
219
222
const Address result_type (fp, result_type_off * wordSize);
@@ -296,6 +299,16 @@ class StubGenerator: public StubCodeGenerator {
296
299
__ fsd (f26, f26_save);
297
300
__ fsd (f27, f27_save);
298
301
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
+
299
312
// install Java thread in global register now we have saved
300
313
// whatever value it held
301
314
__ mv (xthread, c_rarg7);
@@ -413,6 +426,14 @@ class StubGenerator: public StubCodeGenerator {
413
426
414
427
__ ld (x9, x9_save);
415
428
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
+
416
437
__ ld (c_rarg0, call_wrapper);
417
438
__ ld (c_rarg1, result);
418
439
__ ld (c_rarg2, result_type);
0 commit comments