Skip to content

Commit 2aa4f95

Browse files
author
duke
committedNov 30, 2023
Automatic merge of jdk:master into master
2 parents a8c72eb + a3eb664 commit 2aa4f95

File tree

15 files changed

+466
-438
lines changed

15 files changed

+466
-438
lines changed
 

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

+70-24
Original file line numberDiff line numberDiff line change
@@ -1094,32 +1094,78 @@ void C2_MacroAssembler::vminmax_fp(int opcode, BasicType elem_bt,
10941094
bool is_min = (opcode == Op_MinV || opcode == Op_MinReductionV);
10951095
bool is_double_word = is_double_word_type(elem_bt);
10961096

1097+
/* Note on 'non-obvious' assembly sequence:
1098+
*
1099+
* While there are vminps/vmaxps instructions, there are two important differences between hardware
1100+
* and Java on how they handle floats:
1101+
* a. -0.0 and +0.0 are considered equal (vminps/vmaxps will return second parameter when inputs are equal)
1102+
* b. NaN is not necesarily propagated (vminps/vmaxps will return second parameter when either input is NaN)
1103+
*
1104+
* It is still more efficient to use vminps/vmaxps, but with some pre/post-processing:
1105+
* a. -0.0/+0.0: Bias negative (positive) numbers to second parameter before vminps (vmaxps)
1106+
* (only useful when signs differ, noop otherwise)
1107+
* b. NaN: Check if it was the first parameter that had the NaN (with vcmp[UNORD_Q])
1108+
1109+
* Following pseudo code describes the algorithm for max[FD] (Min algorithm is on similar lines):
1110+
* btmp = (b < +0.0) ? a : b
1111+
* atmp = (b < +0.0) ? b : a
1112+
* Tmp = Max_Float(atmp , btmp)
1113+
* Res = (atmp == NaN) ? atmp : Tmp
1114+
*/
1115+
1116+
void (MacroAssembler::*vblend)(XMMRegister, XMMRegister, XMMRegister, XMMRegister, int, bool, XMMRegister);
1117+
void (MacroAssembler::*vmaxmin)(XMMRegister, XMMRegister, XMMRegister, int);
1118+
void (MacroAssembler::*vcmp)(XMMRegister, XMMRegister, XMMRegister, int, int);
1119+
XMMRegister mask;
1120+
10971121
if (!is_double_word && is_min) {
1098-
vblendvps(atmp, a, b, a, vlen_enc);
1099-
vblendvps(btmp, b, a, a, vlen_enc);
1100-
vminps(tmp, atmp, btmp, vlen_enc);
1101-
vcmpps(btmp, atmp, atmp, Assembler::UNORD_Q, vlen_enc);
1102-
vblendvps(dst, tmp, atmp, btmp, vlen_enc);
1122+
mask = a;
1123+
vblend = &MacroAssembler::vblendvps;
1124+
vmaxmin = &MacroAssembler::vminps;
1125+
vcmp = &MacroAssembler::vcmpps;
11031126
} else if (!is_double_word && !is_min) {
1104-
vblendvps(btmp, b, a, b, vlen_enc);
1105-
vblendvps(atmp, a, b, b, vlen_enc);
1106-
vmaxps(tmp, atmp, btmp, vlen_enc);
1107-
vcmpps(btmp, atmp, atmp, Assembler::UNORD_Q, vlen_enc);
1108-
vblendvps(dst, tmp, atmp, btmp, vlen_enc);
1127+
mask = b;
1128+
vblend = &MacroAssembler::vblendvps;
1129+
vmaxmin = &MacroAssembler::vmaxps;
1130+
vcmp = &MacroAssembler::vcmpps;
11091131
} else if (is_double_word && is_min) {
1110-
vblendvpd(atmp, a, b, a, vlen_enc);
1111-
vblendvpd(btmp, b, a, a, vlen_enc);
1112-
vminpd(tmp, atmp, btmp, vlen_enc);
1113-
vcmppd(btmp, atmp, atmp, Assembler::UNORD_Q, vlen_enc);
1114-
vblendvpd(dst, tmp, atmp, btmp, vlen_enc);
1132+
mask = a;
1133+
vblend = &MacroAssembler::vblendvpd;
1134+
vmaxmin = &MacroAssembler::vminpd;
1135+
vcmp = &MacroAssembler::vcmppd;
11151136
} else {
11161137
assert(is_double_word && !is_min, "sanity");
1117-
vblendvpd(btmp, b, a, b, vlen_enc);
1118-
vblendvpd(atmp, a, b, b, vlen_enc);
1119-
vmaxpd(tmp, atmp, btmp, vlen_enc);
1120-
vcmppd(btmp, atmp, atmp, Assembler::UNORD_Q, vlen_enc);
1121-
vblendvpd(dst, tmp, atmp, btmp, vlen_enc);
1138+
mask = b;
1139+
vblend = &MacroAssembler::vblendvpd;
1140+
vmaxmin = &MacroAssembler::vmaxpd;
1141+
vcmp = &MacroAssembler::vcmppd;
11221142
}
1143+
1144+
// Make sure EnableX86ECoreOpts isn't disabled on register overlaps
1145+
XMMRegister maxmin, scratch;
1146+
if (dst == btmp) {
1147+
maxmin = btmp;
1148+
scratch = tmp;
1149+
} else {
1150+
maxmin = tmp;
1151+
scratch = btmp;
1152+
}
1153+
1154+
bool precompute_mask = EnableX86ECoreOpts && UseAVX>1;
1155+
if (precompute_mask && !is_double_word) {
1156+
vpsrad(tmp, mask, 32, vlen_enc);
1157+
mask = tmp;
1158+
} else if (precompute_mask && is_double_word) {
1159+
vpxor(tmp, tmp, tmp, vlen_enc);
1160+
vpcmpgtq(tmp, tmp, mask, vlen_enc);
1161+
mask = tmp;
1162+
}
1163+
1164+
(this->*vblend)(atmp, a, b, mask, vlen_enc, !precompute_mask, btmp);
1165+
(this->*vblend)(btmp, b, a, mask, vlen_enc, !precompute_mask, tmp);
1166+
(this->*vmaxmin)(maxmin, atmp, btmp, vlen_enc);
1167+
(this->*vcmp)(scratch, atmp, atmp, Assembler::UNORD_Q, vlen_enc);
1168+
(this->*vblend)(dst, maxmin, atmp, scratch, vlen_enc, false, scratch);
11231169
}
11241170

