@@ -136,7 +136,8 @@ class StubGenerator: public StubCodeGenerator {
136
136
// [ return_from_Java ] <--- sp
137
137
// [ argument word n ]
138
138
// ...
139
- // -27 [ argument word 1 ]
139
+ // -29 [ argument word 1 ]
140
+ // -28 [ saved Floating-point Control Register ]
140
141
// -26 [ saved v15 ] <--- sp_after_call
141
142
// -25 [ saved v14 ]
142
143
// -24 [ saved v13 ]
@@ -168,8 +169,9 @@ class StubGenerator: public StubCodeGenerator {
168
169
169
170
// Call stub stack layout word offsets from fp
170
171
enum call_stub_layout {
171
- sp_after_call_off = -26 ,
172
+ sp_after_call_off = -28 ,
172
173
174
+ fpcr_off = sp_after_call_off,
173
175
d15_off = -26 ,
174
176
d13_off = -24 ,
175
177
d11_off = -22 ,
@@ -199,8 +201,9 @@ class StubGenerator: public StubCodeGenerator {
199
201
StubCodeMark mark (this , " StubRoutines" , " call_stub" );
200
202
address start = __ pc ();
201
203
202
- const Address sp_after_call (rfp, sp_after_call_off * wordSize);
204
+ const Address sp_after_call (rfp, sp_after_call_off * wordSize);
203
205
206
+ const Address fpcr_save (rfp, fpcr_off * wordSize);
204
207
const Address call_wrapper (rfp, call_wrapper_off * wordSize);
205
208
const Address result (rfp, result_off * wordSize);
206
209
const Address result_type (rfp, result_type_off * wordSize);
@@ -249,6 +252,14 @@ class StubGenerator: public StubCodeGenerator {
249
252
__ stpd (v13, v12, d13_save);
250
253
__ stpd (v15, v14, d15_save);
251
254
255
+ __ get_fpcr (rscratch1);
256
+ __ str (rscratch1, fpcr_save);
257
+ // Set FPCR to the state we need. We do want Round to Nearest. We
258
+ // don't want non-IEEE rounding modes or floating-point traps.
259
+ __ bfi (rscratch1, zr, 22 , 4 ); // Clear DN, FZ, and Rmode
260
+ __ bfi (rscratch1, zr, 8 , 5 ); // Clear exception-control bits (8-12)
261
+ __ set_fpcr (rscratch1);
262
+
252
263
// install Java thread in global register now we have saved
253
264
// whatever value it held
254
265
__ mov (rthread, c_rarg7);
@@ -362,6 +373,10 @@ class StubGenerator: public StubCodeGenerator {
362
373
__ ldp (r22, r21, r22_save);
363
374
__ ldp (r20, r19, r20_save);
364
375
376
+ // restore fpcr
377
+ __ ldr (rscratch1, fpcr_save);
378
+ __ set_fpcr (rscratch1);
379
+
365
380
__ ldp (c_rarg0, c_rarg1, call_wrapper);
366
381
__ ldrw (c_rarg2, result_type);
367
382
__ ldr (c_rarg3, method);
0 commit comments