Skip to content

Commit 069f180

Browse files
author
Vladimir Ivanov
committedJun 4, 2021
8268174: Move x86-specific stub declarations into stubRoutines_x86.hpp
Reviewed-by: kvn
1 parent 3025f05 commit 069f180

16 files changed

+79
-84
lines changed
 

‎src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1582,10 +1582,10 @@ void LIR_Assembler::emit_opConvert(LIR_OpConvert* op) {
15821582
__ cvttsd2sil(dest->as_register(), src->as_xmm_double_reg());
15831583
} else {
15841584
assert(src->fpu() == 0, "input must be on TOS");
1585-
__ fldcw(ExternalAddress(StubRoutines::addr_fpu_cntrl_wrd_trunc()));
1585+
__ fldcw(ExternalAddress(StubRoutines::x86::addr_fpu_cntrl_wrd_trunc()));
15861586
__ fist_s(Address(rsp, 0));
15871587
__ movl(dest->as_register(), Address(rsp, 0));
1588-
__ fldcw(ExternalAddress(StubRoutines::addr_fpu_cntrl_wrd_std()));
1588+
__ fldcw(ExternalAddress(StubRoutines::x86::addr_fpu_cntrl_wrd_std()));
15891589
}
15901590
// IA32 conversion instructions do not match JLS for overflow, underflow and NaN -> fixup in stub
15911591
assert(op->stub() != NULL, "stub required");

‎src/hotspot/cpu/x86/c1_Runtime1_x86.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ void C1_MacroAssembler::save_live_registers_no_oop_map(bool save_fpu_registers)
444444

445445
#ifdef ASSERT
446446
Label ok;
447-
__ cmpw(Address(rsp, fpu_state_off * VMRegImpl::stack_slot_size), StubRoutines::fpu_cntrl_wrd_std());
447+
__ cmpw(Address(rsp, fpu_state_off * VMRegImpl::stack_slot_size), StubRoutines::x86::fpu_cntrl_wrd_std());
448448
__ jccb(Assembler::equal, ok);
449449
__ stop("corrupted control word detected");
450450
__ bind(ok);
@@ -454,7 +454,7 @@ void C1_MacroAssembler::save_live_registers_no_oop_map(bool save_fpu_registers)
454454
// since fstp_d can cause FPU stack underflow exceptions. Write it
455455
// into the on stack copy and then reload that to make sure that the
456456
// current and future values are correct.
457-
__ movw(Address(rsp, fpu_state_off * VMRegImpl::stack_slot_size), StubRoutines::fpu_cntrl_wrd_std());
457+
__ movw(Address(rsp, fpu_state_off * VMRegImpl::stack_slot_size), StubRoutines::x86::fpu_cntrl_wrd_std());
458458
__ frstor(Address(rsp, fpu_state_off * VMRegImpl::stack_slot_size));
459459

460460
// Save the FPU registers in de-opt-able form

‎src/hotspot/cpu/x86/macroAssembler_x86.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -4580,7 +4580,7 @@ static bool _verify_FPU(int stack_depth, char* s, CPU_State* state) {
45804580
return true; // All other stack states do not matter
45814581
}
45824582

