Skip to content

Commit 2aca63b

Browse files
committed
init
1 parent d3d67ec commit 2aca63b

7 files changed

Lines changed: 170 additions & 193 deletions

src/hotspot/cpu/ppc/macroAssembler_ppc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4450,7 +4450,7 @@ void MacroAssembler::profile_receiver_type(Register recv, Register mdp, int mdp_
44504450
addi(offset, offset, receiver_step);
44514451
bdnz(L_loop_search_receiver);
44524452

4453-
// Fast: no receiver, but profile is full
4453+
// Fast: no receiver, but profile is not full
44544454
if (count != noreg) {
44554455
mtctr(count);
44564456
} else {

src/hotspot/cpu/s390/c1_LIRAssembler_s390.cpp

Lines changed: 10 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -2413,32 +2413,9 @@ void LIR_Assembler::emit_alloc_array(LIR_OpAllocArray* op) {
24132413
}
24142414

24152415
void LIR_Assembler::type_profile_helper(Register mdo, ciMethodData *md, ciProfileData *data,
2416-
Register recv, Register tmp1, Label* update_done) {
2417-
uint i;
2418-
for (i = 0; i < VirtualCallData::row_limit(); i++) {
2419-
Label next_test;
2420-
// See if the receiver is receiver[n].
2421-
Address receiver_addr(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_offset(i)));
2422-
__ z_cg(recv, receiver_addr);
2423-
__ z_brne(next_test);
2424-
Address data_addr(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_count_offset(i)));
2425-
__ add2mem_64(data_addr, DataLayout::counter_increment, tmp1);
2426-
__ branch_optimized(Assembler::bcondAlways, *update_done);
2427-
__ bind(next_test);
2428-
}
2429-
2430-
// Didn't find receiver; find next empty slot and fill it in.
2431-
for (i = 0; i < VirtualCallData::row_limit(); i++) {
2432-
Label next_test;
2433-
Address recv_addr(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_offset(i)));
2434-
__ z_ltg(Z_R0_scratch, recv_addr);
2435-
__ z_brne(next_test);
2436-
__ z_stg(recv, recv_addr);
2437-
__ load_const_optimized(tmp1, DataLayout::counter_increment);
2438-
__ z_stg(tmp1, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_count_offset(i)), mdo);
2439-
__ branch_optimized(Assembler::bcondAlways, *update_done);
2440-
__ bind(next_test);
2441-
}
2416+
Register recv, Register tmp1) {
2417+
int mdp_offset = md->byte_offset_of_slot(data, in_ByteSize(0));
2418+
__ profile_receiver_type(recv, mdo, mdp_offset, tmp1);
24422419
}
24432420

