src/share/vm/opto/ifg.cpp

changeset 1001
91263420e1c6
parent 815
eb28cf662f56
child 1014
0fbdb4381b99
child 1040
98cb887364d3
equal deleted inserted replaced
1000:7fe62bb75bf4 1001:91263420e1c6
469 Block *b = _cfg._blocks[i]; 469 Block *b = _cfg._blocks[i];
470 // Clone (rather than smash in place) the liveout info, so it is alive 470 // Clone (rather than smash in place) the liveout info, so it is alive
471 // for the "collect_gc_info" phase later. 471 // for the "collect_gc_info" phase later.
472 IndexSet liveout(_live->live(b)); 472 IndexSet liveout(_live->live(b));
473 uint last_inst = b->end_idx(); 473 uint last_inst = b->end_idx();
474 // Compute last phi index 474 // Compute first nonphi node index
475 uint last_phi; 475 uint first_inst;
476 for( last_phi = 1; last_phi < last_inst; last_phi++ ) 476 for( first_inst = 1; first_inst < last_inst; first_inst++ )
477 if( !b->_nodes[last_phi]->is_Phi() ) 477 if( !b->_nodes[first_inst]->is_Phi() )
478 break; 478 break;
479
480 // Spills could be inserted before CreateEx node which should be
481 // first instruction in block after Phis. Move CreateEx up.
482 for( uint insidx = first_inst; insidx < last_inst; insidx++ ) {
483 Node *ex = b->_nodes[insidx];
484 if( ex->is_SpillCopy() ) continue;
485 if( insidx > first_inst && ex->is_Mach() &&
486 ex->as_Mach()->ideal_Opcode() == Op_CreateEx ) {
487 // If the CreateEx isn't above all the MachSpillCopies
488 // then move it to the top.
489 b->_nodes.remove(insidx);
490 b->_nodes.insert(first_inst, ex);
491 }
492 // Stop once a CreateEx or any other node is found
493 break;
494 }
479 495
480 // Reset block's register pressure values for each ifg construction 496 // Reset block's register pressure values for each ifg construction
481 uint pressure[2], hrp_index[2]; 497 uint pressure[2], hrp_index[2];
482 pressure[0] = pressure[1] = 0; 498 pressure[0] = pressure[1] = 0;
483 hrp_index[0] = hrp_index[1] = last_inst+1; 499 hrp_index[0] = hrp_index[1] = last_inst+1;
484 b->_reg_pressure = b->_freg_pressure = 0; 500 b->_reg_pressure = b->_freg_pressure = 0;
485 // Liveout things are presumed live for the whole block. We accumulate 501 // Liveout things are presumed live for the whole block. We accumulate
486 // 'area' accordingly. If they get killed in the block, we'll subtract 502 // 'area' accordingly. If they get killed in the block, we'll subtract
487 // the unused part of the block from the area. 503 // the unused part of the block from the area.
488 int inst_count = last_inst - last_phi; 504 int inst_count = last_inst - first_inst;
489 double cost = (inst_count <= 0) ? 0.0 : b->_freq * double(inst_count); 505 double cost = (inst_count <= 0) ? 0.0 : b->_freq * double(inst_count);
490 assert(!(cost < 0.0), "negative spill cost" ); 506 assert(!(cost < 0.0), "negative spill cost" );
491 IndexSetIterator elements(&liveout); 507 IndexSetIterator elements(&liveout);
492 uint lidx; 508 uint lidx;
493 while ((lidx = elements.next()) != 0) { 509 while ((lidx = elements.next()) != 0) {

mercurial