Skip to content

Commit 23a08ee

Browse files
committed
8382039: Add support do_arch_array_entry() template
Reviewed-by: kvn, asmehra
1 parent 436d291 commit 23a08ee

28 files changed

Lines changed: 349 additions & 123 deletions

src/hotspot/cpu/aarch64/aarch64_vector.ad

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -597,13 +597,9 @@ instruct vloadcon(vReg dst, immI0 src) %{
597597
BasicType bt = Matcher::vector_element_basic_type(this);
598598
if (UseSVE == 0) {
599599
uint length_in_bytes = Matcher::vector_length_in_bytes(this);
600+
int entry_idx = __ vector_iota_entry_index(bt);
600601
assert(length_in_bytes <= 16, "must be");
601-
// The iota indices are ordered by type B/S/I/L/F/D, and the offset between two types is 16.
602-
int offset = exact_log2(type2aelembytes(bt)) << 4;
603-
if (is_floating_point_type(bt)) {
604-
offset += 32;
605-
}
606-
__ lea(rscratch1, ExternalAddress(StubRoutines::aarch64::vector_iota_indices() + offset));
602+
__ lea(rscratch1, ExternalAddress(StubRoutines::aarch64::vector_iota_indices(entry_idx)));
607603
if (length_in_bytes == 16) {
608604
__ ldrq($dst$$FloatRegister, rscratch1);
609605
} else {

src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.cpp

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2414,17 +2414,17 @@ void C2_MacroAssembler::neon_rearrange_hsd(FloatRegister dst, FloatRegister src,
24142414
break;
24152415
case T_LONG:
24162416
case T_DOUBLE:
2417-
// Load the iota indices for Long type. The indices are ordered by
2418-
// type B/S/I/L/F/D, and the offset between two types is 16; Hence
2419-
// the offset for L is 48.
2420-
lea(rscratch1,
2421-
ExternalAddress(StubRoutines::aarch64::vector_iota_indices() + 48));
2422-
ldrq(tmp, rscratch1);
2423-
// Check whether the input "shuffle" is the same with iota indices.
2424-
// Return "src" if true, otherwise swap the two elements of "src".
2425-
cm(EQ, dst, size2, shuffle, tmp);
2426-
ext(tmp, size1, src, src, 8);
2427-
bsl(dst, size1, src, tmp);
2417+
{
2418+
int idx = vector_iota_entry_index(T_LONG);
2419+
lea(rscratch1,
2420+
ExternalAddress(StubRoutines::aarch64::vector_iota_indices(idx)));
2421+
ldrq(tmp, rscratch1);
2422+
// Check whether the input "shuffle" is the same with iota indices.
2423+
// Return "src" if true, otherwise swap the two elements of "src".
2424+
cm(EQ, dst, size2, shuffle, tmp);
2425+
ext(tmp, size1, src, src, 8);
2426+
bsl(dst, size1, src, tmp);
2427+
}
24282428
break;
24292429
default:
24302430
assert(false, "unsupported element type");
@@ -2896,3 +2896,24 @@ void C2_MacroAssembler::sve_cpy(FloatRegister dst, SIMD_RegVariant T,
28962896
}
28972897
Assembler::sve_cpy(dst, T, pg, imm8, isMerge);
28982898
}
2899+
2900+
int C2_MacroAssembler::vector_iota_entry_index(BasicType bt) {
2901+
// The vector iota entries array is ordered by type B/S/I/L/F/D, and
2902+
// the offset between two types is 16.
2903+
switch(bt) {
2904+
case T_BYTE:
2905+
return 0;
2906+
case T_SHORT:
2907+
return 1;
2908+
case T_INT:
2909+
return 2;
2910+
case T_LONG:
2911+
return 3;
2912+
case T_FLOAT:
2913+
return 4;
2914+
case T_DOUBLE:
2915+
return 5;
2916+
default:
2917+
ShouldNotReachHere();
2918+
}
2919+
}

src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,4 +249,5 @@
249249

250250
void sve_cpy(FloatRegister dst, SIMD_RegVariant T, PRegister pg, int imm8,
251251
bool isMerge);
252+
int vector_iota_entry_index(BasicType bt);
252253
#endif // CPU_AARCH64_C2_MACROASSEMBLER_AARCH64_HPP

src/hotspot/cpu/aarch64/stubDeclarations_aarch64.hpp

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,32 +29,39 @@
2929
#define STUBGEN_PREUNIVERSE_BLOBS_ARCH_DO(do_stub, \
3030
do_arch_blob, \
3131
do_arch_entry, \
32-
do_arch_entry_init) \
32+
do_arch_entry_init, \
33+
do_arch_entry_array) \
3334
do_arch_blob(preuniverse, 0) \
3435

3536

3637
#define STUBGEN_INITIAL_BLOBS_ARCH_DO(do_stub, \
3738
do_arch_blob, \
3839
do_arch_entry, \
39-
do_arch_entry_init) \
40+
do_arch_entry_init, \
41+
do_arch_entry_array) \
4042
do_arch_blob(initial, 10000) \
4143