24442421
void LIR_Assembler::setup_md_access(ciMethod* method, int bci,
@@ -2510,13 +2487,9 @@ void LIR_Assembler::emit_typecheck_helper(LIR_OpTypeCheck *op, Label* success, L
25102487
__ branch_optimized(Assembler::bcondAlways, *obj_is_null);
25112488
__ bind(not_null);
25122489

2513-
NearLabel update_done;
25142490
Register recv = k_RInfo;
25152491
__ load_klass(recv, obj);
2516-
type_profile_helper(mdo, md, data, recv, Rtmp1, &update_done);
2517-
Address counter_addr(mdo, md->byte_offset_of_slot(data, CounterData::count_offset()));
2518-
__ add2mem_64(counter_addr, DataLayout::counter_increment, Rtmp1);
2519-
__ bind(update_done);
2492+
type_profile_helper(mdo, md, data, recv, Rtmp1);
25202493
} else {
25212494
__ compareU64_and_branch(obj, (intptr_t) 0, Assembler::bcondEqual, *obj_is_null);
25222495
}
@@ -2606,13 +2579,9 @@ void LIR_Assembler::emit_opTypeCheck(LIR_OpTypeCheck* op) {
26062579
__ branch_optimized(Assembler::bcondAlways, done);
26072580
__ bind(not_null);
26082581

2609-
NearLabel update_done;
26102582
Register recv = k_RInfo;
26112583
__ load_klass(recv, value);
2612-
type_profile_helper(mdo, md, data, recv, Rtmp1, &update_done);
2613-
Address counter_addr(mdo, md->byte_offset_of_slot(data, CounterData::count_offset()));
2614-
__ add2mem_64(counter_addr, DataLayout::counter_increment, Rtmp1);
2615-
__ bind(update_done);
2584+
type_profile_helper(mdo, md, data, recv, Rtmp1);
26162585
} else {
26172586
__ compareU64_and_branch(value, (intptr_t) 0, Assembler::bcondEqual, done);
26182587
}
@@ -2772,44 +2741,22 @@ void LIR_Assembler::emit_profile_call(LIR_OpProfileCall* op) {
27722741
// statically update the MethodData* rather than needing to do
27732742
// dynamic tests on the receiver type.
27742743

2775-
// NOTE: we should probably put a lock around this search to
2776-
// avoid collisions by concurrent compilations.
27772744
ciVirtualCallData* vc_data = (ciVirtualCallData*) data;
2778-
uint i;
2779-
for (i = 0; i < VirtualCallData::row_limit(); i++) {
2745+
for (uint i = 0; i < VirtualCallData::row_limit(); i++) {
27802746
ciKlass* receiver = vc_data->receiver(i);
27812747
if (known_klass->equals(receiver)) {
27822748
Address data_addr(mdo, md->byte_offset_of_slot(data, VirtualCallData::receiver_count_offset(i)));
27832749
__ add2mem_64(data_addr, DataLayout::counter_increment, tmp1);
27842750
return;
27852751
}
27862752
}
2787-
2788-
// Receiver type not found in profile data. Select an empty slot.
2789-
2790-
// Note that this is less efficient than it should be because it
2791-
// always does a write to the receiver part of the
2792-
// VirtualCallData rather than just the first time.
2793-
for (i = 0; i < VirtualCallData::row_limit(); i++) {
2794-
ciKlass* receiver = vc_data->receiver(i);
2795-
if (receiver == nullptr) {
2796-
Address recv_addr(mdo, md->byte_offset_of_slot(data, VirtualCallData::receiver_offset(i)));
2797-
metadata2reg(known_klass->constant_encoding(), tmp1);
2798-
__ z_stg(tmp1, recv_addr);
2799-
Address data_addr(mdo, md->byte_offset_of_slot(data, VirtualCallData::receiver_count_offset(i)));
2800-
__ add2mem_64(data_addr, DataLayout::counter_increment, tmp1);
2801-
return;
2802-
}
2803-
}
2753+
// Receiver type is not found in profile data.
2754+
// Fall back to runtime helper to handle the rest at runtime.
2755+
metadata2reg(known_klass->constant_encoding(), recv);
28042756
} else {
28052757
__ load_klass(recv, recv);
2806-
NearLabel update_done;
2807-
type_profile_helper(mdo, md, data, recv, tmp1, &update_done);
2808-
// Receiver did not match any saved receiver and there is no empty row for it.
2809-
// Increment total counter to indicate polymorphic case.
2810-
__ add2mem_64(counter_addr, DataLayout::counter_increment, tmp1);
2811-
__ bind(update_done);
28122758
}
2759+
type_profile_helper(mdo, md, data, recv, tmp1);
28132760
} else {
28142761
// static call
28152762
__ add2mem_64(counter_addr, DataLayout::counter_increment, tmp1);

src/hotspot/cpu/s390/c1_LIRAssembler_s390.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
// Record the type of the receiver in ReceiverTypeData.
3232
void type_profile_helper(Register mdo, ciMethodData *md, ciProfileData *data,
33-
Register recv, Register tmp1, Label* update_done);
33+
Register recv, Register tmp1);
3434
// Setup pointers to MDO, MDO slot, also compute offset bias to access the slot.
3535
void setup_md_access(ciMethod* method, int bci,
3636
ciMethodData*& md, ciProfileData*& data, int& mdo_offset_bias);

src/hotspot/cpu/s390/interp_masm_s390.cpp

Lines changed: 2 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,133 +1267,14 @@ void InterpreterMacroAssembler::profile_virtual_call(Register receiver,
12671267
test_method_data_pointer(mdp, profile_continue);
12681268

12691269
// Record the receiver type.
1270-
record_klass_in_profile(receiver, mdp, reg2);
1270+
profile_receiver_type(receiver, mdp, 0, reg2);
12711271

12721272
// The method data pointer needs to be updated to reflect the new target.
12731273
update_mdp_by_constant(mdp, in_bytes(VirtualCallData::virtual_call_data_size()));
12741274
bind(profile_continue);
12751275
}
12761276
}
12771277

