8043546: C1 optimizes @Stable instance fields with default values
Reviewed-by: kvn, jrose
--- a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp Mon Jul 14 03:24:35 2014 -0700
+++ b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp Mon Jul 14 03:25:40 2014 -0700
@@ -1573,6 +1573,7 @@
default:
constant = new Constant(as_ValueType(field_val));
}
+ // Stable static fields are checked for non-default values in ciField::initialize_from().
}
if (constant != NULL) {
push(type, append(constant));
@@ -1614,6 +1615,10 @@
default:
constant = new Constant(as_ValueType(field_val));
}
+ if (FoldStableValues && field->is_stable() && field_val.is_null_or_zero()) {
+ // Stable field with default value can't be constant.
+ constant = NULL;
+ }
} else {
// For CallSite objects treat the target field as a compile time constant.
if (const_oop->is_call_site()) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/stable/StableConfiguration.java Mon Jul 14 03:25:40 2014 -0700
@@ -0,0 +1,62 @@
+/*
+ * 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.
+ */
+package java.lang.invoke;
+
+import java.lang.reflect.Method;
+import java.util.Properties;
+import sun.hotspot.WhiteBox;
+
+public class StableConfiguration {
+ static final WhiteBox WB = WhiteBox.getWhiteBox();
+ static final boolean isStableEnabled;
+ static final boolean isServerWithStable;
+
+ static {
+ Boolean value = WB.getBooleanVMFlag("FoldStableValues");
+ isStableEnabled = (value == null ? false : value);
+ isServerWithStable = isStableEnabled && get();
+ System.out.println("@Stable: " + (isStableEnabled ? "enabled" : "disabled"));
+ System.out.println("Server Compiler: " + get());
+ }
+
+ // ::get() is among immediately compiled methods.
+ static boolean get() {
+ try {
+ Method m = StableConfiguration.class.getDeclaredMethod("get");
+ int level = WB.getMethodCompilationLevel(m);
+ if (level > 0) {
+ return (level == 4);
+ } else {
+ String javaVM = System.getProperty("java.vm.name", "");
+ if (javaVM.contains("Server")) return true;
+ if (javaVM.contains("Client")) return false;
+ throw new Error("Unknown VM type: "+javaVM);
+ }
+ } catch (NoSuchMethodException e) {
+ throw new Error(e);
+ }
+ }
+
+}
--- a/hotspot/test/compiler/stable/TestStableBoolean.java Mon Jul 14 03:24:35 2014 -0700
+++ b/hotspot/test/compiler/stable/TestStableBoolean.java Mon Jul 14 03:25:40 2014 -0700
@@ -26,9 +26,11 @@
/*
* @test TestStableBoolean
* @summary tests on stable fields and arrays
- * @library /testlibrary
- * @compile -XDignore.symbol.file TestStableBoolean.java
+ * @library /testlibrary /testlibrary/whitebox
+ * @build TestStableBoolean StableConfiguration sun.hotspot.WhiteBox
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
* @run main ClassFileInstaller
+ * java/lang/invoke/StableConfiguration
* java/lang/invoke/TestStableBoolean
* java/lang/invoke/TestStableBoolean$BooleanStable
* java/lang/invoke/TestStableBoolean$StaticBooleanStable
@@ -48,46 +50,60 @@
* java/lang/invoke/TestStableBoolean$NestedStableField3
* java/lang/invoke/TestStableBoolean$NestedStableField3$A
* java/lang/invoke/TestStableBoolean$DefaultValue
+ * java/lang/invoke/TestStableBoolean$DefaultStaticValue
* java/lang/invoke/TestStableBoolean$ObjectArrayLowerDim2
*
* @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- * -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:+UseCompressedOop
- * -server -XX:-TieredCompilation -Xcomp
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ * -server -XX:-TieredCompilation
+ * -XX:+FoldStableValues
+ * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ * java.lang.invoke.TestStableBoolean
+ * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ * -server -XX:-TieredCompilation
+ * -XX:-FoldStableValues
* -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
* java.lang.invoke.TestStableBoolean
*
* @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- * -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:-UseCompressedOop
- * -server -XX:-TieredCompilation -Xcomp
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ * -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1
+ * -XX:+FoldStableValues
+ * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ * java.lang.invoke.TestStableBoolean
+ * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ * -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1
+ * -XX:-FoldStableValues
* -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
* java.lang.invoke.TestStableBoolean
*
* @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- * -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:+UseCompressedOop
- * -server -XX:-TieredCompilation -Xcomp
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ * -client -XX:-TieredCompilation
+ * -XX:+FoldStableValues
* -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
* java.lang.invoke.TestStableBoolean
- *
* @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- * -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:-UseCompressedOop
- * -server -XX:-TieredCompilation -Xcomp
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ * -client -XX:-TieredCompilation
+ * -XX:-FoldStableValues
* -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
* java.lang.invoke.TestStableBoolean
*/
package java.lang.invoke;
-import com.sun.management.HotSpotDiagnosticMXBean;
-import com.sun.management.VMOption;
-import sun.management.ManagementFactoryHelper;
import java.lang.reflect.InvocationTargetException;
public class TestStableBoolean {
+ static final boolean isStableEnabled = StableConfiguration.isStableEnabled;
+ static final boolean isServerWithStable = StableConfiguration.isServerWithStable;
+
public static void main(String[] args) throws Exception {
- System.out.println("@Stable enabled: "+isStableEnabled);
- System.out.println();
-
run(DefaultValue.class);
run(BooleanStable.class);
+ run(DefaultStaticValue.class);
run(StaticBooleanStable.class);
run(VolatileBooleanStable.class);
@@ -145,6 +161,21 @@
/* ==================================================== */
+ static class DefaultStaticValue {
+ public static @Stable boolean v;
+
+ public static final DefaultStaticValue c = new DefaultStaticValue();
+ public static boolean get() { return c.v; }
+ public static void test() throws Exception {
+ boolean val1 = get();
+ c.v = true; boolean val2 = get();
+ assertEquals(val1, false);
+ assertEquals(val2, true);
+ }
+ }
+
+ /* ==================================================== */
+
static class StaticBooleanStable {
public static @Stable boolean v;
@@ -188,14 +219,14 @@
c.v = new boolean[1]; c.v[0] = true; boolean val1 = get();
c.v[0] = false; boolean val2 = get();
assertEquals(val1, true);
- assertEquals(val2, (isStableEnabled ? true : false));
+ assertEquals(val2, (isServerWithStable ? true : false));
}
{
c.v = new boolean[20]; c.v[10] = true; boolean val1 = get1();
c.v[10] = false; boolean val2 = get1();
assertEquals(val1, true);
- assertEquals(val2, (isStableEnabled ? true : false));
+ assertEquals(val2, (isServerWithStable ? true : false));
}
{
@@ -220,19 +251,19 @@
c.v = new boolean[1][1]; c.v[0][0] = true; boolean val1 = get();
c.v[0][0] = false; boolean val2 = get();
assertEquals(val1, true);
- assertEquals(val2, (isStableEnabled ? true : false));
+ assertEquals(val2, (isServerWithStable ? true : false));
c.v = new boolean[1][1]; c.v[0][0] = false; boolean val3 = get();
- assertEquals(val3, (isStableEnabled ? true : false));
+ assertEquals(val3, (isServerWithStable ? true : false));
c.v[0] = new boolean[1]; c.v[0][0] = false; boolean val4 = get();
- assertEquals(val4, (isStableEnabled ? true : false));
+ assertEquals(val4, (isServerWithStable ? true : false));
}
{
c.v = new boolean[1][1]; boolean[] val1 = get1();
c.v[0] = new boolean[1]; boolean[] val2 = get1();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
@@ -258,28 +289,28 @@
c.v = new boolean[1][1][1]; c.v[0][0][0] = true; boolean val1 = get();
c.v[0][0][0] = false; boolean val2 = get();
assertEquals(val1, true);
- assertEquals(val2, (isStableEnabled ? true : false));
+ assertEquals(val2, (isServerWithStable ? true : false));
c.v = new boolean[1][1][1]; c.v[0][0][0] = false; boolean val3 = get();
- assertEquals(val3, (isStableEnabled ? true : false));
+ assertEquals(val3, (isServerWithStable ? true : false));
c.v[0] = new boolean[1][1]; c.v[0][0][0] = false; boolean val4 = get();
- assertEquals(val4, (isStableEnabled ? true : false));
+ assertEquals(val4, (isServerWithStable ? true : false));
c.v[0][0] = new boolean[1]; c.v[0][0][0] = false; boolean val5 = get();
- assertEquals(val5, (isStableEnabled ? true : false));
+ assertEquals(val5, (isServerWithStable ? true : false));
}
{
c.v = new boolean[1][1][1]; boolean[] val1 = get1();
c.v[0][0] = new boolean[1]; boolean[] val2 = get1();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
c.v = new boolean[1][1][1]; boolean[][] val1 = get2();
c.v[0] = new boolean[1][1]; boolean[][] val2 = get2();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
@@ -306,37 +337,37 @@
c.v = new boolean[1][1][1][1]; c.v[0][0][0][0] = true; boolean val1 = get();
c.v[0][0][0][0] = false; boolean val2 = get();
assertEquals(val1, true);
- assertEquals(val2, (isStableEnabled ? true : false));
+ assertEquals(val2, (isServerWithStable ? true : false));
c.v = new boolean[1][1][1][1]; c.v[0][0][0][0] = false; boolean val3 = get();
- assertEquals(val3, (isStableEnabled ? true : false));
+ assertEquals(val3, (isServerWithStable ? true : false));
c.v[0] = new boolean[1][1][1]; c.v[0][0][0][0] = false; boolean val4 = get();
- assertEquals(val4, (isStableEnabled ? true : false));
+ assertEquals(val4, (isServerWithStable ? true : false));
c.v[0][0] = new boolean[1][1]; c.v[0][0][0][0] = false; boolean val5 = get();
- assertEquals(val5, (isStableEnabled ? true : false));
+ assertEquals(val5, (isServerWithStable ? true : false));
c.v[0][0][0] = new boolean[1]; c.v[0][0][0][0] = false; boolean val6 = get();
- assertEquals(val6, (isStableEnabled ? true : false));
+ assertEquals(val6, (isServerWithStable ? true : false));
}
{
c.v = new boolean[1][1][1][1]; boolean[] val1 = get1();
c.v[0][0][0] = new boolean[1]; boolean[] val2 = get1();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
c.v = new boolean[1][1][1][1]; boolean[][] val1 = get2();
c.v[0][0] = new boolean[1][1]; boolean[][] val2 = get2();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
c.v = new boolean[1][1][1][1]; boolean[][][] val1 = get3();
c.v[0] = new boolean[1][1][1]; boolean[][][] val2 = get3();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
@@ -399,7 +430,7 @@
c.v = new boolean[1][1]; c.v[0] = new boolean[0]; boolean[] val1 = get1();
c.v[0] = new boolean[0]; boolean[] val2 = get1();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
@@ -435,14 +466,14 @@
c.v = new boolean[1][1][1]; c.v[0][0] = new boolean[0]; boolean[] val1 = get1();
c.v[0][0] = new boolean[0]; boolean[] val2 = get1();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
c.v = new boolean[1][1][1]; c.v[0] = new boolean[0][0]; boolean[][] val1 = get2();
c.v[0] = new boolean[0][0]; boolean[][] val2 = get2();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
@@ -577,7 +608,7 @@
elem.a = false; boolean val3 = get(); boolean val4 = get1();
assertEquals(val1, true);
- assertEquals(val3, (isStableEnabled ? true : false));
+ assertEquals(val3, (isServerWithStable ? true : false));
assertEquals(val2, true);
assertEquals(val4, false);
@@ -611,17 +642,4 @@
}
}
}
-
- static final boolean isStableEnabled;
- static {
- HotSpotDiagnosticMXBean diagnostic
- = ManagementFactoryHelper.getDiagnosticMXBean();
- VMOption tmp;
- try {
- tmp = diagnostic.getVMOption("FoldStableValues");
- } catch (IllegalArgumentException e) {
- tmp = null;
- }
- isStableEnabled = (tmp == null ? false : Boolean.parseBoolean(tmp.getValue()));
- }
}
--- a/hotspot/test/compiler/stable/TestStableByte.java Mon Jul 14 03:24:35 2014 -0700
+++ b/hotspot/test/compiler/stable/TestStableByte.java Mon Jul 14 03:25:40 2014 -0700
@@ -26,9 +26,11 @@
/*
* @test TestStableByte
* @summary tests on stable fields and arrays
- * @library /testlibrary
- * @compile -XDignore.symbol.file TestStableByte.java
+ * @library /testlibrary /testlibrary/whitebox
+ * @build TestStableByte StableConfiguration sun.hotspot.WhiteBox
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
* @run main ClassFileInstaller
+ * java/lang/invoke/StableConfiguration
* java/lang/invoke/TestStableByte
* java/lang/invoke/TestStableByte$ByteStable
* java/lang/invoke/TestStableByte$StaticByteStable
@@ -48,46 +50,60 @@
* java/lang/invoke/TestStableByte$NestedStableField3
* java/lang/invoke/TestStableByte$NestedStableField3$A
* java/lang/invoke/TestStableByte$DefaultValue
+ * java/lang/invoke/TestStableByte$DefaultStaticValue
* java/lang/invoke/TestStableByte$ObjectArrayLowerDim2
*
* @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- * -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:+UseCompressedOop
- * -server -XX:-TieredCompilation -Xcomp
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ * -server -XX:-TieredCompilation
+ * -XX:+FoldStableValues
+ * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ * java.lang.invoke.TestStableByte
+ * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ * -server -XX:-TieredCompilation
+ * -XX:-FoldStableValues
* -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
* java.lang.invoke.TestStableByte
*
* @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- * -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:-UseCompressedOop
- * -server -XX:-TieredCompilation -Xcomp
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ * -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1
+ * -XX:+FoldStableValues
+ * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ * java.lang.invoke.TestStableByte
+ * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ * -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1
+ * -XX:-FoldStableValues
* -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
* java.lang.invoke.TestStableByte
*
* @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- * -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:+UseCompressedOop
- * -server -XX:-TieredCompilation -Xcomp
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ * -client -XX:-TieredCompilation
+ * -XX:+FoldStableValues
* -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
* java.lang.invoke.TestStableByte
- *
* @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- * -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:-UseCompressedOop
- * -server -XX:-TieredCompilation -Xcomp
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ * -client -XX:-TieredCompilation
+ * -XX:-FoldStableValues
* -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
* java.lang.invoke.TestStableByte
*/
package java.lang.invoke;
-import com.sun.management.HotSpotDiagnosticMXBean;
-import com.sun.management.VMOption;
-import sun.management.ManagementFactoryHelper;
import java.lang.reflect.InvocationTargetException;
public class TestStableByte {
+ static final boolean isStableEnabled = StableConfiguration.isStableEnabled;
+ static final boolean isServerWithStable = StableConfiguration.isServerWithStable;
+
public static void main(String[] args) throws Exception {
- System.out.println("@Stable enabled: "+isStableEnabled);
- System.out.println();
-
run(DefaultValue.class);
run(ByteStable.class);
+ run(DefaultStaticValue.class);
run(StaticByteStable.class);
run(VolatileByteStable.class);
@@ -145,6 +161,21 @@
/* ==================================================== */
+ static class DefaultStaticValue {
+ public static @Stable byte v;
+
+ public static final DefaultStaticValue c = new DefaultStaticValue();
+ public static byte get() { return c.v; }
+ public static void test() throws Exception {
+ byte val1 = get();
+ c.v = 1; byte val2 = get();
+ assertEquals(val1, 0);
+ assertEquals(val2, 1);
+ }
+ }
+
+ /* ==================================================== */
+
static class StaticByteStable {
public static @Stable byte v;
@@ -188,20 +219,22 @@
c.v = new byte[1]; c.v[0] = 1; byte val1 = get();
c.v[0] = 2; byte val2 = get();
assertEquals(val1, 1);
- assertEquals(val2, (isStableEnabled ? 1 : 2));
+ assertEquals(val2, (isServerWithStable ? 1 : 2));
c.v = new byte[1]; c.v[0] = 3; byte val3 = get();
- assertEquals(val3, (isStableEnabled ? 1 : 3));
+ assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+ : 3));
}
{
c.v = new byte[20]; c.v[10] = 1; byte val1 = get1();
c.v[10] = 2; byte val2 = get1();
assertEquals(val1, 1);
- assertEquals(val2, (isStableEnabled ? 1 : 2));
+ assertEquals(val2, (isServerWithStable ? 1 : 2));
c.v = new byte[20]; c.v[10] = 3; byte val3 = get1();
- assertEquals(val3, (isStableEnabled ? 1 : 3));
+ assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+ : 3));
}
{
@@ -226,19 +259,21 @@
c.v = new byte[1][1]; c.v[0][0] = 1; byte val1 = get();
c.v[0][0] = 2; byte val2 = get();
assertEquals(val1, 1);
- assertEquals(val2, (isStableEnabled ? 1 : 2));
+ assertEquals(val2, (isServerWithStable ? 1 : 2));
c.v = new byte[1][1]; c.v[0][0] = 3; byte val3 = get();
- assertEquals(val3, (isStableEnabled ? 1 : 3));
+ assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+ : 3));
c.v[0] = new byte[1]; c.v[0][0] = 4; byte val4 = get();
- assertEquals(val4, (isStableEnabled ? 1 : 4));
+ assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+ : 4));
}
{
c.v = new byte[1][1]; byte[] val1 = get1();
c.v[0] = new byte[1]; byte[] val2 = get1();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
@@ -264,28 +299,31 @@
c.v = new byte[1][1][1]; c.v[0][0][0] = 1; byte val1 = get();
c.v[0][0][0] = 2; byte val2 = get();
assertEquals(val1, 1);
- assertEquals(val2, (isStableEnabled ? 1 : 2));
+ assertEquals(val2, (isServerWithStable ? 1 : 2));
c.v = new byte[1][1][1]; c.v[0][0][0] = 3; byte val3 = get();
- assertEquals(val3, (isStableEnabled ? 1 : 3));
+ assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+ : 3));
c.v[0] = new byte[1][1]; c.v[0][0][0] = 4; byte val4 = get();
- assertEquals(val4, (isStableEnabled ? 1 : 4));
+ assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+ : 4));
c.v[0][0] = new byte[1]; c.v[0][0][0] = 5; byte val5 = get();
- assertEquals(val5, (isStableEnabled ? 1 : 5));
+ assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+ : 5));
}
{
c.v = new byte[1][1][1]; byte[] val1 = get1();
c.v[0][0] = new byte[1]; byte[] val2 = get1();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
c.v = new byte[1][1][1]; byte[][] val1 = get2();
c.v[0] = new byte[1][1]; byte[][] val2 = get2();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
@@ -312,37 +350,41 @@
c.v = new byte[1][1][1][1]; c.v[0][0][0][0] = 1; byte val1 = get();
c.v[0][0][0][0] = 2; byte val2 = get();
assertEquals(val1, 1);
- assertEquals(val2, (isStableEnabled ? 1 : 2));
+ assertEquals(val2, (isServerWithStable ? 1 : 2));
c.v = new byte[1][1][1][1]; c.v[0][0][0][0] = 3; byte val3 = get();
- assertEquals(val3, (isStableEnabled ? 1 : 3));
+ assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+ : 3));
c.v[0] = new byte[1][1][1]; c.v[0][0][0][0] = 4; byte val4 = get();
- assertEquals(val4, (isStableEnabled ? 1 : 4));
+ assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+ : 4));
c.v[0][0] = new byte[1][1]; c.v[0][0][0][0] = 5; byte val5 = get();
- assertEquals(val5, (isStableEnabled ? 1 : 5));
+ assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+ : 5));
c.v[0][0][0] = new byte[1]; c.v[0][0][0][0] = 6; byte val6 = get();
- assertEquals(val6, (isStableEnabled ? 1 : 6));
+ assertEquals(val6, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+ : 6));
}
{
c.v = new byte[1][1][1][1]; byte[] val1 = get1();
c.v[0][0][0] = new byte[1]; byte[] val2 = get1();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
c.v = new byte[1][1][1][1]; byte[][] val1 = get2();
c.v[0][0] = new byte[1][1]; byte[][] val2 = get2();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
c.v = new byte[1][1][1][1]; byte[][][] val1 = get3();
c.v[0] = new byte[1][1][1]; byte[][][] val2 = get3();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
@@ -404,7 +446,7 @@
c.v = new byte[1][1]; c.v[0] = new byte[0]; byte[] val1 = get1();
c.v[0] = new byte[0]; byte[] val2 = get1();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
@@ -440,14 +482,14 @@
c.v = new byte[1][1][1]; c.v[0][0] = new byte[0]; byte[] val1 = get1();
c.v[0][0] = new byte[0]; byte[] val2 = get1();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
c.v = new byte[1][1][1]; c.v[0] = new byte[0][0]; byte[][] val1 = get2();
c.v[0] = new byte[0][0]; byte[][] val2 = get2();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
@@ -582,7 +624,7 @@
elem.a = 2; byte val3 = get(); byte val4 = get1();
assertEquals(val1, 1);
- assertEquals(val3, (isStableEnabled ? 1 : 2));
+ assertEquals(val3, (isServerWithStable ? 1 : 2));
assertEquals(val2, 1);
assertEquals(val4, 2);
@@ -616,17 +658,4 @@
}
}
}
-
- static final boolean isStableEnabled;
- static {
- HotSpotDiagnosticMXBean diagnostic
- = ManagementFactoryHelper.getDiagnosticMXBean();
- VMOption tmp;
- try {
- tmp = diagnostic.getVMOption("FoldStableValues");
- } catch (IllegalArgumentException e) {
- tmp = null;
- }
- isStableEnabled = (tmp == null ? false : Boolean.parseBoolean(tmp.getValue()));
- }
}
--- a/hotspot/test/compiler/stable/TestStableChar.java Mon Jul 14 03:24:35 2014 -0700
+++ b/hotspot/test/compiler/stable/TestStableChar.java Mon Jul 14 03:25:40 2014 -0700
@@ -26,9 +26,11 @@
/*
* @test TestStableChar
* @summary tests on stable fields and arrays
- * @library /testlibrary
- * @compile -XDignore.symbol.file TestStableChar.java
+ * @library /testlibrary /testlibrary/whitebox
+ * @build TestStableChar StableConfiguration sun.hotspot.WhiteBox
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
* @run main ClassFileInstaller
+ * java/lang/invoke/StableConfiguration
* java/lang/invoke/TestStableChar
* java/lang/invoke/TestStableChar$CharStable
* java/lang/invoke/TestStableChar$StaticCharStable
@@ -48,46 +50,60 @@
* java/lang/invoke/TestStableChar$NestedStableField3
* java/lang/invoke/TestStableChar$NestedStableField3$A
* java/lang/invoke/TestStableChar$DefaultValue
+ * java/lang/invoke/TestStableChar$DefaultStaticValue
* java/lang/invoke/TestStableChar$ObjectArrayLowerDim2
*
* @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- * -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:-UseCompressedOop
- * -server -XX:-TieredCompilation -Xcomp
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ * -server -XX:-TieredCompilation
+ * -XX:+FoldStableValues
+ * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ * java.lang.invoke.TestStableChar
+ * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ * -server -XX:-TieredCompilation
+ * -XX:-FoldStableValues
* -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
* java.lang.invoke.TestStableChar
*
* @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- * -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:+UseCompressedOop
- * -server -XX:-TieredCompilation -Xcomp
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ * -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1
+ * -XX:+FoldStableValues
+ * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ * java.lang.invoke.TestStableChar
+ * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ * -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1
+ * -XX:-FoldStableValues
* -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
* java.lang.invoke.TestStableChar
*
* @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- * -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:+UseCompressedOop
- * -server -XX:-TieredCompilation -Xcomp
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ * -client -XX:-TieredCompilation
+ * -XX:+FoldStableValues
* -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
* java.lang.invoke.TestStableChar
- *
* @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- * -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:-UseCompressedOop
- * -server -XX:-TieredCompilation -Xcomp
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ * -client -XX:-TieredCompilation
+ * -XX:-FoldStableValues
* -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
* java.lang.invoke.TestStableChar
*/
package java.lang.invoke;
-import com.sun.management.HotSpotDiagnosticMXBean;
-import com.sun.management.VMOption;
-import sun.management.ManagementFactoryHelper;
import java.lang.reflect.InvocationTargetException;
public class TestStableChar {
+ static final boolean isStableEnabled = StableConfiguration.isStableEnabled;
+ static final boolean isServerWithStable = StableConfiguration.isServerWithStable;
+
public static void main(String[] args) throws Exception {
- System.out.println("@Stable enabled: "+isStableEnabled);
- System.out.println();
-
run(DefaultValue.class);
run(CharStable.class);
+ run(DefaultStaticValue.class);
run(StaticCharStable.class);
run(VolatileCharStable.class);
@@ -145,6 +161,21 @@
/* ==================================================== */
+ static class DefaultStaticValue {
+ public static @Stable char v;
+
+ public static final DefaultStaticValue c = new DefaultStaticValue();
+ public static char get() { return c.v; }
+ public static void test() throws Exception {
+ char val1 = get();
+ c.v = 'a'; char val2 = get();
+ assertEquals(val1, 0);
+ assertEquals(val2, 'a');
+ }
+ }
+
+ /* ==================================================== */
+
static class StaticCharStable {
public @Stable char v;
@@ -188,20 +219,22 @@
c.v = new char[1]; c.v[0] = 'a'; char val1 = get();
c.v[0] = 'b'; char val2 = get();
assertEquals(val1, 'a');
- assertEquals(val2, (isStableEnabled ? 'a' : 'b'));
+ assertEquals(val2, (isServerWithStable ? 'a' : 'b'));
c.v = new char[1]; c.v[0] = 'c'; char val3 = get();
- assertEquals(val3, (isStableEnabled ? 'a' : 'c'));
+ assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 'a' : 'b')
+ : 'c'));
}
{
c.v = new char[20]; c.v[10] = 'a'; char val1 = get1();
c.v[10] = 'b'; char val2 = get1();
assertEquals(val1, 'a');
- assertEquals(val2, (isStableEnabled ? 'a' : 'b'));
+ assertEquals(val2, (isServerWithStable ? 'a' : 'b'));
c.v = new char[20]; c.v[10] = 'c'; char val3 = get1();
- assertEquals(val3, (isStableEnabled ? 'a' : 'c'));
+ assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 'a' : 'b')
+ : 'c'));
}
{
@@ -226,19 +259,21 @@
c.v = new char[1][1]; c.v[0][0] = 'a'; char val1 = get();
c.v[0][0] = 'b'; char val2 = get();
assertEquals(val1, 'a');
- assertEquals(val2, (isStableEnabled ? 'a' : 'b'));
+ assertEquals(val2, (isServerWithStable ? 'a' : 'b'));
c.v = new char[1][1]; c.v[0][0] = 'c'; char val3 = get();
- assertEquals(val3, (isStableEnabled ? 'a' : 'c'));
+ assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 'a' : 'b')
+ : 'c'));
c.v[0] = new char[1]; c.v[0][0] = 'd'; char val4 = get();
- assertEquals(val4, (isStableEnabled ? 'a' : 'd'));
+ assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 'a' : 'b')
+ : 'd'));
}
{
c.v = new char[1][1]; char[] val1 = get1();
c.v[0] = new char[1]; char[] val2 = get1();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
@@ -264,28 +299,31 @@
c.v = new char[1][1][1]; c.v[0][0][0] = 'a'; char val1 = get();
c.v[0][0][0] = 'b'; char val2 = get();
assertEquals(val1, 'a');
- assertEquals(val2, (isStableEnabled ? 'a' : 'b'));
+ assertEquals(val2, (isServerWithStable ? 'a' : 'b'));
c.v = new char[1][1][1]; c.v[0][0][0] = 'c'; char val3 = get();
- assertEquals(val3, (isStableEnabled ? 'a' : 'c'));
+ assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 'a' : 'b')
+ : 'c'));
c.v[0] = new char[1][1]; c.v[0][0][0] = 'd'; char val4 = get();
- assertEquals(val4, (isStableEnabled ? 'a' : 'd'));
+ assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 'a' : 'b')
+ : 'd'));
c.v[0][0] = new char[1]; c.v[0][0][0] = 'e'; char val5 = get();
- assertEquals(val5, (isStableEnabled ? 'a' : 'e'));
+ assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 'a' : 'b')
+ : 'e'));
}
{
c.v = new char[1][1][1]; char[] val1 = get1();
c.v[0][0] = new char[1]; char[] val2 = get1();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
c.v = new char[1][1][1]; char[][] val1 = get2();
c.v[0] = new char[1][1]; char[][] val2 = get2();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
@@ -312,37 +350,41 @@
c.v = new char[1][1][1][1]; c.v[0][0][0][0] = 'a'; char val1 = get();
c.v[0][0][0][0] = 'b'; char val2 = get();
assertEquals(val1, 'a');
- assertEquals(val2, (isStableEnabled ? 'a' : 'b'));
+ assertEquals(val2, (isServerWithStable ? 'a' : 'b'));
c.v = new char[1][1][1][1]; c.v[0][0][0][0] = 'c'; char val3 = get();
- assertEquals(val3, (isStableEnabled ? 'a' : 'c'));
+ assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 'a' : 'b')
+ : 'c'));
c.v[0] = new char[1][1][1]; c.v[0][0][0][0] = 'd'; char val4 = get();
- assertEquals(val4, (isStableEnabled ? 'a' : 'd'));
+ assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 'a' : 'b')
+ : 'd'));
c.v[0][0] = new char[1][1]; c.v[0][0][0][0] = 'e'; char val5 = get();
- assertEquals(val5, (isStableEnabled ? 'a' : 'e'));
+ assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 'a' : 'b')
+ : 'e'));
c.v[0][0][0] = new char[1]; c.v[0][0][0][0] = 'f'; char val6 = get();
- assertEquals(val6, (isStableEnabled ? 'a' : 'f'));
+ assertEquals(val6, (isStableEnabled ? (isServerWithStable ? 'a' : 'b')
+ : 'f'));
}
{
c.v = new char[1][1][1][1]; char[] val1 = get1();
c.v[0][0][0] = new char[1]; char[] val2 = get1();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
c.v = new char[1][1][1][1]; char[][] val1 = get2();
c.v[0][0] = new char[1][1]; char[][] val2 = get2();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
c.v = new char[1][1][1][1]; char[][][] val1 = get3();
c.v[0] = new char[1][1][1]; char[][][] val2 = get3();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
@@ -350,7 +392,6 @@
c.v = new char[1][1][1][1]; char[][][][] val2 = get4();
assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
}
-
}
}
@@ -403,7 +444,7 @@
c.v = new char[1][1]; c.v[0] = new char[0]; char[] val1 = get1();
c.v[0] = new char[0]; char[] val2 = get1();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
@@ -439,14 +480,14 @@
c.v = new char[1][1][1]; c.v[0][0] = new char[0]; char[] val1 = get1();
c.v[0][0] = new char[0]; char[] val2 = get1();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
c.v = new char[1][1][1]; c.v[0] = new char[0][0]; char[][] val1 = get2();
c.v[0] = new char[0][0]; char[][] val2 = get2();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
@@ -581,7 +622,7 @@
elem.a = 'b'; char val3 = get(); char val4 = get1();
assertEquals(val1, 'a');
- assertEquals(val3, (isStableEnabled ? 'a' : 'b'));
+ assertEquals(val3, (isServerWithStable ? 'a' : 'b'));
assertEquals(val2, 'a');
assertEquals(val4, 'b');
@@ -615,17 +656,4 @@
}
}
}
-
- static final boolean isStableEnabled;
- static {
- HotSpotDiagnosticMXBean diagnostic
- = ManagementFactoryHelper.getDiagnosticMXBean();
- VMOption tmp;
- try {
- tmp = diagnostic.getVMOption("FoldStableValues");
- } catch (IllegalArgumentException e) {
- tmp = null;
- }
- isStableEnabled = (tmp == null ? false : Boolean.parseBoolean(tmp.getValue()));
- }
}
--- a/hotspot/test/compiler/stable/TestStableDouble.java Mon Jul 14 03:24:35 2014 -0700
+++ b/hotspot/test/compiler/stable/TestStableDouble.java Mon Jul 14 03:25:40 2014 -0700
@@ -26,9 +26,11 @@
/*
* @test TestStableDouble
* @summary tests on stable fields and arrays
- * @library /testlibrary
- * @compile -XDignore.symbol.file TestStableDouble.java
+ * @library /testlibrary /testlibrary/whitebox
+ * @build TestStableDouble StableConfiguration sun.hotspot.WhiteBox
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
* @run main ClassFileInstaller
+ * java/lang/invoke/StableConfiguration
* java/lang/invoke/TestStableDouble
* java/lang/invoke/TestStableDouble$DoubleStable
* java/lang/invoke/TestStableDouble$StaticDoubleStable
@@ -48,46 +50,60 @@
* java/lang/invoke/TestStableDouble$NestedStableField3
* java/lang/invoke/TestStableDouble$NestedStableField3$A
* java/lang/invoke/TestStableDouble$DefaultValue
+ * java/lang/invoke/TestStableDouble$DefaultStaticValue
* java/lang/invoke/TestStableDouble$ObjectArrayLowerDim2
*
* @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- * -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:+UseCompressedOop
- * -server -XX:-TieredCompilation -Xcomp
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ * -server -XX:-TieredCompilation
+ * -XX:+FoldStableValues
+ * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ * java.lang.invoke.TestStableDouble
+ * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ * -server -XX:-TieredCompilation
+ * -XX:-FoldStableValues
* -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
* java.lang.invoke.TestStableDouble
*
* @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- * -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:-UseCompressedOop
- * -server -XX:-TieredCompilation -Xcomp
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ * -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1
+ * -XX:+FoldStableValues
+ * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ * java.lang.invoke.TestStableDouble
+ * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ * -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1
+ * -XX:-FoldStableValues
* -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
* java.lang.invoke.TestStableDouble
*
* @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- * -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:+UseCompressedOop
- * -server -XX:-TieredCompilation -Xcomp
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ * -client -XX:-TieredCompilation
+ * -XX:+FoldStableValues
* -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
* java.lang.invoke.TestStableDouble
- *
* @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- * -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:-UseCompressedOop
- * -server -XX:-TieredCompilation -Xcomp
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ * -client -XX:-TieredCompilation
+ * -XX:-FoldStableValues
* -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
* java.lang.invoke.TestStableDouble
*/
package java.lang.invoke;
-import com.sun.management.HotSpotDiagnosticMXBean;
-import com.sun.management.VMOption;
-import sun.management.ManagementFactoryHelper;
import java.lang.reflect.InvocationTargetException;
public class TestStableDouble {
+ static final boolean isStableEnabled = StableConfiguration.isStableEnabled;
+ static final boolean isServerWithStable = StableConfiguration.isServerWithStable;
+
public static void main(String[] args) throws Exception {
- System.out.println("@Stable enabled: "+isStableEnabled);
- System.out.println();
-
run(DefaultValue.class);
run(DoubleStable.class);
+ run(DefaultStaticValue.class);
run(StaticDoubleStable.class);
run(VolatileDoubleStable.class);
@@ -145,6 +161,21 @@
/* ==================================================== */
+ static class DefaultStaticValue {
+ public static @Stable double v;
+
+ public static final DefaultStaticValue c = new DefaultStaticValue();
+ public static double get() { return c.v; }
+ public static void test() throws Exception {
+ double val1 = get();
+ c.v = 1.0; double val2 = get();
+ assertEquals(val1, 0);
+ assertEquals(val2, 1.0);
+ }
+ }
+
+ /* ==================================================== */
+
static class StaticDoubleStable {
public static @Stable double v;
@@ -188,20 +219,22 @@
c.v = new double[1]; c.v[0] = 1.0; double val1 = get();
c.v[0] = 2.0; double val2 = get();
assertEquals(val1, 1.0);
- assertEquals(val2, (isStableEnabled ? 1.0 : 2.0));
+ assertEquals(val2, (isServerWithStable ? 1.0 : 2.0));
c.v = new double[1]; c.v[0] = 3.0; double val3 = get();
- assertEquals(val3, (isStableEnabled ? 1.0 : 3.0));
+ assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0)
+ : 3.0));
}
{
c.v = new double[20]; c.v[10] = 1.0; double val1 = get1();
c.v[10] = 2.0; double val2 = get1();
assertEquals(val1, 1.0);
- assertEquals(val2, (isStableEnabled ? 1.0 : 2.0));
+ assertEquals(val2, (isServerWithStable ? 1.0 : 2.0));
c.v = new double[20]; c.v[10] = 3.0; double val3 = get1();
- assertEquals(val3, (isStableEnabled ? 1.0 : 3.0));
+ assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0)
+ : 3.0));
}
{
@@ -226,19 +259,21 @@
c.v = new double[1][1]; c.v[0][0] = 1.0; double val1 = get();
c.v[0][0] = 2.0; double val2 = get();
assertEquals(val1, 1.0);
- assertEquals(val2, (isStableEnabled ? 1.0 : 2.0));
+ assertEquals(val2, (isServerWithStable ? 1.0 : 2.0));
c.v = new double[1][1]; c.v[0][0] = 3.0; double val3 = get();
- assertEquals(val3, (isStableEnabled ? 1.0 : 3.0));
+ assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0)
+ : 3.0));
c.v[0] = new double[1]; c.v[0][0] = 4.0; double val4 = get();
- assertEquals(val4, (isStableEnabled ? 1.0 : 4.0));
+ assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0)
+ : 4.0));
}
{
c.v = new double[1][1]; double[] val1 = get1();
c.v[0] = new double[1]; double[] val2 = get1();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
@@ -264,28 +299,31 @@
c.v = new double[1][1][1]; c.v[0][0][0] = 1.0; double val1 = get();
c.v[0][0][0] = 2.0; double val2 = get();
assertEquals(val1, 1.0);
- assertEquals(val2, (isStableEnabled ? 1.0 : 2.0));
+ assertEquals(val2, (isServerWithStable ? 1.0 : 2.0));
c.v = new double[1][1][1]; c.v[0][0][0] = 3.0; double val3 = get();
- assertEquals(val3, (isStableEnabled ? 1.0 : 3.0));
+ assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0)
+ : 3.0));
c.v[0] = new double[1][1]; c.v[0][0][0] = 4.0; double val4 = get();
- assertEquals(val4, (isStableEnabled ? 1.0 : 4.0));
+ assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0)
+ : 4.0));
c.v[0][0] = new double[1]; c.v[0][0][0] = 5.0; double val5 = get();
- assertEquals(val5, (isStableEnabled ? 1.0 : 5.0));
+ assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0)
+ : 5.0));
}
{
c.v = new double[1][1][1]; double[] val1 = get1();
c.v[0][0] = new double[1]; double[] val2 = get1();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
c.v = new double[1][1][1]; double[][] val1 = get2();
c.v[0] = new double[1][1]; double[][] val2 = get2();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
@@ -312,37 +350,41 @@
c.v = new double[1][1][1][1]; c.v[0][0][0][0] = 1.0; double val1 = get();
c.v[0][0][0][0] = 2.0; double val2 = get();
assertEquals(val1, 1.0);
- assertEquals(val2, (isStableEnabled ? 1.0 : 2.0));
+ assertEquals(val2, (isServerWithStable ? 1.0 : 2.0));
c.v = new double[1][1][1][1]; c.v[0][0][0][0] = 3.0; double val3 = get();
- assertEquals(val3, (isStableEnabled ? 1.0 : 3.0));
+ assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0)
+ : 3.0));
c.v[0] = new double[1][1][1]; c.v[0][0][0][0] = 4.0; double val4 = get();
- assertEquals(val4, (isStableEnabled ? 1.0 : 4.0));
+ assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0)
+ : 4.0));
c.v[0][0] = new double[1][1]; c.v[0][0][0][0] = 5.0; double val5 = get();
- assertEquals(val5, (isStableEnabled ? 1.0 : 5.0));
+ assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0)
+ : 5.0));
c.v[0][0][0] = new double[1]; c.v[0][0][0][0] = 6.0; double val6 = get();
- assertEquals(val6, (isStableEnabled ? 1.0 : 6.0));
+ assertEquals(val6, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0)
+ : 6.0));
}
{
c.v = new double[1][1][1][1]; double[] val1 = get1();
c.v[0][0][0] = new double[1]; double[] val2 = get1();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
c.v = new double[1][1][1][1]; double[][] val1 = get2();
c.v[0][0] = new double[1][1]; double[][] val2 = get2();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
c.v = new double[1][1][1][1]; double[][][] val1 = get3();
c.v[0] = new double[1][1][1]; double[][][] val2 = get3();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
@@ -350,13 +392,11 @@
c.v = new double[1][1][1][1]; double[][][][] val2 = get4();
assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
}
-
}
}
/* ==================================================== */
// Dynamic Dim is higher than static
-
static class ObjectArrayLowerDim0 {
public @Stable Object v;
@@ -404,7 +444,7 @@
c.v = new double[1][1]; c.v[0] = new double[0]; double[] val1 = get1();
c.v[0] = new double[0]; double[] val2 = get1();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
@@ -440,14 +480,14 @@
c.v = new double[1][1][1]; c.v[0][0] = new double[0]; double[] val1 = get1();
c.v[0][0] = new double[0]; double[] val2 = get1();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
c.v = new double[1][1][1]; c.v[0] = new double[0][0]; double[][] val1 = get2();
c.v[0] = new double[0][0]; double[][] val2 = get2();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
@@ -582,7 +622,7 @@
elem.a = 2.0; double val3 = get(); double val4 = get1();
assertEquals(val1, 1.0);
- assertEquals(val3, (isStableEnabled ? 1.0 : 2.0));
+ assertEquals(val3, (isServerWithStable ? 1.0 : 2.0));
assertEquals(val2, 1.0);
assertEquals(val4, 2.0);
@@ -616,17 +656,4 @@
}
}
}
-
- static final boolean isStableEnabled;
- static {
- HotSpotDiagnosticMXBean diagnostic
- = ManagementFactoryHelper.getDiagnosticMXBean();
- VMOption tmp;
- try {
- tmp = diagnostic.getVMOption("FoldStableValues");
- } catch (IllegalArgumentException e) {
- tmp = null;
- }
- isStableEnabled = (tmp == null ? false : Boolean.parseBoolean(tmp.getValue()));
- }
}
--- a/hotspot/test/compiler/stable/TestStableFloat.java Mon Jul 14 03:24:35 2014 -0700
+++ b/hotspot/test/compiler/stable/TestStableFloat.java Mon Jul 14 03:25:40 2014 -0700
@@ -26,9 +26,11 @@
/*
* @test TestStableFloat
* @summary tests on stable fields and arrays
- * @library /testlibrary
- * @compile -XDignore.symbol.file TestStableFloat.java
+ * @library /testlibrary /testlibrary/whitebox
+ * @build TestStableFloat StableConfiguration sun.hotspot.WhiteBox
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
* @run main ClassFileInstaller
+ * java/lang/invoke/StableConfiguration
* java/lang/invoke/TestStableFloat
* java/lang/invoke/TestStableFloat$FloatStable
* java/lang/invoke/TestStableFloat$StaticFloatStable
@@ -48,46 +50,60 @@
* java/lang/invoke/TestStableFloat$NestedStableField3
* java/lang/invoke/TestStableFloat$NestedStableField3$A
* java/lang/invoke/TestStableFloat$DefaultValue
+ * java/lang/invoke/TestStableFloat$DefaultStaticValue
* java/lang/invoke/TestStableFloat$ObjectArrayLowerDim2
*
* @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- * -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:+UseCompressedOop
- * -server -XX:-TieredCompilation -Xcomp
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ * -server -XX:-TieredCompilation
+ * -XX:+FoldStableValues
+ * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ * java.lang.invoke.TestStableFloat
+ * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ * -server -XX:-TieredCompilation
+ * -XX:-FoldStableValues
* -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
* java.lang.invoke.TestStableFloat
*
* @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- * -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:-UseCompressedOop
- * -server -XX:-TieredCompilation -Xcomp
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ * -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1
+ * -XX:+FoldStableValues
+ * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ * java.lang.invoke.TestStableFloat
+ * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ * -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1
+ * -XX:-FoldStableValues
* -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
* java.lang.invoke.TestStableFloat
*
* @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- * -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:+UseCompressedOop
- * -server -XX:-TieredCompilation -Xcomp
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ * -client -XX:-TieredCompilation
+ * -XX:+FoldStableValues
* -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
* java.lang.invoke.TestStableFloat
- *
* @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- * -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:-UseCompressedOop
- * -server -XX:-TieredCompilation -Xcomp
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ * -client -XX:-TieredCompilation
+ * -XX:-FoldStableValues
* -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
* java.lang.invoke.TestStableFloat
*/
package java.lang.invoke;
-import com.sun.management.HotSpotDiagnosticMXBean;
-import com.sun.management.VMOption;
-import sun.management.ManagementFactoryHelper;
import java.lang.reflect.InvocationTargetException;
public class TestStableFloat {
+ static final boolean isStableEnabled = StableConfiguration.isStableEnabled;
+ static final boolean isServerWithStable = StableConfiguration.isServerWithStable;
+
public static void main(String[] args) throws Exception {
- System.out.println("@Stable enabled: "+isStableEnabled);
- System.out.println();
-
run(DefaultValue.class);
run(FloatStable.class);
+ run(DefaultStaticValue.class);
run(StaticFloatStable.class);
run(VolatileFloatStable.class);
@@ -145,6 +161,21 @@
/* ==================================================== */
+ static class DefaultStaticValue {
+ public static @Stable float v;
+
+ public static final DefaultStaticValue c = new DefaultStaticValue();
+ public static float get() { return c.v; }
+ public static void test() throws Exception {
+ float val1 = get();
+ c.v = 1.0F; float val2 = get();
+ assertEquals(val1, 0F);
+ assertEquals(val2, 1.0F);
+ }
+ }
+
+ /* ==================================================== */
+
static class StaticFloatStable {
public static @Stable float v;
@@ -188,20 +219,22 @@
c.v = new float[1]; c.v[0] = 1.0F; float val1 = get();
c.v[0] = 2.0F; float val2 = get();
assertEquals(val1, 1.0F);
- assertEquals(val2, (isStableEnabled ? 1.0F : 2.0F));
+ assertEquals(val2, (isServerWithStable ? 1.0F : 2.0F));
c.v = new float[1]; c.v[0] = 3.0F; float val3 = get();
- assertEquals(val3, (isStableEnabled ? 1.0F : 3.0F));
+ assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0F : 2.0F)
+ : 3.0F));
}
{
c.v = new float[20]; c.v[10] = 1.0F; float val1 = get1();
c.v[10] = 2.0F; float val2 = get1();
assertEquals(val1, 1.0F);
- assertEquals(val2, (isStableEnabled ? 1.0F : 2.0F));
+ assertEquals(val2, (isServerWithStable ? 1.0F : 2.0F));
c.v = new float[20]; c.v[10] = 3.0F; float val3 = get1();
- assertEquals(val3, (isStableEnabled ? 1.0F : 3.0F));
+ assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0F : 2.0F)
+ : 3.0F));
}
{
@@ -226,19 +259,21 @@
c.v = new float[1][1]; c.v[0][0] = 1.0F; float val1 = get();
c.v[0][0] = 2.0F; float val2 = get();
assertEquals(val1, 1.0F);
- assertEquals(val2, (isStableEnabled ? 1.0F : 2.0F));
+ assertEquals(val2, (isServerWithStable ? 1.0F : 2.0F));
c.v = new float[1][1]; c.v[0][0] = 3.0F; float val3 = get();
- assertEquals(val3, (isStableEnabled ? 1.0F : 3.0F));
+ assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0F : 2.0F)
+ : 3.0F));
c.v[0] = new float[1]; c.v[0][0] = 4.0F; float val4 = get();
- assertEquals(val4, (isStableEnabled ? 1.0F : 4.0F));
+ assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1.0F : 2.0F)
+ : 4.0F));
}
{
c.v = new float[1][1]; float[] val1 = get1();
c.v[0] = new float[1]; float[] val2 = get1();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
@@ -264,28 +299,31 @@
c.v = new float[1][1][1]; c.v[0][0][0] = 1.0F; float val1 = get();
c.v[0][0][0] = 2.0F; float val2 = get();
assertEquals(val1, 1.0F);
- assertEquals(val2, (isStableEnabled ? 1.0F : 2.0F));
+ assertEquals(val2, (isServerWithStable ? 1.0F : 2.0F));
c.v = new float[1][1][1]; c.v[0][0][0] = 3.0F; float val3 = get();
- assertEquals(val3, (isStableEnabled ? 1.0F : 3.0F));
+ assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0F : 2.0F)
+ : 3.0F));
c.v[0] = new float[1][1]; c.v[0][0][0] = 4.0F; float val4 = get();
- assertEquals(val4, (isStableEnabled ? 1.0F : 4.0F));
+ assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1.0F : 2.0F)
+ : 4.0F));
c.v[0][0] = new float[1]; c.v[0][0][0] = 5.0F; float val5 = get();
- assertEquals(val5, (isStableEnabled ? 1.0F : 5.0F));
+ assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1.0F : 2.0F)
+ : 5.0F));
}
{
c.v = new float[1][1][1]; float[] val1 = get1();
c.v[0][0] = new float[1]; float[] val2 = get1();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
c.v = new float[1][1][1]; float[][] val1 = get2();
c.v[0] = new float[1][1]; float[][] val2 = get2();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
@@ -312,37 +350,41 @@
c.v = new float[1][1][1][1]; c.v[0][0][0][0] = 1.0F; float val1 = get();
c.v[0][0][0][0] = 2.0F; float val2 = get();
assertEquals(val1, 1.0F);
- assertEquals(val2, (isStableEnabled ? 1.0F : 2.0F));
+ assertEquals(val2, (isServerWithStable ? 1.0F : 2.0F));
c.v = new float[1][1][1][1]; c.v[0][0][0][0] = 3.0F; float val3 = get();
- assertEquals(val3, (isStableEnabled ? 1.0F : 3.0F));
+ assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0F : 2.0F)
+ : 3.0F));
c.v[0] = new float[1][1][1]; c.v[0][0][0][0] = 4.0F; float val4 = get();
- assertEquals(val4, (isStableEnabled ? 1.0F : 4.0F));
+ assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1.0F : 2.0F)
+ : 4.0F));
c.v[0][0] = new float[1][1]; c.v[0][0][0][0] = 5.0F; float val5 = get();
- assertEquals(val5, (isStableEnabled ? 1.0F : 5.0F));
+ assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1.0F : 2.0F)
+ : 5.0F));
c.v[0][0][0] = new float[1]; c.v[0][0][0][0] = 6.0F; float val6 = get();
- assertEquals(val6, (isStableEnabled ? 1.0F : 6.0F));
+ assertEquals(val6, (isStableEnabled ? (isServerWithStable ? 1.0F : 2.0F)
+ : 6.0F));
}
{
c.v = new float[1][1][1][1]; float[] val1 = get1();
c.v[0][0][0] = new float[1]; float[] val2 = get1();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
c.v = new float[1][1][1][1]; float[][] val1 = get2();
c.v[0][0] = new float[1][1]; float[][] val2 = get2();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
c.v = new float[1][1][1][1]; float[][][] val1 = get3();
c.v[0] = new float[1][1][1]; float[][][] val2 = get3();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
@@ -350,13 +392,11 @@
c.v = new float[1][1][1][1]; float[][][][] val2 = get4();
assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
}
-
}
}
/* ==================================================== */
// Dynamic Dim is higher than static
-
static class ObjectArrayLowerDim0 {
public @Stable Object v;
@@ -404,7 +444,7 @@
c.v = new float[1][1]; c.v[0] = new float[0]; float[] val1 = get1();
c.v[0] = new float[0]; float[] val2 = get1();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
@@ -440,14 +480,14 @@
c.v = new float[1][1][1]; c.v[0][0] = new float[0]; float[] val1 = get1();
c.v[0][0] = new float[0]; float[] val2 = get1();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
c.v = new float[1][1][1]; c.v[0] = new float[0][0]; float[][] val1 = get2();
c.v[0] = new float[0][0]; float[][] val2 = get2();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
@@ -582,7 +622,7 @@
elem.a = 2.0F; float val3 = get(); float val4 = get1();
assertEquals(val1, 1.0F);
- assertEquals(val3, (isStableEnabled ? 1.0F : 2.0F));
+ assertEquals(val3, (isServerWithStable ? 1.0F : 2.0F));
assertEquals(val2, 1.0F);
assertEquals(val4, 2.0F);
@@ -616,17 +656,4 @@
}
}
}
-
- static final boolean isStableEnabled;
- static {
- HotSpotDiagnosticMXBean diagnostic
- = ManagementFactoryHelper.getDiagnosticMXBean();
- VMOption tmp;
- try {
- tmp = diagnostic.getVMOption("FoldStableValues");
- } catch (IllegalArgumentException e) {
- tmp = null;
- }
- isStableEnabled = (tmp == null ? false : Boolean.parseBoolean(tmp.getValue()));
- }
}
--- a/hotspot/test/compiler/stable/TestStableInt.java Mon Jul 14 03:24:35 2014 -0700
+++ b/hotspot/test/compiler/stable/TestStableInt.java Mon Jul 14 03:25:40 2014 -0700
@@ -26,9 +26,11 @@
/*
* @test TestStableInt
* @summary tests on stable fields and arrays
- * @library /testlibrary
- * @compile -XDignore.symbol.file TestStableInt.java
+ * @library /testlibrary /testlibrary/whitebox
+ * @build TestStableInt StableConfiguration sun.hotspot.WhiteBox
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
* @run main ClassFileInstaller
+ * java/lang/invoke/StableConfiguration
* java/lang/invoke/TestStableInt
* java/lang/invoke/TestStableInt$IntStable
* java/lang/invoke/TestStableInt$StaticIntStable
@@ -48,46 +50,60 @@
* java/lang/invoke/TestStableInt$NestedStableField3
* java/lang/invoke/TestStableInt$NestedStableField3$A
* java/lang/invoke/TestStableInt$DefaultValue
+ * java/lang/invoke/TestStableInt$DefaultStaticValue
* java/lang/invoke/TestStableInt$ObjectArrayLowerDim2
*
* @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- * -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:+UseCompressedOop
- * -server -XX:-TieredCompilation -Xcomp
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ * -server -XX:-TieredCompilation
+ * -XX:+FoldStableValues
+ * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ * java.lang.invoke.TestStableInt
+ * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ * -server -XX:-TieredCompilation
+ * -XX:-FoldStableValues
* -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
* java.lang.invoke.TestStableInt
*
* @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- * -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:-UseCompressedOop
- * -server -XX:-TieredCompilation -Xcomp
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ * -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1
+ * -XX:+FoldStableValues
+ * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ * java.lang.invoke.TestStableInt
+ * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ * -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1
+ * -XX:-FoldStableValues
* -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
* java.lang.invoke.TestStableInt
*
* @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- * -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:+UseCompressedOop
- * -server -XX:-TieredCompilation -Xcomp
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ * -client -XX:-TieredCompilation
+ * -XX:+FoldStableValues
* -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
* java.lang.invoke.TestStableInt
- *
* @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- * -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:-UseCompressedOop
- * -server -XX:-TieredCompilation -Xcomp
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ * -client -XX:-TieredCompilation
+ * -XX:-FoldStableValues
* -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
* java.lang.invoke.TestStableInt
*/
package java.lang.invoke;
-import com.sun.management.HotSpotDiagnosticMXBean;
-import com.sun.management.VMOption;
-import sun.management.ManagementFactoryHelper;
import java.lang.reflect.InvocationTargetException;
public class TestStableInt {
+ static final boolean isStableEnabled = StableConfiguration.isStableEnabled;
+ static final boolean isServerWithStable = StableConfiguration.isServerWithStable;
+
public static void main(String[] args) throws Exception {
- System.out.println("@Stable enabled: "+isStableEnabled);
- System.out.println();
-
run(DefaultValue.class);
run(IntStable.class);
+ run(DefaultStaticValue.class);
run(StaticIntStable.class);
run(VolatileIntStable.class);
@@ -145,6 +161,21 @@
/* ==================================================== */
+ static class DefaultStaticValue {
+ public static @Stable int v;
+
+ public static final DefaultStaticValue c = new DefaultStaticValue();
+ public static int get() { return c.v; }
+ public static void test() throws Exception {
+ int val1 = get();
+ c.v = 1; int val2 = get();
+ assertEquals(val1, 0);
+ assertEquals(val2, 1);
+ }
+ }
+
+ /* ==================================================== */
+
static class StaticIntStable {
public static @Stable int v;
@@ -188,20 +219,22 @@
c.v = new int[1]; c.v[0] = 1; int val1 = get();
c.v[0] = 2; int val2 = get();
assertEquals(val1, 1);
- assertEquals(val2, (isStableEnabled ? 1 : 2));
+ assertEquals(val2, (isServerWithStable ? 1 : 2));
c.v = new int[1]; c.v[0] = 3; int val3 = get();
- assertEquals(val3, (isStableEnabled ? 1 : 3));
+ assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+ : 3));
}
{
c.v = new int[20]; c.v[10] = 1; int val1 = get1();
c.v[10] = 2; int val2 = get1();
assertEquals(val1, 1);
- assertEquals(val2, (isStableEnabled ? 1 : 2));
+ assertEquals(val2, (isServerWithStable ? 1 : 2));
c.v = new int[20]; c.v[10] = 3; int val3 = get1();
- assertEquals(val3, (isStableEnabled ? 1 : 3));
+ assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+ : 3));
}
{
@@ -226,19 +259,21 @@
c.v = new int[1][1]; c.v[0][0] = 1; int val1 = get();
c.v[0][0] = 2; int val2 = get();
assertEquals(val1, 1);
- assertEquals(val2, (isStableEnabled ? 1 : 2));
+ assertEquals(val2, (isServerWithStable ? 1 : 2));
c.v = new int[1][1]; c.v[0][0] = 3; int val3 = get();
- assertEquals(val3, (isStableEnabled ? 1 : 3));
+ assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+ : 3));
c.v[0] = new int[1]; c.v[0][0] = 4; int val4 = get();
- assertEquals(val4, (isStableEnabled ? 1 : 4));
+ assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+ : 4));
}
{
c.v = new int[1][1]; int[] val1 = get1();
c.v[0] = new int[1]; int[] val2 = get1();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
@@ -264,28 +299,31 @@
c.v = new int[1][1][1]; c.v[0][0][0] = 1; int val1 = get();
c.v[0][0][0] = 2; int val2 = get();
assertEquals(val1, 1);
- assertEquals(val2, (isStableEnabled ? 1 : 2));
+ assertEquals(val2, (isServerWithStable ? 1 : 2));
c.v = new int[1][1][1]; c.v[0][0][0] = 3; int val3 = get();
- assertEquals(val3, (isStableEnabled ? 1 : 3));
+ assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+ : 3));
c.v[0] = new int[1][1]; c.v[0][0][0] = 4; int val4 = get();
- assertEquals(val4, (isStableEnabled ? 1 : 4));
+ assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+ : 4));
c.v[0][0] = new int[1]; c.v[0][0][0] = 5; int val5 = get();
- assertEquals(val5, (isStableEnabled ? 1 : 5));
+ assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+ : 5));
}
{
c.v = new int[1][1][1]; int[] val1 = get1();
c.v[0][0] = new int[1]; int[] val2 = get1();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
c.v = new int[1][1][1]; int[][] val1 = get2();
c.v[0] = new int[1][1]; int[][] val2 = get2();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
@@ -312,37 +350,41 @@
c.v = new int[1][1][1][1]; c.v[0][0][0][0] = 1; int val1 = get();
c.v[0][0][0][0] = 2; int val2 = get();
assertEquals(val1, 1);
- assertEquals(val2, (isStableEnabled ? 1 : 2));
+ assertEquals(val2, (isServerWithStable ? 1 : 2));
c.v = new int[1][1][1][1]; c.v[0][0][0][0] = 3; int val3 = get();
- assertEquals(val3, (isStableEnabled ? 1 : 3));
+ assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+ : 3));
c.v[0] = new int[1][1][1]; c.v[0][0][0][0] = 4; int val4 = get();
- assertEquals(val4, (isStableEnabled ? 1 : 4));
+ assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+ : 4));
c.v[0][0] = new int[1][1]; c.v[0][0][0][0] = 5; int val5 = get();
- assertEquals(val5, (isStableEnabled ? 1 : 5));
+ assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+ : 5));
c.v[0][0][0] = new int[1]; c.v[0][0][0][0] = 6; int val6 = get();
- assertEquals(val6, (isStableEnabled ? 1 : 6));
+ assertEquals(val6, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+ : 6));
}
{
c.v = new int[1][1][1][1]; int[] val1 = get1();
c.v[0][0][0] = new int[1]; int[] val2 = get1();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
c.v = new int[1][1][1][1]; int[][] val1 = get2();
c.v[0][0] = new int[1][1]; int[][] val2 = get2();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
c.v = new int[1][1][1][1]; int[][][] val1 = get3();
c.v[0] = new int[1][1][1]; int[][][] val2 = get3();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
@@ -350,13 +392,11 @@
c.v = new int[1][1][1][1]; int[][][][] val2 = get4();
assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
}
-
}
}
/* ==================================================== */
// Dynamic Dim is higher than static
-
static class ObjectArrayLowerDim0 {
public @Stable Object v;
@@ -404,7 +444,7 @@
c.v = new int[1][1]; c.v[0] = new int[0]; int[] val1 = get1();
c.v[0] = new int[0]; int[] val2 = get1();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
@@ -440,14 +480,14 @@
c.v = new int[1][1][1]; c.v[0][0] = new int[0]; int[] val1 = get1();
c.v[0][0] = new int[0]; int[] val2 = get1();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
c.v = new int[1][1][1]; c.v[0] = new int[0][0]; int[][] val1 = get2();
c.v[0] = new int[0][0]; int[][] val2 = get2();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
@@ -582,7 +622,7 @@
elem.a = 2; int val3 = get(); int val4 = get1();
assertEquals(val1, 1);
- assertEquals(val3, (isStableEnabled ? 1 : 2));
+ assertEquals(val3, (isServerWithStable ? 1 : 2));
assertEquals(val2, 1);
assertEquals(val4, 2);
@@ -616,17 +656,4 @@
}
}
}
-
- static final boolean isStableEnabled;
- static {
- HotSpotDiagnosticMXBean diagnostic
- = ManagementFactoryHelper.getDiagnosticMXBean();
- VMOption tmp;
- try {
- tmp = diagnostic.getVMOption("FoldStableValues");
- } catch (IllegalArgumentException e) {
- tmp = null;
- }
- isStableEnabled = (tmp == null ? false : Boolean.parseBoolean(tmp.getValue()));
- }
}
--- a/hotspot/test/compiler/stable/TestStableLong.java Mon Jul 14 03:24:35 2014 -0700
+++ b/hotspot/test/compiler/stable/TestStableLong.java Mon Jul 14 03:25:40 2014 -0700
@@ -26,9 +26,11 @@
/*
* @test TestStableLong
* @summary tests on stable fields and arrays
- * @library /testlibrary
- * @compile -XDignore.symbol.file TestStableLong.java
+ * @library /testlibrary /testlibrary/whitebox
+ * @build TestStableLong StableConfiguration sun.hotspot.WhiteBox
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
* @run main ClassFileInstaller
+ * java/lang/invoke/StableConfiguration
* java/lang/invoke/TestStableLong
* java/lang/invoke/TestStableLong$LongStable
* java/lang/invoke/TestStableLong$StaticLongStable
@@ -48,46 +50,60 @@
* java/lang/invoke/TestStableLong$NestedStableField3
* java/lang/invoke/TestStableLong$NestedStableField3$A
* java/lang/invoke/TestStableLong$DefaultValue
+ * java/lang/invoke/TestStableLong$DefaultStaticValue
* java/lang/invoke/TestStableLong$ObjectArrayLowerDim2
*
* @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- * -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:+UseCompressedOop
- * -server -XX:-TieredCompilation -Xcomp
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ * -server -XX:-TieredCompilation
+ * -XX:+FoldStableValues
+ * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ * java.lang.invoke.TestStableLong
+ * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ * -server -XX:-TieredCompilation
+ * -XX:-FoldStableValues
* -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
* java.lang.invoke.TestStableLong
*
* @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- * -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:-UseCompressedOop
- * -server -XX:-TieredCompilation -Xcomp
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ * -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1
+ * -XX:+FoldStableValues
+ * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ * java.lang.invoke.TestStableLong
+ * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ * -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1
+ * -XX:-FoldStableValues
* -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
* java.lang.invoke.TestStableLong
*
* @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- * -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:+UseCompressedOop
- * -server -XX:-TieredCompilation -Xcomp
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ * -client -XX:-TieredCompilation
+ * -XX:+FoldStableValues
* -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
* java.lang.invoke.TestStableLong
- *
* @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- * -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:-UseCompressedOop
- * -server -XX:-TieredCompilation -Xcomp
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ * -client -XX:-TieredCompilation
+ * -XX:-FoldStableValues
* -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
* java.lang.invoke.TestStableLong
*/
package java.lang.invoke;
-import com.sun.management.HotSpotDiagnosticMXBean;
-import com.sun.management.VMOption;
-import sun.management.ManagementFactoryHelper;
import java.lang.reflect.InvocationTargetException;
public class TestStableLong {
+ static final boolean isStableEnabled = StableConfiguration.isStableEnabled;
+ static final boolean isServerWithStable = StableConfiguration.isServerWithStable;
+
public static void main(String[] args) throws Exception {
- System.out.println("@Stable enabled: "+isStableEnabled);
- System.out.println();
-
run(DefaultValue.class);
run(LongStable.class);
+ run(DefaultStaticValue.class);
run(StaticLongStable.class);
run(VolatileLongStable.class);
@@ -145,6 +161,21 @@
/* ==================================================== */
+ static class DefaultStaticValue {
+ public static @Stable long v;
+
+ public static final DefaultStaticValue c = new DefaultStaticValue();
+ public static long get() { return c.v; }
+ public static void test() throws Exception {
+ long val1 = get();
+ c.v = 1L; long val2 = get();
+ assertEquals(val1, 0);
+ assertEquals(val2, 1L);
+ }
+ }
+
+ /* ==================================================== */
+
static class StaticLongStable {
public static @Stable long v;
@@ -188,20 +219,22 @@
c.v = new long[1]; c.v[0] = 1; long val1 = get();
c.v[0] = 2; long val2 = get();
assertEquals(val1, 1);
- assertEquals(val2, (isStableEnabled ? 1 : 2));
+ assertEquals(val2, (isServerWithStable ? 1 : 2));
c.v = new long[1]; c.v[0] = 3; long val3 = get();
- assertEquals(val3, (isStableEnabled ? 1 : 3));
+ assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+ : 3));
}
{
c.v = new long[20]; c.v[10] = 1; long val1 = get1();
c.v[10] = 2; long val2 = get1();
assertEquals(val1, 1);
- assertEquals(val2, (isStableEnabled ? 1 : 2));
+ assertEquals(val2, (isServerWithStable ? 1 : 2));
c.v = new long[20]; c.v[10] = 3; long val3 = get1();
- assertEquals(val3, (isStableEnabled ? 1 : 3));
+ assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+ : 3));
}
{
@@ -226,19 +259,21 @@
c.v = new long[1][1]; c.v[0][0] = 1; long val1 = get();
c.v[0][0] = 2; long val2 = get();
assertEquals(val1, 1);
- assertEquals(val2, (isStableEnabled ? 1 : 2));
+ assertEquals(val2, (isServerWithStable ? 1 : 2));
c.v = new long[1][1]; c.v[0][0] = 3; long val3 = get();
- assertEquals(val3, (isStableEnabled ? 1 : 3));
+ assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+ : 3));
c.v[0] = new long[1]; c.v[0][0] = 4; long val4 = get();
- assertEquals(val4, (isStableEnabled ? 1 : 4));
+ assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+ : 4));
}
{
c.v = new long[1][1]; long[] val1 = get1();
c.v[0] = new long[1]; long[] val2 = get1();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
@@ -264,28 +299,31 @@
c.v = new long[1][1][1]; c.v[0][0][0] = 1; long val1 = get();
c.v[0][0][0] = 2; long val2 = get();
assertEquals(val1, 1);
- assertEquals(val2, (isStableEnabled ? 1 : 2));
+ assertEquals(val2, (isServerWithStable ? 1 : 2));
c.v = new long[1][1][1]; c.v[0][0][0] = 3; long val3 = get();
- assertEquals(val3, (isStableEnabled ? 1 : 3));
+ assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+ : 3));
c.v[0] = new long[1][1]; c.v[0][0][0] = 4; long val4 = get();
- assertEquals(val4, (isStableEnabled ? 1 : 4));
+ assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+ : 4));
c.v[0][0] = new long[1]; c.v[0][0][0] = 5; long val5 = get();
- assertEquals(val5, (isStableEnabled ? 1 : 5));
+ assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+ : 5));
}
{
c.v = new long[1][1][1]; long[] val1 = get1();
c.v[0][0] = new long[1]; long[] val2 = get1();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
c.v = new long[1][1][1]; long[][] val1 = get2();
c.v[0] = new long[1][1]; long[][] val2 = get2();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
@@ -312,37 +350,41 @@
c.v = new long[1][1][1][1]; c.v[0][0][0][0] = 1; long val1 = get();
c.v[0][0][0][0] = 2; long val2 = get();
assertEquals(val1, 1);
- assertEquals(val2, (isStableEnabled ? 1 : 2));
+ assertEquals(val2, (isServerWithStable ? 1 : 2));
c.v = new long[1][1][1][1]; c.v[0][0][0][0] = 3; long val3 = get();
- assertEquals(val3, (isStableEnabled ? 1 : 3));
+ assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+ : 3));
c.v[0] = new long[1][1][1]; c.v[0][0][0][0] = 4; long val4 = get();
- assertEquals(val4, (isStableEnabled ? 1 : 4));
+ assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+ : 4));
c.v[0][0] = new long[1][1]; c.v[0][0][0][0] = 5; long val5 = get();
- assertEquals(val5, (isStableEnabled ? 1 : 5));
+ assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+ : 5));
c.v[0][0][0] = new long[1]; c.v[0][0][0][0] = 6; long val6 = get();
- assertEquals(val6, (isStableEnabled ? 1 : 6));
+ assertEquals(val6, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+ : 6));
}
{
c.v = new long[1][1][1][1]; long[] val1 = get1();
c.v[0][0][0] = new long[1]; long[] val2 = get1();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
c.v = new long[1][1][1][1]; long[][] val1 = get2();
c.v[0][0] = new long[1][1]; long[][] val2 = get2();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
c.v = new long[1][1][1][1]; long[][][] val1 = get3();
c.v[0] = new long[1][1][1]; long[][][] val2 = get3();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
@@ -350,13 +392,11 @@
c.v = new long[1][1][1][1]; long[][][][] val2 = get4();
assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
}
-
}
}
/* ==================================================== */
// Dynamic Dim is higher than static
-
static class ObjectArrayLowerDim0 {
public @Stable Object v;
@@ -404,7 +444,7 @@
c.v = new long[1][1]; c.v[0] = new long[0]; long[] val1 = get1();
c.v[0] = new long[0]; long[] val2 = get1();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
@@ -440,14 +480,14 @@
c.v = new long[1][1][1]; c.v[0][0] = new long[0]; long[] val1 = get1();
c.v[0][0] = new long[0]; long[] val2 = get1();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
c.v = new long[1][1][1]; c.v[0] = new long[0][0]; long[][] val1 = get2();
c.v[0] = new long[0][0]; long[][] val2 = get2();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
@@ -582,7 +622,7 @@
elem.a = 2; long val3 = get(); long val4 = get1();
assertEquals(val1, 1);
- assertEquals(val3, (isStableEnabled ? 1 : 2));
+ assertEquals(val3, (isServerWithStable ? 1 : 2));
assertEquals(val2, 1);
assertEquals(val4, 2);
@@ -616,17 +656,4 @@
}
}
}
-
- static final boolean isStableEnabled;
- static {
- HotSpotDiagnosticMXBean diagnostic
- = ManagementFactoryHelper.getDiagnosticMXBean();
- VMOption tmp;
- try {
- tmp = diagnostic.getVMOption("FoldStableValues");
- } catch (IllegalArgumentException e) {
- tmp = null;
- }
- isStableEnabled = (tmp == null ? false : Boolean.parseBoolean(tmp.getValue()));
- }
}
--- a/hotspot/test/compiler/stable/TestStableObject.java Mon Jul 14 03:24:35 2014 -0700
+++ b/hotspot/test/compiler/stable/TestStableObject.java Mon Jul 14 03:25:40 2014 -0700
@@ -26,9 +26,11 @@
/*
* @test TestStableObject
* @summary tests on stable fields and arrays
- * @library /testlibrary
- * @compile -XDignore.symbol.file TestStableObject.java
+ * @library /testlibrary /testlibrary/whitebox
+ * @build TestStableObject StableConfiguration sun.hotspot.WhiteBox
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
* @run main ClassFileInstaller
+ * java/lang/invoke/StableConfiguration
* java/lang/invoke/TestStableObject
* java/lang/invoke/TestStableObject$ObjectStable
* java/lang/invoke/TestStableObject$StaticObjectStable
@@ -49,46 +51,60 @@
* java/lang/invoke/TestStableObject$NestedStableField3$A
* java/lang/invoke/TestStableObject$Values
* java/lang/invoke/TestStableObject$DefaultValue
+ * java/lang/invoke/TestStableObject$DefaultStaticValue
* java/lang/invoke/TestStableObject$ObjectArrayLowerDim2
*
* @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- * -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:+UseCompressedOop
- * -server -XX:-TieredCompilation -Xcomp
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ * -server -XX:-TieredCompilation
+ * -XX:+FoldStableValues
+ * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ * java.lang.invoke.TestStableObject
+ * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ * -server -XX:-TieredCompilation
+ * -XX:-FoldStableValues
* -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
* java.lang.invoke.TestStableObject
*
* @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- * -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:-UseCompressedOop
- * -server -XX:-TieredCompilation -Xcomp
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ * -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1
+ * -XX:+FoldStableValues
+ * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ * java.lang.invoke.TestStableObject
+ * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ * -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1
+ * -XX:-FoldStableValues
* -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
* java.lang.invoke.TestStableObject
*
* @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- * -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:+UseCompressedOop
- * -server -XX:-TieredCompilation -Xcomp
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ * -client -XX:-TieredCompilation
+ * -XX:+FoldStableValues
* -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
* java.lang.invoke.TestStableObject
- *
* @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- * -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:-UseCompressedOop
- * -server -XX:-TieredCompilation -Xcomp
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ * -client -XX:-TieredCompilation
+ * -XX:-FoldStableValues
* -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
* java.lang.invoke.TestStableObject
*/
package java.lang.invoke;
-import com.sun.management.HotSpotDiagnosticMXBean;
-import com.sun.management.VMOption;
-import sun.management.ManagementFactoryHelper;
import java.lang.reflect.InvocationTargetException;
public class TestStableObject {
+ static final boolean isStableEnabled = StableConfiguration.isStableEnabled;
+ static final boolean isServerWithStable = StableConfiguration.isServerWithStable;
+
public static void main(String[] args) throws Exception {
- System.out.println("@Stable enabled: "+isStableEnabled);
- System.out.println();
-
run(DefaultValue.class);
run(ObjectStable.class);
+ run(DefaultStaticValue.class);
run(StaticObjectStable.class);
run(VolatileObjectStable.class);
@@ -148,6 +164,21 @@
/* ==================================================== */
+ static class DefaultStaticValue {
+ public static @Stable Object v;
+
+ public static final DefaultStaticValue c = new DefaultStaticValue();
+ public static Object get() { return c.v; }
+ public static void test() throws Exception {
+ Object val1 = get();
+ c.v = Values.A; Object val2 = get();
+ assertEquals(val1, null);
+ assertEquals(val2, Values.A);
+ }
+ }
+
+ /* ==================================================== */
+
static class StaticObjectStable {
public static @Stable Values v;
@@ -191,20 +222,22 @@
c.v = new Object[1]; c.v[0] = Values.A; Object val1 = get();
c.v[0] = Values.B; Object val2 = get();
assertEquals(val1, Values.A);
- assertEquals(val2, (isStableEnabled ? Values.A : Values.B));
+ assertEquals(val2, (isServerWithStable ? Values.A : Values.B));
c.v = new Object[1]; c.v[0] = Values.C; Object val3 = get();
- assertEquals(val3, (isStableEnabled ? Values.A : Values.C));
+ assertEquals(val3, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B)
+ : Values.C));
}
{
c.v = new Object[20]; c.v[10] = Values.A; Object val1 = get1();
c.v[10] = Values.B; Object val2 = get1();
assertEquals(val1, Values.A);
- assertEquals(val2, (isStableEnabled ? Values.A : Values.B));
+ assertEquals(val2, (isServerWithStable ? Values.A : Values.B));
c.v = new Object[20]; c.v[10] = Values.C; Object val3 = get1();
- assertEquals(val3, (isStableEnabled ? Values.A : Values.C));
+ assertEquals(val3, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B)
+ : Values.C));
}
{
@@ -229,19 +262,21 @@
c.v = new Object[1][1]; c.v[0][0] = Values.A; Object val1 = get();
c.v[0][0] = Values.B; Object val2 = get();
assertEquals(val1, Values.A);
- assertEquals(val2, (isStableEnabled ? Values.A : Values.B));
+ assertEquals(val2, (isServerWithStable ? Values.A : Values.B));
c.v = new Object[1][1]; c.v[0][0] = Values.C; Object val3 = get();
- assertEquals(val3, (isStableEnabled ? Values.A : Values.C));
+ assertEquals(val3, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B)
+ : Values.C));
c.v[0] = new Object[1]; c.v[0][0] = Values.D; Object val4 = get();
- assertEquals(val4, (isStableEnabled ? Values.A : Values.D));
+ assertEquals(val4, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B)
+ : Values.D));
}
{
c.v = new Object[1][1]; Object[] val1 = get1();
c.v[0] = new Object[1]; Object[] val2 = get1();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
@@ -267,28 +302,31 @@
c.v = new Object[1][1][1]; c.v[0][0][0] = Values.A; Object val1 = get();
c.v[0][0][0] = Values.B; Object val2 = get();
assertEquals(val1, Values.A);
- assertEquals(val2, (isStableEnabled ? Values.A : Values.B));
+ assertEquals(val2, (isServerWithStable ? Values.A : Values.B));
c.v = new Object[1][1][1]; c.v[0][0][0] = Values.C; Object val3 = get();
- assertEquals(val3, (isStableEnabled ? Values.A : Values.C));
+ assertEquals(val3, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B)
+ : Values.C));
c.v[0] = new Object[1][1]; c.v[0][0][0] = Values.D; Object val4 = get();
- assertEquals(val4, (isStableEnabled ? Values.A : Values.D));
+ assertEquals(val4, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B)
+ : Values.D));
c.v[0][0] = new Object[1]; c.v[0][0][0] = Values.E; Object val5 = get();
- assertEquals(val5, (isStableEnabled ? Values.A : Values.E));
+ assertEquals(val5, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B)
+ : Values.E));
}
{
c.v = new Object[1][1][1]; Object[] val1 = get1();
c.v[0][0] = new Object[1]; Object[] val2 = get1();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
c.v = new Object[1][1][1]; Object[][] val1 = get2();
c.v[0] = new Object[1][1]; Object[][] val2 = get2();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
@@ -315,37 +353,41 @@
c.v = new Object[1][1][1][1]; c.v[0][0][0][0] = Values.A; Object val1 = get();
c.v[0][0][0][0] = Values.B; Object val2 = get();
assertEquals(val1, Values.A);
- assertEquals(val2, (isStableEnabled ? Values.A : Values.B));
+ assertEquals(val2, (isServerWithStable ? Values.A : Values.B));
c.v = new Object[1][1][1][1]; c.v[0][0][0][0] = Values.C; Object val3 = get();
- assertEquals(val3, (isStableEnabled ? Values.A : Values.C));
+ assertEquals(val3, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B)
+ : Values.C));
c.v[0] = new Object[1][1][1]; c.v[0][0][0][0] = Values.D; Object val4 = get();
- assertEquals(val4, (isStableEnabled ? Values.A : Values.D));
+ assertEquals(val4, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B)
+ : Values.D));
c.v[0][0] = new Object[1][1]; c.v[0][0][0][0] = Values.E; Object val5 = get();
- assertEquals(val5, (isStableEnabled ? Values.A : Values.E));
+ assertEquals(val5, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B)
+ : Values.E));
c.v[0][0][0] = new Object[1]; c.v[0][0][0][0] = Values.F; Object val6 = get();
- assertEquals(val6, (isStableEnabled ? Values.A : Values.F));
+ assertEquals(val6, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B)
+ : Values.F));
}
{
c.v = new Object[1][1][1][1]; Object[] val1 = get1();
c.v[0][0][0] = new Object[1]; Object[] val2 = get1();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
c.v = new Object[1][1][1][1]; Object[][] val1 = get2();
c.v[0][0] = new Object[1][1]; Object[][] val2 = get2();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
c.v = new Object[1][1][1][1]; Object[][][] val1 = get3();
c.v[0] = new Object[1][1][1]; Object[][][] val2 = get3();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
@@ -353,13 +395,11 @@
c.v = new Object[1][1][1][1]; Object[][][][] val2 = get4();
assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
}
-
}
}
/* ==================================================== */
// Dynamic Dim is higher than static
-
static class ObjectArrayLowerDim0 {
public @Stable Object v;
@@ -407,7 +447,7 @@
c.v = new Object[1][1]; c.v[0] = new Object[0]; Object[] val1 = get1();
c.v[0] = new Object[0]; Object[] val2 = get1();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
@@ -443,14 +483,14 @@
c.v = new Object[1][1][1]; c.v[0][0] = new Object[0]; Object[] val1 = get1();
c.v[0][0] = new Object[0]; Object[] val2 = get1();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
c.v = new Object[1][1][1]; c.v[0] = new Object[0][0]; Object[][] val1 = get2();
c.v[0] = new Object[0][0]; Object[][] val2 = get2();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
@@ -585,7 +625,7 @@
elem.a = Values.B; Object val3 = get(); Object val4 = get1();
assertEquals(val1, Values.A);
- assertEquals(val3, (isStableEnabled ? Values.A : Values.B));
+ assertEquals(val3, (isServerWithStable ? Values.A : Values.B));
assertEquals(val2, Values.A);
assertEquals(val4, Values.B);
@@ -619,17 +659,4 @@
}
}
}
-
- static final boolean isStableEnabled;
- static {
- HotSpotDiagnosticMXBean diagnostic
- = ManagementFactoryHelper.getDiagnosticMXBean();
- VMOption tmp;
- try {
- tmp = diagnostic.getVMOption("FoldStableValues");
- } catch (IllegalArgumentException e) {
- tmp = null;
- }
- isStableEnabled = (tmp == null ? false : Boolean.parseBoolean(tmp.getValue()));
- }
}
--- a/hotspot/test/compiler/stable/TestStableShort.java Mon Jul 14 03:24:35 2014 -0700
+++ b/hotspot/test/compiler/stable/TestStableShort.java Mon Jul 14 03:25:40 2014 -0700
@@ -26,9 +26,11 @@
/*
* @test TestStableShort
* @summary tests on stable fields and arrays
- * @library /testlibrary
- * @compile -XDignore.symbol.file TestStableShort.java
+ * @library /testlibrary /testlibrary/whitebox
+ * @build TestStableShort StableConfiguration sun.hotspot.WhiteBox
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
* @run main ClassFileInstaller
+ * java/lang/invoke/StableConfiguration
* java/lang/invoke/TestStableShort
* java/lang/invoke/TestStableShort$ShortStable
* java/lang/invoke/TestStableShort$StaticShortStable
@@ -48,46 +50,60 @@
* java/lang/invoke/TestStableShort$NestedStableField3
* java/lang/invoke/TestStableShort$NestedStableField3$A
* java/lang/invoke/TestStableShort$DefaultValue
+ * java/lang/invoke/TestStableShort$DefaultStaticValue
* java/lang/invoke/TestStableShort$ObjectArrayLowerDim2
*
* @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- * -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:+UseCompressedOop
- * -server -XX:-TieredCompilation -Xcomp
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ * -server -XX:-TieredCompilation
+ * -XX:+FoldStableValues
+ * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ * java.lang.invoke.TestStableShort
+ * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ * -server -XX:-TieredCompilation
+ * -XX:-FoldStableValues
* -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
* java.lang.invoke.TestStableShort
*
* @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- * -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:-UseCompressedOop
- * -server -XX:-TieredCompilation -Xcomp
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ * -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1
+ * -XX:+FoldStableValues
+ * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ * java.lang.invoke.TestStableShort
+ * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ * -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1
+ * -XX:-FoldStableValues
* -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
* java.lang.invoke.TestStableShort
*
* @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- * -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:+UseCompressedOop
- * -server -XX:-TieredCompilation -Xcomp
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ * -client -XX:-TieredCompilation
+ * -XX:+FoldStableValues
* -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
* java.lang.invoke.TestStableShort
- *
* @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- * -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:-UseCompressedOop
- * -server -XX:-TieredCompilation -Xcomp
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ * -client -XX:-TieredCompilation
+ * -XX:-FoldStableValues
* -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
* java.lang.invoke.TestStableShort
*/
package java.lang.invoke;
-import com.sun.management.HotSpotDiagnosticMXBean;
-import com.sun.management.VMOption;
-import sun.management.ManagementFactoryHelper;
import java.lang.reflect.InvocationTargetException;
public class TestStableShort {
+ static final boolean isStableEnabled = StableConfiguration.isStableEnabled;
+ static final boolean isServerWithStable = StableConfiguration.isServerWithStable;
+
public static void main(String[] args) throws Exception {
- System.out.println("@Stable enabled: "+isStableEnabled);
- System.out.println();
-
run(DefaultValue.class);
run(ShortStable.class);
+ run(DefaultStaticValue.class);
run(StaticShortStable.class);
run(VolatileShortStable.class);
@@ -145,6 +161,21 @@
/* ==================================================== */
+ static class DefaultStaticValue {
+ public static @Stable short v;
+
+ public static final DefaultStaticValue c = new DefaultStaticValue();
+ public static short get() { return c.v; }
+ public static void test() throws Exception {
+ short val1 = get();
+ c.v = 1; short val2 = get();
+ assertEquals(val1, 0);
+ assertEquals(val2, 1);
+ }
+ }
+
+ /* ==================================================== */
+
static class StaticShortStable {
public static @Stable short v;
@@ -188,20 +219,22 @@
c.v = new short[1]; c.v[0] = 1; short val1 = get();
c.v[0] = 2; short val2 = get();
assertEquals(val1, 1);
- assertEquals(val2, (isStableEnabled ? 1 : 2));
+ assertEquals(val2, (isServerWithStable ? 1 : 2));
c.v = new short[1]; c.v[0] = 3; short val3 = get();
- assertEquals(val3, (isStableEnabled ? 1 : 3));
+ assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+ : 3));
}
{
c.v = new short[20]; c.v[10] = 1; short val1 = get1();
c.v[10] = 2; short val2 = get1();
assertEquals(val1, 1);
- assertEquals(val2, (isStableEnabled ? 1 : 2));
+ assertEquals(val2, (isServerWithStable ? 1 : 2));
c.v = new short[20]; c.v[10] = 3; short val3 = get1();
- assertEquals(val3, (isStableEnabled ? 1 : 3));
+ assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+ : 3));
}
{
@@ -226,19 +259,21 @@
c.v = new short[1][1]; c.v[0][0] = 1; short val1 = get();
c.v[0][0] = 2; short val2 = get();
assertEquals(val1, 1);
- assertEquals(val2, (isStableEnabled ? 1 : 2));
+ assertEquals(val2, (isServerWithStable ? 1 : 2));
c.v = new short[1][1]; c.v[0][0] = 3; short val3 = get();
- assertEquals(val3, (isStableEnabled ? 1 : 3));
+ assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+ : 3));
c.v[0] = new short[1]; c.v[0][0] = 4; short val4 = get();
- assertEquals(val4, (isStableEnabled ? 1 : 4));
+ assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+ : 4));
}
{
c.v = new short[1][1]; short[] val1 = get1();
c.v[0] = new short[1]; short[] val2 = get1();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
@@ -264,28 +299,31 @@
c.v = new short[1][1][1]; c.v[0][0][0] = 1; short val1 = get();
c.v[0][0][0] = 2; short val2 = get();
assertEquals(val1, 1);
- assertEquals(val2, (isStableEnabled ? 1 : 2));
+ assertEquals(val2, (isServerWithStable ? 1 : 2));
c.v = new short[1][1][1]; c.v[0][0][0] = 3; short val3 = get();
- assertEquals(val3, (isStableEnabled ? 1 : 3));
+ assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+ : 3));
c.v[0] = new short[1][1]; c.v[0][0][0] = 4; short val4 = get();
- assertEquals(val4, (isStableEnabled ? 1 : 4));
+ assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+ : 4));
c.v[0][0] = new short[1]; c.v[0][0][0] = 5; short val5 = get();
- assertEquals(val5, (isStableEnabled ? 1 : 5));
+ assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+ : 5));
}
{
c.v = new short[1][1][1]; short[] val1 = get1();
c.v[0][0] = new short[1]; short[] val2 = get1();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
c.v = new short[1][1][1]; short[][] val1 = get2();
c.v[0] = new short[1][1]; short[][] val2 = get2();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
@@ -312,37 +350,41 @@
c.v = new short[1][1][1][1]; c.v[0][0][0][0] = 1; short val1 = get();
c.v[0][0][0][0] = 2; short val2 = get();
assertEquals(val1, 1);
- assertEquals(val2, (isStableEnabled ? 1 : 2));
+ assertEquals(val2, (isServerWithStable ? 1 : 2));
c.v = new short[1][1][1][1]; c.v[0][0][0][0] = 3; short val3 = get();
- assertEquals(val3, (isStableEnabled ? 1 : 3));
+ assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+ : 3));
c.v[0] = new short[1][1][1]; c.v[0][0][0][0] = 4; short val4 = get();
- assertEquals(val4, (isStableEnabled ? 1 : 4));
+ assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+ : 4));
c.v[0][0] = new short[1][1]; c.v[0][0][0][0] = 5; short val5 = get();
- assertEquals(val5, (isStableEnabled ? 1 : 5));
+ assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+ : 5));
c.v[0][0][0] = new short[1]; c.v[0][0][0][0] = 6; short val6 = get();
- assertEquals(val6, (isStableEnabled ? 1 : 6));
+ assertEquals(val6, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+ : 6));
}
{
c.v = new short[1][1][1][1]; short[] val1 = get1();
c.v[0][0][0] = new short[1]; short[] val2 = get1();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
c.v = new short[1][1][1][1]; short[][] val1 = get2();
c.v[0][0] = new short[1][1]; short[][] val2 = get2();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
c.v = new short[1][1][1][1]; short[][][] val1 = get3();
c.v[0] = new short[1][1][1]; short[][][] val2 = get3();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
@@ -350,13 +392,11 @@
c.v = new short[1][1][1][1]; short[][][][] val2 = get4();
assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
}
-
}
}
/* ==================================================== */
// Dynamic Dim is higher than static
-
static class ObjectArrayLowerDim0 {
public @Stable Object v;
@@ -404,7 +444,7 @@
c.v = new short[1][1]; c.v[0] = new short[0]; short[] val1 = get1();
c.v[0] = new short[0]; short[] val2 = get1();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
@@ -440,14 +480,14 @@
c.v = new short[1][1][1]; c.v[0][0] = new short[0]; short[] val1 = get1();
c.v[0][0] = new short[0]; short[] val2 = get1();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
c.v = new short[1][1][1]; c.v[0] = new short[0][0]; short[][] val1 = get2();
c.v[0] = new short[0][0]; short[][] val2 = get2();
- assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+ assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
}
{
@@ -582,7 +622,7 @@
elem.a = 2; short val3 = get(); short val4 = get1();
assertEquals(val1, 1);
- assertEquals(val3, (isStableEnabled ? 1 : 2));
+ assertEquals(val3, (isServerWithStable ? 1 : 2));
assertEquals(val2, 1);
assertEquals(val4, 2);
@@ -616,17 +656,4 @@
}
}
}
-
- static final boolean isStableEnabled;
- static {
- HotSpotDiagnosticMXBean diagnostic
- = ManagementFactoryHelper.getDiagnosticMXBean();
- VMOption tmp;
- try {
- tmp = diagnostic.getVMOption("FoldStableValues");
- } catch (IllegalArgumentException e) {
- tmp = null;
- }
- isStableEnabled = (tmp == null ? false : Boolean.parseBoolean(tmp.getValue()));
- }
}