diff src/share/vm/opto/ifg.cpp @ 14499:1077c8270209

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: kvn, roland
author adlertz
date Tue, 25 Feb 2014 17:51:27 +0100
parents 99fc8c086679
children 4ca6dc0799b6
line wrap: on
line diff
--- a/src/share/vm/opto/ifg.cpp	Tue Feb 25 14:09:02 2014 +0100
+++ b/src/share/vm/opto/ifg.cpp	Tue Feb 25 17:51:27 2014 +0100
@@ -693,7 +693,7 @@
       assert(int_pressure.current_pressure() == count_int_pressure(liveout), "the int pressure is incorrect");
       assert(float_pressure.current_pressure() == count_float_pressure(liveout), "the float pressure is incorrect");
     }
-    assert(!(lrg._area < 0.0), "negative spill area" );
+    assert(lrg._area >= 0.0, "negative spill area" );
   }
 }
 
@@ -762,7 +762,7 @@
 
     int inst_count = last_inst - first_inst;
     double cost = (inst_count <= 0) ? 0.0 : block->_freq * double(inst_count);
-    assert(!(cost < 0.0), "negative spill cost" );
+    assert(cost >= 0.0, "negative spill cost" );
 
     compute_initial_block_pressure(block, &liveout, int_pressure, float_pressure, cost);
 
@@ -789,7 +789,11 @@
           }
         } else {
           // A live range ends at its definition, remove the remaining area.
-          lrg._area -= cost;
+          // If the cost is +Inf (which might happen in extreme cases), the lrg area will also be +Inf,
+          // and +Inf - +Inf = NaN. So let's not do that subtraction.
+          if (g_isfinite(cost)) {
+            lrg._area -= cost;
+          }
           assert(lrg._area >= 0.0, "negative spill area" );
 
           assign_high_score_to_immediate_copies(block, n, lrg, location + 1, last_inst);