@@ -141,7 +141,8 @@ class StubGenerator: public StubCodeGenerator {
141
141
// [ return_from_Java ] <--- sp
142
142
// [ argument word n ]
143
143
// ...
144
- // -27 [ argument word 1 ]
144
+ // -29 [ argument word 1 ]
145
+ // -28 [ saved Floating-point Control Register ]
145
146
// -26 [ saved v15 ] <--- sp_after_call
146
147
// -25 [ saved v14 ]
147
148
// -24 [ saved v13 ]
@@ -173,8 +174,9 @@ class StubGenerator: public StubCodeGenerator {
173
174
174
175
// Call stub stack layout word offsets from fp
175
176
enum call_stub_layout {
176
- sp_after_call_off = -26 ,
177
+ sp_after_call_off = -28 ,
177
178
179
+ fpcr_off = sp_after_call_off,
178
180
d15_off = -26 ,
179
181
d13_off = -24 ,
180
182
d11_off = -22 ,
@@ -204,8 +206,9 @@ class StubGenerator: public StubCodeGenerator {
204
206
StubCodeMark mark (this , " StubRoutines" , " call_stub" );
205
207
address start = __ pc ();
206
208
207
- const Address sp_after_call (rfp, sp_after_call_off * wordSize);
209
+ const Address sp_after_call (rfp, sp_after_call_off * wordSize);
208
210
211
+ const Address fpcr_save (rfp, fpcr_off * wordSize);
209
212
const Address call_wrapper (rfp, call_wrapper_off * wordSize);
210
213
const Address result (rfp, result_off * wordSize);
211
214
const Address result_type (rfp, result_type_off * wordSize);
@@ -254,6 +257,14 @@ class StubGenerator: public StubCodeGenerator {
254
257
__ stpd (v13, v12, d13_save);
255
258
__ stpd (v15, v14, d15_save);
256
259
260
+ __ get_fpcr (rscratch1);
261
+ __ str (rscratch1, fpcr_save);
262
+ // Set FPCR to the state we need. We do want Round to Nearest. We
263
+ // don't want non-IEEE rounding modes or floating-point traps.
264
+ __ bfi (rscratch1, zr, 22 , 4 ); // Clear DN, FZ, and Rmode
265
+ __ bfi (rscratch1, zr, 8 , 5 ); // Clear exception-control bits (8-12)
266
+ __ set_fpcr (rscratch1);
267
+
257
268
// install Java thread in global register now we have saved
258
269
// whatever value it held
259
270
__ mov (rthread, c_rarg7);
@@ -367,6 +378,10 @@ class StubGenerator: public StubCodeGenerator {
367
378
__ ldp (r22, r21, r22_save);
368
379
__ ldp (r20, r19, r20_save);
369
380
381
+ // restore fpcr
382
+ __ ldr (rscratch1, fpcr_save);
383
+ __ set_fpcr (rscratch1);
384
+
370
385
__ ldp (c_rarg0, c_rarg1, call_wrapper);
371
386
__ ldrw (c_rarg2, result_type);
372
387
__ ldr (c_rarg3, method);
0 commit comments