11251171
void C2_MacroAssembler::evminmax_fp(int opcode, BasicType elem_bt,
@@ -5318,18 +5364,18 @@ void C2_MacroAssembler::vector_signum_avx(int opcode, XMMRegister dst, XMMRegist
53185364
if (opcode == Op_SignumVD) {
53195365
vsubpd(dst, zero, one, vec_enc);
53205366
// if src < 0 ? -1 : 1
5321-
vblendvpd(dst, one, dst, src, vec_enc);
5367+
vblendvpd(dst, one, dst, src, vec_enc, true, xtmp1);
53225368
// if src == NaN, -0.0 or 0.0 return src.
53235369
vcmppd(xtmp1, src, zero, Assembler::EQ_UQ, vec_enc);
5324-
vblendvpd(dst, dst, src, xtmp1, vec_enc);
5370+
vblendvpd(dst, dst, src, xtmp1, vec_enc, false, xtmp1);
53255371
} else {
53265372
assert(opcode == Op_SignumVF, "");
53275373
vsubps(dst, zero, one, vec_enc);
53285374
// if src < 0 ? -1 : 1
5329-
vblendvps(dst, one, dst, src, vec_enc);
5375+
vblendvps(dst, one, dst, src, vec_enc, true, xtmp1);
53305376
// if src == NaN, -0.0 or 0.0 return src.
53315377
vcmpps(xtmp1, src, zero, Assembler::EQ_UQ, vec_enc);
5332-
vblendvps(dst, dst, src, xtmp1, vec_enc);
5378+
vblendvps(dst, dst, src, xtmp1, vec_enc, false, xtmp1);
53335379
}
53345380
}
53355381

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

+50
Original file line numberDiff line numberDiff line change
@@ -3566,6 +3566,56 @@ void MacroAssembler::vbroadcastss(XMMRegister dst, AddressLiteral src, int vecto
35663566
}
35673567
}
35683568