4244

4345
#define STUBGEN_CONTINUATION_BLOBS_ARCH_DO(do_stub, \
4446
do_arch_blob, \
4547
do_arch_entry, \
46-
do_arch_entry_init) \
48+
do_arch_entry_init, \
49+
do_arch_entry_array) \
4750
do_arch_blob(continuation, 2000) \
4851

52+
// count needed for declaration of vector_iota_indices stub
53+
#define VECTOR_IOTA_COUNT 6
4954

5055
#define STUBGEN_COMPILER_BLOBS_ARCH_DO(do_stub, \
5156
do_arch_blob, \
5257
do_arch_entry, \
53-
do_arch_entry_init) \
58+
do_arch_entry_init, \
59+
do_arch_entry_array) \
5460
do_arch_blob(compiler, 70000) \
5561
do_stub(compiler, vector_iota_indices) \
56-
do_arch_entry(aarch64, compiler, vector_iota_indices, \
57-
vector_iota_indices, vector_iota_indices) \
62+
do_arch_entry_array(aarch64, compiler, vector_iota_indices, \
63+
vector_iota_indices, vector_iota_indices, \
64+
VECTOR_IOTA_COUNT) \
5865
do_stub(compiler, large_array_equals) \
5966
do_arch_entry(aarch64, compiler, large_array_equals, \
6067
large_array_equals, large_array_equals) \
@@ -115,7 +122,8 @@
115122
#define STUBGEN_FINAL_BLOBS_ARCH_DO(do_stub, \
116123
do_arch_blob, \
117124
do_arch_entry, \
118-
do_arch_entry_init) \
125+
do_arch_entry_init, \
126+
do_arch_entry_array) \
119127
do_arch_blob(final, 20000 ZGC_ONLY(+85000)) \
120128
do_stub(final, copy_byte_f) \
121129
do_arch_entry(aarch64, final, copy_byte_f, copy_byte_f, \

src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -819,39 +819,57 @@ class StubGenerator: public StubCodeGenerator {
819819
}
820820

821821
// Generate indices for iota vector.
822-
address generate_iota_indices(StubId stub_id) {
822+
void generate_iota_indices(StubId stub_id) {
823+
GrowableArray<address> entries;
823824
int entry_count = StubInfo::entry_count(stub_id);
824-
assert(entry_count == 1, "sanity check");
825-
address start = load_archive_data(stub_id);
825+
assert(entry_count == VECTOR_IOTA_COUNT, "sanity check");
826+
address start = load_archive_data(stub_id, &entries);
826827
if (start != nullptr) {
827-
return start;
828+
assert(entries.length() == entry_count - 1,
829+
"unexpected entries count %d", entries.length());
830+
StubRoutines::aarch64::_vector_iota_indices[0] = start;
831+
for (int i = 1; i < VECTOR_IOTA_COUNT; i++) {
832+
StubRoutines::aarch64::_vector_iota_indices[i] = entries.at(i - 1);
833+
}
834+
return;
828835
}
829836
__ align(CodeEntryAlignment);
830837
StubCodeMark mark(this, stub_id);
831838
start = __ pc();
832839
// B
833840
__ emit_data64(0x0706050403020100, relocInfo::none);
834841
__ emit_data64(0x0F0E0D0C0B0A0908, relocInfo::none);
842+
entries.append(__ pc());
835843
// H
836844
__ emit_data64(0x0003000200010000, relocInfo::none);
837845
__ emit_data64(0x0007000600050004, relocInfo::none);
846+
entries.append(__ pc());
838847
// S
839848
__ emit_data64(0x0000000100000000, relocInfo::none);
840849
__ emit_data64(0x0000000300000002, relocInfo::none);
850+
entries.append(__ pc());
841851
// D
842852
__ emit_data64(0x0000000000000000, relocInfo::none);
843853
__ emit_data64(0x0000000000000001, relocInfo::none);
854+
entries.append(__ pc());
844855
// S - FP
845856
__ emit_data64(0x3F80000000000000, relocInfo::none); // 0.0f, 1.0f
846857
__ emit_data64(0x4040000040000000, relocInfo::none); // 2.0f, 3.0f
858+
entries.append(__ pc());
847859
// D - FP
848860
__ emit_data64(0x0000000000000000, relocInfo::none); // 0.0d
849861
__ emit_data64(0x3FF0000000000000, relocInfo::none); // 1.0d
850862

851863
// record the stub entry and end
852-
store_archive_data(stub_id, start, __ pc());
864+
store_archive_data(stub_id, start, __ pc(), &entries);
853865

854-
return start;
866+
// install the entry addresses in the entry array
867+
assert(entries.length() == entry_count - 1,
868+
"unexpected entries count %d", entries.length());
869+
StubRoutines::aarch64::_vector_iota_indices[0] = start;
870+
for (int i = 1; i < VECTOR_IOTA_COUNT; i++) {
871+
StubRoutines::aarch64::_vector_iota_indices[i] = entries.at(i - 1);
872+
}
855873
}
856874

857875
// The inner part of zero_words(). This is the bulk operation,
@@ -12621,7 +12639,7 @@ class StubGenerator: public StubCodeGenerator {
1262112639
#if COMPILER2_OR_JVMCI
1262212640

1262312641
if (UseSVE == 0) {
12624-
StubRoutines::aarch64::_vector_iota_indices = generate_iota_indices(StubId::stubgen_vector_iota_indices_id);
12642+
generate_iota_indices(StubId::stubgen_vector_iota_indices_id);
1262512643
}
1262612644

1262712645
// array equals stub for large arrays.

src/hotspot/cpu/aarch64/stubRoutines_aarch64.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,12 @@ static void empty_spin_wait() { }
4141
#define DEFINE_ARCH_ENTRY_INIT(arch, blob_name, stub_name, field_name, getter_name, init_function) \
4242
address StubRoutines:: arch :: STUB_FIELD_NAME(field_name) = CAST_FROM_FN_PTR(address, init_function);
4343

44-
STUBGEN_ARCH_ENTRIES_DO(DEFINE_ARCH_ENTRY, DEFINE_ARCH_ENTRY_INIT)
44+
#define DEFINE_ARCH_ENTRY_ARRAY(arch, blob_name, stub_name, field_name, getter_name, count) \
45+
address StubRoutines:: arch :: STUB_FIELD_NAME(field_name) [count];
4546

47+
STUBGEN_ARCH_ENTRIES_DO(DEFINE_ARCH_ENTRY, DEFINE_ARCH_ENTRY_INIT, DEFINE_ARCH_ENTRY_ARRAY)
48+
49+
#undef DEFINE_ARCH_ENTRY_ARARAY
4650
#undef DEFINE_ARCH_ENTRY_INIT
4751
#undef DEFINE_ARCH_ENTRY
4852

src/hotspot/cpu/aarch64/stubRoutines_aarch64.hpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,13 @@ class aarch64 {
6060
#define DECLARE_ARCH_ENTRY_INIT(arch, blob_name, stub_name, field_name, getter_name, init_function) \
6161
DECLARE_ARCH_ENTRY(arch, blob_name, stub_name, field_name, getter_name)
6262

63+
#define DECLARE_ARCH_ENTRY_ARRAY(arch, blob_name, stub_name, field_name, getter_name, count) \
64+
static address STUB_FIELD_NAME(field_name) [count];
65+
6366
private:
64-
STUBGEN_ARCH_ENTRIES_DO(DECLARE_ARCH_ENTRY, DECLARE_ARCH_ENTRY_INIT)
67+
STUBGEN_ARCH_ENTRIES_DO(DECLARE_ARCH_ENTRY, DECLARE_ARCH_ENTRY_INIT, DECLARE_ARCH_ENTRY_ARRAY)
6568

69+
#undef DECLARE_ARCH_ENTRY_ARRAY
6670
#undef DECLARE_ARCH_ENTRY_INIT
6771
#undef DECLARE_ARCH_ENTRY
6872

@@ -78,8 +82,15 @@ class aarch64 {
7882
#define DEFINE_ARCH_ENTRY_GETTER_INIT(arch, blob_name, stub_name, field_name, getter_name, init_function) \
7983
DEFINE_ARCH_ENTRY_GETTER(arch, blob_name, stub_name, field_name, getter_name)
8084

81-
STUBGEN_ARCH_ENTRIES_DO(DEFINE_ARCH_ENTRY_GETTER, DEFINE_ARCH_ENTRY_GETTER_INIT)
85+
#define DEFINE_ARCH_ENTRY_GETTER_ARRAY(arch, blob_name, stub_name, field_name, getter_name, count) \
86+
static address getter_name(int idx) { \
87+
assert(0 <= idx && idx < count, "entry array index out of range"); \
88+
return STUB_FIELD_NAME(field_name) [idx]; \
89+
}
90+
91+
STUBGEN_ARCH_ENTRIES_DO(DEFINE_ARCH_ENTRY_GETTER, DEFINE_ARCH_ENTRY_GETTER_INIT, DEFINE_ARCH_ENTRY_GETTER_ARRAY)
8292

93+
#undef DEFINE_ARCH_ENTRY_GETTER_ARRAY
8394
#undef DEFINE_ARCH_ENTRY_GETTER_INIT
8495
#undef DEFINE_ARCH_ENTRY_GETTER
8596

src/hotspot/cpu/arm/stubDeclarations_arm.hpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
#define STUBGEN_PREUNIVERSE_BLOBS_ARCH_DO(do_stub, \
3030
do_arch_blob, \
3131
do_arch_entry, \
32-
do_arch_entry_init) \
32+
do_arch_entry_init, \
33+
do_arch_entry_array) \
3334
do_arch_blob(preuniverse, 500) \
3435
do_stub(preuniverse, atomic_load_long) \
3536
do_arch_entry(Arm, preuniverse, atomic_load_long, \
@@ -42,7 +43,8 @@
4243
#define STUBGEN_INITIAL_BLOBS_ARCH_DO(do_stub, \
4344
do_arch_blob, \
4445
do_arch_entry, \
45-
do_arch_entry_init) \
46+
do_arch_entry_init, \
47+
do_arch_entry_array) \
4648
do_arch_blob(initial, 9000) \
4749
do_stub(initial, idiv_irem) \
4850
do_arch_entry(Arm, initial, idiv_irem, \
@@ -51,14 +53,16 @@
5153
#define STUBGEN_CONTINUATION_BLOBS_ARCH_DO(do_stub, \
5254
do_arch_blob, \
5355
do_arch_entry, \
54-
do_arch_entry_init) \
56+
do_arch_entry_init, \
57+
do_arch_entry_array) \
5558
do_arch_blob(continuation, 2000) \
5659

5760

5861
#define STUBGEN_COMPILER_BLOBS_ARCH_DO(do_stub, \
5962
do_arch_blob, \
6063
do_arch_entry, \
61-
do_arch_entry_init) \
64+
do_arch_entry_init, \
65+
do_arch_entry_array) \
6266
do_arch_blob(compiler, 22000) \
6367
do_stub(compiler, partial_subtype_check) \
6468
do_arch_entry(Arm, compiler, partial_subtype_check, \
@@ -68,7 +72,8 @@
6872
#define STUBGEN_FINAL_BLOBS_ARCH_DO(do_stub, \
6973
do_arch_blob, \
7074
do_arch_entry, \
71-
do_arch_entry_init) \
75+
do_arch_entry_init, \
76+
do_arch_entry_array) \
7277
do_arch_blob(final, 22000) \
7378

