8072398: assert fails in L1RGenerator::increment_event_counter_impl
authorzmajo
Fri, 06 Feb 2015 18:16:55 +0100
changeset 28928 e3815b017664
parent 28927 48e4a707e777
child 28929 853493ff65e5
8072398: assert fails in L1RGenerator::increment_event_counter_impl Summary: Change scaling code to allow scaling with 0.0; change set_tiered_flags() to treat CompileThresholdScaling==0.0 in a special way. Reviewed-by: kvn, iveresov
hotspot/src/share/vm/runtime/arguments.cpp
hotspot/src/share/vm/runtime/globals.hpp
hotspot/test/compiler/arguments/CheckCompileThresholdScaling.java
--- a/hotspot/src/share/vm/runtime/arguments.cpp	Fri Jan 30 12:53:56 2015 +0100
+++ b/hotspot/src/share/vm/runtime/arguments.cpp	Fri Feb 06 18:16:55 2015 +0100
@@ -1126,34 +1126,39 @@
 }
 #endif
 
+// Returns threshold scaled with the value of scale.
+// If scale < 0.0, threshold is returned without scaling.
 intx Arguments::scaled_compile_threshold(intx threshold, double scale) {
-  if (scale == 1.0 || scale <= 0.0) {
+  if (scale == 1.0 || scale < 0.0) {
     return threshold;
   } else {
     return (intx)(threshold * scale);
   }
 }
 
-// Returns freq_log scaled with CompileThresholdScaling
+// Returns freq_log scaled with the value of scale.
+// Returned values are in the range of [0, InvocationCounter::number_of_count_bits + 1].
+// If scale < 0.0, freq_log is returned without scaling.
 intx Arguments::scaled_freq_log(intx freq_log, double scale) {
-  // Check if scaling is necessary or negative value was specified.
+  // Check if scaling is necessary or if negative value was specified.
   if (scale == 1.0 || scale < 0.0) {
     return freq_log;
   }
-
-  // Check value to avoid calculating log2 of 0.
-  if (scale == 0.0) {
-    return freq_log;
+  // Check values to avoid calculating log2 of 0.
+  if (scale == 0.0 || freq_log == 0) {
+    return 0;
   }
-
-  intx scaled_freq = scaled_compile_threshold((intx)1 << freq_log, scale);
   // Determine the maximum notification frequency value currently supported.
   // The largest mask value that the interpreter/C1 can handle is
   // of length InvocationCounter::number_of_count_bits. Mask values are always
   // one bit shorter then the value of the notification frequency. Set
   // max_freq_bits accordingly.
   intx max_freq_bits = InvocationCounter::number_of_count_bits + 1;
-  if (scaled_freq > nth_bit(max_freq_bits)) {
+  intx scaled_freq = scaled_compile_threshold((intx)1 << freq_log, scale);
+  if (scaled_freq == 0) {
+    // Return 0 right away to avoid calculating log2 of 0.
+    return 0;
+  } else if (scaled_freq > nth_bit(max_freq_bits)) {
     return max_freq_bits;
   } else {
     return log2_intptr(scaled_freq);
@@ -1204,8 +1209,9 @@
     vm_exit_during_initialization("Negative value specified for CompileThresholdScaling", NULL);
   }
 
-  // Scale tiered compilation thresholds
-  if (!FLAG_IS_DEFAULT(CompileThresholdScaling)) {
+  // Scale tiered compilation thresholds.
+  // CompileThresholdScaling == 0.0 is equivalent to -Xint and leaves compilation thresholds unchanged.
+  if (!FLAG_IS_DEFAULT(CompileThresholdScaling) && CompileThresholdScaling > 0.0) {
     FLAG_SET_ERGO(intx, Tier0InvokeNotifyFreqLog, scaled_freq_log(Tier0InvokeNotifyFreqLog));
     FLAG_SET_ERGO(intx, Tier0BackedgeNotifyFreqLog, scaled_freq_log(Tier0BackedgeNotifyFreqLog));
 
@@ -3921,7 +3927,8 @@
         "Incompatible compilation policy selected", NULL);
     }
     // Scale CompileThreshold
-    if (!FLAG_IS_DEFAULT(CompileThresholdScaling)) {
+    // CompileThresholdScaling == 0.0 is equivalent to -Xint and leaves CompileThreshold unchanged.
+    if (!FLAG_IS_DEFAULT(CompileThresholdScaling) && CompileThresholdScaling > 0.0) {
       FLAG_SET_ERGO(intx, CompileThreshold, scaled_compile_threshold(CompileThreshold));
     }
   }
--- a/hotspot/src/share/vm/runtime/globals.hpp	Fri Jan 30 12:53:56 2015 +0100
+++ b/hotspot/src/share/vm/runtime/globals.hpp	Fri Feb 06 18:16:55 2015 +0100
@@ -3531,7 +3531,7 @@
           "(both with and without tiered compilation): "                    \
           "values greater than 1.0 delay counter overflow, "                \
           "values between 0 and 1.0 rush counter overflow, "                \
-          "value of 1.0 leave compilation thresholds unchanged "            \
+          "value of 1.0 leaves compilation thresholds unchanged "           \
           "value of 0.0 is equivalent to -Xint. "                           \
           ""                                                                \
           "Flag can be set as per-method option. "                          \
--- a/hotspot/test/compiler/arguments/CheckCompileThresholdScaling.java	Fri Jan 30 12:53:56 2015 +0100
+++ b/hotspot/test/compiler/arguments/CheckCompileThresholdScaling.java	Fri Feb 06 18:16:55 2015 +0100
@@ -26,7 +26,7 @@
 /*
  * @test CheckCompileThresholdScaling
  * @bug 8059604
- * @summary "Add CompileThresholdScalingPercentage flag to control when methods are first compiled (with +/-TieredCompilation)"
+ * @summary "Add CompileThresholdScaling flag to control when methods are first compiled (with +/-TieredCompilation)"
  * @library /testlibrary
  * @run main CheckCompileThresholdScaling
  */