src/share/vm/opto/ifg.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File JDK-8033260 Sdiff src/share/vm/opto

src/share/vm/opto/ifg.cpp

Print this page
rev 5903 : 8033260: assert(lrg._area >= 0.0) failed: negative spill area
Summary: Change type from float to double on block frequency, and add check for +Inf - +Inf operation
Reviewed-by:


 686     uint lid = _lrg_map.live_range_id(def);
 687     if (!lid) {
 688       continue;
 689     }
 690     LRG& lrg = lrgs(lid);
 691 
 692     // No use-side cost for spilling debug info
 693     if (k < debug_start) {
 694       // A USE costs twice block frequency (once for the Load, once
 695       // for a Load-delay).  Rematerialized uses only cost once.
 696       lrg._cost += (def->rematerialize() ? b->_freq : (b->_freq * 2));
 697     }
 698 
 699     if (liveout->insert(lid)) {
 700       // Newly live things assumed live from here to top of block
 701       lrg._area += cost;
 702       raise_pressure(b, lrg, int_pressure, float_pressure);
 703       assert(int_pressure._current_pressure == count_int_pressure(liveout), "the int pressure is incorrect");
 704       assert(float_pressure._current_pressure == count_float_pressure(liveout), "the float pressure is incorrect");
 705     }
 706     assert(!(lrg._area < 0.0), "negative spill area" );
 707   }
 708 }
 709 
 710 /*
 711  * If we run off the top of the block with high pressure just record that the
 712  * whole block is high pressure. (Even though we might have a transition
 713  * lower down in the block)
 714  */
 715 void PhaseChaitin::check_for_high_pressure_block(Pressure& pressure) {
 716   // current pressure now means the pressure before the first instruction in the block
 717   // (since we have stepped through all instructions backwards)
 718   if (pressure._current_pressure > pressure._high_pressure_limit) {
 719     pressure._high_pressure_index = 0;
 720   }
 721 }
 722 
 723 /*
 724  * Compute high pressure indice; avoid landing in the middle of projnodes
 725  * and set the high pressure index for the block
 726  */


 755   uint must_spill = 0;
 756   for (uint i = 0; i < _cfg.number_of_blocks(); i++) {
 757     Block* block = _cfg.get_block(i);
 758 
 759     // Clone (rather than smash in place) the liveout info, so it is alive
 760     // for the "collect_gc_info" phase later.
 761     IndexSet liveout(_live->live(block));
 762 
 763     uint first_inst = first_nonphi_index(block);
 764     uint last_inst = block->end_idx();
 765 
 766     move_exception_node_up(block, first_inst, last_inst);
 767 
 768     Pressure int_pressure(last_inst + 1, INTPRESSURE);
 769     Pressure float_pressure(last_inst + 1, FLOATPRESSURE);
 770     block->_reg_pressure = 0;
 771     block->_freg_pressure = 0;
 772 
 773     int inst_count = last_inst - first_inst;
 774     double cost = (inst_count <= 0) ? 0.0 : block->_freq * double(inst_count);
 775     assert(!(cost < 0.0), "negative spill cost" );
 776 
 777     compute_initial_block_pressure(block, &liveout, int_pressure, float_pressure, cost);
 778 
 779     for (uint location = last_inst; location > 0; location--) {
 780       Node* n = block->get_node(location);
 781       uint lid = _lrg_map.live_range_id(n);
 782 
 783       if(lid) {
 784         LRG& lrg = lrgs(lid);
 785 
 786         // A DEF normally costs block frequency; rematerialized values are
 787         // removed from the DEF sight, so LOWER costs here.
 788         lrg._cost += n->rematerialize() ? 0 : block->_freq;
 789 
 790         if (!liveout.member(lid) && n->Opcode() != Op_SafePoint) {
 791           if (remove_node_if_not_used(block, location, n, lid, &liveout)) {
 792             float_pressure._high_pressure_index--;
 793             int_pressure._high_pressure_index--;
 794             continue;
 795           }
 796           if (lrg._fat_proj) {
 797             check_for_high_pressure_transition_at_fatproj(block->_reg_pressure, location, lrg, int_pressure, Op_RegI);
 798             check_for_high_pressure_transition_at_fatproj(block->_freg_pressure, location, lrg, float_pressure, Op_RegD);
 799           }
 800         } else {
 801           // A live range ends at its definition, remove the remaining area.



 802           lrg._area -= cost;

 803           assert(lrg._area >= 0.0, "negative spill area" );
 804 
 805           assign_high_score_to_immediate_copies(block, n, lrg, location + 1, last_inst);
 806 
 807           if (liveout.remove(lid)) {
 808             lower_pressure(block, location, lrg, &liveout, int_pressure, float_pressure);
 809           }
 810           uint copy_idx = n->is_Copy();
 811           if (copy_idx) {
 812             uint lid_copy = _lrg_map.live_range_id(n->in(copy_idx));
 813             remove_interference_from_copy(block, location, lid_copy, &liveout, cost, int_pressure, float_pressure);
 814           }
 815         }
 816 
 817         // Since rematerializable DEFs are not bound but the live range is,
 818         // some uses must be bound. If we spill live range 'r', it can
 819         // rematerialize at each use site according to its bindings.
 820         if (lrg.is_bound() && !n->rematerialize() && lrg.mask().is_NotEmpty()) {
 821           remove_bound_register_from_interfering_live_ranges(lrg, &liveout, must_spill);
 822         }




 686     uint lid = _lrg_map.live_range_id(def);
 687     if (!lid) {
 688       continue;
 689     }
 690     LRG& lrg = lrgs(lid);
 691 
 692     // No use-side cost for spilling debug info
 693     if (k < debug_start) {
 694       // A USE costs twice block frequency (once for the Load, once
 695       // for a Load-delay).  Rematerialized uses only cost once.
 696       lrg._cost += (def->rematerialize() ? b->_freq : (b->_freq * 2));
 697     }
 698 
 699     if (liveout->insert(lid)) {
 700       // Newly live things assumed live from here to top of block
 701       lrg._area += cost;
 702       raise_pressure(b, lrg, int_pressure, float_pressure);
 703       assert(int_pressure._current_pressure == count_int_pressure(liveout), "the int pressure is incorrect");
 704       assert(float_pressure._current_pressure == count_float_pressure(liveout), "the float pressure is incorrect");
 705     }
 706     assert(lrg._area >= 0.0, "negative spill area" );
 707   }
 708 }
 709 
 710 /*
 711  * If we run off the top of the block with high pressure just record that the
 712  * whole block is high pressure. (Even though we might have a transition
 713  * lower down in the block)
 714  */
 715 void PhaseChaitin::check_for_high_pressure_block(Pressure& pressure) {
 716   // current pressure now means the pressure before the first instruction in the block
 717   // (since we have stepped through all instructions backwards)
 718   if (pressure._current_pressure > pressure._high_pressure_limit) {
 719     pressure._high_pressure_index = 0;
 720   }
 721 }
 722 
 723 /*
 724  * Compute high pressure indice; avoid landing in the middle of projnodes
 725  * and set the high pressure index for the block
 726  */


 755   uint must_spill = 0;
 756   for (uint i = 0; i < _cfg.number_of_blocks(); i++) {
 757     Block* block = _cfg.get_block(i);
 758 
 759     // Clone (rather than smash in place) the liveout info, so it is alive
 760     // for the "collect_gc_info" phase later.
 761     IndexSet liveout(_live->live(block));
 762 
 763     uint first_inst = first_nonphi_index(block);
 764     uint last_inst = block->end_idx();
 765 
 766     move_exception_node_up(block, first_inst, last_inst);
 767 
 768     Pressure int_pressure(last_inst + 1, INTPRESSURE);
 769     Pressure float_pressure(last_inst + 1, FLOATPRESSURE);
 770     block->_reg_pressure = 0;
 771     block->_freg_pressure = 0;
 772 
 773     int inst_count = last_inst - first_inst;
 774     double cost = (inst_count <= 0) ? 0.0 : block->_freq * double(inst_count);
 775     assert(cost >= 0.0, "negative spill cost" );
 776 
 777     compute_initial_block_pressure(block, &liveout, int_pressure, float_pressure, cost);
 778 
 779     for (uint location = last_inst; location > 0; location--) {
 780       Node* n = block->get_node(location);
 781       uint lid = _lrg_map.live_range_id(n);
 782 
 783       if(lid) {
 784         LRG& lrg = lrgs(lid);
 785 
 786         // A DEF normally costs block frequency; rematerialized values are
 787         // removed from the DEF sight, so LOWER costs here.
 788         lrg._cost += n->rematerialize() ? 0 : block->_freq;
 789 
 790         if (!liveout.member(lid) && n->Opcode() != Op_SafePoint) {
 791           if (remove_node_if_not_used(block, location, n, lid, &liveout)) {
 792             float_pressure._high_pressure_index--;
 793             int_pressure._high_pressure_index--;
 794             continue;
 795           }
 796           if (lrg._fat_proj) {
 797             check_for_high_pressure_transition_at_fatproj(block->_reg_pressure, location, lrg, int_pressure, Op_RegI);
 798             check_for_high_pressure_transition_at_fatproj(block->_freg_pressure, location, lrg, float_pressure, Op_RegD);
 799           }
 800         } else {
 801           // A live range ends at its definition, remove the remaining area.
 802           // If the cost is +Inf (which might happen in extreme cases), the lrg area will also be +Inf,
 803           // and +Inf - +Inf = NaN. So let's not do that subtraction.
 804           if (g_isfinite(cost)) {
 805             lrg._area -= cost;
 806           }
 807           assert(lrg._area >= 0.0, "negative spill area" );
 808 
 809           assign_high_score_to_immediate_copies(block, n, lrg, location + 1, last_inst);
 810 
 811           if (liveout.remove(lid)) {
 812             lower_pressure(block, location, lrg, &liveout, int_pressure, float_pressure);
 813           }
 814           uint copy_idx = n->is_Copy();
 815           if (copy_idx) {
 816             uint lid_copy = _lrg_map.live_range_id(n->in(copy_idx));
 817             remove_interference_from_copy(block, location, lid_copy, &liveout, cost, int_pressure, float_pressure);
 818           }
 819         }
 820 
 821         // Since rematerializable DEFs are not bound but the live range is,
 822         // some uses must be bound. If we spill live range 'r', it can
 823         // rematerialize at each use site according to its bindings.
 824         if (lrg.is_bound() && !n->rematerialize() && lrg.mask().is_NotEmpty()) {
 825           remove_bound_register_from_interfering_live_ranges(lrg, &liveout, must_spill);
 826         }


src/share/vm/opto/ifg.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File