Skip to content

Commit 8259585

Browse files
Scott Gibbonswenshao
authored andcommitted
8314056: Remove runtime platform check from frem/drem
Reviewed-by: sviswanathan, jbhateja
1 parent 78a4b78 commit 8259585

File tree

8 files changed

+110
-129
lines changed

8 files changed

+110
-129
lines changed

src/hotspot/cpu/x86/assembler_x86.cpp

Lines changed: 39 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6232,11 +6232,17 @@ void Assembler::subss(XMMRegister dst, Address src) {
62326232
emit_operand(dst, src, 0);
62336233
}
62346234

6235-
void Assembler::testb(Register dst, int imm8) {
6235+
void Assembler::testb(Register dst, int imm8, bool use_ral) {
62366236
NOT_LP64(assert(dst->has_byte_register(), "must have byte register"));
62376237
if (dst == rax) {
6238-
emit_int8((unsigned char)0xA8);
6239-
emit_int8(imm8);
6238+
if (use_ral) {
6239+
emit_int8((unsigned char)0xA8);
6240+
emit_int8(imm8);
6241+
} else {
6242+
emit_int8((unsigned char)0xF6);
6243+
emit_int8((unsigned char)0xC4);
6244+
emit_int8(imm8);
6245+
}
62406246
} else {
62416247
(void) prefix_and_encode(dst->encoding(), true);
62426248
emit_arith_b(0xF6, 0xC0, dst, imm8);
@@ -10967,6 +10973,36 @@ void Assembler::emit_operand32(Register reg, Address adr, int post_addr_length)
1096710973
emit_operand(reg, adr._base, adr._index, adr._scale, adr._disp, adr._rspec, post_addr_length);
1096810974
}
1096910975

10976+
void Assembler::fld_d(Address adr) {
10977+
InstructionMark im(this);
10978+
emit_int8((unsigned char)0xDD);
10979+
emit_operand32(rax, adr, 0);
10980+
}
10981+
10982+
void Assembler::fprem() {
10983+
emit_int16((unsigned char)0xD9, (unsigned char)0xF8);
10984+
}
10985+
10986+
void Assembler::fnstsw_ax() {
10987+
emit_int16((unsigned char)0xDF, (unsigned char)0xE0);
10988+
}
10989+
10990+
void Assembler::fstp_d(Address adr) {
10991+
InstructionMark im(this);
10992+
emit_int8((unsigned char)0xDD);
10993+
emit_operand32(rbx, adr, 0);
10994+
}
10995+
10996+
void Assembler::fstp_d(int index) {
10997+
emit_farith(0xDD, 0xD8, index);
10998+
}
10999+
11000+
void Assembler::emit_farith(int b1, int b2, int i) {
11001+
assert(isByte(b1) && isByte(b2), "wrong opcode");
11002+
assert(0 <= i && i < 8, "illegal stack offset");
11003+
emit_int16(b1, b2 + i);
11004+
}
11005+
1097011006
#ifndef _LP64
1097111007
// 32bit only pieces of the assembler
1097211008

@@ -11010,12 +11046,6 @@ void Assembler::decl(Register dst) {
1101011046

1101111047
// 64bit doesn't use the x87
1101211048

11013-
void Assembler::emit_farith(int b1, int b2, int i) {
11014-
assert(isByte(b1) && isByte(b2), "wrong opcode");
11015-
assert(0 <= i && i < 8, "illegal stack offset");
11016-
emit_int16(b1, b2 + i);
11017-
}
11018-
1101911049
void Assembler::fabs() {
1102011050
emit_int16((unsigned char)0xD9, (unsigned char)0xE1);
1102111051
}
@@ -11177,12 +11207,6 @@ void Assembler::fld1() {
1117711207
emit_int16((unsigned char)0xD9, (unsigned char)0xE8);
1117811208
}
1117911209

11180-
void Assembler::fld_d(Address adr) {
11181-
InstructionMark im(this);
11182-
emit_int8((unsigned char)0xDD);
11183-
emit_operand32(rax, adr, 0);
11184-
}
11185-
1118611210
void Assembler::fld_s(Address adr) {
1118711211
InstructionMark im(this);
1118811212
emit_int8((unsigned char)0xD9);
@@ -11266,14 +11290,6 @@ void Assembler::fnstcw(Address src) {
1126611290
emit_operand32(rdi, src, 0);
1126711291
}
1126811292

11269-
void Assembler::fnstsw_ax() {
11270-
emit_int16((unsigned char)0xDF, (unsigned char)0xE0);
11271-
}
11272-
11273-
void Assembler::fprem() {
11274-
emit_int16((unsigned char)0xD9, (unsigned char)0xF8);
11275-
}
11276-
1127711293
void Assembler::fprem1() {
1127811294
emit_int16((unsigned char)0xD9, (unsigned char)0xF5);
1127911295
}
@@ -11304,16 +11320,6 @@ void Assembler::fst_s(Address adr) {
1130411320
emit_operand32(rdx, adr, 0);
1130511321
}
1130611322

11307-
void Assembler::fstp_d(Address adr) {
11308-
InstructionMark im(this);
11309-
emit_int8((unsigned char)0xDD);
11310-
emit_operand32(rbx, adr, 0);
11311-
}
11312-
11313-
void Assembler::fstp_d(int index) {
11314-
emit_farith(0xDD, 0xD8, index);
11315-
}
11316-
1131711323
void Assembler::fstp_s(Address adr) {
1131811324
InstructionMark im(this);
1131911325
emit_int8((unsigned char)0xD9);

src/hotspot/cpu/x86/assembler_x86.hpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,12 +1245,18 @@ class Assembler : public AbstractAssembler {
12451245
void divss(XMMRegister dst, XMMRegister src);
12461246

12471247

1248-
#ifndef _LP64
1248+
void fnstsw_ax();
1249+
void fprem();
1250+
void fld_d(Address adr);
1251+
void fstp_d(Address adr);
1252+
void fstp_d(int index);
1253+
12491254
private:
12501255

12511256
void emit_farith(int b1, int b2, int i);
12521257

12531258
public:
1259+
#ifndef _LP64
12541260
void emms();
12551261

12561262
void fabs();
@@ -1309,7 +1315,6 @@ class Assembler : public AbstractAssembler {
13091315

13101316
void fld1();
13111317

1312-
void fld_d(Address adr);
13131318
void fld_s(Address adr);
13141319
void fld_s(int index);
13151320

@@ -1338,10 +1343,6 @@ class Assembler : public AbstractAssembler {
13381343
void fnsave(Address dst);
13391344

13401345
void fnstcw(Address src);
1341-
1342-
void fnstsw_ax();
1343-
1344-
void fprem();
13451346
void fprem1();
13461347

13471348
void frstor(Address src);
@@ -1353,8 +1354,6 @@ class Assembler : public AbstractAssembler {
13531354
void fst_d(Address adr);
13541355
void fst_s(Address adr);
13551356

1356-
void fstp_d(Address adr);
1357-
void fstp_d(int index);
13581357
void fstp_s(Address adr);
13591358

13601359
void fsub(int i);
@@ -2184,7 +2183,7 @@ class Assembler : public AbstractAssembler {
21842183
void subss(XMMRegister dst, XMMRegister src);
21852184

21862185
void testb(Address dst, int imm8);
2187-
void testb(Register dst, int imm8);
2186+
void testb(Register dst, int imm8, bool use_ral = true);
21882187

21892188
void testl(Address dst, int32_t imm32);
21902189
void testl(Register dst, int32_t imm32);

src/hotspot/cpu/x86/sharedRuntime_x86.cpp

Lines changed: 8 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -84,52 +84,18 @@ void SharedRuntime::inline_check_hashcode_from_object_header(MacroAssembler* mas
8484
}
8585
#endif //COMPILER1
8686

87-
#if defined(TARGET_COMPILER_gcc) && !defined(_WIN64)
8887
JRT_LEAF(jfloat, SharedRuntime::frem(jfloat x, jfloat y))
89-
jfloat retval;
90-
const bool is_LP64 = LP64_ONLY(true) NOT_LP64(false);
91-
if (!is_LP64 || UseAVX < 1 || !UseFMA) {
92-
asm ("\
93-
1: \n\
94-
fprem \n\
95-
fnstsw %%ax \n\
96-
test $0x4,%%ah \n\
97-
jne 1b \n\
98-
"
99-
:"=t"(retval)
100-
:"0"(x), "u"(y)
101-
:"cc", "ax");
102-
} else {
103-
assert(StubRoutines::fmod() != nullptr, "");
104-
jdouble (*addr)(jdouble, jdouble) = (double (*)(double, double))StubRoutines::fmod();
105-
jdouble dx = (jdouble) x;
106-
jdouble dy = (jdouble) y;
88+
assert(StubRoutines::fmod() != nullptr, "");
89+
jdouble (*addr)(jdouble, jdouble) = (double (*)(double, double))StubRoutines::fmod();
90+
jdouble dx = (jdouble) x;
91+
jdouble dy = (jdouble) y;
10792

108-
retval = (jfloat) (*addr)(dx, dy);
109-
}
110-
return retval;
93+
return (jfloat) (*addr)(dx, dy);
11194
JRT_END
11295

11396
JRT_LEAF(jdouble, SharedRuntime::drem(jdouble x, jdouble y))
114-
jdouble retval;
115-
const bool is_LP64 = LP64_ONLY(true) NOT_LP64(false);
116-
if (!is_LP64 || UseAVX < 1 || !UseFMA) {
117-
asm ("\
118-
1: \n\
119-
fprem \n\
120-
fnstsw %%ax \n\
121-
test $0x4,%%ah \n\
122-
jne 1b \n\
123-
"
124-
:"=t"(retval)
125-
:"0"(x), "u"(y)
126-
:"cc", "ax");
127-
} else {
128-
assert(StubRoutines::fmod() != nullptr, "");
129-
jdouble (*addr)(jdouble, jdouble) = (double (*)(double, double))StubRoutines::fmod();
97+
assert(StubRoutines::fmod() != nullptr, "");
98+
jdouble (*addr)(jdouble, jdouble) = (double (*)(double, double))StubRoutines::fmod();
13099

131-
retval = (*addr)(x, y);
132-
}
133-
return retval;
100+
return (*addr)(x, y);
134101
JRT_END
135-
#endif // TARGET_COMPILER_gcc && !_WIN64

src/hotspot/cpu/x86/stubGenerator_x86_64.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3897,6 +3897,8 @@ address StubGenerator::generate_throw_exception(const char* name,
38973897
void StubGenerator::create_control_words() {
38983898
// Round to nearest, 64-bit mode, exceptions masked
38993899
StubRoutines::x86::_mxcsr_std = 0x1F80;
3900+
// Round to zero, 64-bit mode, exceptions masked
3901+
StubRoutines::x86::_mxcsr_rz = 0x7F80;
39003902
}
39013903

39023904
// Initialization
@@ -3979,9 +3981,7 @@ void StubGenerator::generate_initial_stubs() {
39793981

39803982
generate_libm_stubs();
39813983

3982-
if ((UseAVX >= 1) && (VM_Version::supports_avx512vlbwdq() || VM_Version::supports_fma())) {
3983-
StubRoutines::_fmod = generate_libmFmod(); // from stubGenerator_x86_64_fmod.cpp
3984-
}
3984+
StubRoutines::_fmod = generate_libmFmod(); // from stubGenerator_x86_64_fmod.cpp
39853985
}
39863986

39873987
void StubGenerator::generate_continuation_stubs() {

0 commit comments

Comments
 (0)