4583-
assert((fs->_control_word._value & 0xffff) == StubRoutines::_fpu_cntrl_wrd_std,
4583+
assert((fs->_control_word._value & 0xffff) == StubRoutines::x86::fpu_cntrl_wrd_std(),
45844584
"bad FPU control word");
45854585

45864586
// compute stack depth
@@ -4646,7 +4646,7 @@ void MacroAssembler::restore_cpu_control_state_after_jni() {
46464646
// or verify that it wasn't changed (with -Xcheck:jni flag).
46474647
if (VM_Version::supports_sse()) {
46484648
if (RestoreMXCSROnJNICalls) {
4649-
ldmxcsr(ExternalAddress(StubRoutines::addr_mxcsr_std()));
4649+
ldmxcsr(ExternalAddress(StubRoutines::x86::addr_mxcsr_std()));
46504650
} else if (CheckJNICalls) {
46514651
call(RuntimeAddress(StubRoutines::x86::verify_mxcsr_entry()));
46524652
}
@@ -5167,7 +5167,7 @@ void MacroAssembler::verified_entry(int framesize, int stack_bang_size, bool fp_
51675167
#ifndef _LP64
51685168
// If method sets FPU control word do it now
51695169
if (fp_mode_24b) {
5170-
fldcw(ExternalAddress(StubRoutines::addr_fpu_cntrl_wrd_24()));
5170+
fldcw(ExternalAddress(StubRoutines::x86::addr_fpu_cntrl_wrd_24()));
51715171
}
51725172
if (UseSSE >= 2 && VerifyFPU) {
51735173
verify_FPU(0, "FPU stack must be clean on entry");

‎src/hotspot/cpu/x86/sharedRuntime_x86_32.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ OopMap* RegisterSaver::save_live_registers(MacroAssembler* masm, int additional_
175175
#ifdef ASSERT
176176
// Make sure the control word has the expected value
177177
Label ok;
178-
__ cmpw(Address(rsp, 0), StubRoutines::fpu_cntrl_wrd_std());
178+
__ cmpw(Address(rsp, 0), StubRoutines::x86::fpu_cntrl_wrd_std());
179179
__ jccb(Assembler::equal, ok);
180180
__ stop("corrupted control word detected");
181181
__ bind(ok);
@@ -185,14 +185,14 @@ OopMap* RegisterSaver::save_live_registers(MacroAssembler* masm, int additional_
185185
// since fstp_d can cause FPU stack underflow exceptions. Write it
186186
// into the on stack copy and then reload that to make sure that the
187187
// current and future values are correct.
188-
__ movw(Address(rsp, 0), StubRoutines::fpu_cntrl_wrd_std());
188+
__ movw(Address(rsp, 0), StubRoutines::x86::fpu_cntrl_wrd_std());
189189
}
190190

191191
__ frstor(Address(rsp, 0));
192192
if (!verify_fpu) {
193193
// Set the control word so that exceptions are masked for the
194194
// following code.
195-
__ fldcw(ExternalAddress(StubRoutines::addr_fpu_cntrl_wrd_std()));
195+
__ fldcw(ExternalAddress(StubRoutines::x86::addr_fpu_cntrl_wrd_std()));
196196
}
197197

198198
int off = st0_off;
@@ -1937,7 +1937,7 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
19371937

19381938
if (AlwaysRestoreFPU) {
19391939
// Make sure the control word is correct.
1940-
__ fldcw(ExternalAddress(StubRoutines::addr_fpu_cntrl_wrd_std()));
1940+
__ fldcw(ExternalAddress(StubRoutines::x86::addr_fpu_cntrl_wrd_std()));
19411941
}
19421942

19431943
// check for safepoint operation in progress and/or pending suspend requests
@@ -2416,7 +2416,7 @@ void SharedRuntime::generate_deopt_blob() {
24162416
// Non standard control word may be leaked out through a safepoint blob, and we can
24172417
// deopt at a poll point with the non standard control word. However, we should make
24182418
// sure the control word is correct after restore_result_registers.
2419-
__ fldcw(ExternalAddress(StubRoutines::addr_fpu_cntrl_wrd_std()));
2419+
__ fldcw(ExternalAddress(StubRoutines::x86::addr_fpu_cntrl_wrd_std()));
24202420

24212421
// All of the register save area has been popped of the stack. Only the
24222422
// return address remains.

‎src/hotspot/cpu/x86/stubGenerator_x86_32.cpp

+12-14
Original file line numberDiff line numberDiff line change
@@ -162,15 +162,15 @@ class StubGenerator: public StubCodeGenerator {
162162
__ stmxcsr(mxcsr_save);
163163
__ movl(rax, mxcsr_save);
164164
__ andl(rax, MXCSR_MASK); // Only check control and mask bits
165-
ExternalAddress mxcsr_std(StubRoutines::addr_mxcsr_std());
165+
ExternalAddress mxcsr_std(StubRoutines::x86::addr_mxcsr_std());
166166
__ cmp32(rax, mxcsr_std);
167167
__ jcc(Assembler::equal, skip_ldmx);
168168
__ ldmxcsr(mxcsr_std);
169169
__ bind(skip_ldmx);
170170
}
171171

172172
// make sure the control word is correct.
173-
__ fldcw(ExternalAddress(StubRoutines::addr_fpu_cntrl_wrd_std()));
173+
__ fldcw(ExternalAddress(StubRoutines::x86::addr_fpu_cntrl_wrd_std()));
174174

175175
#ifdef ASSERT
176176
// make sure we have no pending exceptions
@@ -446,7 +446,7 @@ class StubGenerator: public StubCodeGenerator {
446446

447447
if (CheckJNICalls && UseSSE > 0 ) {
448448
Label ok_ret;
449-
ExternalAddress mxcsr_std(StubRoutines::addr_mxcsr_std());
449+
ExternalAddress mxcsr_std(StubRoutines::x86::addr_mxcsr_std());
450450
__ push(rax);
451451
__ subptr(rsp, wordSize); // allocate a temp location
452452
__ stmxcsr(mxcsr_save);
@@ -490,7 +490,7 @@ class StubGenerator: public StubCodeGenerator {
490490
__ fnstcw(fpu_cntrl_wrd_save);
491491
__ movl(rax, fpu_cntrl_wrd_save);
492492
__ andl(rax, FPU_CNTRL_WRD_MASK);
493-
ExternalAddress fpu_std(StubRoutines::addr_fpu_cntrl_wrd_std());
493+
ExternalAddress fpu_std(StubRoutines::x86::addr_fpu_cntrl_wrd_std());
494494
__ cmp32(rax, fpu_std);
495495
__ jcc(Assembler::equal, ok_ret);
496496

@@ -3857,13 +3857,13 @@ class StubGenerator: public StubCodeGenerator {
38573857

38583858
void create_control_words() {
38593859
// Round to nearest, 53-bit mode, exceptions masked
3860-
StubRoutines::_fpu_cntrl_wrd_std = 0x027F;
3860+
StubRoutines::x86::_fpu_cntrl_wrd_std = 0x027F;
38613861
// Round to zero, 53-bit mode, exception mased
3862-
StubRoutines::_fpu_cntrl_wrd_trunc = 0x0D7F;
3862+
StubRoutines::x86::_fpu_cntrl_wrd_trunc = 0x0D7F;
38633863
// Round to nearest, 24-bit mode, exceptions masked
3864-
StubRoutines::_fpu_cntrl_wrd_24 = 0x007F;
3864+
StubRoutines::x86::_fpu_cntrl_wrd_24 = 0x007F;
38653865
// Round to nearest, 64-bit mode, exceptions masked
3866-
StubRoutines::_mxcsr_std = 0x1F80;
3866+
StubRoutines::x86::_mxcsr_std = 0x1F80;
38673867
// Note: the following two constants are 80-bit values
38683868
// layout is critical for correct loading by FPU.
38693869
// Bias for strict fp multiply/divide
@@ -3896,12 +3896,10 @@ class StubGenerator: public StubCodeGenerator {
38963896
// platform dependent
38973897
create_control_words();
38983898

3899-
StubRoutines::x86::_verify_mxcsr_entry = generate_verify_mxcsr();
3900-
StubRoutines::x86::_verify_fpu_cntrl_wrd_entry = generate_verify_fpu_cntrl_wrd();
3901-
StubRoutines::_d2i_wrapper = generate_d2i_wrapper(T_INT,
3902-
CAST_FROM_FN_PTR(address, SharedRuntime::d2i));
3903-
StubRoutines::_d2l_wrapper = generate_d2i_wrapper(T_LONG,
3904-
CAST_FROM_FN_PTR(address, SharedRuntime::d2l));
3899+
StubRoutines::x86::_verify_mxcsr_entry = generate_verify_mxcsr();
3900+
StubRoutines::x86::_verify_fpu_cntrl_wrd_entry = generate_verify_fpu_cntrl_wrd();
3901+
StubRoutines::x86::_d2i_wrapper = generate_d2i_wrapper(T_INT, CAST_FROM_FN_PTR(address, SharedRuntime::d2i));
3902+
StubRoutines::x86::_d2l_wrapper = generate_d2i_wrapper(T_LONG, CAST_FROM_FN_PTR(address, SharedRuntime::d2l));
39053903

39063904
// Build this early so it's available for the interpreter
39073905
StubRoutines::_throw_StackOverflowError_entry = generate_throw_exception("StackOverflowError throw_exception",

‎src/hotspot/cpu/x86/stubGenerator_x86_64.cpp

+3-9
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ class StubGenerator: public StubCodeGenerator {
289289
__ stmxcsr(mxcsr_save);
290290
__ movl(rax, mxcsr_save);
291291
__ andl(rax, MXCSR_MASK); // Only check control and mask bits
292-
ExternalAddress mxcsr_std(StubRoutines::addr_mxcsr_std());
292+
ExternalAddress mxcsr_std(StubRoutines::x86::addr_mxcsr_std());
293293
__ cmp32(rax, mxcsr_std);
294294
__ jcc(Assembler::equal, skip_ldmx);
295295
__ ldmxcsr(mxcsr_std);
@@ -602,7 +602,7 @@ class StubGenerator: public StubCodeGenerator {
602602

603603
if (CheckJNICalls) {
604604
Label ok_ret;
605-
ExternalAddress mxcsr_std(StubRoutines::addr_mxcsr_std());
605+
ExternalAddress mxcsr_std(StubRoutines::x86::addr_mxcsr_std());
606606
__ push(rax);
607607
__ subptr(rsp, wordSize); // allocate a temp location
608608
__ stmxcsr(mxcsr_save);
@@ -6713,14 +6713,8 @@ address generate_avx_ghash_processBlocks() {
67136713
}
67146714

67156715
void create_control_words() {
6716-
// Round to nearest, 53-bit mode, exceptions masked
6717-
StubRoutines::_fpu_cntrl_wrd_std = 0x027F;
6718-
// Round to zero, 53-bit mode, exception mased
6719-
StubRoutines::_fpu_cntrl_wrd_trunc = 0x0D7F;
6720-
// Round to nearest, 24-bit mode, exceptions masked
6721-
StubRoutines::_fpu_cntrl_wrd_24 = 0x007F;
67226716
// Round to nearest, 64-bit mode, exceptions masked
6723-
StubRoutines::_mxcsr_std = 0x1F80;
6717+
StubRoutines::x86::_mxcsr_std = 0x1F80;
67246718
}
67256719

67266720
// Initialization

‎src/hotspot/cpu/x86/stubRoutines_x86.hpp

+15-1
Original file line numberDiff line numberDiff line change
@@ -96,19 +96,32 @@ class x86 {
9696

9797
private:
9898
static address _verify_fpu_cntrl_wrd_entry;
99+
static address _d2i_wrapper;
100+
static address _d2l_wrapper;
101+
102+
static jint _fpu_cntrl_wrd_std;
103+
static jint _fpu_cntrl_wrd_24;
104+
static jint _fpu_cntrl_wrd_trunc;
99105

100106
static jint _fpu_subnormal_bias1[3];
101107
static jint _fpu_subnormal_bias2[3];
102108

103109
public:
104110
static address verify_fpu_cntrl_wrd_entry() { return _verify_fpu_cntrl_wrd_entry; }
105-
111+
static address d2i_wrapper() { return _d2i_wrapper; }
112+
static address d2l_wrapper() { return _d2l_wrapper; }
113+
static address addr_fpu_cntrl_wrd_std() { return (address)&_fpu_cntrl_wrd_std; }
114+
static address addr_fpu_cntrl_wrd_24() { return (address)&_fpu_cntrl_wrd_24; }
115+
static address addr_fpu_cntrl_wrd_trunc() { return (address)&_fpu_cntrl_wrd_trunc; }
106116
static address addr_fpu_subnormal_bias1() { return (address)&_fpu_subnormal_bias1; }
107117
static address addr_fpu_subnormal_bias2() { return (address)&_fpu_subnormal_bias2; }
108118

119+
static jint fpu_cntrl_wrd_std() { return _fpu_cntrl_wrd_std; }
109120
#endif // !LP64
110121

111122
private:
123+
static jint _mxcsr_std;
124+
112125
static address _verify_mxcsr_entry;
113126
// shuffle mask for fixing up 128-bit words consisting of big-endian 32-bit integers
114127
static address _key_shuffle_mask_addr;
@@ -225,6 +238,7 @@ class x86 {
225238
static address _ones_adr;
226239

227240
public:
241+
static address addr_mxcsr_std() { return (address)&_mxcsr_std; }
228242
static address verify_mxcsr_entry() { return _verify_mxcsr_entry; }
229243
static address key_shuffle_mask_addr() { return _key_shuffle_mask_addr; }
230244
static address counter_shuffle_mask_addr() { return _counter_shuffle_mask_addr; }

‎src/hotspot/cpu/x86/stubRoutines_x86_32.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@
3434
address StubRoutines::x86::_verify_fpu_cntrl_wrd_entry = NULL;
3535
address StubRoutines::x86::_method_entry_barrier = NULL;
3636

37+
address StubRoutines::x86::_d2i_wrapper = NULL;
38+
address StubRoutines::x86::_d2l_wrapper = NULL;
39+
40+
jint StubRoutines::x86::_fpu_cntrl_wrd_std = 0;
41+
jint StubRoutines::x86::_fpu_cntrl_wrd_24 = 0;
42+
jint StubRoutines::x86::_fpu_cntrl_wrd_trunc = 0;
43+
44+
jint StubRoutines::x86::_mxcsr_std = 0;
45+
3746
jint StubRoutines::x86::_fpu_subnormal_bias1[3] = { 0, 0, 0 };
3847
jint StubRoutines::x86::_fpu_subnormal_bias2[3] = { 0, 0, 0 };
3948

‎src/hotspot/cpu/x86/stubRoutines_x86_64.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
// Implementation of the platform-specific part of StubRoutines - for
3232
// a description of how to extend it, see the stubRoutines.hpp file.
3333

34+
jint StubRoutines::x86::_mxcsr_std = 0;
35+
3436
address StubRoutines::x86::_get_previous_sp_entry = NULL;
3537

3638
address StubRoutines::x86::_f2i_fixup = NULL;
@@ -42,3 +44,4 @@ address StubRoutines::x86::_float_sign_flip = NULL;
4244
address StubRoutines::x86::_double_sign_mask = NULL;
4345
address StubRoutines::x86::_double_sign_flip = NULL;
4446
address StubRoutines::x86::_method_entry_barrier = NULL;
47+

‎src/hotspot/cpu/x86/templateInterpreterGenerator_x86.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1050,7 +1050,7 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) {
10501050
#ifndef _LP64
10511051
if (AlwaysRestoreFPU) {
10521052
// Make sure the control word is correct.
1053-
__ fldcw(ExternalAddress(StubRoutines::addr_fpu_cntrl_wrd_std()));
1053+
__ fldcw(ExternalAddress(StubRoutines::x86::addr_fpu_cntrl_wrd_std()));
10541054
}
10551055
#endif // _LP64
10561056

‎src/hotspot/cpu/x86/universalUpcallHandler_x86_64.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ static void preserve_callee_saved_registers(MacroAssembler* _masm, const ABIDesc
483483
__ stmxcsr(mxcsr_save);
484484
__ movl(rax, mxcsr_save);
485485
__ andl(rax, MXCSR_MASK); // Only check control and mask bits
486-
ExternalAddress mxcsr_std(StubRoutines::addr_mxcsr_std());
486+
ExternalAddress mxcsr_std(StubRoutines::x86::addr_mxcsr_std());
487487
__ cmp32(rax, mxcsr_std);
488488
__ jcc(Assembler::equal, skip_ldmx);
489489
__ ldmxcsr(mxcsr_std);

0 commit comments

Comments
 (0)
Please sign in to comment.