8072398: assert fails in L1RGenerator::increment_event_counter_impl

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
This commit is contained in:
Zoltan Majo 2015-02-06 18:16:55 +01:00
parent d4d8ef4585
commit a25fe37e17
3 changed files with 22 additions and 15 deletions

View File

@ -1126,34 +1126,39 @@ static void no_shared_spaces(const char* message) {
} }
#endif #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) { 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; return threshold;
} else { } else {
return (intx)(threshold * scale); 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) { 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) { if (scale == 1.0 || scale < 0.0) {
return freq_log; return freq_log;
} }
// Check values to avoid calculating log2 of 0.
// Check value to avoid calculating log2 of 0. if (scale == 0.0 || freq_log == 0) {
if (scale == 0.0) { return 0;
return freq_log;
} }
intx scaled_freq = scaled_compile_threshold((intx)1 << freq_log, scale);
// Determine the maximum notification frequency value currently supported. // Determine the maximum notification frequency value currently supported.
// The largest mask value that the interpreter/C1 can handle is // The largest mask value that the interpreter/C1 can handle is
// of length InvocationCounter::number_of_count_bits. Mask values are always // of length InvocationCounter::number_of_count_bits. Mask values are always
// one bit shorter then the value of the notification frequency. Set // one bit shorter then the value of the notification frequency. Set
// max_freq_bits accordingly. // max_freq_bits accordingly.
intx max_freq_bits = InvocationCounter::number_of_count_bits + 1; 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; return max_freq_bits;
} else { } else {
return log2_intptr(scaled_freq); return log2_intptr(scaled_freq);
@ -1204,8 +1209,9 @@ void Arguments::set_tiered_flags() {
vm_exit_during_initialization("Negative value specified for CompileThresholdScaling", NULL); vm_exit_during_initialization("Negative value specified for CompileThresholdScaling", NULL);
} }
// Scale tiered compilation thresholds // Scale tiered compilation thresholds.
if (!FLAG_IS_DEFAULT(CompileThresholdScaling)) { // 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, Tier0InvokeNotifyFreqLog, scaled_freq_log(Tier0InvokeNotifyFreqLog));
FLAG_SET_ERGO(intx, Tier0BackedgeNotifyFreqLog, scaled_freq_log(Tier0BackedgeNotifyFreqLog)); FLAG_SET_ERGO(intx, Tier0BackedgeNotifyFreqLog, scaled_freq_log(Tier0BackedgeNotifyFreqLog));
@ -3921,7 +3927,8 @@ jint Arguments::apply_ergo() {
"Incompatible compilation policy selected", NULL); "Incompatible compilation policy selected", NULL);
} }
// Scale CompileThreshold // 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)); FLAG_SET_ERGO(intx, CompileThreshold, scaled_compile_threshold(CompileThreshold));
} }
} }

View File

@ -3531,7 +3531,7 @@ class CommandLineFlags {
"(both with and without tiered compilation): " \ "(both with and without tiered compilation): " \
"values greater than 1.0 delay counter overflow, " \ "values greater than 1.0 delay counter overflow, " \
"values between 0 and 1.0 rush 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. " \ "value of 0.0 is equivalent to -Xint. " \
"" \ "" \
"Flag can be set as per-method option. " \ "Flag can be set as per-method option. " \

View File

@ -26,7 +26,7 @@ import com.oracle.java.testlibrary.*;
/* /*
* @test CheckCompileThresholdScaling * @test CheckCompileThresholdScaling
* @bug 8059604 * @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 * @library /testlibrary
* @run main CheckCompileThresholdScaling * @run main CheckCompileThresholdScaling
*/ */