Print this page


Split Close
Expand all
Collapse all
          --- old/src/share/vm/opto/split_if.cpp
          +++ new/src/share/vm/opto/split_if.cpp
↓ open down ↓ 492 lines elided ↑ open up ↑
 493  493    _igvn.remove_dead_node(new_iff);
 494  494    // Lazy replace IDOM info with the region's dominator
 495  495    lazy_replace( iff, region_dom );
 496  496  
 497  497    // Now make the original merge point go dead, by handling all its uses.
 498  498    small_cache region_cache;
 499  499    // Preload some control flow in region-cache
 500  500    region_cache.lru_insert( new_false, new_false );
 501  501    region_cache.lru_insert( new_true , new_true  );
 502  502    // Now handle all uses of the splitting block
 503      -  for (DUIterator_Last kmin, k = region->last_outs(kmin); k >= kmin; --k) {
 504      -    Node* phi = region->last_out(k);
 505      -    if( !phi->in(0) ) {         // Dead phi?  Remove it
      503 +  for (DUIterator k = region->outs(); region->has_out(k); k++) {
      504 +    Node* phi = region->out(k);
      505 +    if (!phi->in(0)) {         // Dead phi?  Remove it
 506  506        _igvn.remove_dead_node(phi);
 507      -      continue;
 508      -    }
 509      -    assert( phi->in(0) == region, "" );
 510      -    if( phi == region ) {       // Found the self-reference
 511      -      phi->set_req(0, NULL);
 512      -      continue;                 // Break the self-cycle
 513      -    }
 514      -    // Expected common case: Phi hanging off of Region
 515      -    if( phi->is_Phi() ) {
      507 +    } else if (phi == region) { // Found the self-reference
      508 +      continue;                 // No roll-back of DUIterator
      509 +    } else if (phi->is_Phi()) { // Expected common case: Phi hanging off of Region
      510 +      assert(phi->in(0) == region, "Inconsistent graph");
 516  511        // Need a per-def cache.  Phi represents a def, so make a cache
 517  512        small_cache phi_cache;
 518  513  
 519  514        // Inspect all Phi uses to make the Phi go dead
 520  515        for (DUIterator_Last lmin, l = phi->last_outs(lmin); l >= lmin; --l) {
 521  516          Node* use = phi->last_out(l);
 522  517          // Compute the new DEF for this USE.  New DEF depends on the path
 523  518          // taken from the original DEF to the USE.  The new DEF may be some
 524  519          // collection of PHI's merging values from different paths.  The Phis
 525  520          // inserted depend only on the location of the USE.  We use a
 526  521          // 2-element cache to handle multiple uses from the same block.
 527      -        handle_use( use, phi, &phi_cache, region_dom, new_false, new_true, old_false, old_true );
      522 +        handle_use(use, phi, &phi_cache, region_dom, new_false, new_true, old_false, old_true);
 528  523        } // End of while phi has uses
 529      -
 530      -      // Because handle_use might relocate region->_out,
 531      -      // we must refresh the iterator.
 532      -      k = region->last_outs(kmin);
 533      -
 534  524        // Remove the dead Phi
 535  525        _igvn.remove_dead_node( phi );
 536      -
 537  526      } else {
      527 +      assert(phi->in(0) == region, "Inconsistent graph");
 538  528        // Random memory op guarded by Region.  Compute new DEF for USE.
 539      -      handle_use( phi, region, &region_cache, region_dom, new_false, new_true, old_false, old_true );
      529 +      handle_use(phi, region, &region_cache, region_dom, new_false, new_true, old_false, old_true);
 540  530      }
 541      -
      531 +    // Every path above deletes a use of the region, except for the region
      532 +    // self-cycle (which is needed by handle_use calling find_use_block
      533 +    // calling get_ctrl calling get_ctrl_no_update looking for dead
      534 +    // regions).  So roll back the DUIterator innards.
      535 +    --k;
 542  536    } // End of while merge point has phis
 543  537  
      538 +  assert(region->outcnt() == 1, "Only self reference should remain"); // Just Self on the Region
      539 +  region->set_req(0, NULL);       // Break the self-cycle
      540 +
 544  541    // Any leftover bits in the splitting block must not have depended on local
 545  542    // Phi inputs (these have already been split-up).  Hence it's safe to hoist
 546  543    // these guys to the dominating point.
 547  544    lazy_replace( region, region_dom );
 548  545  #ifndef PRODUCT
 549  546    if( VerifyLoopOptimizations ) verify();
 550  547  #endif
 551  548  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX