@@ -237,15 +237,14 @@ void InterpreterMacroAssembler::load_resolved_klass_at_offset(
237237// Rsub_klass: subklass
238238//
239239// Kills:
240- // x12, x15
240+ // x12
241241void InterpreterMacroAssembler::gen_subtype_check (Register Rsub_klass,
242242 Label& ok_is_subtype) {
243243 assert (Rsub_klass != x10, " x10 holds superklass" );
244244 assert (Rsub_klass != x12, " x12 holds 2ndary super array length" );
245- assert (Rsub_klass != x15, " x15 holds 2ndary super array scan ptr" );
246245
247246 // Profile the not-null value's klass.
248- profile_typecheck (x12, Rsub_klass, x15 ); // blows x12, reloads x15
247+ profile_typecheck (x12, Rsub_klass); // blows x12
249248
250249 // Do the check.
251250 check_klass_subtype (Rsub_klass, x10, x12, ok_is_subtype); // blows x12
@@ -1042,7 +1041,6 @@ void InterpreterMacroAssembler::profile_final_call(Register mdp) {
10421041
10431042void InterpreterMacroAssembler::profile_virtual_call (Register receiver,
10441043 Register mdp,
1045- Register reg2,
10461044 bool receiver_can_be_null) {
10471045 if (ProfileInterpreter) {
10481046 Label profile_continue;
@@ -1060,7 +1058,7 @@ void InterpreterMacroAssembler::profile_virtual_call(Register receiver,
10601058 }
10611059
10621060 // Record the receiver type.
1063- record_klass_in_profile (receiver, mdp, reg2 );
1061+ profile_receiver_type (receiver, mdp, 0 );
10641062 bind (skip_receiver_profile);
10651063
10661064 // The method data pointer needs to be updated to reflect the new target.
@@ -1072,153 +1070,6 @@ void InterpreterMacroAssembler::profile_virtual_call(Register receiver,
10721070 }
10731071}
10741072
1075- // This routine creates a state machine for updating the multi-row
1076- // type profile at a virtual call site (or other type-sensitive bytecode).
1077- // The machine visits each row (of receiver/count) until the receiver type
1078- // is found, or until it runs out of rows. At the same time, it remembers
1079- // the location of the first empty row. (An empty row records null for its
1080- // receiver, and can be allocated for a newly-observed receiver type.)
1081- // Because there are two degrees of freedom in the state, a simple linear
1082- // search will not work; it must be a decision tree. Hence this helper
1083- // function is recursive, to generate the required tree structured code.
1084- // It's the interpreter, so we are trading off code space for speed.
1085- // See below for example code.
1086- void InterpreterMacroAssembler::record_klass_in_profile_helper (
1087- Register receiver, Register mdp,
1088- Register reg2, Label& done) {
1089- if (TypeProfileWidth == 0 ) {
1090- increment_mdp_data_at (mdp, in_bytes (CounterData::count_offset ()));
1091- } else {
1092- record_item_in_profile_helper (receiver, mdp, reg2, 0 , done, TypeProfileWidth,
1093- &VirtualCallData::receiver_offset, &VirtualCallData::receiver_count_offset);
1094- }
1095- }
1096-
1097- void InterpreterMacroAssembler::record_item_in_profile_helper (Register item, Register mdp,
1098- Register reg2, int start_row, Label& done, int total_rows,
1099- OffsetFunction item_offset_fn, OffsetFunction item_count_offset_fn) {
1100- int last_row = total_rows - 1 ;
1101- assert (start_row <= last_row, " must be work left to do" );
1102- // Test this row for both the item and for null.
1103- // Take any of three different outcomes:
1104- // 1. found item => increment count and goto done
1105- // 2. found null => keep looking for case 1, maybe allocate this cell
1106- // 3. found something else => keep looking for cases 1 and 2
1107- // Case 3 is handled by a recursive call.
1108- for (int row = start_row; row <= last_row; row++) {
1109- Label next_test;
1110- bool test_for_null_also = (row == start_row);
1111-
1112- // See if the item is item[n].
1113- int item_offset = in_bytes (item_offset_fn (row));
1114- test_mdp_data_at (mdp, item_offset, item,
1115- (test_for_null_also ? reg2 : noreg),
1116- next_test);
1117- // (Reg2 now contains the item from the CallData.)
1118-
1119- // The item is item[n]. Increment count[n].
1120- int count_offset = in_bytes (item_count_offset_fn (row));
1121- increment_mdp_data_at (mdp, count_offset);
1122- j (done);
1123- bind (next_test);
1124-
1125- if (test_for_null_also) {
1126- Label found_null;
1127- // Failed the equality check on item[n]... Test for null.
1128- if (start_row == last_row) {
1129- // The only thing left to do is handle the null case.
1130- beqz (reg2, found_null);
1131- // Item did not match any saved item and there is no empty row for it.
1132- // Increment total counter to indicate polymorphic case.
1133- increment_mdp_data_at (mdp, in_bytes (CounterData::count_offset ()));
1134- j (done);
1135- bind (found_null);
1136- break ;
1137- }
1138- // Since null is rare, make it be the branch-taken case.
1139- beqz (reg2, found_null);
1140-
1141- // Put all the "Case 3" tests here.
1142- record_item_in_profile_helper (item, mdp, reg2, start_row + 1 , done, total_rows,
1143- item_offset_fn, item_count_offset_fn);
1144-
1145- // Found a null. Keep searching for a matching item,
1146- // but remember that this is an empty (unused) slot.
1147- bind (found_null);
1148- }
1149- }
1150-
1151- // In the fall-through case, we found no matching item, but we
1152- // observed the item[start_row] is null.
1153- // Fill in the item field and increment the count.
1154- int item_offset = in_bytes (item_offset_fn (start_row));
1155- set_mdp_data_at (mdp, item_offset, item);
1156- int count_offset = in_bytes (item_count_offset_fn (start_row));
1157- mv (reg2, DataLayout::counter_increment);
1158- set_mdp_data_at (mdp, count_offset, reg2);
1159- if (start_row > 0 ) {
1160- j (done);
1161- }
1162- }
1163-
1164- // Example state machine code for three profile rows:
1165- // # main copy of decision tree, rooted at row[1]
1166- // if (row[0].rec == rec) then [
1167- // row[0].incr()
1168- // goto done
1169- // ]
1170- // if (row[0].rec != nullptr) then [
1171- // # inner copy of decision tree, rooted at row[1]
1172- // if (row[1].rec == rec) then [
1173- // row[1].incr()
1174- // goto done
1175- // ]
1176- // if (row[1].rec != nullptr) then [
1177- // # degenerate decision tree, rooted at row[2]
1178- // if (row[2].rec == rec) then [
1179- // row[2].incr()
1180- // goto done
1181- // ]
1182- // if (row[2].rec != nullptr) then [
1183- // count.incr()
1184- // goto done
1185- // ] # overflow
1186- // row[2].init(rec)
1187- // goto done
1188- // ] else [
1189- // # remember row[1] is empty
1190- // if (row[2].rec == rec) then [
1191- // row[2].incr()
1192- // goto done
1193- // ]
1194- // row[1].init(rec)
1195- // goto done
1196- // ]
1197- // else [
1198- // # remember row[0] is empty
1199- // if (row[1].rec == rec) then [
1200- // row[1].incr()
1201- // goto done
1202- // ]
1203- // if (row[2].rec == rec) then [
1204- // row[2].incr()
1205- // goto done
1206- // ]
1207- // row[0].init(rec)
1208- // goto done
1209- // ]
1210- // done:
1211-
1212- void InterpreterMacroAssembler::record_klass_in_profile (Register receiver,
1213- Register mdp, Register reg2) {
1214- assert (ProfileInterpreter, " must be profiling" );
1215- Label done;
1216-
1217- record_klass_in_profile_helper (receiver, mdp, reg2, done);
1218-
1219- bind (done);
1220- }
1221-
12221073void InterpreterMacroAssembler::profile_ret (Register return_bci, Register mdp) {
12231074 if (ProfileInterpreter) {
12241075 Label profile_continue;
@@ -1274,7 +1125,7 @@ void InterpreterMacroAssembler::profile_null_seen(Register mdp) {
12741125 }
12751126}
12761127
1277- void InterpreterMacroAssembler::profile_typecheck (Register mdp, Register klass, Register reg2 ) {
1128+ void InterpreterMacroAssembler::profile_typecheck (Register mdp, Register klass) {
12781129 if (ProfileInterpreter) {
12791130 Label profile_continue;
12801131
@@ -1287,7 +1138,7 @@ void InterpreterMacroAssembler::profile_typecheck(Register mdp, Register klass,
12871138 mdp_delta = in_bytes (VirtualCallData::virtual_call_data_size ());
12881139
12891140 // Record the object type.
1290- record_klass_in_profile (klass, mdp, reg2 );
1141+ profile_receiver_type (klass, mdp, 0 );
12911142 }
12921143 update_mdp_by_constant (mdp, mdp_delta);
12931144
0 commit comments