1.1 --- a/src/share/vm/opto/ifg.cpp Thu Feb 05 14:43:58 2009 -0800 1.2 +++ b/src/share/vm/opto/ifg.cpp Fri Feb 06 13:31:03 2009 -0800 1.3 @@ -471,12 +471,28 @@ 1.4 // for the "collect_gc_info" phase later. 1.5 IndexSet liveout(_live->live(b)); 1.6 uint last_inst = b->end_idx(); 1.7 - // Compute last phi index 1.8 - uint last_phi; 1.9 - for( last_phi = 1; last_phi < last_inst; last_phi++ ) 1.10 - if( !b->_nodes[last_phi]->is_Phi() ) 1.11 + // Compute first nonphi node index 1.12 + uint first_inst; 1.13 + for( first_inst = 1; first_inst < last_inst; first_inst++ ) 1.14 + if( !b->_nodes[first_inst]->is_Phi() ) 1.15 break; 1.16 1.17 + // Spills could be inserted before CreateEx node which should be 1.18 + // first instruction in block after Phis. Move CreateEx up. 1.19 + for( uint insidx = first_inst; insidx < last_inst; insidx++ ) { 1.20 + Node *ex = b->_nodes[insidx]; 1.21 + if( ex->is_SpillCopy() ) continue; 1.22 + if( insidx > first_inst && ex->is_Mach() && 1.23 + ex->as_Mach()->ideal_Opcode() == Op_CreateEx ) { 1.24 + // If the CreateEx isn't above all the MachSpillCopies 1.25 + // then move it to the top. 1.26 + b->_nodes.remove(insidx); 1.27 + b->_nodes.insert(first_inst, ex); 1.28 + } 1.29 + // Stop once a CreateEx or any other node is found 1.30 + break; 1.31 + } 1.32 + 1.33 // Reset block's register pressure values for each ifg construction 1.34 uint pressure[2], hrp_index[2]; 1.35 pressure[0] = pressure[1] = 0; 1.36 @@ -485,7 +501,7 @@ 1.37 // Liveout things are presumed live for the whole block. We accumulate 1.38 // 'area' accordingly. If they get killed in the block, we'll subtract 1.39 // the unused part of the block from the area. 1.40 - int inst_count = last_inst - last_phi; 1.41 + int inst_count = last_inst - first_inst; 1.42 double cost = (inst_count <= 0) ? 0.0 : b->_freq * double(inst_count); 1.43 assert(!(cost < 0.0), "negative spill cost" ); 1.44 IndexSetIterator elements(&liveout);