3569+
// Vector float blend
3570+
// vblendvps(XMMRegister dst, XMMRegister nds, XMMRegister src, XMMRegister mask, int vector_len, bool compute_mask = true, XMMRegister scratch = xnoreg)
3571+
void MacroAssembler::vblendvps(XMMRegister dst, XMMRegister src1, XMMRegister src2, XMMRegister mask, int vector_len, bool compute_mask, XMMRegister scratch) {
3572+
// WARN: Allow dst == (src1|src2), mask == scratch
3573+
bool blend_emulation = EnableX86ECoreOpts && UseAVX > 1;
3574+
bool scratch_available = scratch != xnoreg && scratch != src1 && scratch != src2 && scratch != dst;
3575+
bool dst_available = dst != mask && (dst != src1 || dst != src2);
3576+
if (blend_emulation && scratch_available && dst_available) {
3577+
if (compute_mask) {
3578+
vpsrad(scratch, mask, 32, vector_len);
3579+
mask = scratch;
3580+
}
3581+
if (dst == src1) {
3582+
vpandn(dst, mask, src1, vector_len); // if mask == 0, src1
3583+
vpand (scratch, mask, src2, vector_len); // if mask == 1, src2
3584+
} else {
3585+
vpand (dst, mask, src2, vector_len); // if mask == 1, src2
3586+
vpandn(scratch, mask, src1, vector_len); // if mask == 0, src1
3587+
}
3588+
vpor(dst, dst, scratch, vector_len);
3589+
} else {
3590+
Assembler::vblendvps(dst, src1, src2, mask, vector_len);
3591+
}
3592+
}
3593+
3594+
// vblendvpd(XMMRegister dst, XMMRegister nds, XMMRegister src, XMMRegister mask, int vector_len, bool compute_mask = true, XMMRegister scratch = xnoreg)
3595+
void MacroAssembler::vblendvpd(XMMRegister dst, XMMRegister src1, XMMRegister src2, XMMRegister mask, int vector_len, bool compute_mask, XMMRegister scratch) {
3596+
// WARN: Allow dst == (src1|src2), mask == scratch
3597+
bool blend_emulation = EnableX86ECoreOpts && UseAVX > 1;
3598+
bool scratch_available = scratch != xnoreg && scratch != src1 && scratch != src2 && scratch != dst && (!compute_mask || scratch != mask);
3599+
bool dst_available = dst != mask && (dst != src1 || dst != src2);
3600+
if (blend_emulation && scratch_available && dst_available) {
3601+
if (compute_mask) {
3602+
vpxor(scratch, scratch, scratch, vector_len);
3603+
vpcmpgtq(scratch, scratch, mask, vector_len);
3604+
mask = scratch;
3605+
}
3606+
if (dst == src1) {
3607+
vpandn(dst, mask, src1, vector_len); // if mask == 0, src
3608+
vpand (scratch, mask, src2, vector_len); // if mask == 1, src2
3609+
} else {
3610+
vpand (dst, mask, src2, vector_len); // if mask == 1, src2
3611+
vpandn(scratch, mask, src1, vector_len); // if mask == 0, src
3612+
}
3613+
vpor(dst, dst, scratch, vector_len);
3614+
} else {
3615+
Assembler::vblendvpd(dst, src1, src2, mask, vector_len);
3616+
}
3617+
}
3618+
35693619
void MacroAssembler::vpcmpeqb(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) {
35703620
assert(((dst->encoding() < 16 && src->encoding() < 16 && nds->encoding() < 16) || VM_Version::supports_avx512vlbw()),"XMM register should be 0-15");
35713621
Assembler::vpcmpeqb(dst, nds, src, vector_len);

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

+4
Original file line numberDiff line numberDiff line change
@@ -1130,6 +1130,10 @@ class MacroAssembler: public Assembler {
11301130
using Assembler::vbroadcastss;
11311131
void vbroadcastss(XMMRegister dst, AddressLiteral src, int vector_len, Register rscratch = noreg);
11321132

1133+
// Vector float blend
1134+
void vblendvps(XMMRegister dst, XMMRegister nds, XMMRegister src, XMMRegister mask, int vector_len, bool compute_mask = true, XMMRegister scratch = xnoreg);
1135+
void vblendvpd(XMMRegister dst, XMMRegister nds, XMMRegister src, XMMRegister mask, int vector_len, bool compute_mask = true, XMMRegister scratch = xnoreg);
1136+
11331137
void divsd(XMMRegister dst, XMMRegister src) { Assembler::divsd(dst, src); }
11341138
void divsd(XMMRegister dst, Address src) { Assembler::divsd(dst, src); }
11351139
void divsd(XMMRegister dst, AddressLiteral src, Register rscratch = noreg);

‎src/hotspot/cpu/x86/x86.ad

+18-2
Original file line numberDiff line numberDiff line change
@@ -7801,7 +7801,7 @@ instruct blendvp(vec dst, vec src, vec mask, rxmm0 tmp) %{
78017801
%}
78027802

78037803
instruct vblendvpI(legVec dst, legVec src1, legVec src2, legVec mask) %{
7804-
predicate(UseAVX > 0 &&
7804+
predicate(UseAVX > 0 && !EnableX86ECoreOpts &&
78057805
n->in(2)->bottom_type()->isa_vectmask() == NULL &&
78067806
Matcher::vector_length_in_bytes(n) <= 32 &&
78077807
is_integral_type(Matcher::vector_element_basic_type(n)));
@@ -7815,7 +7815,7 @@ instruct vblendvpI(legVec dst, legVec src1, legVec src2, legVec mask) %{
78157815
%}
78167816

78177817
instruct vblendvpFD(legVec dst, legVec src1, legVec src2, legVec mask) %{
7818-
predicate(UseAVX > 0 &&
7818+
predicate(UseAVX > 0 && !EnableX86ECoreOpts &&
78197819
n->in(2)->bottom_type()->isa_vectmask() == NULL &&
78207820
Matcher::vector_length_in_bytes(n) <= 32 &&
78217821
!is_integral_type(Matcher::vector_element_basic_type(n)));
@@ -7828,6 +7828,22 @@ instruct vblendvpFD(legVec dst, legVec src1, legVec src2, legVec mask) %{
78287828
ins_pipe( pipe_slow );
78297829
%}
78307830

7831+
instruct vblendvp(legVec dst, legVec src1, legVec src2, legVec mask, legVec vtmp) %{
7832+
predicate(UseAVX > 0 && EnableX86ECoreOpts &&
7833+
n->in(2)->bottom_type()->isa_vectmask() == NULL &&
7834+
Matcher::vector_length_in_bytes(n) <= 32);
7835+
match(Set dst (VectorBlend (Binary src1 src2) mask));
7836+
format %{ "vector_blend $dst,$src1,$src2,$mask\t! using $vtmp as TEMP" %}
7837+
effect(TEMP vtmp, TEMP dst);
7838+
ins_encode %{
7839+
int vlen_enc = vector_length_encoding(this);
7840+
__ vpandn($vtmp$$XMMRegister, $mask$$XMMRegister, $src1$$XMMRegister, vlen_enc);
7841+
__ vpand ($dst$$XMMRegister, $mask$$XMMRegister, $src2$$XMMRegister, vlen_enc);
7842+
__ vpor ($dst$$XMMRegister, $dst$$XMMRegister, $vtmp$$XMMRegister, vlen_enc);
7843+
%}
7844+
ins_pipe( pipe_slow );
7845+
%}
7846+
78317847
instruct evblendvp64(vec dst, vec src1, vec src2, vec mask, kReg ktmp) %{
78327848
predicate(Matcher::vector_length_in_bytes(n) == 64 &&
78337849
n->in(2)->bottom_type()->isa_vectmask() == NULL);

‎src/hotspot/cpu/x86/x86_64.ad

+11-63
Original file line numberDiff line numberDiff line change
@@ -4478,34 +4478,15 @@ instruct loadD(regD dst, memory mem)
44784478
ins_pipe(pipe_slow); // XXX
44794479
%}
44804480

4481-
4482-
// Following pseudo code describes the algorithm for max[FD]:
4483-
// Min algorithm is on similar lines
4484-
// btmp = (b < +0.0) ? a : b
4485-
// atmp = (b < +0.0) ? b : a
4486-
// Tmp = Max_Float(atmp , btmp)
4487-
// Res = (atmp == NaN) ? atmp : Tmp
4488-
44894481
// max = java.lang.Math.max(float a, float b)
44904482
instruct maxF_reg(legRegF dst, legRegF a, legRegF b, legRegF tmp, legRegF atmp, legRegF btmp) %{
44914483
predicate(UseAVX > 0 && !SuperWord::is_reduction(n));
44924484
match(Set dst (MaxF a b));
44934485
effect(USE a, USE b, TEMP tmp, TEMP atmp, TEMP btmp);
4494-
format %{
4495-
"vblendvps $btmp,$b,$a,$b \n\t"
4496-
"vblendvps $atmp,$a,$b,$b \n\t"
4497-
"vmaxss $tmp,$atmp,$btmp \n\t"
4498-
"vcmpps.unordered $btmp,$atmp,$atmp \n\t"
4499-
"vblendvps $dst,$tmp,$atmp,$btmp \n\t"
4500-
%}
4501-
ins_encode %{
4502-
int vector_len = Assembler::AVX_128bit;
4503-
__ vblendvps($btmp$$XMMRegister, $b$$XMMRegister, $a$$XMMRegister, $b$$XMMRegister, vector_len);
4504-
__ vblendvps($atmp$$XMMRegister, $a$$XMMRegister, $b$$XMMRegister, $b$$XMMRegister, vector_len);
4505-
__ vmaxss($tmp$$XMMRegister, $atmp$$XMMRegister, $btmp$$XMMRegister);
4506-
__ vcmpps($btmp$$XMMRegister, $atmp$$XMMRegister, $atmp$$XMMRegister, Assembler::_false, vector_len);
4507-
__ vblendvps($dst$$XMMRegister, $tmp$$XMMRegister, $atmp$$XMMRegister, $btmp$$XMMRegister, vector_len);
4508-
%}
4486+
format %{ "maxF $dst, $a, $b \t! using tmp, atmp and btmp as TEMP" %}
4487+
ins_encode %{
4488+
__ vminmax_fp(Op_MaxV, T_FLOAT, $dst$$XMMRegister, $a$$XMMRegister, $b$$XMMRegister, $tmp$$XMMRegister, $atmp$$XMMRegister, $btmp$$XMMRegister, Assembler::AVX_128bit);
4489+
%}
45094490
ins_pipe( pipe_slow );
45104491
%}
45114492

@@ -4527,20 +4508,9 @@ instruct maxD_reg(legRegD dst, legRegD a, legRegD b, legRegD tmp, legRegD atmp,
45274508
predicate(UseAVX > 0 && !SuperWord::is_reduction(n));
45284509
match(Set dst (MaxD a b));
45294510
effect(USE a, USE b, TEMP atmp, TEMP btmp, TEMP tmp);
4530-
format %{
4531-
"vblendvpd $btmp,$b,$a,$b \n\t"
4532-
"vblendvpd $atmp,$a,$b,$b \n\t"
4533-
"vmaxsd $tmp,$atmp,$btmp \n\t"
4534-
"vcmppd.unordered $btmp,$atmp,$atmp \n\t"
4535-
"vblendvpd $dst,$tmp,$atmp,$btmp \n\t"
4536-
%}
4511+
format %{ "maxD $dst, $a, $b \t! using tmp, atmp and btmp as TEMP" %}
45374512
ins_encode %{
4538-
int vector_len = Assembler::AVX_128bit;
4539-
__ vblendvpd($btmp$$XMMRegister, $b$$XMMRegister, $a$$XMMRegister, $b$$XMMRegister, vector_len);
4540-
__ vblendvpd($atmp$$XMMRegister, $a$$XMMRegister, $b$$XMMRegister, $b$$XMMRegister, vector_len);
4541-
__ vmaxsd($tmp$$XMMRegister, $atmp$$XMMRegister, $btmp$$XMMRegister);
4542-
__ vcmppd($btmp$$XMMRegister, $atmp$$XMMRegister, $atmp$$XMMRegister, Assembler::_false, vector_len);
4543-
__ vblendvpd($dst$$XMMRegister, $tmp$$XMMRegister, $atmp$$XMMRegister, $btmp$$XMMRegister, vector_len);
4513+
__ vminmax_fp(Op_MaxV, T_DOUBLE, $dst$$XMMRegister, $a$$XMMRegister, $b$$XMMRegister, $tmp$$XMMRegister, $atmp$$XMMRegister, $btmp$$XMMRegister, Assembler::AVX_128bit);
45444514
%}
45454515
ins_pipe( pipe_slow );
45464516
%}
@@ -4563,20 +4533,9 @@ instruct minF_reg(legRegF dst, legRegF a, legRegF b, legRegF tmp, legRegF atmp,
45634533
predicate(UseAVX > 0 && !SuperWord::is_reduction(n));
45644534
match(Set dst (MinF a b));
45654535
effect(USE a, USE b, TEMP tmp, TEMP atmp, TEMP btmp);
4566-
format %{
4567-
"vblendvps $atmp,$a,$b,$a \n\t"
4568-
"vblendvps $btmp,$b,$a,$a \n\t"
4569-
"vminss $tmp,$atmp,$btmp \n\t"
4570-
"vcmpps.unordered $btmp,$atmp,$atmp \n\t"
4571-
"vblendvps $dst,$tmp,$atmp,$btmp \n\t"
4572-
%}
4536+
format %{ "minF $dst, $a, $b \t! using tmp, atmp and btmp as TEMP" %}
45734537
ins_encode %{
4574-
int vector_len = Assembler::AVX_128bit;
4575-
__ vblendvps($atmp$$XMMRegister, $a$$XMMRegister, $b$$XMMRegister, $a$$XMMRegister, vector_len);
4576-
__ vblendvps($btmp$$XMMRegister, $b$$XMMRegister, $a$$XMMRegister, $a$$XMMRegister, vector_len);
4577-
__ vminss($tmp$$XMMRegister, $atmp$$XMMRegister, $btmp$$XMMRegister);
4578-
__ vcmpps($btmp$$XMMRegister, $atmp$$XMMRegister, $atmp$$XMMRegister, Assembler::_false, vector_len);
4579-
__ vblendvps($dst$$XMMRegister, $tmp$$XMMRegister, $atmp$$XMMRegister, $btmp$$XMMRegister, vector_len);
4538+
__ vminmax_fp(Op_MinV, T_FLOAT, $dst$$XMMRegister, $a$$XMMRegister, $b$$XMMRegister, $tmp$$XMMRegister, $atmp$$XMMRegister, $btmp$$XMMRegister, Assembler::AVX_128bit);
45804539
%}
45814540
ins_pipe( pipe_slow );
45824541
%}
@@ -4599,20 +4558,9 @@ instruct minD_reg(legRegD dst, legRegD a, legRegD b, legRegD tmp, legRegD atmp,
45994558
predicate(UseAVX > 0 && !SuperWord::is_reduction(n));
46004559
match(Set dst (MinD a b));
46014560
effect(USE a, USE b, TEMP tmp, TEMP atmp, TEMP btmp);
4602-
format %{
4603-
"vblendvpd $atmp,$a,$b,$a \n\t"
4604-
"vblendvpd $btmp,$b,$a,$a \n\t"
4605-
"vminsd $tmp,$atmp,$btmp \n\t"
4606-
"vcmppd.unordered $btmp,$atmp,$atmp \n\t"
4607-
"vblendvpd $dst,$tmp,$atmp,$btmp \n\t"
4608-
%}
4609-
ins_encode %{
4610-
int vector_len = Assembler::AVX_128bit;
4611-
__ vblendvpd($atmp$$XMMRegister, $a$$XMMRegister, $b$$XMMRegister, $a$$XMMRegister, vector_len);
4612-
__ vblendvpd($btmp$$XMMRegister, $b$$XMMRegister, $a$$XMMRegister, $a$$XMMRegister, vector_len);
4613-
__ vminsd($tmp$$XMMRegister, $atmp$$XMMRegister, $btmp$$XMMRegister);
4614-
__ vcmppd($btmp$$XMMRegister, $atmp$$XMMRegister, $atmp$$XMMRegister, Assembler::_false, vector_len);
4615-
__ vblendvpd($dst$$XMMRegister, $tmp$$XMMRegister, $atmp$$XMMRegister, $btmp$$XMMRegister, vector_len);
4561+
format %{ "minD $dst, $a, $b \t! using tmp, atmp and btmp as TEMP" %}
4562+
ins_encode %{
4563+
__ vminmax_fp(Op_MinV, T_DOUBLE, $dst$$XMMRegister, $a$$XMMRegister, $b$$XMMRegister, $tmp$$XMMRegister, $atmp$$XMMRegister, $btmp$$XMMRegister, Assembler::AVX_128bit);
46164564
%}
46174565
ins_pipe( pipe_slow );
46184566
%}

‎src/java.desktop/macosx/classes/sun/lwawt/LWWindowPeer.java

+8-4
Original file line numberDiff line numberDiff line change
@@ -1044,7 +1044,7 @@ public void notifyMouseWheelEvent(long when, int x, int y, int absX,
10441044
*/
10451045
@Override
10461046
public void notifyKeyEvent(int id, long when, int modifiers,
1047-
int keyCode, char keyChar, int keyLocation)
1047+
int keyCode, char keyChar, int keyLocation, int extendedKeyCode)
10481048
{
10491049
LWKeyboardFocusManagerPeer kfmPeer = LWKeyboardFocusManagerPeer.getInstance();
10501050
Component focusOwner = kfmPeer.getCurrentFocusOwner();
@@ -1058,9 +1058,13 @@ public void notifyKeyEvent(int id, long when, int modifiers,
10581058

10591059
KeyEvent keyEvent = new KeyEvent(focusOwner, id, when, modifiers,
10601060
keyCode, keyChar, keyLocation);
1061-
AWTAccessor.getKeyEventAccessor().setExtendedKeyCode(keyEvent,
1062-
(keyChar == KeyEvent.CHAR_UNDEFINED) ? keyCode
1063-
: ExtendedKeyCodes.getExtendedKeyCodeForChar(keyChar));
1061+
if (extendedKeyCode >= 0) {
1062+
AWTAccessor.getKeyEventAccessor().setExtendedKeyCode(keyEvent, extendedKeyCode);
1063+
} else {
1064+
AWTAccessor.getKeyEventAccessor().setExtendedKeyCode(keyEvent,
1065+
(keyChar == KeyEvent.CHAR_UNDEFINED) ? keyCode
1066+
: ExtendedKeyCodes.getExtendedKeyCodeForChar(keyChar));
1067+
}
10641068
postEvent(keyEvent);
10651069
}
10661070

‎src/java.desktop/macosx/classes/sun/lwawt/PlatformEventNotifier.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,5 @@ void notifyMouseWheelEvent(long when, int x, int y, final int absX,
6161
* Called by the delegate when a key is pressed.
6262
*/
6363
void notifyKeyEvent(int id, long when, int modifiers,
64-
int keyCode, char keyChar, int keyLocation);
64+
int keyCode, char keyChar, int keyLocation, int extendedKeyCode);
6565
}

‎src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java

+8-6
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ void handleKeyEvent(int eventType, int modifierFlags, String chars, String chars
143143

144144
int jeventType = KeyEvent.KEY_PRESSED;
145145
int jkeyCode = KeyEvent.VK_UNDEFINED;
146+
int jextendedkeyCode = -1;
146147
int jkeyLocation = KeyEvent.KEY_LOCATION_UNKNOWN;
147148
boolean postsTyped = false;
148149
boolean spaceKeyTyped = false;
@@ -173,7 +174,7 @@ void handleKeyEvent(int eventType, int modifierFlags, String chars, String chars
173174
charsIgnoringModifiers.charAt(0) : KeyEvent.CHAR_UNDEFINED;
174175

175176
int[] in = new int[] {testCharIgnoringModifiers, isDeadChar ? 1 : 0, modifierFlags, keyCode};
176-
int[] out = new int[3]; // [jkeyCode, jkeyLocation, deadChar]
177+
int[] out = new int[4]; // [jkeyCode, jkeyLocation, deadChar, extendedKeyCode]
177178

178179
postsTyped = NSEvent.nsToJavaKeyInfo(in, out);
179180
if (!postsTyped) {
@@ -201,6 +202,7 @@ void handleKeyEvent(int eventType, int modifierFlags, String chars, String chars
201202
}
202203

203204
jkeyCode = out[0];
205+
jextendedkeyCode = out[3];
204206
jkeyLocation = out[1];
205207
jeventType = isNpapiCallback ? NSEvent.npToJavaEventType(eventType) :
206208
NSEvent.nsToJavaEventType(eventType);
@@ -221,7 +223,7 @@ void handleKeyEvent(int eventType, int modifierFlags, String chars, String chars
221223
lastKeyPressCode = jkeyCode;
222224
}
223225
eventNotifier.notifyKeyEvent(jeventType, when, jmodifiers,
224-
jkeyCode, javaChar, jkeyLocation);
226+
jkeyCode, javaChar, jkeyLocation, jextendedkeyCode);
225227

226228
// Current browser may be sending input events, so don't
227229
// post the KEY_TYPED here.
@@ -241,12 +243,12 @@ void handleKeyEvent(int eventType, int modifierFlags, String chars, String chars
241243
}
242244
eventNotifier.notifyKeyEvent(KeyEvent.KEY_TYPED, when, jmodifiers,
243245
KeyEvent.VK_UNDEFINED, javaChar,
244-
KeyEvent.KEY_LOCATION_UNKNOWN);
246+
KeyEvent.KEY_LOCATION_UNKNOWN, jextendedkeyCode);
245247
//If events come from Firefox, released events should also be generated.
246248
if (needsKeyReleased) {
247249
eventNotifier.notifyKeyEvent(KeyEvent.KEY_RELEASED, when, jmodifiers,
248250
jkeyCode, javaChar,
249-
KeyEvent.KEY_LOCATION_UNKNOWN);
251+
KeyEvent.KEY_LOCATION_UNKNOWN, jextendedkeyCode);
250252
}
251253
}
252254
}
@@ -260,13 +262,13 @@ void handleInputEvent(String text) {
260262
eventNotifier.notifyKeyEvent(KeyEvent.KEY_TYPED,
261263
System.currentTimeMillis(),
262264
0, KeyEvent.VK_UNDEFINED, c,
263-
KeyEvent.KEY_LOCATION_UNKNOWN);
265+
KeyEvent.KEY_LOCATION_UNKNOWN, -1);
264266
index++;
265267
}
266268
eventNotifier.notifyKeyEvent(KeyEvent.KEY_RELEASED,
267269
System.currentTimeMillis(),
268270
0, lastKeyPressCode, c,
269-
KeyEvent.KEY_LOCATION_UNKNOWN);
271+
KeyEvent.KEY_LOCATION_UNKNOWN, -1);
270272
}
271273
}
272274

‎src/java.desktop/macosx/classes/sun/lwawt/macosx/CWarningWindow.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ public void notifyMouseWheelEvent(long when, int x, int y, int absX,
245245

246246
@Override
247247
public void notifyKeyEvent(int id, long when, int modifiers, int keyCode,
248-
char keyChar, int keyLocation) {
248+
char keyChar, int keyLocation, int jextendedkeyCode) {
249249
}
250250

251251
protected int getInitialStyleBits() {

‎src/java.desktop/macosx/native/libawt_lwawt/awt/AWTEvent.m

+7-6
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ static unichar NsGetDeadKeyChar(unsigned short keyCode)
429429
NsCharToJavaVirtualKeyCode(unichar ch, BOOL isDeadChar,
430430
NSUInteger flags, unsigned short key,
431431
jint *keyCode, jint *keyLocation, BOOL *postsTyped,
432-
unichar *deadChar)
432+
unichar *deadChar, jint *extendedkeyCode)
433433
{
434434
static size_t size = sizeof(keyTable) / sizeof(struct _key);
435435
NSInteger offset;
@@ -469,10 +469,9 @@ static unichar NsGetDeadKeyChar(unsigned short keyCode)
469469
*postsTyped = YES;
470470
// do quick conversion
471471
// the keyCode is off by 32, so adding it here
472-
*keyCode = java_awt_event_KeyEvent_VK_A + offset + 32;
472+
*extendedkeyCode = java_awt_event_KeyEvent_VK_A + offset + 32;
473473
*keyLocation = java_awt_event_KeyEvent_KEY_LOCATION_STANDARD;
474-
return;
475-
}
474+
}
476475
}
477476

