8330266: RISC-V: Restore frm to RoundingMode::rne after JNI
Reviewed-by: fyang, rehn
This commit is contained in:
parent
9f2a4fad17
commit
85261bcebc
@ -278,6 +278,9 @@ void DowncallLinker::StubGenerator::generate() {
|
||||
Label L_reguard;
|
||||
Label L_after_reguard;
|
||||
if (_needs_transition) {
|
||||
// Restore cpu control state after JNI call
|
||||
__ restore_cpu_control_state_after_jni(t0);
|
||||
|
||||
__ block_comment("{ thread native2java");
|
||||
__ mv(t0, _thread_in_native_trans);
|
||||
__ sw(t0, Address(xthread, JavaThread::thread_state_offset()));
|
||||
|
@ -1167,6 +1167,19 @@ void MacroAssembler::fsflagsi(Register Rd, unsigned imm) {
|
||||
|
||||
#undef INSN
|
||||
|
||||
void MacroAssembler::restore_cpu_control_state_after_jni(Register tmp) {
|
||||
if (RestoreMXCSROnJNICalls) {
|
||||
Label skip_fsrmi;
|
||||
frrm(tmp);
|
||||
// Set FRM to the state we need. We do want Round to Nearest.
|
||||
// We don't want non-IEEE rounding modes.
|
||||
guarantee(RoundingMode::rne == 0, "must be");
|
||||
beqz(tmp, skip_fsrmi); // Only reset FRM if it's wrong
|
||||
fsrmi(RoundingMode::rne);
|
||||
bind(skip_fsrmi);
|
||||
}
|
||||
}
|
||||
|
||||
void MacroAssembler::push_reg(Register Rs)
|
||||
{
|
||||
addi(esp, esp, 0 - wordSize);
|
||||
|
@ -581,6 +581,9 @@ class MacroAssembler: public Assembler {
|
||||
void fsflagsi(Register Rd, unsigned imm);
|
||||
void fsflagsi(unsigned imm);
|
||||
|
||||
// Restore cpu control state after JNI call
|
||||
void restore_cpu_control_state_after_jni(Register tmp);
|
||||
|
||||
// Control transfer pseudo instructions
|
||||
void beqz(Register Rs, const address dest);
|
||||
void bnez(Register Rs, const address dest);
|
||||
|
@ -1748,6 +1748,9 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
|
||||
intptr_t return_pc = (intptr_t) __ pc();
|
||||
oop_maps->add_gc_map(return_pc - start, map);
|
||||
|
||||
// Verify or restore cpu control state after JNI call
|
||||
__ restore_cpu_control_state_after_jni(t0);
|
||||
|
||||
// Unpack native results.
|
||||
if (ret_type != T_OBJECT && ret_type != T_ARRAY) {
|
||||
__ cast_primitive_type(ret_type, x10);
|
||||
|
@ -1157,6 +1157,9 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) {
|
||||
__ get_method(xmethod);
|
||||
// result potentially in x10 or f10
|
||||
|
||||
// Restore cpu control state after JNI call
|
||||
__ restore_cpu_control_state_after_jni(t0);
|
||||
|
||||
// make room for the pushes we're about to do
|
||||
__ sub(t0, esp, 4 * wordSize);
|
||||
__ andi(sp, t0, -16);
|
||||
|
Loading…
x
Reference in New Issue
Block a user