--- a/hotspot/src/share/vm/runtime/arguments.cpp Wed Oct 15 10:51:43 2014 +0200
+++ b/hotspot/src/share/vm/runtime/arguments.cpp Wed Oct 15 14:00:41 2014 +0200
@@ -1135,6 +1135,21 @@
}
#endif
+// Returns threshold scaled with CompileThresholdScaling
+intx Arguments::get_scaled_compile_threshold(intx threshold) {
+ return (intx)(threshold * CompileThresholdScaling);
+}
+
+// Returns freq_log scaled with CompileThresholdScaling
+intx Arguments::get_scaled_freq_log(intx freq_log) {
+ intx scaled_freq = get_scaled_compile_threshold((intx)1 << freq_log);
+ if (scaled_freq == 0) {
+ return 0;
+ } else {
+ return log2_intptr(scaled_freq);
+ }
+}
+
void Arguments::set_tiered_flags() {
// With tiered, set default policy to AdvancedThresholdPolicy, which is 3.
if (FLAG_IS_DEFAULT(CompilationPolicyChoice)) {
@@ -1174,6 +1189,32 @@
Tier3InvokeNotifyFreqLog = 0;
Tier4InvocationThreshold = 0;
}
+ // Scale tiered compilation thresholds
+ if (!FLAG_IS_DEFAULT(CompileThresholdScaling)) {
+ FLAG_SET_ERGO(intx, Tier0InvokeNotifyFreqLog, get_scaled_freq_log(Tier0InvokeNotifyFreqLog));
+ FLAG_SET_ERGO(intx, Tier0BackedgeNotifyFreqLog, get_scaled_freq_log(Tier0BackedgeNotifyFreqLog));
+
+ FLAG_SET_ERGO(intx, Tier3InvocationThreshold, get_scaled_compile_threshold(Tier3InvocationThreshold));
+ FLAG_SET_ERGO(intx, Tier3MinInvocationThreshold, get_scaled_compile_threshold(Tier3MinInvocationThreshold));
+ FLAG_SET_ERGO(intx, Tier3CompileThreshold, get_scaled_compile_threshold(Tier3CompileThreshold));
+ FLAG_SET_ERGO(intx, Tier3BackEdgeThreshold, get_scaled_compile_threshold(Tier3BackEdgeThreshold));
+
+ // Tier2{Invocation,MinInvocation,Compile,Backedge}Threshold should be scaled here
+ // once these thresholds become supported.
+
+ FLAG_SET_ERGO(intx, Tier2InvokeNotifyFreqLog, get_scaled_freq_log(Tier2InvokeNotifyFreqLog));
+ FLAG_SET_ERGO(intx, Tier2BackedgeNotifyFreqLog, get_scaled_freq_log(Tier2BackedgeNotifyFreqLog));
+
+ FLAG_SET_ERGO(intx, Tier3InvokeNotifyFreqLog, get_scaled_freq_log(Tier3InvokeNotifyFreqLog));
+ FLAG_SET_ERGO(intx, Tier3BackedgeNotifyFreqLog, get_scaled_freq_log(Tier3BackedgeNotifyFreqLog));
+
+ FLAG_SET_ERGO(intx, Tier23InlineeNotifyFreqLog, get_scaled_freq_log(Tier23InlineeNotifyFreqLog));
+
+ FLAG_SET_ERGO(intx, Tier4InvocationThreshold, get_scaled_compile_threshold(Tier4InvocationThreshold));
+ FLAG_SET_ERGO(intx, Tier4MinInvocationThreshold, get_scaled_compile_threshold(Tier4MinInvocationThreshold));
+ FLAG_SET_ERGO(intx, Tier4CompileThreshold, get_scaled_compile_threshold(Tier4CompileThreshold));
+ FLAG_SET_ERGO(intx, Tier4BackEdgeThreshold, get_scaled_compile_threshold(Tier4BackEdgeThreshold));
+ }
}
/**
@@ -3501,7 +3542,9 @@
// not specified.
set_mode_flags(_int);
}
- if (CompileThreshold == 0) {
+
+ if ((TieredCompilation && CompileThresholdScaling == 0)
+ || (!TieredCompilation && get_scaled_compile_threshold(CompileThreshold) == 0)) {
set_mode_flags(_int);
}
@@ -3921,6 +3964,10 @@
vm_exit_during_initialization(
"Incompatible compilation policy selected", NULL);
}
+ // Scale CompileThreshold
+ if (!FLAG_IS_DEFAULT(CompileThresholdScaling)) {
+ FLAG_SET_ERGO(intx, CompileThreshold, get_scaled_compile_threshold(CompileThreshold));
+ }
}
#ifdef COMPILER2
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/arguments/CheckCompileThresholdScaling.java Wed Oct 15 14:00:41 2014 +0200
@@ -0,0 +1,359 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import com.oracle.java.testlibrary.*;
+
+/*
+ * @test CheckCompileThresholdScaling
+ * @bug 8059604
+ * @summary "Add CompileThresholdScalingPercentage flag to control when methods are first compiled (with +/-TieredCompilation)"
+ * @library /testlibrary
+ * @run main CheckCompileThresholdScaling
+ */
+
+public class CheckCompileThresholdScaling {
+
+ // The flag CompileThresholdScaling scales compilation thresholds
+ // in the following way:
+ //
+ // - if CompileThresholdScaling==1.0, the default threshold values
+ // are used;
+ //
+ // - if CompileThresholdScaling>1.0, threshold values are scaled
+ // up (e.g., CompileThresholdScalingPercentage=1.2 scales up
+ // thresholds by a factor of 1.2X);
+ //
+ // - if CompileThresholdScaling<1.0, threshold values are scaled
+ // down;
+ //
+ // - if CompileThresholdScaling==0, compilation is disabled
+ // (equivalent to using -Xint).
+ //
+ // With tiered compilation enabled, the values of the following
+ // flags are changed:
+ //
+ // Tier0InvokeNotifyFreqLog, Tier0BackedgeNotifyFreqLog,
+ // Tier3InvocationThreshold, Tier3MinInvocationThreshold,
+ // Tier3CompileThreshold, and Tier3BackEdgeThreshold,
+ // Tier2InvokeNotifyFreqLog, Tier2BackedgeNotifyFreqLog,
+ // Tier3InvokeNotifyFreqLog, Tier3BackedgeNotifyFreqLog,
+ // Tier23InlineeNotifyFreqLog, Tier4InvocationThreshold,
+ // Tier4MinInvocationThreshold, Tier4CompileThreshold,
+ // Tier4BackEdgeThreshold
+ //
+ // With tiered compilation disabled the value of CompileThreshold
+ // is scaled.
+ private static final String[][] NON_TIERED_ARGUMENTS = {
+ {
+ "-XX:-TieredCompilation",
+ "-XX:+PrintFlagsFinal",
+ "-XX:CompileThreshold=1000",
+ "-version"
+ },
+ {
+ "-XX:-TieredCompilation",
+ "-XX:+PrintFlagsFinal",
+ "-XX:CompileThreshold=1000",
+ "-XX:CompileThresholdScaling=1.25",
+ "-version"
+ },
+ {
+ "-XX:-TieredCompilation",
+ "-XX:+PrintFlagsFinal",
+ "-XX:CompileThreshold=1000",
+ "-XX:CompileThresholdScaling=0.75",
+ "-version"
+ },
+ {
+ "-XX:-TieredCompilation",
+ "-XX:+PrintFlagsFinal",
+ "-XX:CompileThreshold=0",
+ "-XX:CompileThresholdScaling=0.75",
+ "-version"
+ }
+
+ };
+
+ private static final String[][] NON_TIERED_EXPECTED_OUTPUTS = {
+ {
+ "intx CompileThreshold := 1000 {pd product}",
+ "double CompileThresholdScaling = 1.000000 {product}"
+ },
+ {
+ "intx CompileThreshold := 1250 {pd product}",
+ "double CompileThresholdScaling := 1.250000 {product}"
+ },
+ {
+ "intx CompileThreshold := 750 {pd product}",
+ "double CompileThresholdScaling := 0.750000 {product}"
+ },
+ {
+ "intx CompileThreshold := 0 {pd product}",
+ "double CompileThresholdScaling := 0.750000 {product}",
+ "interpreted mode"
+ }
+ };
+
+ private static final String[][] TIERED_ARGUMENTS = {
+ {
+ "-XX:+TieredCompilation",
+ "-XX:+PrintFlagsFinal",
+ "-XX:Tier0InvokeNotifyFreqLog=7",
+ "-XX:Tier0BackedgeNotifyFreqLog=10",
+ "-XX:Tier3InvocationThreshold=200",
+ "-XX:Tier3MinInvocationThreshold=100",
+ "-XX:Tier3CompileThreshold=2000",
+ "-XX:Tier3BackEdgeThreshold=60000",
+ "-XX:Tier2InvokeNotifyFreqLog=11",
+ "-XX:Tier2BackedgeNotifyFreqLog=14",
+ "-XX:Tier3InvokeNotifyFreqLog=10",
+ "-XX:Tier3BackedgeNotifyFreqLog=13",
+ "-XX:Tier23InlineeNotifyFreqLog=20",
+ "-XX:Tier4InvocationThreshold=5000",
+ "-XX:Tier4MinInvocationThreshold=600",
+ "-XX:Tier4CompileThreshold=15000",
+ "-XX:Tier4BackEdgeThreshold=40000",
+ "-version"
+ },
+ {
+ "-XX:+TieredCompilation",
+ "-XX:+PrintFlagsFinal",
+ "-XX:Tier0InvokeNotifyFreqLog=7",
+ "-XX:Tier0BackedgeNotifyFreqLog=10",
+ "-XX:Tier3InvocationThreshold=200",
+ "-XX:Tier3MinInvocationThreshold=100",
+ "-XX:Tier3CompileThreshold=2000",
+ "-XX:Tier3BackEdgeThreshold=60000",
+ "-XX:Tier2InvokeNotifyFreqLog=11",
+ "-XX:Tier2BackedgeNotifyFreqLog=14",
+ "-XX:Tier3InvokeNotifyFreqLog=10",
+ "-XX:Tier3BackedgeNotifyFreqLog=13",
+ "-XX:Tier23InlineeNotifyFreqLog=20",
+ "-XX:Tier4InvocationThreshold=5000",
+ "-XX:Tier4MinInvocationThreshold=600",
+ "-XX:Tier4CompileThreshold=15000",
+ "-XX:Tier4BackEdgeThreshold=40000",
+ "-XX:CompileThresholdScaling=0.75",
+ "-version"
+ },
+ {
+ "-XX:+TieredCompilation",
+ "-XX:+PrintFlagsFinal",
+ "-XX:Tier0InvokeNotifyFreqLog=7",
+ "-XX:Tier0BackedgeNotifyFreqLog=10",
+ "-XX:Tier3InvocationThreshold=200",
+ "-XX:Tier3MinInvocationThreshold=100",
+ "-XX:Tier3CompileThreshold=2000",
+ "-XX:Tier3BackEdgeThreshold=60000",
+ "-XX:Tier2InvokeNotifyFreqLog=11",
+ "-XX:Tier2BackedgeNotifyFreqLog=14",
+ "-XX:Tier3InvokeNotifyFreqLog=10",
+ "-XX:Tier3BackedgeNotifyFreqLog=13",
+ "-XX:Tier23InlineeNotifyFreqLog=20",
+ "-XX:Tier4InvocationThreshold=5000",
+ "-XX:Tier4MinInvocationThreshold=600",
+ "-XX:Tier4CompileThreshold=15000",
+ "-XX:Tier4BackEdgeThreshold=40000",
+ "-XX:CompileThresholdScaling=1.25",
+ "-version"
+ },
+ {
+ "-XX:+TieredCompilation",
+ "-XX:+PrintFlagsFinal",
+ "-XX:Tier0InvokeNotifyFreqLog=7",
+ "-XX:Tier0BackedgeNotifyFreqLog=10",
+ "-XX:Tier3InvocationThreshold=200",
+ "-XX:Tier3MinInvocationThreshold=100",
+ "-XX:Tier3CompileThreshold=2000",
+ "-XX:Tier3BackEdgeThreshold=60000",
+ "-XX:Tier2InvokeNotifyFreqLog=11",
+ "-XX:Tier2BackedgeNotifyFreqLog=14",
+ "-XX:Tier3InvokeNotifyFreqLog=10",
+ "-XX:Tier3BackedgeNotifyFreqLog=13",
+ "-XX:Tier23InlineeNotifyFreqLog=20",
+ "-XX:Tier4InvocationThreshold=5000",
+ "-XX:Tier4MinInvocationThreshold=600",
+ "-XX:Tier4CompileThreshold=15000",
+ "-XX:Tier4BackEdgeThreshold=40000",
+ "-XX:CompileThresholdScaling=2.0",
+ "-version"
+ },
+ {
+ "-XX:+TieredCompilation",
+ "-XX:+PrintFlagsFinal",
+ "-XX:Tier0InvokeNotifyFreqLog=7",
+ "-XX:Tier0BackedgeNotifyFreqLog=10",
+ "-XX:Tier3InvocationThreshold=200",
+ "-XX:Tier3MinInvocationThreshold=100",
+ "-XX:Tier3CompileThreshold=2000",
+ "-XX:Tier3BackEdgeThreshold=60000",
+ "-XX:Tier2InvokeNotifyFreqLog=11",
+ "-XX:Tier2BackedgeNotifyFreqLog=14",
+ "-XX:Tier3InvokeNotifyFreqLog=10",
+ "-XX:Tier3BackedgeNotifyFreqLog=13",
+ "-XX:Tier23InlineeNotifyFreqLog=20",
+ "-XX:Tier4InvocationThreshold=5000",
+ "-XX:Tier4MinInvocationThreshold=600",
+ "-XX:Tier4CompileThreshold=15000",
+ "-XX:Tier4BackEdgeThreshold=40000",
+ "-XX:CompileThresholdScaling=0.0",
+ "-version"
+ }
+ };
+
+ private static final String[][] TIERED_EXPECTED_OUTPUTS = {
+ {
+ "intx Tier0BackedgeNotifyFreqLog := 10 {product}",
+ "intx Tier0InvokeNotifyFreqLog := 7 {product}",
+ "intx Tier23InlineeNotifyFreqLog := 20 {product}",
+ "intx Tier2BackedgeNotifyFreqLog := 14 {product}",
+ "intx Tier2InvokeNotifyFreqLog := 11 {product}",
+ "intx Tier3BackEdgeThreshold := 60000 {product}",
+ "intx Tier3BackedgeNotifyFreqLog := 13 {product}",
+ "intx Tier3CompileThreshold := 2000 {product}",
+ "intx Tier3InvocationThreshold := 200 {product}",
+ "intx Tier3InvokeNotifyFreqLog := 10 {product}",
+ "intx Tier3MinInvocationThreshold := 100 {product}",
+ "intx Tier4BackEdgeThreshold := 40000 {product}",
+ "intx Tier4CompileThreshold := 15000 {product}",
+ "intx Tier4InvocationThreshold := 5000 {product}",
+ "intx Tier4MinInvocationThreshold := 600 {product}",
+ "double CompileThresholdScaling = 1.000000 {product}"
+ },
+ {
+ "intx Tier0BackedgeNotifyFreqLog := 9 {product}",
+ "intx Tier0InvokeNotifyFreqLog := 6 {product}",
+ "intx Tier23InlineeNotifyFreqLog := 19 {product}",
+ "intx Tier2BackedgeNotifyFreqLog := 13 {product}",
+ "intx Tier2InvokeNotifyFreqLog := 10 {product}",
+ "intx Tier3BackEdgeThreshold := 45000 {product}",
+ "intx Tier3BackedgeNotifyFreqLog := 12 {product}",
+ "intx Tier3CompileThreshold := 1500 {product}",
+ "intx Tier3InvocationThreshold := 150 {product}",
+ "intx Tier3InvokeNotifyFreqLog := 9 {product}",
+ "intx Tier3MinInvocationThreshold := 75 {product}",
+ "intx Tier4BackEdgeThreshold := 30000 {product}",
+ "intx Tier4CompileThreshold := 11250 {product}",
+ "intx Tier4InvocationThreshold := 3750 {product}",
+ "intx Tier4MinInvocationThreshold := 450 {product}",
+ "double CompileThresholdScaling := 0.750000 {product}"
+ },
+ {
+ "intx Tier0BackedgeNotifyFreqLog := 10 {product}",
+ "intx Tier0InvokeNotifyFreqLog := 7 {product}",
+ "intx Tier23InlineeNotifyFreqLog := 20 {product}",
+ "intx Tier2BackedgeNotifyFreqLog := 14 {product}",
+ "intx Tier2InvokeNotifyFreqLog := 11 {product}",
+ "intx Tier3BackEdgeThreshold := 75000 {product}",
+ "intx Tier3BackedgeNotifyFreqLog := 13 {product}",
+ "intx Tier3CompileThreshold := 2500 {product}",
+ "intx Tier3InvocationThreshold := 250 {product}",
+ "intx Tier3InvokeNotifyFreqLog := 10 {product}",
+ "intx Tier3MinInvocationThreshold := 125 {product}",
+ "intx Tier4BackEdgeThreshold := 50000 {product}",
+ "intx Tier4CompileThreshold := 18750 {product}",
+ "intx Tier4InvocationThreshold := 6250 {product}",
+ "intx Tier4MinInvocationThreshold := 750 {product}",
+ "double CompileThresholdScaling := 1.250000 {product}"
+ },
+ {
+ "intx Tier0BackedgeNotifyFreqLog := 11 {product}",
+ "intx Tier0InvokeNotifyFreqLog := 8 {product}",
+ "intx Tier23InlineeNotifyFreqLog := 21 {product}",
+ "intx Tier2BackedgeNotifyFreqLog := 15 {product}",
+ "intx Tier2InvokeNotifyFreqLog := 12 {product}",
+ "intx Tier3BackEdgeThreshold := 120000 {product}",
+ "intx Tier3BackedgeNotifyFreqLog := 14 {product}",
+ "intx Tier3CompileThreshold := 4000 {product}",
+ "intx Tier3InvocationThreshold := 400 {product}",
+ "intx Tier3InvokeNotifyFreqLog := 11 {product}",
+ "intx Tier3MinInvocationThreshold := 200 {product}",
+ "intx Tier4BackEdgeThreshold := 80000 {product}",
+ "intx Tier4CompileThreshold := 30000 {product}",
+ "intx Tier4InvocationThreshold := 10000 {product}",
+ "intx Tier4MinInvocationThreshold := 1200 {product}",
+ "double CompileThresholdScaling := 2.000000 {product}"
+ },
+ {
+ "intx Tier0BackedgeNotifyFreqLog := 0 {product}",
+ "intx Tier0InvokeNotifyFreqLog := 0 {product}",
+ "intx Tier23InlineeNotifyFreqLog := 0 {product}",
+ "intx Tier2BackedgeNotifyFreqLog := 0 {product}",
+ "intx Tier2InvokeNotifyFreqLog := 0 {product}",
+ "intx Tier3BackEdgeThreshold := 0 {product}",
+ "intx Tier3BackedgeNotifyFreqLog := 0 {product}",
+ "intx Tier3CompileThreshold := 0 {product}",
+ "intx Tier3InvocationThreshold := 0 {product}",
+ "intx Tier3InvokeNotifyFreqLog := 0 {product}",
+ "intx Tier3MinInvocationThreshold := 0 {product}",
+ "intx Tier4BackEdgeThreshold := 0 {product}",
+ "intx Tier4CompileThreshold := 0 {product}",
+ "intx Tier4InvocationThreshold := 0 {product}",
+ "intx Tier4MinInvocationThreshold := 0 {product}",
+ "double CompileThresholdScaling := 0.000000 {product}",
+ "interpreted mode"
+ }
+ };
+
+ private static void verifyValidOption(String[] arguments, String[] expected_outputs, boolean tiered) throws Exception {
+ ProcessBuilder pb;
+ OutputAnalyzer out;
+
+ pb = ProcessTools.createJavaProcessBuilder(arguments);
+ out = new OutputAnalyzer(pb.start());
+
+ try {
+ for (String expected_output : expected_outputs) {
+ out.shouldContain(expected_output);
+ }
+ out.shouldHaveExitValue(0);
+ } catch (RuntimeException e) {
+ // Check if tiered compilation is available in this JVM
+ // Version. Throw exception only if it is available.
+ if (!(tiered && out.getOutput().contains("Client VM warning: TieredCompilation is disabled in this release."))) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+
+ if (NON_TIERED_ARGUMENTS.length != NON_TIERED_EXPECTED_OUTPUTS.length) {
+ throw new RuntimeException("Test is set up incorrectly: length of arguments and expected outputs in non-tiered mode of operation does not match.");
+ }
+
+ if (TIERED_ARGUMENTS.length != TIERED_EXPECTED_OUTPUTS.length) {
+ throw new RuntimeException("Test is set up incorrectly: length of arguments and expected outputs in tiered mode of operation.");
+ }
+
+ // Check if thresholds are scaled properly in non-tiered mode of operation
+ for (int i = 0; i < NON_TIERED_ARGUMENTS.length; i++) {
+ verifyValidOption(NON_TIERED_ARGUMENTS[i], NON_TIERED_EXPECTED_OUTPUTS[i], false);
+ }
+
+ // Check if thresholds are scaled properly in tiered mode of operation
+ for (int i = 0; i < TIERED_ARGUMENTS.length; i++) {
+ verifyValidOption(TIERED_ARGUMENTS[i], TIERED_EXPECTED_OUTPUTS[i], true);
+ }
+ }
+}