Skip to content

Commit 02b17d7

Browse files
committedJun 28, 2023
8310264: In PhaseChaitin::Split defs and phis are leaked
Reviewed-by: thartmann, chagedorn, kvn
1 parent a63afa4 commit 02b17d7

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed
 

‎src/hotspot/share/opto/reg_split.cpp

+18-16
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,6 @@ uint PhaseChaitin::Split(uint maxlrg, ResourceArea* split_arena) {
503503
uint bidx, pidx, slidx, insidx, inpidx, twoidx;
504504
uint non_phi = 1, spill_cnt = 0;
505505
Node *n1, *n2, *n3;
506-
Node_List *defs,*phis;
507506
bool *UPblock;
508507
bool u1, u2, u3;
509508
Block *b, *pred;
@@ -519,9 +518,6 @@ uint PhaseChaitin::Split(uint maxlrg, ResourceArea* split_arena) {
519518
//----------Setup Code----------
520519
// Create a convenient mapping from lrg numbers to reaches/leaves indices
521520
uint *lrg2reach = NEW_SPLIT_ARRAY(uint, maxlrg);
522-
// Keep track of DEFS & Phis for later passes
523-
defs = new Node_List();
524-
phis = new Node_List();
525521
// Gather info on which LRG's are spilling, and build maps
526522
for (bidx = 1; bidx < maxlrg; bidx++) {
527523
if (lrgs(bidx).alive() && lrgs(bidx).reg() >= LRG::SPILL_REG) {
@@ -569,8 +565,14 @@ uint PhaseChaitin::Split(uint maxlrg, ResourceArea* split_arena) {
569565
#undef NEW_SPLIT_ARRAY
570566

571567
// Initialize to array of empty vectorsets
572-
for( slidx = 0; slidx < spill_cnt; slidx++ )
573-
UP_entry[slidx] = new VectorSet(split_arena);
568+
// Each containing at most spill_cnt * _cfg.number_of_blocks() entries.
569+
for (slidx = 0; slidx < spill_cnt; slidx++) {
570+
UP_entry[slidx] = new(split_arena) VectorSet(split_arena);
571+
}
572+
573+
// Keep track of DEFS & Phis for later passes
574+
Node_List defs(split_arena, 8);
575+
Node_List phis(split_arena, 16);
574576

575577
//----------PASS 1----------
576578
//----------Propagation & Node Insertion Code----------
@@ -702,7 +704,7 @@ uint PhaseChaitin::Split(uint maxlrg, ResourceArea* split_arena) {
702704
} // end if not found correct phi
703705
// Here you have either found or created the Phi, so record it
704706
assert(phi != nullptr,"Must have a Phi Node here");
705-
phis->push(phi);
707+
phis.push(phi);
706708
// PhiNodes should either force the LRG UP or DOWN depending
707709
// on its inputs and the register pressure in the Phi's block.
708710
UPblock[slidx] = true; // Assume new DEF is UP
@@ -1189,7 +1191,7 @@ uint PhaseChaitin::Split(uint maxlrg, ResourceArea* split_arena) {
11891191
if( deflrg.reg() >= LRG::SPILL_REG ) { // Spilled?
11901192
uint slidx = lrg2reach[defidx];
11911193
// Add to defs list for later assignment of new live range number
1192-
defs->push(n);
1194+
defs.push(n);
11931195
// Set a flag on the Node indicating it has already spilled.
11941196
// Only do it for capacity spills not conflict spills.
11951197
if( !deflrg._direct_conflict )
@@ -1308,9 +1310,9 @@ uint PhaseChaitin::Split(uint maxlrg, ResourceArea* split_arena) {
13081310

13091311
//----------PASS 2----------
13101312
// Reset all DEF live range numbers here
1311-
for( insidx = 0; insidx < defs->size(); insidx++ ) {
1313+
for( insidx = 0; insidx < defs.size(); insidx++ ) {
13121314
// Grab the def
1313-
n1 = defs->at(insidx);
1315+
n1 = defs.at(insidx);
13141316
// Set new lidx for DEF
13151317
new_lrg(n1, maxlrg++);
13161318
}
@@ -1320,8 +1322,8 @@ uint PhaseChaitin::Split(uint maxlrg, ResourceArea* split_arena) {
13201322
// info for each spilled LRG and update edges.
13211323
// Walk the phis list to patch inputs, split phis, and name phis
13221324
uint lrgs_before_phi_split = maxlrg;
1323-
for( insidx = 0; insidx < phis->size(); insidx++ ) {
1324-
Node *phi = phis->at(insidx);
1325+
for( insidx = 0; insidx < phis.size(); insidx++ ) {
1326+
Node *phi = phis.at(insidx);
13251327
assert(phi->is_Phi(),"This list must only contain Phi Nodes");
13261328
Block *b = _cfg.get_block_for_node(phi);
13271329
// Grab the live range number
@@ -1389,8 +1391,8 @@ uint PhaseChaitin::Split(uint maxlrg, ResourceArea* split_arena) {
13891391

13901392
//----------PASS 3----------
13911393
// Pass over all Phi's to union the live ranges
1392-
for( insidx = 0; insidx < phis->size(); insidx++ ) {
1393-
Node *phi = phis->at(insidx);
1394+
for( insidx = 0; insidx < phis.size(); insidx++ ) {
1395+
Node *phi = phis.at(insidx);
13941396
assert(phi->is_Phi(),"This list must only contain Phi Nodes");
13951397
// Walk all inputs to Phi and Union input live range with Phi live range
13961398
for( uint i = 1; i < phi->req(); i++ ) {
@@ -1408,9 +1410,9 @@ uint PhaseChaitin::Split(uint maxlrg, ResourceArea* split_arena) {
14081410
} // End for all inputs to the Phi Node
14091411
} // End for all Phi Nodes
14101412
// Now union all two address instructions
1411-
for (insidx = 0; insidx < defs->size(); insidx++) {
1413+
for (insidx = 0; insidx < defs.size(); insidx++) {
14121414
// Grab the def
1413-
n1 = defs->at(insidx);
1415+
n1 = defs.at(insidx);
14141416
// Set new lidx for DEF & handle 2-addr instructions
14151417
if (n1->is_Mach() && ((twoidx = n1->as_Mach()->two_adr()) != 0)) {
14161418
assert(_lrg_map.find(n1->in(twoidx)) < maxlrg,"Assigning bad live range index");

0 commit comments

Comments
 (0)
Please sign in to comment.