Skip to content

Commit 5a0bdd0

Browse files
author
Andrew Haley
committed
8346890: AArch64: Type profile counters generate suboptimal code
Reviewed-by: shade, adinn
1 parent 4a375e5 commit 5a0bdd0

File tree

2 files changed

+24
-14
lines changed

2 files changed

+24
-14
lines changed

src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,31 +1217,37 @@ void LIR_Assembler::emit_alloc_array(LIR_OpAllocArray* op) {
12171217
void LIR_Assembler::type_profile_helper(Register mdo,
12181218
ciMethodData *md, ciProfileData *data,
12191219
Register recv, Label* update_done) {
1220+
1221+
// Given a profile data offset, generate an Address which points to
1222+
// the corresponding slot in mdo->data().
1223+
// Clobbers rscratch2.
1224+
auto slot_at = [=](ByteSize offset) -> Address {
1225+
return __ form_address(rscratch2, mdo,
1226+
md->byte_offset_of_slot(data, offset),
1227+
LogBytesPerWord);
1228+
};
1229+
12201230
for (uint i = 0; i < ReceiverTypeData::row_limit(); i++) {
12211231
Label next_test;
12221232
// See if the receiver is receiver[n].
1223-
__ lea(rscratch2, Address(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_offset(i))));
1224-
__ ldr(rscratch1, Address(rscratch2));
1233+
__ ldr(rscratch1, slot_at(ReceiverTypeData::receiver_offset(i)));
12251234
__ cmp(recv, rscratch1);
12261235
__ br(Assembler::NE, next_test);
1227-
Address data_addr(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_count_offset(i)));
1228-
__ addptr(data_addr, DataLayout::counter_increment);
1236+
__ addptr(slot_at(ReceiverTypeData::receiver_count_offset(i)),
1237+
DataLayout::counter_increment);
12291238
__ b(*update_done);
12301239
__ bind(next_test);
12311240
}
12321241

12331242
// Didn't find receiver; find next empty slot and fill it in
12341243
for (uint i = 0; i < ReceiverTypeData::row_limit(); i++) {
12351244
Label next_test;
1236-
__ lea(rscratch2,
1237-
Address(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_offset(i))));
1238-
Address recv_addr(rscratch2);
1245+
Address recv_addr(slot_at(ReceiverTypeData::receiver_offset(i)));
12391246
__ ldr(rscratch1, recv_addr);
12401247
__ cbnz(rscratch1, next_test);
12411248
__ str(recv, recv_addr);
12421249
__ mov(rscratch1, DataLayout::counter_increment);
1243-
__ lea(rscratch2, Address(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_count_offset(i))));
1244-
__ str(rscratch1, Address(rscratch2));
1250+
__ str(rscratch1, slot_at(ReceiverTypeData::receiver_count_offset(i)));
12451251
__ b(*update_done);
12461252
__ bind(next_test);
12471253
}
@@ -1413,8 +1419,7 @@ void LIR_Assembler::emit_opTypeCheck(LIR_OpTypeCheck* op) {
14131419
// Object is null; update MDO and exit
14141420
Address data_addr
14151421
= __ form_address(rscratch2, mdo,
1416-
md->byte_offset_of_slot(data, DataLayout::flags_offset()),
1417-
0);
1422+
md->byte_offset_of_slot(data, DataLayout::flags_offset()), 0);
14181423
__ ldrb(rscratch1, data_addr);
14191424
__ orr(rscratch1, rscratch1, BitData::null_seen_byte_constant());
14201425
__ strb(rscratch1, data_addr);
@@ -2565,10 +2570,12 @@ void LIR_Assembler::emit_profile_call(LIR_OpProfileCall* op) {
25652570
for (i = 0; i < VirtualCallData::row_limit(); i++) {
25662571
ciKlass* receiver = vc_data->receiver(i);
25672572
if (receiver == nullptr) {
2568-
Address recv_addr(mdo, md->byte_offset_of_slot(data, VirtualCallData::receiver_offset(i)));
25692573
__ mov_metadata(rscratch1, known_klass->constant_encoding());
2570-
__ lea(rscratch2, recv_addr);
2571-
__ str(rscratch1, Address(rscratch2));
2574+
Address recv_addr =
2575+
__ form_address(rscratch2, mdo,
2576+
md->byte_offset_of_slot(data, VirtualCallData::receiver_offset(i)),
2577+
LogBytesPerWord);
2578+
__ str(rscratch1, recv_addr);
25722579
Address data_addr(mdo, md->byte_offset_of_slot(data, VirtualCallData::receiver_count_offset(i)));
25732580
__ addptr(data_addr, DataLayout::counter_increment);
25742581
return;

src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,7 +1173,10 @@ class MacroAssembler: public Assembler {
11731173

11741174
// Arithmetics
11751175

1176+
// Clobber: rscratch1, rscratch2
11761177
void addptr(const Address &dst, int32_t src);
1178+
1179+
// Clobber: rscratch1
11771180
void cmpptr(Register src1, Address src2);
11781181

11791182
void cmpoop(Register obj1, Register obj2);

0 commit comments

Comments
 (0)