7479

src/hotspot/cpu/arm/stubRoutines_arm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#define DEFINE_ARCH_ENTRY_INIT(arch, blob_name, stub_name, field_name, getter_name, init_function) \
3333
address StubRoutines:: arch :: STUB_FIELD_NAME(field_name) = CAST_FROM_FN_PTR(address, init_function);
3434

35-
STUBGEN_ARCH_ENTRIES_DO(DEFINE_ARCH_ENTRY, DEFINE_ARCH_ENTRY_INIT)
35+
STUBGEN_ARCH_ENTRIES_DO(DEFINE_ARCH_ENTRY, DEFINE_ARCH_ENTRY_INIT, DEFINE_ARCH_ENTRY_ARRAY)
3636

3737
#undef DEFINE_ARCH_ENTRY_INIT
3838
#undef DEFINE_ARCH_ENTRY

src/hotspot/cpu/arm/stubRoutines_arm.hpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,13 @@ class Arm {
5555
#define DECLARE_ARCH_ENTRY_INIT(arch, blob_name, stub_name, field_name, getter_name, init_function) \
5656
DECLARE_ARCH_ENTRY(arch, blob_name, stub_name, field_name, getter_name)
5757

58+
#define DECLARE_ARCH_ENTRY_ARRAY(arch, blob_name, stub_name, field_name, getter_name, count) \
59+
static address STUB_FIELD_NAME(field_name) [count] ;
60+
5861
private:
59-
STUBGEN_ARCH_ENTRIES_DO(DECLARE_ARCH_ENTRY, DECLARE_ARCH_ENTRY_INIT)
62+
STUBGEN_ARCH_ENTRIES_DO(DECLARE_ARCH_ENTRY, DECLARE_ARCH_ENTRY_INIT, DECLARE_ARCH_ENTRY_ARRAY)
6063

64+
#undef DECLARE_ARCH_ENTRY_ARRAY
6165
#undef DECLARE_ARCH_ENTRY_INIT
6266
#undef DECLARE_ARCH_ENTRY
6367

@@ -71,8 +75,12 @@ class Arm {
7175
#define DEFINE_ARCH_ENTRY_GETTER_INIT(arch, blob_name, stub_name, field_name, getter_name, init_function) \
7276
DEFINE_ARCH_ENTRY_GETTER(arch, blob_name, stub_name, field_name, getter_name)
7377

74-
STUBGEN_ARCH_ENTRIES_DO(DEFINE_ARCH_ENTRY_GETTER, DEFINE_ARCH_ENTRY_GETTER_INIT)
78+
#define DEFINE_ARCH_ENTRY_GETTER_ARRAY(arch, blob_name, stub_name, field_name, getter_name, count) \
79+
static address getter_name(int idx) { return STUB_FIELD_NAME(field_name) [idx] ; }
80+
81+
STUBGEN_ARCH_ENTRIES_DO(DEFINE_ARCH_ENTRY_GETTER, DEFINE_ARCH_ENTRY_GETTER_INIT, DEFINE_ARCH_ENTRY_GETTER_ARRAY)
7582

83+
#undef DEFINE_ARCH_ENTRY_GETTER_ARRAY
7684
#undef DEFINE_ARCH_ENTRY_GETTER_INIT
7785
#undef DEFINE_ARCH_ENTRY_GETTER
7886

0 commit comments

Comments
 (0)