478477
if ([[NSCharacterSet decimalDigitCharacterSet] characterIsMember:ch]) {
@@ -695,18 +694,20 @@ jlong UTC(NSEvent *event) {
695694
jshort keyCode = (jshort)data[3];
696695

697696
jint jkeyCode = java_awt_event_KeyEvent_VK_UNDEFINED;
697+
jint jextendedkeyCode = -1;
698698
jint jkeyLocation = java_awt_event_KeyEvent_KEY_LOCATION_UNKNOWN;
699699
jint testDeadChar = 0;
700700

701701
NsCharToJavaVirtualKeyCode((unichar)testChar, isDeadChar,
702702
(NSUInteger)modifierFlags, (unsigned short)keyCode,
703703
&jkeyCode, &jkeyLocation, &postsTyped,
704-
(unichar *) &testDeadChar);
704+
(unichar *) &testDeadChar, &jextendedkeyCode);
705705

706-
// out = [jkeyCode, jkeyLocation, deadChar];
706+
// out = [jkeyCode, jkeyLocation, deadChar, jextendedkeyCode];
707707
(*env)->SetIntArrayRegion(env, outData, 0, 1, &jkeyCode);
708708
(*env)->SetIntArrayRegion(env, outData, 1, 1, &jkeyLocation);
709709
(*env)->SetIntArrayRegion(env, outData, 2, 1, &testDeadChar);
710+
(*env)->SetIntArrayRegion(env, outData, 3, 1, &jextendedkeyCode);
710711

711712
(*env)->ReleaseIntArrayElements(env, inData, data, 0);
712713

‎test/hotspot/jtreg/compiler/vectorization/TestSignumVector.java

+24-2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333

3434
package compiler.vectorization;
3535

36+
import java.util.Random;
37+
3638
import compiler.lib.ir_framework.*;
3739

3840
public class TestSignumVector {
@@ -62,12 +64,22 @@ public void test_signum_double(double[] dout, double[] dinp) {
6264
public void kernel_test_signum_double() {
6365
dinp = new double[ARRLEN];
6466
dout = new double[ARRLEN];
67+
Random rnd = new Random(20);
6568
for(int i = 0 ; i < ARRLEN; i++) {
66-
dinp[i] = (double)i*1.4;
69+
dinp[i] = (i-ARRLEN/2)*rnd.nextDouble();
6770
}
6871
for (int i = 0; i < ITERS; i++) {
6972
test_signum_double(dout , dinp);
7073
}
74+
for(int i = 0 ; i < ARRLEN; i++) {
75+
if (i-ARRLEN/2<0) {
76+
if (dout[i] != -1.0) throw new RuntimeException("Expected negative numbers in first half of array: " + java.util.Arrays.toString(dout));
77+
} else if (i-ARRLEN/2==0) {
78+
if (dout[i] != 0) throw new RuntimeException("Expected zero in the middle of array: " + java.util.Arrays.toString(dout));
79+
} else {
80+
if (dout[i] != 1.0) throw new RuntimeException("Expected positive numbers in second half of array: " + java.util.Arrays.toString(dout));
81+
}
82+
}
7183
}
7284

7385
@Test
@@ -82,11 +94,21 @@ public void test_signum_float(float[] fout, float[] finp) {
8294
public void kernel_test_round() {
8395
finp = new float[ARRLEN];
8496
fout = new float[ARRLEN];
97+
Random rnd = new Random(20);
8598
for(int i = 0 ; i < ARRLEN; i++) {
86-
finp[i] = (float)i*1.4f;
99+
finp[i] = (i-ARRLEN/2)*rnd.nextFloat();
87100
}
88101
for (int i = 0; i < ITERS; i++) {
89102
test_signum_float(fout , finp);
90103
}
104+
for(int i = 0 ; i < ARRLEN; i++) {
105+
if (i-ARRLEN/2<0) {
106+
if (fout[i] != -1.0) throw new RuntimeException("Expected negative numbers in first half of array: " + java.util.Arrays.toString(fout));
107+
} else if (i-ARRLEN/2==0) {
108+
if (fout[i] != 0) throw new RuntimeException("Expected zero in the middle of array: " + java.util.Arrays.toString(fout));
109+
} else {
110+
if (fout[i] != 1.0) throw new RuntimeException("Expected positive numbers in second half of array: " + java.util.Arrays.toString(fout));
111+
}
112+
}
91113
}
92114
}

‎test/hotspot/jtreg/compiler/vectorization/runner/BasicDoubleOpTest.java

+55-2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
package compiler.vectorization.runner;
4343

4444
import compiler.lib.ir_framework.*;
45+
import java.util.Random;
4546

4647
public class BasicDoubleOpTest extends VectorizationTestRunner {
4748

@@ -50,11 +51,63 @@ public class BasicDoubleOpTest extends VectorizationTestRunner {
5051
private double[] a;
5152
private double[] b;
5253
private double[] c;
54+
private double[] d;
55+
private double[] e;
5356

5457
public BasicDoubleOpTest() {
58+
// Positive test values sign | exponent | mantisa
59+
double smallPositive = Double.longBitsToDouble(0<<63 | 0x03f << 52 | 0x30000f);
60+
double positive = Double.longBitsToDouble(0<<63 | 0x07f << 52 | 0x30000f);
61+
double bigPositive = Double.longBitsToDouble(0<<63 | 0x07f << 52 | 0x30100f);
62+
double biggerPositive = Double.longBitsToDouble(0<<63 | 0x7fe << 52 | 0x30000f);
63+
double maxPositive = Double.MAX_VALUE;
64+
65+
// Special positive
66+
double nan1 = Double.longBitsToDouble(0<<63 | 0x7ff << 52 | 0x7fffff);
67+
double nan2 = Double.longBitsToDouble(0<<63 | 0x7ff << 52 | 0x30000f);
68+
double inf = Double.longBitsToDouble(0<<63 | 0x7ff << 52);
69+
double zero = 0.0;
70+
71+
// Negative test values sign | exponent | mantisa
72+
double smallNegative = Double.longBitsToDouble(1<<63 | 0x003 << 52 | 0x30000f);
73+
double negative = Double.longBitsToDouble(1<<63 | 0x783 << 52 | 0x30100f);
74+
double bigNegative = Double.longBitsToDouble(1<<63 | 0x783 << 52 | 0x30000f);
75+
double biggerNegative = Double.longBitsToDouble(1<<63 | 0x786 << 52 | 0x30000f);
76+
double maxNegative = Double.longBitsToDouble(1<<63 | 0x7fe << 52 | 0x7fffff);
77+
78+
// Special negative
79+
double nNan1 = Double.longBitsToDouble(1<<63 | 0x7ff << 52 | 0x7fffff);
80+
double nNan2 = Double.longBitsToDouble(1<<63 | 0x7ff << 52 | 0x30000f);
81+
double nInf = Double.longBitsToDouble(1<<63 | 0x7ff << 52);
82+
double nZero = -0.0;
83+
84+
double[] numberList = new double[] {
85+
nInf, maxNegative, biggerNegative, bigNegative, negative, smallNegative, nZero,
86+
zero, smallPositive, positive, bigPositive, biggerPositive, maxPositive, inf,
87+
nan1, nan2, nNan1, nNan2
88+
};
89+
90+
Random rnd = new Random(10);
5591
a = new double[SIZE];
5692
b = new double[SIZE];
5793
c = new double[SIZE];
94+
d = new double[SIZE];
95+
e = new double[SIZE];
96+
97+
for (int i = 0; i < SIZE;) {
98+
for (int j = 0; j < numberList.length && i < SIZE; j++, i++) {
99+
for (int k = j; k < numberList.length && i < SIZE; k++, i++) {
100+
if (rnd.nextBoolean()) {
101+
d[i] = numberList[j];
102+
e[i] = numberList[k];
103+
} else {
104+
d[i] = numberList[k];
105+
e[i] = numberList[j];
106+
}
107+
}
108+
}
109+
}
110+
58111
for (int i = 0; i < SIZE; i++) {
59112
a[i] = 850.0 * i + 22222.22;
60113
b[i] = -12345.678;
@@ -179,7 +232,7 @@ public double[] vectorDiv() {
179232
public double[] vectorMax() {
180233
double[] res = new double[SIZE];
181234
for (int i = 0; i < SIZE; i++) {
182-
res[i] = Math.max(a[i], b[i]);
235+
res[i] = Math.max(d[i], e[i]);
183236
}
184237
return res;
185238
}
@@ -190,7 +243,7 @@ public double[] vectorMax() {
190243
public double[] vectorMin() {
191244
double[] res = new double[SIZE];
192245
for (int i = 0; i < SIZE; i++) {
193-
res[i] = Math.min(a[i], b[i]);
246+
res[i] = Math.min(d[i], e[i]);
194247
}
195248
return res;
196249
}

‎test/hotspot/jtreg/compiler/vectorization/runner/BasicFloatOpTest.java

+64-2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
package compiler.vectorization.runner;
4343

4444
import compiler.lib.ir_framework.*;
45+
import java.util.Random;
4546

4647
public class BasicFloatOpTest extends VectorizationTestRunner {
4748

@@ -50,11 +51,72 @@ public class BasicFloatOpTest extends VectorizationTestRunner {
5051
private float[] a;
5152
private float[] b;
5253
private float[] c;
54+
private float[] d;
55+
private float[] e;
5356

5457
public BasicFloatOpTest() {
58+
// Positive test values sign | exponent | mantisa
59+
float smallPositive = Float.intBitsToFloat(0<<31 | 0x3f << 23 | 0x30000f);
60+
float positive = Float.intBitsToFloat(0<<31 | 0x7f << 23 | 0x30000f);
61+
float bigPositive = Float.intBitsToFloat(0<<31 | 0x7f << 23 | 0x30100f);
62+
float biggerPositive = Float.intBitsToFloat(0<<31 | 0xfe << 23 | 0x30000f);
63+
float maxPositive = Float.MAX_VALUE;
64+
65+
// Special positive
66+
float nan1 = Float.intBitsToFloat(0<<31 | 0xff << 23 | 0x7fffff);
67+
float nan2 = Float.intBitsToFloat(0<<31 | 0xff << 23 | 0x30000f);
68+
float inf = Float.intBitsToFloat(0<<31 | 0xff << 23);
69+
float zero = 0.0f;
70+
71+
// Negative test values sign | exponent | mantisa
72+
float smallNegative = Float.intBitsToFloat(1<<31 | 0x03 << 23 | 0x30000f);
73+
float negative = Float.intBitsToFloat(1<<31 | 0x83 << 23 | 0x30100f);
74+
float bigNegative = Float.intBitsToFloat(1<<31 | 0x83 << 23 | 0x30000f);
75+
float biggerNegative = Float.intBitsToFloat(1<<31 | 0x86 << 23 | 0x30000f);
76+
float maxNegative = Float.intBitsToFloat(1<<31 | 0xfe << 23 | 0x7fffff);
77+
78+
// Special negative
79+
float nNan1 = Float.intBitsToFloat(1<<31 | 0xff << 23 | 0x7fffff);
80+
float nNan2 = Float.intBitsToFloat(1<<31 | 0xff << 23 | 0x30000f);
81+
float nInf = Float.intBitsToFloat(1<<31 | 0xff << 23);
82+
float nZero = -0.0f;
83+
84+
float[] orderedList = new float[] {
85+
nInf, maxNegative, biggerNegative, bigNegative, negative, smallNegative, nZero,
86+
zero, smallPositive, positive, bigPositive, biggerPositive, maxPositive, inf
87+
};
88+
89+
float[] NaNs = new float[] {
90+
nan1, nan2, nNan1, nNan2
91+
};
92+
93+
float[] numberList = new float[] {
94+
nInf, maxNegative, biggerNegative, bigNegative, negative, smallNegative, nZero,
95+
zero, smallPositive, positive, bigPositive, biggerPositive, maxPositive, inf,
96+
nan1, nan2, nNan1, nNan2
97+
};
98+
99+
Random rnd = new Random(11);
55100
a = new float[SIZE];
56101
b = new float[SIZE];
57102
c = new float[SIZE];
103+
d = new float[SIZE];
104+
e = new float[SIZE];
105+
106+
for (int i = 0; i < SIZE;) {
107+
for (int j = 0; j < numberList.length && i < SIZE; j++, i++) {
108+
for (int k = j; k < numberList.length && i < SIZE; k++, i++) {
109+
if (rnd.nextBoolean()) {
110+
d[i] = numberList[j];
111+
e[i] = numberList[k];
112+
} else {
113+
d[i] = numberList[k];
114+
e[i] = numberList[j];
115+
}
116+
}
117+
}
118+
}
119+
58120
for (int i = 0; i < SIZE; i++) {
59121
a[i] = 850.0f * i + 22222.22f;
60122
b[i] = -12345.678f;
@@ -146,7 +208,7 @@ public float[] vectorDiv() {
146208
public float[] vectorMax() {
147209
float[] res = new float[SIZE];
148210
for (int i = 0; i < SIZE; i++) {
149-
res[i] = Math.max(a[i], b[i]);
211+
res[i] = Math.max(d[i], e[i]);
150212
}
151213
return res;
152214
}
@@ -157,7 +219,7 @@ public float[] vectorMax() {
157219
public float[] vectorMin() {
158220
float[] res = new float[SIZE];
159221
for (int i = 0; i < SIZE; i++) {
160-
res[i] = Math.min(a[i], b[i]);
222+
res[i] = Math.min(d[i], e[i]);
161223
}
162224
return res;
163225
}

‎test/jdk/java/awt/event/KeyEvent/AcceleratorTest/AcceleratorTest.html

-43
This file was deleted.

‎test/jdk/java/awt/event/KeyEvent/AcceleratorTest/AcceleratorTest.java

+145-282
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.