1278-
// This routine creates a state machine for updating the multi-row
1279-
// type profile at a virtual call site (or other type-sensitive bytecode).
1280-
// The machine visits each row (of receiver/count) until the receiver type
1281-
// is found, or until it runs out of rows. At the same time, it remembers
1282-
// the location of the first empty row. (An empty row records null for its
1283-
// receiver, and can be allocated for a newly-observed receiver type.)
1284-
// Because there are two degrees of freedom in the state, a simple linear
1285-
// search will not work; it must be a decision tree. Hence this helper
1286-
// function is recursive, to generate the required tree structured code.
1287-
// It's the interpreter, so we are trading off code space for speed.
1288-
// See below for example code.
1289-
void InterpreterMacroAssembler::record_klass_in_profile_helper(
1290-
Register receiver, Register mdp,
1291-
Register reg2, int start_row,
1292-
Label& done) {
1293-
if (TypeProfileWidth == 0) {
1294-
increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset()));
1295-
return;
1296-
}
1297-
1298-
int last_row = VirtualCallData::row_limit() - 1;
1299-
assert(start_row <= last_row, "must be work left to do");
1300-
// Test this row for both the receiver and for null.
1301-
// Take any of three different outcomes:
1302-
// 1. found receiver => increment count and goto done
1303-
// 2. found null => keep looking for case 1, maybe allocate this cell
1304-
// 3. found something else => keep looking for cases 1 and 2
1305-
// Case 3 is handled by a recursive call.
1306-
for (int row = start_row; row <= last_row; row++) {
1307-
NearLabel next_test;
1308-
bool test_for_null_also = (row == start_row);
1309-
1310-
// See if the receiver is receiver[n].
1311-
int recvr_offset = in_bytes(VirtualCallData::receiver_offset(row));
1312-
test_mdp_data_at(mdp, recvr_offset, receiver,
1313-
(test_for_null_also ? reg2 : noreg),
1314-
next_test);
1315-
// (Reg2 now contains the receiver from the CallData.)
1316-
1317-
// The receiver is receiver[n]. Increment count[n].
1318-
int count_offset = in_bytes(VirtualCallData::receiver_count_offset(row));
1319-
increment_mdp_data_at(mdp, count_offset);
1320-
z_bru(done);
1321-
bind(next_test);
1322-
1323-
if (test_for_null_also) {
1324-
Label found_null;
1325-
// Failed the equality check on receiver[n]... Test for null.
1326-
z_ltgr(reg2, reg2);
1327-
if (start_row == last_row) {
1328-
// The only thing left to do is handle the null case.
1329-
z_brz(found_null);
1330-
// Receiver did not match any saved receiver and there is no empty row for it.
1331-
// Increment total counter to indicate polymorphic case.
1332-
increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset()));
1333-
z_bru(done);
1334-
bind(found_null);
1335-
break;
1336-
}
1337-
// Since null is rare, make it be the branch-taken case.
1338-
z_brz(found_null);
1339-
1340-
// Put all the "Case 3" tests here.
1341-
record_klass_in_profile_helper(receiver, mdp, reg2, start_row + 1, done);
1342-
1343-
// Found a null. Keep searching for a matching receiver,
1344-
// but remember that this is an empty (unused) slot.
1345-
bind(found_null);
1346-
}
1347-
}
1348-
1349-
// In the fall-through case, we found no matching receiver, but we
1350-
// observed the receiver[start_row] is null.
1351-
1352-
// Fill in the receiver field and increment the count.
1353-
int recvr_offset = in_bytes(VirtualCallData::receiver_offset(start_row));
1354-
set_mdp_data_at(mdp, recvr_offset, receiver);
1355-
int count_offset = in_bytes(VirtualCallData::receiver_count_offset(start_row));
1356-
load_const_optimized(reg2, DataLayout::counter_increment);
1357-
set_mdp_data_at(mdp, count_offset, reg2);
1358-
if (start_row > 0) {
1359-
z_bru(done);
1360-
}
1361-
}
1362-
1363-
// Example state machine code for three profile rows:
1364-
// // main copy of decision tree, rooted at row[1]
1365-
// if (row[0].rec == rec) { row[0].incr(); goto done; }
1366-
// if (row[0].rec != nullptr) {
1367-
// // inner copy of decision tree, rooted at row[1]
1368-
// if (row[1].rec == rec) { row[1].incr(); goto done; }
1369-
// if (row[1].rec != nullptr) {
1370-
// // degenerate decision tree, rooted at row[2]
1371-
// if (row[2].rec == rec) { row[2].incr(); goto done; }
1372-
// if (row[2].rec != nullptr) { count.incr(); goto done; } // overflow
1373-
// row[2].init(rec); goto done;
1374-
// } else {
1375-
// // remember row[1] is empty
1376-
// if (row[2].rec == rec) { row[2].incr(); goto done; }
1377-
// row[1].init(rec); goto done;
1378-
// }
1379-
// } else {
1380-
// // remember row[0] is empty
1381-
// if (row[1].rec == rec) { row[1].incr(); goto done; }
1382-
// if (row[2].rec == rec) { row[2].incr(); goto done; }
1383-
// row[0].init(rec); goto done;
1384-
// }
1385-
// done:
1386-
1387-
void InterpreterMacroAssembler::record_klass_in_profile(Register receiver,
1388-
Register mdp, Register reg2) {
1389-
assert(ProfileInterpreter, "must be profiling");
1390-
Label done;
1391-
1392-
record_klass_in_profile_helper(receiver, mdp, reg2, 0, done);
1393-
1394-
bind (done);
1395-
}
1396-
13971278
void InterpreterMacroAssembler::profile_ret(Register return_bci, Register mdp) {
13981279
if (ProfileInterpreter) {
13991280
NearLabel profile_continue;
@@ -1462,7 +1343,7 @@ void InterpreterMacroAssembler::profile_typecheck(Register mdp, Register klass,
14621343
mdp_delta = in_bytes(VirtualCallData::virtual_call_data_size());
14631344

14641345
// Record the object type.
1465-
record_klass_in_profile(klass, mdp, reg2);
1346+
profile_receiver_type(klass, mdp, 0, reg2);
14661347
}
14671348
update_mdp_by_constant(mdp, mdp_delta);
14681349

src/hotspot/cpu/s390/interp_masm_s390.hpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -280,12 +280,6 @@ class InterpreterMacroAssembler: public MacroAssembler {
280280
Register test_value_out,
281281
Label& not_equal_continue);
282282

283-
void record_klass_in_profile(Register receiver, Register mdp,
284-
Register reg2);
285-
void record_klass_in_profile_helper(Register receiver, Register mdp,
286-
Register reg2, int start_row,
287-
Label& done);
288-
289283
void update_mdp_by_offset(Register mdp_in, int offset_of_offset);
290284
void update_mdp_by_offset(Register mdp_in, Register dataidx, int offset_of_disp);
291285
void update_mdp_by_constant(Register mdp_in, int constant);

0 commit comments

Comments
 (0)