Thu, 10 Jul 2014 12:04:43 -0700
8043546: C1 optimizes @Stable instance fields with default values
Reviewed-by: kvn, jrose
1.1 --- a/src/share/vm/c1/c1_GraphBuilder.cpp Wed Jul 02 22:54:18 2014 +0200 1.2 +++ b/src/share/vm/c1/c1_GraphBuilder.cpp Thu Jul 10 12:04:43 2014 -0700 1.3 @@ -1569,6 +1569,7 @@ 1.4 default: 1.5 constant = new Constant(as_ValueType(field_val)); 1.6 } 1.7 + // Stable static fields are checked for non-default values in ciField::initialize_from(). 1.8 } 1.9 if (constant != NULL) { 1.10 push(type, append(constant)); 1.11 @@ -1610,6 +1611,10 @@ 1.12 default: 1.13 constant = new Constant(as_ValueType(field_val)); 1.14 } 1.15 + if (FoldStableValues && field->is_stable() && field_val.is_null_or_zero()) { 1.16 + // Stable field with default value can't be constant. 1.17 + constant = NULL; 1.18 + } 1.19 } else { 1.20 // For CallSite objects treat the target field as a compile time constant. 1.21 if (const_oop->is_call_site()) {
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/test/compiler/stable/StableConfiguration.java Thu Jul 10 12:04:43 2014 -0700 2.3 @@ -0,0 +1,62 @@ 2.4 +/* 2.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 2.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2.7 + * 2.8 + * This code is free software; you can redistribute it and/or modify it 2.9 + * under the terms of the GNU General Public License version 2 only, as 2.10 + * published by the Free Software Foundation. Oracle designates this 2.11 + * particular file as subject to the "Classpath" exception as provided 2.12 + * by Oracle in the LICENSE file that accompanied this code. 2.13 + * 2.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 2.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 2.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 2.17 + * version 2 for more details (a copy is included in the LICENSE file that 2.18 + * accompanied this code). 2.19 + * 2.20 + * You should have received a copy of the GNU General Public License version 2.21 + * 2 along with this work; if not, write to the Free Software Foundation, 2.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2.23 + * 2.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2.25 + * or visit www.oracle.com if you need additional information or have any 2.26 + * questions. 2.27 + */ 2.28 +package java.lang.invoke; 2.29 + 2.30 +import java.lang.reflect.Method; 2.31 +import java.util.Properties; 2.32 +import sun.hotspot.WhiteBox; 2.33 + 2.34 +public class StableConfiguration { 2.35 + static final WhiteBox WB = WhiteBox.getWhiteBox(); 2.36 + static final boolean isStableEnabled; 2.37 + static final boolean isServerWithStable; 2.38 + 2.39 + static { 2.40 + Boolean value = WB.getBooleanVMFlag("FoldStableValues"); 2.41 + isStableEnabled = (value == null ? false : value); 2.42 + isServerWithStable = isStableEnabled && get(); 2.43 + System.out.println("@Stable: " + (isStableEnabled ? "enabled" : "disabled")); 2.44 + System.out.println("Server Compiler: " + get()); 2.45 + } 2.46 + 2.47 + // ::get() is among immediately compiled methods. 2.48 + static boolean get() { 2.49 + try { 2.50 + Method m = StableConfiguration.class.getDeclaredMethod("get"); 2.51 + int level = WB.getMethodCompilationLevel(m); 2.52 + if (level > 0) { 2.53 + return (level == 4); 2.54 + } else { 2.55 + String javaVM = System.getProperty("java.vm.name", ""); 2.56 + if (javaVM.contains("Server")) return true; 2.57 + if (javaVM.contains("Client")) return false; 2.58 + throw new Error("Unknown VM type: "+javaVM); 2.59 + } 2.60 + } catch (NoSuchMethodException e) { 2.61 + throw new Error(e); 2.62 + } 2.63 + } 2.64 + 2.65 +}
3.1 --- a/test/compiler/stable/TestStableBoolean.java Wed Jul 02 22:54:18 2014 +0200 3.2 +++ b/test/compiler/stable/TestStableBoolean.java Thu Jul 10 12:04:43 2014 -0700 3.3 @@ -26,9 +26,11 @@ 3.4 /* 3.5 * @test TestStableBoolean 3.6 * @summary tests on stable fields and arrays 3.7 - * @library /testlibrary 3.8 - * @compile -XDignore.symbol.file TestStableBoolean.java 3.9 + * @library /testlibrary /testlibrary/whitebox 3.10 + * @build TestStableBoolean StableConfiguration sun.hotspot.WhiteBox 3.11 + * @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission 3.12 * @run main ClassFileInstaller 3.13 + * java/lang/invoke/StableConfiguration 3.14 * java/lang/invoke/TestStableBoolean 3.15 * java/lang/invoke/TestStableBoolean$BooleanStable 3.16 * java/lang/invoke/TestStableBoolean$StaticBooleanStable 3.17 @@ -48,46 +50,60 @@ 3.18 * java/lang/invoke/TestStableBoolean$NestedStableField3 3.19 * java/lang/invoke/TestStableBoolean$NestedStableField3$A 3.20 * java/lang/invoke/TestStableBoolean$DefaultValue 3.21 + * java/lang/invoke/TestStableBoolean$DefaultStaticValue 3.22 * java/lang/invoke/TestStableBoolean$ObjectArrayLowerDim2 3.23 * 3.24 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 3.25 - * -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:+UseCompressedOop 3.26 - * -server -XX:-TieredCompilation -Xcomp 3.27 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 3.28 + * -server -XX:-TieredCompilation 3.29 + * -XX:+FoldStableValues 3.30 + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 3.31 + * java.lang.invoke.TestStableBoolean 3.32 + * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 3.33 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 3.34 + * -server -XX:-TieredCompilation 3.35 + * -XX:-FoldStableValues 3.36 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 3.37 * java.lang.invoke.TestStableBoolean 3.38 * 3.39 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 3.40 - * -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:-UseCompressedOop 3.41 - * -server -XX:-TieredCompilation -Xcomp 3.42 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 3.43 + * -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1 3.44 + * -XX:+FoldStableValues 3.45 + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 3.46 + * java.lang.invoke.TestStableBoolean 3.47 + * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 3.48 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 3.49 + * -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1 3.50 + * -XX:-FoldStableValues 3.51 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 3.52 * java.lang.invoke.TestStableBoolean 3.53 * 3.54 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 3.55 - * -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:+UseCompressedOop 3.56 - * -server -XX:-TieredCompilation -Xcomp 3.57 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 3.58 + * -client -XX:-TieredCompilation 3.59 + * -XX:+FoldStableValues 3.60 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 3.61 * java.lang.invoke.TestStableBoolean 3.62 - * 3.63 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 3.64 - * -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:-UseCompressedOop 3.65 - * -server -XX:-TieredCompilation -Xcomp 3.66 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 3.67 + * -client -XX:-TieredCompilation 3.68 + * -XX:-FoldStableValues 3.69 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 3.70 * java.lang.invoke.TestStableBoolean 3.71 */ 3.72 package java.lang.invoke; 3.73 3.74 -import com.sun.management.HotSpotDiagnosticMXBean; 3.75 -import com.sun.management.VMOption; 3.76 -import sun.management.ManagementFactoryHelper; 3.77 import java.lang.reflect.InvocationTargetException; 3.78 3.79 public class TestStableBoolean { 3.80 + static final boolean isStableEnabled = StableConfiguration.isStableEnabled; 3.81 + static final boolean isServerWithStable = StableConfiguration.isServerWithStable; 3.82 + 3.83 public static void main(String[] args) throws Exception { 3.84 - System.out.println("@Stable enabled: "+isStableEnabled); 3.85 - System.out.println(); 3.86 - 3.87 run(DefaultValue.class); 3.88 run(BooleanStable.class); 3.89 + run(DefaultStaticValue.class); 3.90 run(StaticBooleanStable.class); 3.91 run(VolatileBooleanStable.class); 3.92 3.93 @@ -145,6 +161,21 @@ 3.94 3.95 /* ==================================================== */ 3.96 3.97 + static class DefaultStaticValue { 3.98 + public static @Stable boolean v; 3.99 + 3.100 + public static final DefaultStaticValue c = new DefaultStaticValue(); 3.101 + public static boolean get() { return c.v; } 3.102 + public static void test() throws Exception { 3.103 + boolean val1 = get(); 3.104 + c.v = true; boolean val2 = get(); 3.105 + assertEquals(val1, false); 3.106 + assertEquals(val2, true); 3.107 + } 3.108 + } 3.109 + 3.110 + /* ==================================================== */ 3.111 + 3.112 static class StaticBooleanStable { 3.113 public static @Stable boolean v; 3.114 3.115 @@ -188,14 +219,14 @@ 3.116 c.v = new boolean[1]; c.v[0] = true; boolean val1 = get(); 3.117 c.v[0] = false; boolean val2 = get(); 3.118 assertEquals(val1, true); 3.119 - assertEquals(val2, (isStableEnabled ? true : false)); 3.120 + assertEquals(val2, (isServerWithStable ? true : false)); 3.121 } 3.122 3.123 { 3.124 c.v = new boolean[20]; c.v[10] = true; boolean val1 = get1(); 3.125 c.v[10] = false; boolean val2 = get1(); 3.126 assertEquals(val1, true); 3.127 - assertEquals(val2, (isStableEnabled ? true : false)); 3.128 + assertEquals(val2, (isServerWithStable ? true : false)); 3.129 } 3.130 3.131 { 3.132 @@ -220,19 +251,19 @@ 3.133 c.v = new boolean[1][1]; c.v[0][0] = true; boolean val1 = get(); 3.134 c.v[0][0] = false; boolean val2 = get(); 3.135 assertEquals(val1, true); 3.136 - assertEquals(val2, (isStableEnabled ? true : false)); 3.137 + assertEquals(val2, (isServerWithStable ? true : false)); 3.138 3.139 c.v = new boolean[1][1]; c.v[0][0] = false; boolean val3 = get(); 3.140 - assertEquals(val3, (isStableEnabled ? true : false)); 3.141 + assertEquals(val3, (isServerWithStable ? true : false)); 3.142 3.143 c.v[0] = new boolean[1]; c.v[0][0] = false; boolean val4 = get(); 3.144 - assertEquals(val4, (isStableEnabled ? true : false)); 3.145 + assertEquals(val4, (isServerWithStable ? true : false)); 3.146 } 3.147 3.148 { 3.149 c.v = new boolean[1][1]; boolean[] val1 = get1(); 3.150 c.v[0] = new boolean[1]; boolean[] val2 = get1(); 3.151 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 3.152 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 3.153 } 3.154 3.155 { 3.156 @@ -258,28 +289,28 @@ 3.157 c.v = new boolean[1][1][1]; c.v[0][0][0] = true; boolean val1 = get(); 3.158 c.v[0][0][0] = false; boolean val2 = get(); 3.159 assertEquals(val1, true); 3.160 - assertEquals(val2, (isStableEnabled ? true : false)); 3.161 + assertEquals(val2, (isServerWithStable ? true : false)); 3.162 3.163 c.v = new boolean[1][1][1]; c.v[0][0][0] = false; boolean val3 = get(); 3.164 - assertEquals(val3, (isStableEnabled ? true : false)); 3.165 + assertEquals(val3, (isServerWithStable ? true : false)); 3.166 3.167 c.v[0] = new boolean[1][1]; c.v[0][0][0] = false; boolean val4 = get(); 3.168 - assertEquals(val4, (isStableEnabled ? true : false)); 3.169 + assertEquals(val4, (isServerWithStable ? true : false)); 3.170 3.171 c.v[0][0] = new boolean[1]; c.v[0][0][0] = false; boolean val5 = get(); 3.172 - assertEquals(val5, (isStableEnabled ? true : false)); 3.173 + assertEquals(val5, (isServerWithStable ? true : false)); 3.174 } 3.175 3.176 { 3.177 c.v = new boolean[1][1][1]; boolean[] val1 = get1(); 3.178 c.v[0][0] = new boolean[1]; boolean[] val2 = get1(); 3.179 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 3.180 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 3.181 } 3.182 3.183 { 3.184 c.v = new boolean[1][1][1]; boolean[][] val1 = get2(); 3.185 c.v[0] = new boolean[1][1]; boolean[][] val2 = get2(); 3.186 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 3.187 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 3.188 } 3.189 3.190 { 3.191 @@ -306,37 +337,37 @@ 3.192 c.v = new boolean[1][1][1][1]; c.v[0][0][0][0] = true; boolean val1 = get(); 3.193 c.v[0][0][0][0] = false; boolean val2 = get(); 3.194 assertEquals(val1, true); 3.195 - assertEquals(val2, (isStableEnabled ? true : false)); 3.196 + assertEquals(val2, (isServerWithStable ? true : false)); 3.197 3.198 c.v = new boolean[1][1][1][1]; c.v[0][0][0][0] = false; boolean val3 = get(); 3.199 - assertEquals(val3, (isStableEnabled ? true : false)); 3.200 + assertEquals(val3, (isServerWithStable ? true : false)); 3.201 3.202 c.v[0] = new boolean[1][1][1]; c.v[0][0][0][0] = false; boolean val4 = get(); 3.203 - assertEquals(val4, (isStableEnabled ? true : false)); 3.204 + assertEquals(val4, (isServerWithStable ? true : false)); 3.205 3.206 c.v[0][0] = new boolean[1][1]; c.v[0][0][0][0] = false; boolean val5 = get(); 3.207 - assertEquals(val5, (isStableEnabled ? true : false)); 3.208 + assertEquals(val5, (isServerWithStable ? true : false)); 3.209 3.210 c.v[0][0][0] = new boolean[1]; c.v[0][0][0][0] = false; boolean val6 = get(); 3.211 - assertEquals(val6, (isStableEnabled ? true : false)); 3.212 + assertEquals(val6, (isServerWithStable ? true : false)); 3.213 } 3.214 3.215 { 3.216 c.v = new boolean[1][1][1][1]; boolean[] val1 = get1(); 3.217 c.v[0][0][0] = new boolean[1]; boolean[] val2 = get1(); 3.218 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 3.219 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 3.220 } 3.221 3.222 { 3.223 c.v = new boolean[1][1][1][1]; boolean[][] val1 = get2(); 3.224 c.v[0][0] = new boolean[1][1]; boolean[][] val2 = get2(); 3.225 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 3.226 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 3.227 } 3.228 3.229 { 3.230 c.v = new boolean[1][1][1][1]; boolean[][][] val1 = get3(); 3.231 c.v[0] = new boolean[1][1][1]; boolean[][][] val2 = get3(); 3.232 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 3.233 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 3.234 } 3.235 3.236 { 3.237 @@ -399,7 +430,7 @@ 3.238 c.v = new boolean[1][1]; c.v[0] = new boolean[0]; boolean[] val1 = get1(); 3.239 c.v[0] = new boolean[0]; boolean[] val2 = get1(); 3.240 3.241 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 3.242 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 3.243 } 3.244 3.245 { 3.246 @@ -435,14 +466,14 @@ 3.247 c.v = new boolean[1][1][1]; c.v[0][0] = new boolean[0]; boolean[] val1 = get1(); 3.248 c.v[0][0] = new boolean[0]; boolean[] val2 = get1(); 3.249 3.250 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 3.251 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 3.252 } 3.253 3.254 { 3.255 c.v = new boolean[1][1][1]; c.v[0] = new boolean[0][0]; boolean[][] val1 = get2(); 3.256 c.v[0] = new boolean[0][0]; boolean[][] val2 = get2(); 3.257 3.258 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 3.259 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 3.260 } 3.261 3.262 { 3.263 @@ -577,7 +608,7 @@ 3.264 elem.a = false; boolean val3 = get(); boolean val4 = get1(); 3.265 3.266 assertEquals(val1, true); 3.267 - assertEquals(val3, (isStableEnabled ? true : false)); 3.268 + assertEquals(val3, (isServerWithStable ? true : false)); 3.269 3.270 assertEquals(val2, true); 3.271 assertEquals(val4, false); 3.272 @@ -611,17 +642,4 @@ 3.273 } 3.274 } 3.275 } 3.276 - 3.277 - static final boolean isStableEnabled; 3.278 - static { 3.279 - HotSpotDiagnosticMXBean diagnostic 3.280 - = ManagementFactoryHelper.getDiagnosticMXBean(); 3.281 - VMOption tmp; 3.282 - try { 3.283 - tmp = diagnostic.getVMOption("FoldStableValues"); 3.284 - } catch (IllegalArgumentException e) { 3.285 - tmp = null; 3.286 - } 3.287 - isStableEnabled = (tmp == null ? false : Boolean.parseBoolean(tmp.getValue())); 3.288 - } 3.289 }
4.1 --- a/test/compiler/stable/TestStableByte.java Wed Jul 02 22:54:18 2014 +0200 4.2 +++ b/test/compiler/stable/TestStableByte.java Thu Jul 10 12:04:43 2014 -0700 4.3 @@ -26,9 +26,11 @@ 4.4 /* 4.5 * @test TestStableByte 4.6 * @summary tests on stable fields and arrays 4.7 - * @library /testlibrary 4.8 - * @compile -XDignore.symbol.file TestStableByte.java 4.9 + * @library /testlibrary /testlibrary/whitebox 4.10 + * @build TestStableByte StableConfiguration sun.hotspot.WhiteBox 4.11 + * @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission 4.12 * @run main ClassFileInstaller 4.13 + * java/lang/invoke/StableConfiguration 4.14 * java/lang/invoke/TestStableByte 4.15 * java/lang/invoke/TestStableByte$ByteStable 4.16 * java/lang/invoke/TestStableByte$StaticByteStable 4.17 @@ -48,46 +50,60 @@ 4.18 * java/lang/invoke/TestStableByte$NestedStableField3 4.19 * java/lang/invoke/TestStableByte$NestedStableField3$A 4.20 * java/lang/invoke/TestStableByte$DefaultValue 4.21 + * java/lang/invoke/TestStableByte$DefaultStaticValue 4.22 * java/lang/invoke/TestStableByte$ObjectArrayLowerDim2 4.23 * 4.24 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 4.25 - * -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:+UseCompressedOop 4.26 - * -server -XX:-TieredCompilation -Xcomp 4.27 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 4.28 + * -server -XX:-TieredCompilation 4.29 + * -XX:+FoldStableValues 4.30 + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 4.31 + * java.lang.invoke.TestStableByte 4.32 + * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 4.33 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 4.34 + * -server -XX:-TieredCompilation 4.35 + * -XX:-FoldStableValues 4.36 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 4.37 * java.lang.invoke.TestStableByte 4.38 * 4.39 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 4.40 - * -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:-UseCompressedOop 4.41 - * -server -XX:-TieredCompilation -Xcomp 4.42 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 4.43 + * -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1 4.44 + * -XX:+FoldStableValues 4.45 + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 4.46 + * java.lang.invoke.TestStableByte 4.47 + * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 4.48 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 4.49 + * -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1 4.50 + * -XX:-FoldStableValues 4.51 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 4.52 * java.lang.invoke.TestStableByte 4.53 * 4.54 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 4.55 - * -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:+UseCompressedOop 4.56 - * -server -XX:-TieredCompilation -Xcomp 4.57 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 4.58 + * -client -XX:-TieredCompilation 4.59 + * -XX:+FoldStableValues 4.60 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 4.61 * java.lang.invoke.TestStableByte 4.62 - * 4.63 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 4.64 - * -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:-UseCompressedOop 4.65 - * -server -XX:-TieredCompilation -Xcomp 4.66 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 4.67 + * -client -XX:-TieredCompilation 4.68 + * -XX:-FoldStableValues 4.69 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 4.70 * java.lang.invoke.TestStableByte 4.71 */ 4.72 package java.lang.invoke; 4.73 4.74 -import com.sun.management.HotSpotDiagnosticMXBean; 4.75 -import com.sun.management.VMOption; 4.76 -import sun.management.ManagementFactoryHelper; 4.77 import java.lang.reflect.InvocationTargetException; 4.78 4.79 public class TestStableByte { 4.80 + static final boolean isStableEnabled = StableConfiguration.isStableEnabled; 4.81 + static final boolean isServerWithStable = StableConfiguration.isServerWithStable; 4.82 + 4.83 public static void main(String[] args) throws Exception { 4.84 - System.out.println("@Stable enabled: "+isStableEnabled); 4.85 - System.out.println(); 4.86 - 4.87 run(DefaultValue.class); 4.88 run(ByteStable.class); 4.89 + run(DefaultStaticValue.class); 4.90 run(StaticByteStable.class); 4.91 run(VolatileByteStable.class); 4.92 4.93 @@ -145,6 +161,21 @@ 4.94 4.95 /* ==================================================== */ 4.96 4.97 + static class DefaultStaticValue { 4.98 + public static @Stable byte v; 4.99 + 4.100 + public static final DefaultStaticValue c = new DefaultStaticValue(); 4.101 + public static byte get() { return c.v; } 4.102 + public static void test() throws Exception { 4.103 + byte val1 = get(); 4.104 + c.v = 1; byte val2 = get(); 4.105 + assertEquals(val1, 0); 4.106 + assertEquals(val2, 1); 4.107 + } 4.108 + } 4.109 + 4.110 + /* ==================================================== */ 4.111 + 4.112 static class StaticByteStable { 4.113 public static @Stable byte v; 4.114 4.115 @@ -188,20 +219,22 @@ 4.116 c.v = new byte[1]; c.v[0] = 1; byte val1 = get(); 4.117 c.v[0] = 2; byte val2 = get(); 4.118 assertEquals(val1, 1); 4.119 - assertEquals(val2, (isStableEnabled ? 1 : 2)); 4.120 + assertEquals(val2, (isServerWithStable ? 1 : 2)); 4.121 4.122 c.v = new byte[1]; c.v[0] = 3; byte val3 = get(); 4.123 - assertEquals(val3, (isStableEnabled ? 1 : 3)); 4.124 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2) 4.125 + : 3)); 4.126 } 4.127 4.128 { 4.129 c.v = new byte[20]; c.v[10] = 1; byte val1 = get1(); 4.130 c.v[10] = 2; byte val2 = get1(); 4.131 assertEquals(val1, 1); 4.132 - assertEquals(val2, (isStableEnabled ? 1 : 2)); 4.133 + assertEquals(val2, (isServerWithStable ? 1 : 2)); 4.134 4.135 c.v = new byte[20]; c.v[10] = 3; byte val3 = get1(); 4.136 - assertEquals(val3, (isStableEnabled ? 1 : 3)); 4.137 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2) 4.138 + : 3)); 4.139 } 4.140 4.141 { 4.142 @@ -226,19 +259,21 @@ 4.143 c.v = new byte[1][1]; c.v[0][0] = 1; byte val1 = get(); 4.144 c.v[0][0] = 2; byte val2 = get(); 4.145 assertEquals(val1, 1); 4.146 - assertEquals(val2, (isStableEnabled ? 1 : 2)); 4.147 + assertEquals(val2, (isServerWithStable ? 1 : 2)); 4.148 4.149 c.v = new byte[1][1]; c.v[0][0] = 3; byte val3 = get(); 4.150 - assertEquals(val3, (isStableEnabled ? 1 : 3)); 4.151 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2) 4.152 + : 3)); 4.153 4.154 c.v[0] = new byte[1]; c.v[0][0] = 4; byte val4 = get(); 4.155 - assertEquals(val4, (isStableEnabled ? 1 : 4)); 4.156 + assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2) 4.157 + : 4)); 4.158 } 4.159 4.160 { 4.161 c.v = new byte[1][1]; byte[] val1 = get1(); 4.162 c.v[0] = new byte[1]; byte[] val2 = get1(); 4.163 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 4.164 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 4.165 } 4.166 4.167 { 4.168 @@ -264,28 +299,31 @@ 4.169 c.v = new byte[1][1][1]; c.v[0][0][0] = 1; byte val1 = get(); 4.170 c.v[0][0][0] = 2; byte val2 = get(); 4.171 assertEquals(val1, 1); 4.172 - assertEquals(val2, (isStableEnabled ? 1 : 2)); 4.173 + assertEquals(val2, (isServerWithStable ? 1 : 2)); 4.174 4.175 c.v = new byte[1][1][1]; c.v[0][0][0] = 3; byte val3 = get(); 4.176 - assertEquals(val3, (isStableEnabled ? 1 : 3)); 4.177 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2) 4.178 + : 3)); 4.179 4.180 c.v[0] = new byte[1][1]; c.v[0][0][0] = 4; byte val4 = get(); 4.181 - assertEquals(val4, (isStableEnabled ? 1 : 4)); 4.182 + assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2) 4.183 + : 4)); 4.184 4.185 c.v[0][0] = new byte[1]; c.v[0][0][0] = 5; byte val5 = get(); 4.186 - assertEquals(val5, (isStableEnabled ? 1 : 5)); 4.187 + assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1 : 2) 4.188 + : 5)); 4.189 } 4.190 4.191 { 4.192 c.v = new byte[1][1][1]; byte[] val1 = get1(); 4.193 c.v[0][0] = new byte[1]; byte[] val2 = get1(); 4.194 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 4.195 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 4.196 } 4.197 4.198 { 4.199 c.v = new byte[1][1][1]; byte[][] val1 = get2(); 4.200 c.v[0] = new byte[1][1]; byte[][] val2 = get2(); 4.201 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 4.202 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 4.203 } 4.204 4.205 { 4.206 @@ -312,37 +350,41 @@ 4.207 c.v = new byte[1][1][1][1]; c.v[0][0][0][0] = 1; byte val1 = get(); 4.208 c.v[0][0][0][0] = 2; byte val2 = get(); 4.209 assertEquals(val1, 1); 4.210 - assertEquals(val2, (isStableEnabled ? 1 : 2)); 4.211 + assertEquals(val2, (isServerWithStable ? 1 : 2)); 4.212 4.213 c.v = new byte[1][1][1][1]; c.v[0][0][0][0] = 3; byte val3 = get(); 4.214 - assertEquals(val3, (isStableEnabled ? 1 : 3)); 4.215 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2) 4.216 + : 3)); 4.217 4.218 c.v[0] = new byte[1][1][1]; c.v[0][0][0][0] = 4; byte val4 = get(); 4.219 - assertEquals(val4, (isStableEnabled ? 1 : 4)); 4.220 + assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2) 4.221 + : 4)); 4.222 4.223 c.v[0][0] = new byte[1][1]; c.v[0][0][0][0] = 5; byte val5 = get(); 4.224 - assertEquals(val5, (isStableEnabled ? 1 : 5)); 4.225 + assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1 : 2) 4.226 + : 5)); 4.227 4.228 c.v[0][0][0] = new byte[1]; c.v[0][0][0][0] = 6; byte val6 = get(); 4.229 - assertEquals(val6, (isStableEnabled ? 1 : 6)); 4.230 + assertEquals(val6, (isStableEnabled ? (isServerWithStable ? 1 : 2) 4.231 + : 6)); 4.232 } 4.233 4.234 { 4.235 c.v = new byte[1][1][1][1]; byte[] val1 = get1(); 4.236 c.v[0][0][0] = new byte[1]; byte[] val2 = get1(); 4.237 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 4.238 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 4.239 } 4.240 4.241 { 4.242 c.v = new byte[1][1][1][1]; byte[][] val1 = get2(); 4.243 c.v[0][0] = new byte[1][1]; byte[][] val2 = get2(); 4.244 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 4.245 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 4.246 } 4.247 4.248 { 4.249 c.v = new byte[1][1][1][1]; byte[][][] val1 = get3(); 4.250 c.v[0] = new byte[1][1][1]; byte[][][] val2 = get3(); 4.251 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 4.252 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 4.253 } 4.254 4.255 { 4.256 @@ -404,7 +446,7 @@ 4.257 c.v = new byte[1][1]; c.v[0] = new byte[0]; byte[] val1 = get1(); 4.258 c.v[0] = new byte[0]; byte[] val2 = get1(); 4.259 4.260 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 4.261 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 4.262 } 4.263 4.264 { 4.265 @@ -440,14 +482,14 @@ 4.266 c.v = new byte[1][1][1]; c.v[0][0] = new byte[0]; byte[] val1 = get1(); 4.267 c.v[0][0] = new byte[0]; byte[] val2 = get1(); 4.268 4.269 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 4.270 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 4.271 } 4.272 4.273 { 4.274 c.v = new byte[1][1][1]; c.v[0] = new byte[0][0]; byte[][] val1 = get2(); 4.275 c.v[0] = new byte[0][0]; byte[][] val2 = get2(); 4.276 4.277 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 4.278 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 4.279 } 4.280 4.281 { 4.282 @@ -582,7 +624,7 @@ 4.283 elem.a = 2; byte val3 = get(); byte val4 = get1(); 4.284 4.285 assertEquals(val1, 1); 4.286 - assertEquals(val3, (isStableEnabled ? 1 : 2)); 4.287 + assertEquals(val3, (isServerWithStable ? 1 : 2)); 4.288 4.289 assertEquals(val2, 1); 4.290 assertEquals(val4, 2); 4.291 @@ -616,17 +658,4 @@ 4.292 } 4.293 } 4.294 } 4.295 - 4.296 - static final boolean isStableEnabled; 4.297 - static { 4.298 - HotSpotDiagnosticMXBean diagnostic 4.299 - = ManagementFactoryHelper.getDiagnosticMXBean(); 4.300 - VMOption tmp; 4.301 - try { 4.302 - tmp = diagnostic.getVMOption("FoldStableValues"); 4.303 - } catch (IllegalArgumentException e) { 4.304 - tmp = null; 4.305 - } 4.306 - isStableEnabled = (tmp == null ? false : Boolean.parseBoolean(tmp.getValue())); 4.307 - } 4.308 }
5.1 --- a/test/compiler/stable/TestStableChar.java Wed Jul 02 22:54:18 2014 +0200 5.2 +++ b/test/compiler/stable/TestStableChar.java Thu Jul 10 12:04:43 2014 -0700 5.3 @@ -26,9 +26,11 @@ 5.4 /* 5.5 * @test TestStableChar 5.6 * @summary tests on stable fields and arrays 5.7 - * @library /testlibrary 5.8 - * @compile -XDignore.symbol.file TestStableChar.java 5.9 + * @library /testlibrary /testlibrary/whitebox 5.10 + * @build TestStableChar StableConfiguration sun.hotspot.WhiteBox 5.11 + * @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission 5.12 * @run main ClassFileInstaller 5.13 + * java/lang/invoke/StableConfiguration 5.14 * java/lang/invoke/TestStableChar 5.15 * java/lang/invoke/TestStableChar$CharStable 5.16 * java/lang/invoke/TestStableChar$StaticCharStable 5.17 @@ -48,46 +50,60 @@ 5.18 * java/lang/invoke/TestStableChar$NestedStableField3 5.19 * java/lang/invoke/TestStableChar$NestedStableField3$A 5.20 * java/lang/invoke/TestStableChar$DefaultValue 5.21 + * java/lang/invoke/TestStableChar$DefaultStaticValue 5.22 * java/lang/invoke/TestStableChar$ObjectArrayLowerDim2 5.23 * 5.24 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 5.25 - * -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:-UseCompressedOop 5.26 - * -server -XX:-TieredCompilation -Xcomp 5.27 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 5.28 + * -server -XX:-TieredCompilation 5.29 + * -XX:+FoldStableValues 5.30 + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 5.31 + * java.lang.invoke.TestStableChar 5.32 + * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 5.33 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 5.34 + * -server -XX:-TieredCompilation 5.35 + * -XX:-FoldStableValues 5.36 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 5.37 * java.lang.invoke.TestStableChar 5.38 * 5.39 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 5.40 - * -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:+UseCompressedOop 5.41 - * -server -XX:-TieredCompilation -Xcomp 5.42 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 5.43 + * -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1 5.44 + * -XX:+FoldStableValues 5.45 + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 5.46 + * java.lang.invoke.TestStableChar 5.47 + * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 5.48 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 5.49 + * -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1 5.50 + * -XX:-FoldStableValues 5.51 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 5.52 * java.lang.invoke.TestStableChar 5.53 * 5.54 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 5.55 - * -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:+UseCompressedOop 5.56 - * -server -XX:-TieredCompilation -Xcomp 5.57 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 5.58 + * -client -XX:-TieredCompilation 5.59 + * -XX:+FoldStableValues 5.60 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 5.61 * java.lang.invoke.TestStableChar 5.62 - * 5.63 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 5.64 - * -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:-UseCompressedOop 5.65 - * -server -XX:-TieredCompilation -Xcomp 5.66 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 5.67 + * -client -XX:-TieredCompilation 5.68 + * -XX:-FoldStableValues 5.69 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 5.70 * java.lang.invoke.TestStableChar 5.71 */ 5.72 package java.lang.invoke; 5.73 5.74 -import com.sun.management.HotSpotDiagnosticMXBean; 5.75 -import com.sun.management.VMOption; 5.76 -import sun.management.ManagementFactoryHelper; 5.77 import java.lang.reflect.InvocationTargetException; 5.78 5.79 public class TestStableChar { 5.80 + static final boolean isStableEnabled = StableConfiguration.isStableEnabled; 5.81 + static final boolean isServerWithStable = StableConfiguration.isServerWithStable; 5.82 + 5.83 public static void main(String[] args) throws Exception { 5.84 - System.out.println("@Stable enabled: "+isStableEnabled); 5.85 - System.out.println(); 5.86 - 5.87 run(DefaultValue.class); 5.88 run(CharStable.class); 5.89 + run(DefaultStaticValue.class); 5.90 run(StaticCharStable.class); 5.91 run(VolatileCharStable.class); 5.92 5.93 @@ -145,6 +161,21 @@ 5.94 5.95 /* ==================================================== */ 5.96 5.97 + static class DefaultStaticValue { 5.98 + public static @Stable char v; 5.99 + 5.100 + public static final DefaultStaticValue c = new DefaultStaticValue(); 5.101 + public static char get() { return c.v; } 5.102 + public static void test() throws Exception { 5.103 + char val1 = get(); 5.104 + c.v = 'a'; char val2 = get(); 5.105 + assertEquals(val1, 0); 5.106 + assertEquals(val2, 'a'); 5.107 + } 5.108 + } 5.109 + 5.110 + /* ==================================================== */ 5.111 + 5.112 static class StaticCharStable { 5.113 public @Stable char v; 5.114 5.115 @@ -188,20 +219,22 @@ 5.116 c.v = new char[1]; c.v[0] = 'a'; char val1 = get(); 5.117 c.v[0] = 'b'; char val2 = get(); 5.118 assertEquals(val1, 'a'); 5.119 - assertEquals(val2, (isStableEnabled ? 'a' : 'b')); 5.120 + assertEquals(val2, (isServerWithStable ? 'a' : 'b')); 5.121 5.122 c.v = new char[1]; c.v[0] = 'c'; char val3 = get(); 5.123 - assertEquals(val3, (isStableEnabled ? 'a' : 'c')); 5.124 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 'a' : 'b') 5.125 + : 'c')); 5.126 } 5.127 5.128 { 5.129 c.v = new char[20]; c.v[10] = 'a'; char val1 = get1(); 5.130 c.v[10] = 'b'; char val2 = get1(); 5.131 assertEquals(val1, 'a'); 5.132 - assertEquals(val2, (isStableEnabled ? 'a' : 'b')); 5.133 + assertEquals(val2, (isServerWithStable ? 'a' : 'b')); 5.134 5.135 c.v = new char[20]; c.v[10] = 'c'; char val3 = get1(); 5.136 - assertEquals(val3, (isStableEnabled ? 'a' : 'c')); 5.137 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 'a' : 'b') 5.138 + : 'c')); 5.139 } 5.140 5.141 { 5.142 @@ -226,19 +259,21 @@ 5.143 c.v = new char[1][1]; c.v[0][0] = 'a'; char val1 = get(); 5.144 c.v[0][0] = 'b'; char val2 = get(); 5.145 assertEquals(val1, 'a'); 5.146 - assertEquals(val2, (isStableEnabled ? 'a' : 'b')); 5.147 + assertEquals(val2, (isServerWithStable ? 'a' : 'b')); 5.148 5.149 c.v = new char[1][1]; c.v[0][0] = 'c'; char val3 = get(); 5.150 - assertEquals(val3, (isStableEnabled ? 'a' : 'c')); 5.151 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 'a' : 'b') 5.152 + : 'c')); 5.153 5.154 c.v[0] = new char[1]; c.v[0][0] = 'd'; char val4 = get(); 5.155 - assertEquals(val4, (isStableEnabled ? 'a' : 'd')); 5.156 + assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 'a' : 'b') 5.157 + : 'd')); 5.158 } 5.159 5.160 { 5.161 c.v = new char[1][1]; char[] val1 = get1(); 5.162 c.v[0] = new char[1]; char[] val2 = get1(); 5.163 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 5.164 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 5.165 } 5.166 5.167 { 5.168 @@ -264,28 +299,31 @@ 5.169 c.v = new char[1][1][1]; c.v[0][0][0] = 'a'; char val1 = get(); 5.170 c.v[0][0][0] = 'b'; char val2 = get(); 5.171 assertEquals(val1, 'a'); 5.172 - assertEquals(val2, (isStableEnabled ? 'a' : 'b')); 5.173 + assertEquals(val2, (isServerWithStable ? 'a' : 'b')); 5.174 5.175 c.v = new char[1][1][1]; c.v[0][0][0] = 'c'; char val3 = get(); 5.176 - assertEquals(val3, (isStableEnabled ? 'a' : 'c')); 5.177 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 'a' : 'b') 5.178 + : 'c')); 5.179 5.180 c.v[0] = new char[1][1]; c.v[0][0][0] = 'd'; char val4 = get(); 5.181 - assertEquals(val4, (isStableEnabled ? 'a' : 'd')); 5.182 + assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 'a' : 'b') 5.183 + : 'd')); 5.184 5.185 c.v[0][0] = new char[1]; c.v[0][0][0] = 'e'; char val5 = get(); 5.186 - assertEquals(val5, (isStableEnabled ? 'a' : 'e')); 5.187 + assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 'a' : 'b') 5.188 + : 'e')); 5.189 } 5.190 5.191 { 5.192 c.v = new char[1][1][1]; char[] val1 = get1(); 5.193 c.v[0][0] = new char[1]; char[] val2 = get1(); 5.194 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 5.195 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 5.196 } 5.197 5.198 { 5.199 c.v = new char[1][1][1]; char[][] val1 = get2(); 5.200 c.v[0] = new char[1][1]; char[][] val2 = get2(); 5.201 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 5.202 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 5.203 } 5.204 5.205 { 5.206 @@ -312,37 +350,41 @@ 5.207 c.v = new char[1][1][1][1]; c.v[0][0][0][0] = 'a'; char val1 = get(); 5.208 c.v[0][0][0][0] = 'b'; char val2 = get(); 5.209 assertEquals(val1, 'a'); 5.210 - assertEquals(val2, (isStableEnabled ? 'a' : 'b')); 5.211 + assertEquals(val2, (isServerWithStable ? 'a' : 'b')); 5.212 5.213 c.v = new char[1][1][1][1]; c.v[0][0][0][0] = 'c'; char val3 = get(); 5.214 - assertEquals(val3, (isStableEnabled ? 'a' : 'c')); 5.215 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 'a' : 'b') 5.216 + : 'c')); 5.217 5.218 c.v[0] = new char[1][1][1]; c.v[0][0][0][0] = 'd'; char val4 = get(); 5.219 - assertEquals(val4, (isStableEnabled ? 'a' : 'd')); 5.220 + assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 'a' : 'b') 5.221 + : 'd')); 5.222 5.223 c.v[0][0] = new char[1][1]; c.v[0][0][0][0] = 'e'; char val5 = get(); 5.224 - assertEquals(val5, (isStableEnabled ? 'a' : 'e')); 5.225 + assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 'a' : 'b') 5.226 + : 'e')); 5.227 5.228 c.v[0][0][0] = new char[1]; c.v[0][0][0][0] = 'f'; char val6 = get(); 5.229 - assertEquals(val6, (isStableEnabled ? 'a' : 'f')); 5.230 + assertEquals(val6, (isStableEnabled ? (isServerWithStable ? 'a' : 'b') 5.231 + : 'f')); 5.232 } 5.233 5.234 { 5.235 c.v = new char[1][1][1][1]; char[] val1 = get1(); 5.236 c.v[0][0][0] = new char[1]; char[] val2 = get1(); 5.237 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 5.238 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 5.239 } 5.240 5.241 { 5.242 c.v = new char[1][1][1][1]; char[][] val1 = get2(); 5.243 c.v[0][0] = new char[1][1]; char[][] val2 = get2(); 5.244 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 5.245 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 5.246 } 5.247 5.248 { 5.249 c.v = new char[1][1][1][1]; char[][][] val1 = get3(); 5.250 c.v[0] = new char[1][1][1]; char[][][] val2 = get3(); 5.251 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 5.252 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 5.253 } 5.254 5.255 { 5.256 @@ -350,7 +392,6 @@ 5.257 c.v = new char[1][1][1][1]; char[][][][] val2 = get4(); 5.258 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 5.259 } 5.260 - 5.261 } 5.262 } 5.263 5.264 @@ -403,7 +444,7 @@ 5.265 c.v = new char[1][1]; c.v[0] = new char[0]; char[] val1 = get1(); 5.266 c.v[0] = new char[0]; char[] val2 = get1(); 5.267 5.268 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 5.269 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 5.270 } 5.271 5.272 { 5.273 @@ -439,14 +480,14 @@ 5.274 c.v = new char[1][1][1]; c.v[0][0] = new char[0]; char[] val1 = get1(); 5.275 c.v[0][0] = new char[0]; char[] val2 = get1(); 5.276 5.277 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 5.278 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 5.279 } 5.280 5.281 { 5.282 c.v = new char[1][1][1]; c.v[0] = new char[0][0]; char[][] val1 = get2(); 5.283 c.v[0] = new char[0][0]; char[][] val2 = get2(); 5.284 5.285 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 5.286 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 5.287 } 5.288 5.289 { 5.290 @@ -581,7 +622,7 @@ 5.291 elem.a = 'b'; char val3 = get(); char val4 = get1(); 5.292 5.293 assertEquals(val1, 'a'); 5.294 - assertEquals(val3, (isStableEnabled ? 'a' : 'b')); 5.295 + assertEquals(val3, (isServerWithStable ? 'a' : 'b')); 5.296 5.297 assertEquals(val2, 'a'); 5.298 assertEquals(val4, 'b'); 5.299 @@ -615,17 +656,4 @@ 5.300 } 5.301 } 5.302 } 5.303 - 5.304 - static final boolean isStableEnabled; 5.305 - static { 5.306 - HotSpotDiagnosticMXBean diagnostic 5.307 - = ManagementFactoryHelper.getDiagnosticMXBean(); 5.308 - VMOption tmp; 5.309 - try { 5.310 - tmp = diagnostic.getVMOption("FoldStableValues"); 5.311 - } catch (IllegalArgumentException e) { 5.312 - tmp = null; 5.313 - } 5.314 - isStableEnabled = (tmp == null ? false : Boolean.parseBoolean(tmp.getValue())); 5.315 - } 5.316 }
6.1 --- a/test/compiler/stable/TestStableDouble.java Wed Jul 02 22:54:18 2014 +0200 6.2 +++ b/test/compiler/stable/TestStableDouble.java Thu Jul 10 12:04:43 2014 -0700 6.3 @@ -26,9 +26,11 @@ 6.4 /* 6.5 * @test TestStableDouble 6.6 * @summary tests on stable fields and arrays 6.7 - * @library /testlibrary 6.8 - * @compile -XDignore.symbol.file TestStableDouble.java 6.9 + * @library /testlibrary /testlibrary/whitebox 6.10 + * @build TestStableDouble StableConfiguration sun.hotspot.WhiteBox 6.11 + * @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission 6.12 * @run main ClassFileInstaller 6.13 + * java/lang/invoke/StableConfiguration 6.14 * java/lang/invoke/TestStableDouble 6.15 * java/lang/invoke/TestStableDouble$DoubleStable 6.16 * java/lang/invoke/TestStableDouble$StaticDoubleStable 6.17 @@ -48,46 +50,60 @@ 6.18 * java/lang/invoke/TestStableDouble$NestedStableField3 6.19 * java/lang/invoke/TestStableDouble$NestedStableField3$A 6.20 * java/lang/invoke/TestStableDouble$DefaultValue 6.21 + * java/lang/invoke/TestStableDouble$DefaultStaticValue 6.22 * java/lang/invoke/TestStableDouble$ObjectArrayLowerDim2 6.23 * 6.24 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 6.25 - * -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:+UseCompressedOop 6.26 - * -server -XX:-TieredCompilation -Xcomp 6.27 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 6.28 + * -server -XX:-TieredCompilation 6.29 + * -XX:+FoldStableValues 6.30 + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 6.31 + * java.lang.invoke.TestStableDouble 6.32 + * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 6.33 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 6.34 + * -server -XX:-TieredCompilation 6.35 + * -XX:-FoldStableValues 6.36 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 6.37 * java.lang.invoke.TestStableDouble 6.38 * 6.39 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 6.40 - * -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:-UseCompressedOop 6.41 - * -server -XX:-TieredCompilation -Xcomp 6.42 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 6.43 + * -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1 6.44 + * -XX:+FoldStableValues 6.45 + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 6.46 + * java.lang.invoke.TestStableDouble 6.47 + * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 6.48 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 6.49 + * -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1 6.50 + * -XX:-FoldStableValues 6.51 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 6.52 * java.lang.invoke.TestStableDouble 6.53 * 6.54 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 6.55 - * -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:+UseCompressedOop 6.56 - * -server -XX:-TieredCompilation -Xcomp 6.57 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 6.58 + * -client -XX:-TieredCompilation 6.59 + * -XX:+FoldStableValues 6.60 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 6.61 * java.lang.invoke.TestStableDouble 6.62 - * 6.63 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 6.64 - * -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:-UseCompressedOop 6.65 - * -server -XX:-TieredCompilation -Xcomp 6.66 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 6.67 + * -client -XX:-TieredCompilation 6.68 + * -XX:-FoldStableValues 6.69 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 6.70 * java.lang.invoke.TestStableDouble 6.71 */ 6.72 package java.lang.invoke; 6.73 6.74 -import com.sun.management.HotSpotDiagnosticMXBean; 6.75 -import com.sun.management.VMOption; 6.76 -import sun.management.ManagementFactoryHelper; 6.77 import java.lang.reflect.InvocationTargetException; 6.78 6.79 public class TestStableDouble { 6.80 + static final boolean isStableEnabled = StableConfiguration.isStableEnabled; 6.81 + static final boolean isServerWithStable = StableConfiguration.isServerWithStable; 6.82 + 6.83 public static void main(String[] args) throws Exception { 6.84 - System.out.println("@Stable enabled: "+isStableEnabled); 6.85 - System.out.println(); 6.86 - 6.87 run(DefaultValue.class); 6.88 run(DoubleStable.class); 6.89 + run(DefaultStaticValue.class); 6.90 run(StaticDoubleStable.class); 6.91 run(VolatileDoubleStable.class); 6.92 6.93 @@ -145,6 +161,21 @@ 6.94 6.95 /* ==================================================== */ 6.96 6.97 + static class DefaultStaticValue { 6.98 + public static @Stable double v; 6.99 + 6.100 + public static final DefaultStaticValue c = new DefaultStaticValue(); 6.101 + public static double get() { return c.v; } 6.102 + public static void test() throws Exception { 6.103 + double val1 = get(); 6.104 + c.v = 1.0; double val2 = get(); 6.105 + assertEquals(val1, 0); 6.106 + assertEquals(val2, 1.0); 6.107 + } 6.108 + } 6.109 + 6.110 + /* ==================================================== */ 6.111 + 6.112 static class StaticDoubleStable { 6.113 public static @Stable double v; 6.114 6.115 @@ -188,20 +219,22 @@ 6.116 c.v = new double[1]; c.v[0] = 1.0; double val1 = get(); 6.117 c.v[0] = 2.0; double val2 = get(); 6.118 assertEquals(val1, 1.0); 6.119 - assertEquals(val2, (isStableEnabled ? 1.0 : 2.0)); 6.120 + assertEquals(val2, (isServerWithStable ? 1.0 : 2.0)); 6.121 6.122 c.v = new double[1]; c.v[0] = 3.0; double val3 = get(); 6.123 - assertEquals(val3, (isStableEnabled ? 1.0 : 3.0)); 6.124 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0) 6.125 + : 3.0)); 6.126 } 6.127 6.128 { 6.129 c.v = new double[20]; c.v[10] = 1.0; double val1 = get1(); 6.130 c.v[10] = 2.0; double val2 = get1(); 6.131 assertEquals(val1, 1.0); 6.132 - assertEquals(val2, (isStableEnabled ? 1.0 : 2.0)); 6.133 + assertEquals(val2, (isServerWithStable ? 1.0 : 2.0)); 6.134 6.135 c.v = new double[20]; c.v[10] = 3.0; double val3 = get1(); 6.136 - assertEquals(val3, (isStableEnabled ? 1.0 : 3.0)); 6.137 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0) 6.138 + : 3.0)); 6.139 } 6.140 6.141 { 6.142 @@ -226,19 +259,21 @@ 6.143 c.v = new double[1][1]; c.v[0][0] = 1.0; double val1 = get(); 6.144 c.v[0][0] = 2.0; double val2 = get(); 6.145 assertEquals(val1, 1.0); 6.146 - assertEquals(val2, (isStableEnabled ? 1.0 : 2.0)); 6.147 + assertEquals(val2, (isServerWithStable ? 1.0 : 2.0)); 6.148 6.149 c.v = new double[1][1]; c.v[0][0] = 3.0; double val3 = get(); 6.150 - assertEquals(val3, (isStableEnabled ? 1.0 : 3.0)); 6.151 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0) 6.152 + : 3.0)); 6.153 6.154 c.v[0] = new double[1]; c.v[0][0] = 4.0; double val4 = get(); 6.155 - assertEquals(val4, (isStableEnabled ? 1.0 : 4.0)); 6.156 + assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0) 6.157 + : 4.0)); 6.158 } 6.159 6.160 { 6.161 c.v = new double[1][1]; double[] val1 = get1(); 6.162 c.v[0] = new double[1]; double[] val2 = get1(); 6.163 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 6.164 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 6.165 } 6.166 6.167 { 6.168 @@ -264,28 +299,31 @@ 6.169 c.v = new double[1][1][1]; c.v[0][0][0] = 1.0; double val1 = get(); 6.170 c.v[0][0][0] = 2.0; double val2 = get(); 6.171 assertEquals(val1, 1.0); 6.172 - assertEquals(val2, (isStableEnabled ? 1.0 : 2.0)); 6.173 + assertEquals(val2, (isServerWithStable ? 1.0 : 2.0)); 6.174 6.175 c.v = new double[1][1][1]; c.v[0][0][0] = 3.0; double val3 = get(); 6.176 - assertEquals(val3, (isStableEnabled ? 1.0 : 3.0)); 6.177 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0) 6.178 + : 3.0)); 6.179 6.180 c.v[0] = new double[1][1]; c.v[0][0][0] = 4.0; double val4 = get(); 6.181 - assertEquals(val4, (isStableEnabled ? 1.0 : 4.0)); 6.182 + assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0) 6.183 + : 4.0)); 6.184 6.185 c.v[0][0] = new double[1]; c.v[0][0][0] = 5.0; double val5 = get(); 6.186 - assertEquals(val5, (isStableEnabled ? 1.0 : 5.0)); 6.187 + assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0) 6.188 + : 5.0)); 6.189 } 6.190 6.191 { 6.192 c.v = new double[1][1][1]; double[] val1 = get1(); 6.193 c.v[0][0] = new double[1]; double[] val2 = get1(); 6.194 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 6.195 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 6.196 } 6.197 6.198 { 6.199 c.v = new double[1][1][1]; double[][] val1 = get2(); 6.200 c.v[0] = new double[1][1]; double[][] val2 = get2(); 6.201 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 6.202 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 6.203 } 6.204 6.205 { 6.206 @@ -312,37 +350,41 @@ 6.207 c.v = new double[1][1][1][1]; c.v[0][0][0][0] = 1.0; double val1 = get(); 6.208 c.v[0][0][0][0] = 2.0; double val2 = get(); 6.209 assertEquals(val1, 1.0); 6.210 - assertEquals(val2, (isStableEnabled ? 1.0 : 2.0)); 6.211 + assertEquals(val2, (isServerWithStable ? 1.0 : 2.0)); 6.212 6.213 c.v = new double[1][1][1][1]; c.v[0][0][0][0] = 3.0; double val3 = get(); 6.214 - assertEquals(val3, (isStableEnabled ? 1.0 : 3.0)); 6.215 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0) 6.216 + : 3.0)); 6.217 6.218 c.v[0] = new double[1][1][1]; c.v[0][0][0][0] = 4.0; double val4 = get(); 6.219 - assertEquals(val4, (isStableEnabled ? 1.0 : 4.0)); 6.220 + assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0) 6.221 + : 4.0)); 6.222 6.223 c.v[0][0] = new double[1][1]; c.v[0][0][0][0] = 5.0; double val5 = get(); 6.224 - assertEquals(val5, (isStableEnabled ? 1.0 : 5.0)); 6.225 + assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0) 6.226 + : 5.0)); 6.227 6.228 c.v[0][0][0] = new double[1]; c.v[0][0][0][0] = 6.0; double val6 = get(); 6.229 - assertEquals(val6, (isStableEnabled ? 1.0 : 6.0)); 6.230 + assertEquals(val6, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0) 6.231 + : 6.0)); 6.232 } 6.233 6.234 { 6.235 c.v = new double[1][1][1][1]; double[] val1 = get1(); 6.236 c.v[0][0][0] = new double[1]; double[] val2 = get1(); 6.237 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 6.238 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 6.239 } 6.240 6.241 { 6.242 c.v = new double[1][1][1][1]; double[][] val1 = get2(); 6.243 c.v[0][0] = new double[1][1]; double[][] val2 = get2(); 6.244 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 6.245 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 6.246 } 6.247 6.248 { 6.249 c.v = new double[1][1][1][1]; double[][][] val1 = get3(); 6.250 c.v[0] = new double[1][1][1]; double[][][] val2 = get3(); 6.251 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 6.252 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 6.253 } 6.254 6.255 { 6.256 @@ -350,13 +392,11 @@ 6.257 c.v = new double[1][1][1][1]; double[][][][] val2 = get4(); 6.258 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 6.259 } 6.260 - 6.261 } 6.262 } 6.263 6.264 /* ==================================================== */ 6.265 // Dynamic Dim is higher than static 6.266 - 6.267 static class ObjectArrayLowerDim0 { 6.268 public @Stable Object v; 6.269 6.270 @@ -404,7 +444,7 @@ 6.271 c.v = new double[1][1]; c.v[0] = new double[0]; double[] val1 = get1(); 6.272 c.v[0] = new double[0]; double[] val2 = get1(); 6.273 6.274 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 6.275 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 6.276 } 6.277 6.278 { 6.279 @@ -440,14 +480,14 @@ 6.280 c.v = new double[1][1][1]; c.v[0][0] = new double[0]; double[] val1 = get1(); 6.281 c.v[0][0] = new double[0]; double[] val2 = get1(); 6.282 6.283 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 6.284 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 6.285 } 6.286 6.287 { 6.288 c.v = new double[1][1][1]; c.v[0] = new double[0][0]; double[][] val1 = get2(); 6.289 c.v[0] = new double[0][0]; double[][] val2 = get2(); 6.290 6.291 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 6.292 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 6.293 } 6.294 6.295 { 6.296 @@ -582,7 +622,7 @@ 6.297 elem.a = 2.0; double val3 = get(); double val4 = get1(); 6.298 6.299 assertEquals(val1, 1.0); 6.300 - assertEquals(val3, (isStableEnabled ? 1.0 : 2.0)); 6.301 + assertEquals(val3, (isServerWithStable ? 1.0 : 2.0)); 6.302 6.303 assertEquals(val2, 1.0); 6.304 assertEquals(val4, 2.0); 6.305 @@ -616,17 +656,4 @@ 6.306 } 6.307 } 6.308 } 6.309 - 6.310 - static final boolean isStableEnabled; 6.311 - static { 6.312 - HotSpotDiagnosticMXBean diagnostic 6.313 - = ManagementFactoryHelper.getDiagnosticMXBean(); 6.314 - VMOption tmp; 6.315 - try { 6.316 - tmp = diagnostic.getVMOption("FoldStableValues"); 6.317 - } catch (IllegalArgumentException e) { 6.318 - tmp = null; 6.319 - } 6.320 - isStableEnabled = (tmp == null ? false : Boolean.parseBoolean(tmp.getValue())); 6.321 - } 6.322 }
7.1 --- a/test/compiler/stable/TestStableFloat.java Wed Jul 02 22:54:18 2014 +0200 7.2 +++ b/test/compiler/stable/TestStableFloat.java Thu Jul 10 12:04:43 2014 -0700 7.3 @@ -26,9 +26,11 @@ 7.4 /* 7.5 * @test TestStableFloat 7.6 * @summary tests on stable fields and arrays 7.7 - * @library /testlibrary 7.8 - * @compile -XDignore.symbol.file TestStableFloat.java 7.9 + * @library /testlibrary /testlibrary/whitebox 7.10 + * @build TestStableFloat StableConfiguration sun.hotspot.WhiteBox 7.11 + * @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission 7.12 * @run main ClassFileInstaller 7.13 + * java/lang/invoke/StableConfiguration 7.14 * java/lang/invoke/TestStableFloat 7.15 * java/lang/invoke/TestStableFloat$FloatStable 7.16 * java/lang/invoke/TestStableFloat$StaticFloatStable 7.17 @@ -48,46 +50,60 @@ 7.18 * java/lang/invoke/TestStableFloat$NestedStableField3 7.19 * java/lang/invoke/TestStableFloat$NestedStableField3$A 7.20 * java/lang/invoke/TestStableFloat$DefaultValue 7.21 + * java/lang/invoke/TestStableFloat$DefaultStaticValue 7.22 * java/lang/invoke/TestStableFloat$ObjectArrayLowerDim2 7.23 * 7.24 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 7.25 - * -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:+UseCompressedOop 7.26 - * -server -XX:-TieredCompilation -Xcomp 7.27 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 7.28 + * -server -XX:-TieredCompilation 7.29 + * -XX:+FoldStableValues 7.30 + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 7.31 + * java.lang.invoke.TestStableFloat 7.32 + * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 7.33 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 7.34 + * -server -XX:-TieredCompilation 7.35 + * -XX:-FoldStableValues 7.36 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 7.37 * java.lang.invoke.TestStableFloat 7.38 * 7.39 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 7.40 - * -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:-UseCompressedOop 7.41 - * -server -XX:-TieredCompilation -Xcomp 7.42 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 7.43 + * -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1 7.44 + * -XX:+FoldStableValues 7.45 + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 7.46 + * java.lang.invoke.TestStableFloat 7.47 + * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 7.48 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 7.49 + * -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1 7.50 + * -XX:-FoldStableValues 7.51 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 7.52 * java.lang.invoke.TestStableFloat 7.53 * 7.54 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 7.55 - * -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:+UseCompressedOop 7.56 - * -server -XX:-TieredCompilation -Xcomp 7.57 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 7.58 + * -client -XX:-TieredCompilation 7.59 + * -XX:+FoldStableValues 7.60 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 7.61 * java.lang.invoke.TestStableFloat 7.62 - * 7.63 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 7.64 - * -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:-UseCompressedOop 7.65 - * -server -XX:-TieredCompilation -Xcomp 7.66 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 7.67 + * -client -XX:-TieredCompilation 7.68 + * -XX:-FoldStableValues 7.69 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 7.70 * java.lang.invoke.TestStableFloat 7.71 */ 7.72 package java.lang.invoke; 7.73 7.74 -import com.sun.management.HotSpotDiagnosticMXBean; 7.75 -import com.sun.management.VMOption; 7.76 -import sun.management.ManagementFactoryHelper; 7.77 import java.lang.reflect.InvocationTargetException; 7.78 7.79 public class TestStableFloat { 7.80 + static final boolean isStableEnabled = StableConfiguration.isStableEnabled; 7.81 + static final boolean isServerWithStable = StableConfiguration.isServerWithStable; 7.82 + 7.83 public static void main(String[] args) throws Exception { 7.84 - System.out.println("@Stable enabled: "+isStableEnabled); 7.85 - System.out.println(); 7.86 - 7.87 run(DefaultValue.class); 7.88 run(FloatStable.class); 7.89 + run(DefaultStaticValue.class); 7.90 run(StaticFloatStable.class); 7.91 run(VolatileFloatStable.class); 7.92 7.93 @@ -145,6 +161,21 @@ 7.94 7.95 /* ==================================================== */ 7.96 7.97 + static class DefaultStaticValue { 7.98 + public static @Stable float v; 7.99 + 7.100 + public static final DefaultStaticValue c = new DefaultStaticValue(); 7.101 + public static float get() { return c.v; } 7.102 + public static void test() throws Exception { 7.103 + float val1 = get(); 7.104 + c.v = 1.0F; float val2 = get(); 7.105 + assertEquals(val1, 0F); 7.106 + assertEquals(val2, 1.0F); 7.107 + } 7.108 + } 7.109 + 7.110 + /* ==================================================== */ 7.111 + 7.112 static class StaticFloatStable { 7.113 public static @Stable float v; 7.114 7.115 @@ -188,20 +219,22 @@ 7.116 c.v = new float[1]; c.v[0] = 1.0F; float val1 = get(); 7.117 c.v[0] = 2.0F; float val2 = get(); 7.118 assertEquals(val1, 1.0F); 7.119 - assertEquals(val2, (isStableEnabled ? 1.0F : 2.0F)); 7.120 + assertEquals(val2, (isServerWithStable ? 1.0F : 2.0F)); 7.121 7.122 c.v = new float[1]; c.v[0] = 3.0F; float val3 = get(); 7.123 - assertEquals(val3, (isStableEnabled ? 1.0F : 3.0F)); 7.124 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0F : 2.0F) 7.125 + : 3.0F)); 7.126 } 7.127 7.128 { 7.129 c.v = new float[20]; c.v[10] = 1.0F; float val1 = get1(); 7.130 c.v[10] = 2.0F; float val2 = get1(); 7.131 assertEquals(val1, 1.0F); 7.132 - assertEquals(val2, (isStableEnabled ? 1.0F : 2.0F)); 7.133 + assertEquals(val2, (isServerWithStable ? 1.0F : 2.0F)); 7.134 7.135 c.v = new float[20]; c.v[10] = 3.0F; float val3 = get1(); 7.136 - assertEquals(val3, (isStableEnabled ? 1.0F : 3.0F)); 7.137 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0F : 2.0F) 7.138 + : 3.0F)); 7.139 } 7.140 7.141 { 7.142 @@ -226,19 +259,21 @@ 7.143 c.v = new float[1][1]; c.v[0][0] = 1.0F; float val1 = get(); 7.144 c.v[0][0] = 2.0F; float val2 = get(); 7.145 assertEquals(val1, 1.0F); 7.146 - assertEquals(val2, (isStableEnabled ? 1.0F : 2.0F)); 7.147 + assertEquals(val2, (isServerWithStable ? 1.0F : 2.0F)); 7.148 7.149 c.v = new float[1][1]; c.v[0][0] = 3.0F; float val3 = get(); 7.150 - assertEquals(val3, (isStableEnabled ? 1.0F : 3.0F)); 7.151 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0F : 2.0F) 7.152 + : 3.0F)); 7.153 7.154 c.v[0] = new float[1]; c.v[0][0] = 4.0F; float val4 = get(); 7.155 - assertEquals(val4, (isStableEnabled ? 1.0F : 4.0F)); 7.156 + assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1.0F : 2.0F) 7.157 + : 4.0F)); 7.158 } 7.159 7.160 { 7.161 c.v = new float[1][1]; float[] val1 = get1(); 7.162 c.v[0] = new float[1]; float[] val2 = get1(); 7.163 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 7.164 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 7.165 } 7.166 7.167 { 7.168 @@ -264,28 +299,31 @@ 7.169 c.v = new float[1][1][1]; c.v[0][0][0] = 1.0F; float val1 = get(); 7.170 c.v[0][0][0] = 2.0F; float val2 = get(); 7.171 assertEquals(val1, 1.0F); 7.172 - assertEquals(val2, (isStableEnabled ? 1.0F : 2.0F)); 7.173 + assertEquals(val2, (isServerWithStable ? 1.0F : 2.0F)); 7.174 7.175 c.v = new float[1][1][1]; c.v[0][0][0] = 3.0F; float val3 = get(); 7.176 - assertEquals(val3, (isStableEnabled ? 1.0F : 3.0F)); 7.177 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0F : 2.0F) 7.178 + : 3.0F)); 7.179 7.180 c.v[0] = new float[1][1]; c.v[0][0][0] = 4.0F; float val4 = get(); 7.181 - assertEquals(val4, (isStableEnabled ? 1.0F : 4.0F)); 7.182 + assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1.0F : 2.0F) 7.183 + : 4.0F)); 7.184 7.185 c.v[0][0] = new float[1]; c.v[0][0][0] = 5.0F; float val5 = get(); 7.186 - assertEquals(val5, (isStableEnabled ? 1.0F : 5.0F)); 7.187 + assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1.0F : 2.0F) 7.188 + : 5.0F)); 7.189 } 7.190 7.191 { 7.192 c.v = new float[1][1][1]; float[] val1 = get1(); 7.193 c.v[0][0] = new float[1]; float[] val2 = get1(); 7.194 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 7.195 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 7.196 } 7.197 7.198 { 7.199 c.v = new float[1][1][1]; float[][] val1 = get2(); 7.200 c.v[0] = new float[1][1]; float[][] val2 = get2(); 7.201 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 7.202 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 7.203 } 7.204 7.205 { 7.206 @@ -312,37 +350,41 @@ 7.207 c.v = new float[1][1][1][1]; c.v[0][0][0][0] = 1.0F; float val1 = get(); 7.208 c.v[0][0][0][0] = 2.0F; float val2 = get(); 7.209 assertEquals(val1, 1.0F); 7.210 - assertEquals(val2, (isStableEnabled ? 1.0F : 2.0F)); 7.211 + assertEquals(val2, (isServerWithStable ? 1.0F : 2.0F)); 7.212 7.213 c.v = new float[1][1][1][1]; c.v[0][0][0][0] = 3.0F; float val3 = get(); 7.214 - assertEquals(val3, (isStableEnabled ? 1.0F : 3.0F)); 7.215 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0F : 2.0F) 7.216 + : 3.0F)); 7.217 7.218 c.v[0] = new float[1][1][1]; c.v[0][0][0][0] = 4.0F; float val4 = get(); 7.219 - assertEquals(val4, (isStableEnabled ? 1.0F : 4.0F)); 7.220 + assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1.0F : 2.0F) 7.221 + : 4.0F)); 7.222 7.223 c.v[0][0] = new float[1][1]; c.v[0][0][0][0] = 5.0F; float val5 = get(); 7.224 - assertEquals(val5, (isStableEnabled ? 1.0F : 5.0F)); 7.225 + assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1.0F : 2.0F) 7.226 + : 5.0F)); 7.227 7.228 c.v[0][0][0] = new float[1]; c.v[0][0][0][0] = 6.0F; float val6 = get(); 7.229 - assertEquals(val6, (isStableEnabled ? 1.0F : 6.0F)); 7.230 + assertEquals(val6, (isStableEnabled ? (isServerWithStable ? 1.0F : 2.0F) 7.231 + : 6.0F)); 7.232 } 7.233 7.234 { 7.235 c.v = new float[1][1][1][1]; float[] val1 = get1(); 7.236 c.v[0][0][0] = new float[1]; float[] val2 = get1(); 7.237 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 7.238 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 7.239 } 7.240 7.241 { 7.242 c.v = new float[1][1][1][1]; float[][] val1 = get2(); 7.243 c.v[0][0] = new float[1][1]; float[][] val2 = get2(); 7.244 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 7.245 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 7.246 } 7.247 7.248 { 7.249 c.v = new float[1][1][1][1]; float[][][] val1 = get3(); 7.250 c.v[0] = new float[1][1][1]; float[][][] val2 = get3(); 7.251 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 7.252 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 7.253 } 7.254 7.255 { 7.256 @@ -350,13 +392,11 @@ 7.257 c.v = new float[1][1][1][1]; float[][][][] val2 = get4(); 7.258 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 7.259 } 7.260 - 7.261 } 7.262 } 7.263 7.264 /* ==================================================== */ 7.265 // Dynamic Dim is higher than static 7.266 - 7.267 static class ObjectArrayLowerDim0 { 7.268 public @Stable Object v; 7.269 7.270 @@ -404,7 +444,7 @@ 7.271 c.v = new float[1][1]; c.v[0] = new float[0]; float[] val1 = get1(); 7.272 c.v[0] = new float[0]; float[] val2 = get1(); 7.273 7.274 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 7.275 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 7.276 } 7.277 7.278 { 7.279 @@ -440,14 +480,14 @@ 7.280 c.v = new float[1][1][1]; c.v[0][0] = new float[0]; float[] val1 = get1(); 7.281 c.v[0][0] = new float[0]; float[] val2 = get1(); 7.282 7.283 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 7.284 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 7.285 } 7.286 7.287 { 7.288 c.v = new float[1][1][1]; c.v[0] = new float[0][0]; float[][] val1 = get2(); 7.289 c.v[0] = new float[0][0]; float[][] val2 = get2(); 7.290 7.291 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 7.292 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 7.293 } 7.294 7.295 { 7.296 @@ -582,7 +622,7 @@ 7.297 elem.a = 2.0F; float val3 = get(); float val4 = get1(); 7.298 7.299 assertEquals(val1, 1.0F); 7.300 - assertEquals(val3, (isStableEnabled ? 1.0F : 2.0F)); 7.301 + assertEquals(val3, (isServerWithStable ? 1.0F : 2.0F)); 7.302 7.303 assertEquals(val2, 1.0F); 7.304 assertEquals(val4, 2.0F); 7.305 @@ -616,17 +656,4 @@ 7.306 } 7.307 } 7.308 } 7.309 - 7.310 - static final boolean isStableEnabled; 7.311 - static { 7.312 - HotSpotDiagnosticMXBean diagnostic 7.313 - = ManagementFactoryHelper.getDiagnosticMXBean(); 7.314 - VMOption tmp; 7.315 - try { 7.316 - tmp = diagnostic.getVMOption("FoldStableValues"); 7.317 - } catch (IllegalArgumentException e) { 7.318 - tmp = null; 7.319 - } 7.320 - isStableEnabled = (tmp == null ? false : Boolean.parseBoolean(tmp.getValue())); 7.321 - } 7.322 }
8.1 --- a/test/compiler/stable/TestStableInt.java Wed Jul 02 22:54:18 2014 +0200 8.2 +++ b/test/compiler/stable/TestStableInt.java Thu Jul 10 12:04:43 2014 -0700 8.3 @@ -26,9 +26,11 @@ 8.4 /* 8.5 * @test TestStableInt 8.6 * @summary tests on stable fields and arrays 8.7 - * @library /testlibrary 8.8 - * @compile -XDignore.symbol.file TestStableInt.java 8.9 + * @library /testlibrary /testlibrary/whitebox 8.10 + * @build TestStableInt StableConfiguration sun.hotspot.WhiteBox 8.11 + * @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission 8.12 * @run main ClassFileInstaller 8.13 + * java/lang/invoke/StableConfiguration 8.14 * java/lang/invoke/TestStableInt 8.15 * java/lang/invoke/TestStableInt$IntStable 8.16 * java/lang/invoke/TestStableInt$StaticIntStable 8.17 @@ -48,46 +50,60 @@ 8.18 * java/lang/invoke/TestStableInt$NestedStableField3 8.19 * java/lang/invoke/TestStableInt$NestedStableField3$A 8.20 * java/lang/invoke/TestStableInt$DefaultValue 8.21 + * java/lang/invoke/TestStableInt$DefaultStaticValue 8.22 * java/lang/invoke/TestStableInt$ObjectArrayLowerDim2 8.23 * 8.24 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 8.25 - * -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:+UseCompressedOop 8.26 - * -server -XX:-TieredCompilation -Xcomp 8.27 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 8.28 + * -server -XX:-TieredCompilation 8.29 + * -XX:+FoldStableValues 8.30 + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 8.31 + * java.lang.invoke.TestStableInt 8.32 + * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 8.33 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 8.34 + * -server -XX:-TieredCompilation 8.35 + * -XX:-FoldStableValues 8.36 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 8.37 * java.lang.invoke.TestStableInt 8.38 * 8.39 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 8.40 - * -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:-UseCompressedOop 8.41 - * -server -XX:-TieredCompilation -Xcomp 8.42 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 8.43 + * -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1 8.44 + * -XX:+FoldStableValues 8.45 + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 8.46 + * java.lang.invoke.TestStableInt 8.47 + * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 8.48 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 8.49 + * -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1 8.50 + * -XX:-FoldStableValues 8.51 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 8.52 * java.lang.invoke.TestStableInt 8.53 * 8.54 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 8.55 - * -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:+UseCompressedOop 8.56 - * -server -XX:-TieredCompilation -Xcomp 8.57 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 8.58 + * -client -XX:-TieredCompilation 8.59 + * -XX:+FoldStableValues 8.60 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 8.61 * java.lang.invoke.TestStableInt 8.62 - * 8.63 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 8.64 - * -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:-UseCompressedOop 8.65 - * -server -XX:-TieredCompilation -Xcomp 8.66 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 8.67 + * -client -XX:-TieredCompilation 8.68 + * -XX:-FoldStableValues 8.69 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 8.70 * java.lang.invoke.TestStableInt 8.71 */ 8.72 package java.lang.invoke; 8.73 8.74 -import com.sun.management.HotSpotDiagnosticMXBean; 8.75 -import com.sun.management.VMOption; 8.76 -import sun.management.ManagementFactoryHelper; 8.77 import java.lang.reflect.InvocationTargetException; 8.78 8.79 public class TestStableInt { 8.80 + static final boolean isStableEnabled = StableConfiguration.isStableEnabled; 8.81 + static final boolean isServerWithStable = StableConfiguration.isServerWithStable; 8.82 + 8.83 public static void main(String[] args) throws Exception { 8.84 - System.out.println("@Stable enabled: "+isStableEnabled); 8.85 - System.out.println(); 8.86 - 8.87 run(DefaultValue.class); 8.88 run(IntStable.class); 8.89 + run(DefaultStaticValue.class); 8.90 run(StaticIntStable.class); 8.91 run(VolatileIntStable.class); 8.92 8.93 @@ -145,6 +161,21 @@ 8.94 8.95 /* ==================================================== */ 8.96 8.97 + static class DefaultStaticValue { 8.98 + public static @Stable int v; 8.99 + 8.100 + public static final DefaultStaticValue c = new DefaultStaticValue(); 8.101 + public static int get() { return c.v; } 8.102 + public static void test() throws Exception { 8.103 + int val1 = get(); 8.104 + c.v = 1; int val2 = get(); 8.105 + assertEquals(val1, 0); 8.106 + assertEquals(val2, 1); 8.107 + } 8.108 + } 8.109 + 8.110 + /* ==================================================== */ 8.111 + 8.112 static class StaticIntStable { 8.113 public static @Stable int v; 8.114 8.115 @@ -188,20 +219,22 @@ 8.116 c.v = new int[1]; c.v[0] = 1; int val1 = get(); 8.117 c.v[0] = 2; int val2 = get(); 8.118 assertEquals(val1, 1); 8.119 - assertEquals(val2, (isStableEnabled ? 1 : 2)); 8.120 + assertEquals(val2, (isServerWithStable ? 1 : 2)); 8.121 8.122 c.v = new int[1]; c.v[0] = 3; int val3 = get(); 8.123 - assertEquals(val3, (isStableEnabled ? 1 : 3)); 8.124 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2) 8.125 + : 3)); 8.126 } 8.127 8.128 { 8.129 c.v = new int[20]; c.v[10] = 1; int val1 = get1(); 8.130 c.v[10] = 2; int val2 = get1(); 8.131 assertEquals(val1, 1); 8.132 - assertEquals(val2, (isStableEnabled ? 1 : 2)); 8.133 + assertEquals(val2, (isServerWithStable ? 1 : 2)); 8.134 8.135 c.v = new int[20]; c.v[10] = 3; int val3 = get1(); 8.136 - assertEquals(val3, (isStableEnabled ? 1 : 3)); 8.137 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2) 8.138 + : 3)); 8.139 } 8.140 8.141 { 8.142 @@ -226,19 +259,21 @@ 8.143 c.v = new int[1][1]; c.v[0][0] = 1; int val1 = get(); 8.144 c.v[0][0] = 2; int val2 = get(); 8.145 assertEquals(val1, 1); 8.146 - assertEquals(val2, (isStableEnabled ? 1 : 2)); 8.147 + assertEquals(val2, (isServerWithStable ? 1 : 2)); 8.148 8.149 c.v = new int[1][1]; c.v[0][0] = 3; int val3 = get(); 8.150 - assertEquals(val3, (isStableEnabled ? 1 : 3)); 8.151 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2) 8.152 + : 3)); 8.153 8.154 c.v[0] = new int[1]; c.v[0][0] = 4; int val4 = get(); 8.155 - assertEquals(val4, (isStableEnabled ? 1 : 4)); 8.156 + assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2) 8.157 + : 4)); 8.158 } 8.159 8.160 { 8.161 c.v = new int[1][1]; int[] val1 = get1(); 8.162 c.v[0] = new int[1]; int[] val2 = get1(); 8.163 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 8.164 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 8.165 } 8.166 8.167 { 8.168 @@ -264,28 +299,31 @@ 8.169 c.v = new int[1][1][1]; c.v[0][0][0] = 1; int val1 = get(); 8.170 c.v[0][0][0] = 2; int val2 = get(); 8.171 assertEquals(val1, 1); 8.172 - assertEquals(val2, (isStableEnabled ? 1 : 2)); 8.173 + assertEquals(val2, (isServerWithStable ? 1 : 2)); 8.174 8.175 c.v = new int[1][1][1]; c.v[0][0][0] = 3; int val3 = get(); 8.176 - assertEquals(val3, (isStableEnabled ? 1 : 3)); 8.177 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2) 8.178 + : 3)); 8.179 8.180 c.v[0] = new int[1][1]; c.v[0][0][0] = 4; int val4 = get(); 8.181 - assertEquals(val4, (isStableEnabled ? 1 : 4)); 8.182 + assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2) 8.183 + : 4)); 8.184 8.185 c.v[0][0] = new int[1]; c.v[0][0][0] = 5; int val5 = get(); 8.186 - assertEquals(val5, (isStableEnabled ? 1 : 5)); 8.187 + assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1 : 2) 8.188 + : 5)); 8.189 } 8.190 8.191 { 8.192 c.v = new int[1][1][1]; int[] val1 = get1(); 8.193 c.v[0][0] = new int[1]; int[] val2 = get1(); 8.194 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 8.195 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 8.196 } 8.197 8.198 { 8.199 c.v = new int[1][1][1]; int[][] val1 = get2(); 8.200 c.v[0] = new int[1][1]; int[][] val2 = get2(); 8.201 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 8.202 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 8.203 } 8.204 8.205 { 8.206 @@ -312,37 +350,41 @@ 8.207 c.v = new int[1][1][1][1]; c.v[0][0][0][0] = 1; int val1 = get(); 8.208 c.v[0][0][0][0] = 2; int val2 = get(); 8.209 assertEquals(val1, 1); 8.210 - assertEquals(val2, (isStableEnabled ? 1 : 2)); 8.211 + assertEquals(val2, (isServerWithStable ? 1 : 2)); 8.212 8.213 c.v = new int[1][1][1][1]; c.v[0][0][0][0] = 3; int val3 = get(); 8.214 - assertEquals(val3, (isStableEnabled ? 1 : 3)); 8.215 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2) 8.216 + : 3)); 8.217 8.218 c.v[0] = new int[1][1][1]; c.v[0][0][0][0] = 4; int val4 = get(); 8.219 - assertEquals(val4, (isStableEnabled ? 1 : 4)); 8.220 + assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2) 8.221 + : 4)); 8.222 8.223 c.v[0][0] = new int[1][1]; c.v[0][0][0][0] = 5; int val5 = get(); 8.224 - assertEquals(val5, (isStableEnabled ? 1 : 5)); 8.225 + assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1 : 2) 8.226 + : 5)); 8.227 8.228 c.v[0][0][0] = new int[1]; c.v[0][0][0][0] = 6; int val6 = get(); 8.229 - assertEquals(val6, (isStableEnabled ? 1 : 6)); 8.230 + assertEquals(val6, (isStableEnabled ? (isServerWithStable ? 1 : 2) 8.231 + : 6)); 8.232 } 8.233 8.234 { 8.235 c.v = new int[1][1][1][1]; int[] val1 = get1(); 8.236 c.v[0][0][0] = new int[1]; int[] val2 = get1(); 8.237 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 8.238 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 8.239 } 8.240 8.241 { 8.242 c.v = new int[1][1][1][1]; int[][] val1 = get2(); 8.243 c.v[0][0] = new int[1][1]; int[][] val2 = get2(); 8.244 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 8.245 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 8.246 } 8.247 8.248 { 8.249 c.v = new int[1][1][1][1]; int[][][] val1 = get3(); 8.250 c.v[0] = new int[1][1][1]; int[][][] val2 = get3(); 8.251 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 8.252 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 8.253 } 8.254 8.255 { 8.256 @@ -350,13 +392,11 @@ 8.257 c.v = new int[1][1][1][1]; int[][][][] val2 = get4(); 8.258 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 8.259 } 8.260 - 8.261 } 8.262 } 8.263 8.264 /* ==================================================== */ 8.265 // Dynamic Dim is higher than static 8.266 - 8.267 static class ObjectArrayLowerDim0 { 8.268 public @Stable Object v; 8.269 8.270 @@ -404,7 +444,7 @@ 8.271 c.v = new int[1][1]; c.v[0] = new int[0]; int[] val1 = get1(); 8.272 c.v[0] = new int[0]; int[] val2 = get1(); 8.273 8.274 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 8.275 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 8.276 } 8.277 8.278 { 8.279 @@ -440,14 +480,14 @@ 8.280 c.v = new int[1][1][1]; c.v[0][0] = new int[0]; int[] val1 = get1(); 8.281 c.v[0][0] = new int[0]; int[] val2 = get1(); 8.282 8.283 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 8.284 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 8.285 } 8.286 8.287 { 8.288 c.v = new int[1][1][1]; c.v[0] = new int[0][0]; int[][] val1 = get2(); 8.289 c.v[0] = new int[0][0]; int[][] val2 = get2(); 8.290 8.291 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 8.292 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 8.293 } 8.294 8.295 { 8.296 @@ -582,7 +622,7 @@ 8.297 elem.a = 2; int val3 = get(); int val4 = get1(); 8.298 8.299 assertEquals(val1, 1); 8.300 - assertEquals(val3, (isStableEnabled ? 1 : 2)); 8.301 + assertEquals(val3, (isServerWithStable ? 1 : 2)); 8.302 8.303 assertEquals(val2, 1); 8.304 assertEquals(val4, 2); 8.305 @@ -616,17 +656,4 @@ 8.306 } 8.307 } 8.308 } 8.309 - 8.310 - static final boolean isStableEnabled; 8.311 - static { 8.312 - HotSpotDiagnosticMXBean diagnostic 8.313 - = ManagementFactoryHelper.getDiagnosticMXBean(); 8.314 - VMOption tmp; 8.315 - try { 8.316 - tmp = diagnostic.getVMOption("FoldStableValues"); 8.317 - } catch (IllegalArgumentException e) { 8.318 - tmp = null; 8.319 - } 8.320 - isStableEnabled = (tmp == null ? false : Boolean.parseBoolean(tmp.getValue())); 8.321 - } 8.322 }
9.1 --- a/test/compiler/stable/TestStableLong.java Wed Jul 02 22:54:18 2014 +0200 9.2 +++ b/test/compiler/stable/TestStableLong.java Thu Jul 10 12:04:43 2014 -0700 9.3 @@ -26,9 +26,11 @@ 9.4 /* 9.5 * @test TestStableLong 9.6 * @summary tests on stable fields and arrays 9.7 - * @library /testlibrary 9.8 - * @compile -XDignore.symbol.file TestStableLong.java 9.9 + * @library /testlibrary /testlibrary/whitebox 9.10 + * @build TestStableLong StableConfiguration sun.hotspot.WhiteBox 9.11 + * @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission 9.12 * @run main ClassFileInstaller 9.13 + * java/lang/invoke/StableConfiguration 9.14 * java/lang/invoke/TestStableLong 9.15 * java/lang/invoke/TestStableLong$LongStable 9.16 * java/lang/invoke/TestStableLong$StaticLongStable 9.17 @@ -48,46 +50,60 @@ 9.18 * java/lang/invoke/TestStableLong$NestedStableField3 9.19 * java/lang/invoke/TestStableLong$NestedStableField3$A 9.20 * java/lang/invoke/TestStableLong$DefaultValue 9.21 + * java/lang/invoke/TestStableLong$DefaultStaticValue 9.22 * java/lang/invoke/TestStableLong$ObjectArrayLowerDim2 9.23 * 9.24 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 9.25 - * -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:+UseCompressedOop 9.26 - * -server -XX:-TieredCompilation -Xcomp 9.27 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 9.28 + * -server -XX:-TieredCompilation 9.29 + * -XX:+FoldStableValues 9.30 + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 9.31 + * java.lang.invoke.TestStableLong 9.32 + * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 9.33 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 9.34 + * -server -XX:-TieredCompilation 9.35 + * -XX:-FoldStableValues 9.36 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 9.37 * java.lang.invoke.TestStableLong 9.38 * 9.39 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 9.40 - * -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:-UseCompressedOop 9.41 - * -server -XX:-TieredCompilation -Xcomp 9.42 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 9.43 + * -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1 9.44 + * -XX:+FoldStableValues 9.45 + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 9.46 + * java.lang.invoke.TestStableLong 9.47 + * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 9.48 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 9.49 + * -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1 9.50 + * -XX:-FoldStableValues 9.51 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 9.52 * java.lang.invoke.TestStableLong 9.53 * 9.54 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 9.55 - * -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:+UseCompressedOop 9.56 - * -server -XX:-TieredCompilation -Xcomp 9.57 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 9.58 + * -client -XX:-TieredCompilation 9.59 + * -XX:+FoldStableValues 9.60 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 9.61 * java.lang.invoke.TestStableLong 9.62 - * 9.63 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 9.64 - * -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:-UseCompressedOop 9.65 - * -server -XX:-TieredCompilation -Xcomp 9.66 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 9.67 + * -client -XX:-TieredCompilation 9.68 + * -XX:-FoldStableValues 9.69 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 9.70 * java.lang.invoke.TestStableLong 9.71 */ 9.72 package java.lang.invoke; 9.73 9.74 -import com.sun.management.HotSpotDiagnosticMXBean; 9.75 -import com.sun.management.VMOption; 9.76 -import sun.management.ManagementFactoryHelper; 9.77 import java.lang.reflect.InvocationTargetException; 9.78 9.79 public class TestStableLong { 9.80 + static final boolean isStableEnabled = StableConfiguration.isStableEnabled; 9.81 + static final boolean isServerWithStable = StableConfiguration.isServerWithStable; 9.82 + 9.83 public static void main(String[] args) throws Exception { 9.84 - System.out.println("@Stable enabled: "+isStableEnabled); 9.85 - System.out.println(); 9.86 - 9.87 run(DefaultValue.class); 9.88 run(LongStable.class); 9.89 + run(DefaultStaticValue.class); 9.90 run(StaticLongStable.class); 9.91 run(VolatileLongStable.class); 9.92 9.93 @@ -145,6 +161,21 @@ 9.94 9.95 /* ==================================================== */ 9.96 9.97 + static class DefaultStaticValue { 9.98 + public static @Stable long v; 9.99 + 9.100 + public static final DefaultStaticValue c = new DefaultStaticValue(); 9.101 + public static long get() { return c.v; } 9.102 + public static void test() throws Exception { 9.103 + long val1 = get(); 9.104 + c.v = 1L; long val2 = get(); 9.105 + assertEquals(val1, 0); 9.106 + assertEquals(val2, 1L); 9.107 + } 9.108 + } 9.109 + 9.110 + /* ==================================================== */ 9.111 + 9.112 static class StaticLongStable { 9.113 public static @Stable long v; 9.114 9.115 @@ -188,20 +219,22 @@ 9.116 c.v = new long[1]; c.v[0] = 1; long val1 = get(); 9.117 c.v[0] = 2; long val2 = get(); 9.118 assertEquals(val1, 1); 9.119 - assertEquals(val2, (isStableEnabled ? 1 : 2)); 9.120 + assertEquals(val2, (isServerWithStable ? 1 : 2)); 9.121 9.122 c.v = new long[1]; c.v[0] = 3; long val3 = get(); 9.123 - assertEquals(val3, (isStableEnabled ? 1 : 3)); 9.124 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2) 9.125 + : 3)); 9.126 } 9.127 9.128 { 9.129 c.v = new long[20]; c.v[10] = 1; long val1 = get1(); 9.130 c.v[10] = 2; long val2 = get1(); 9.131 assertEquals(val1, 1); 9.132 - assertEquals(val2, (isStableEnabled ? 1 : 2)); 9.133 + assertEquals(val2, (isServerWithStable ? 1 : 2)); 9.134 9.135 c.v = new long[20]; c.v[10] = 3; long val3 = get1(); 9.136 - assertEquals(val3, (isStableEnabled ? 1 : 3)); 9.137 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2) 9.138 + : 3)); 9.139 } 9.140 9.141 { 9.142 @@ -226,19 +259,21 @@ 9.143 c.v = new long[1][1]; c.v[0][0] = 1; long val1 = get(); 9.144 c.v[0][0] = 2; long val2 = get(); 9.145 assertEquals(val1, 1); 9.146 - assertEquals(val2, (isStableEnabled ? 1 : 2)); 9.147 + assertEquals(val2, (isServerWithStable ? 1 : 2)); 9.148 9.149 c.v = new long[1][1]; c.v[0][0] = 3; long val3 = get(); 9.150 - assertEquals(val3, (isStableEnabled ? 1 : 3)); 9.151 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2) 9.152 + : 3)); 9.153 9.154 c.v[0] = new long[1]; c.v[0][0] = 4; long val4 = get(); 9.155 - assertEquals(val4, (isStableEnabled ? 1 : 4)); 9.156 + assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2) 9.157 + : 4)); 9.158 } 9.159 9.160 { 9.161 c.v = new long[1][1]; long[] val1 = get1(); 9.162 c.v[0] = new long[1]; long[] val2 = get1(); 9.163 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 9.164 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 9.165 } 9.166 9.167 { 9.168 @@ -264,28 +299,31 @@ 9.169 c.v = new long[1][1][1]; c.v[0][0][0] = 1; long val1 = get(); 9.170 c.v[0][0][0] = 2; long val2 = get(); 9.171 assertEquals(val1, 1); 9.172 - assertEquals(val2, (isStableEnabled ? 1 : 2)); 9.173 + assertEquals(val2, (isServerWithStable ? 1 : 2)); 9.174 9.175 c.v = new long[1][1][1]; c.v[0][0][0] = 3; long val3 = get(); 9.176 - assertEquals(val3, (isStableEnabled ? 1 : 3)); 9.177 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2) 9.178 + : 3)); 9.179 9.180 c.v[0] = new long[1][1]; c.v[0][0][0] = 4; long val4 = get(); 9.181 - assertEquals(val4, (isStableEnabled ? 1 : 4)); 9.182 + assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2) 9.183 + : 4)); 9.184 9.185 c.v[0][0] = new long[1]; c.v[0][0][0] = 5; long val5 = get(); 9.186 - assertEquals(val5, (isStableEnabled ? 1 : 5)); 9.187 + assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1 : 2) 9.188 + : 5)); 9.189 } 9.190 9.191 { 9.192 c.v = new long[1][1][1]; long[] val1 = get1(); 9.193 c.v[0][0] = new long[1]; long[] val2 = get1(); 9.194 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 9.195 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 9.196 } 9.197 9.198 { 9.199 c.v = new long[1][1][1]; long[][] val1 = get2(); 9.200 c.v[0] = new long[1][1]; long[][] val2 = get2(); 9.201 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 9.202 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 9.203 } 9.204 9.205 { 9.206 @@ -312,37 +350,41 @@ 9.207 c.v = new long[1][1][1][1]; c.v[0][0][0][0] = 1; long val1 = get(); 9.208 c.v[0][0][0][0] = 2; long val2 = get(); 9.209 assertEquals(val1, 1); 9.210 - assertEquals(val2, (isStableEnabled ? 1 : 2)); 9.211 + assertEquals(val2, (isServerWithStable ? 1 : 2)); 9.212 9.213 c.v = new long[1][1][1][1]; c.v[0][0][0][0] = 3; long val3 = get(); 9.214 - assertEquals(val3, (isStableEnabled ? 1 : 3)); 9.215 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2) 9.216 + : 3)); 9.217 9.218 c.v[0] = new long[1][1][1]; c.v[0][0][0][0] = 4; long val4 = get(); 9.219 - assertEquals(val4, (isStableEnabled ? 1 : 4)); 9.220 + assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2) 9.221 + : 4)); 9.222 9.223 c.v[0][0] = new long[1][1]; c.v[0][0][0][0] = 5; long val5 = get(); 9.224 - assertEquals(val5, (isStableEnabled ? 1 : 5)); 9.225 + assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1 : 2) 9.226 + : 5)); 9.227 9.228 c.v[0][0][0] = new long[1]; c.v[0][0][0][0] = 6; long val6 = get(); 9.229 - assertEquals(val6, (isStableEnabled ? 1 : 6)); 9.230 + assertEquals(val6, (isStableEnabled ? (isServerWithStable ? 1 : 2) 9.231 + : 6)); 9.232 } 9.233 9.234 { 9.235 c.v = new long[1][1][1][1]; long[] val1 = get1(); 9.236 c.v[0][0][0] = new long[1]; long[] val2 = get1(); 9.237 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 9.238 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 9.239 } 9.240 9.241 { 9.242 c.v = new long[1][1][1][1]; long[][] val1 = get2(); 9.243 c.v[0][0] = new long[1][1]; long[][] val2 = get2(); 9.244 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 9.245 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 9.246 } 9.247 9.248 { 9.249 c.v = new long[1][1][1][1]; long[][][] val1 = get3(); 9.250 c.v[0] = new long[1][1][1]; long[][][] val2 = get3(); 9.251 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 9.252 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 9.253 } 9.254 9.255 { 9.256 @@ -350,13 +392,11 @@ 9.257 c.v = new long[1][1][1][1]; long[][][][] val2 = get4(); 9.258 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 9.259 } 9.260 - 9.261 } 9.262 } 9.263 9.264 /* ==================================================== */ 9.265 // Dynamic Dim is higher than static 9.266 - 9.267 static class ObjectArrayLowerDim0 { 9.268 public @Stable Object v; 9.269 9.270 @@ -404,7 +444,7 @@ 9.271 c.v = new long[1][1]; c.v[0] = new long[0]; long[] val1 = get1(); 9.272 c.v[0] = new long[0]; long[] val2 = get1(); 9.273 9.274 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 9.275 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 9.276 } 9.277 9.278 { 9.279 @@ -440,14 +480,14 @@ 9.280 c.v = new long[1][1][1]; c.v[0][0] = new long[0]; long[] val1 = get1(); 9.281 c.v[0][0] = new long[0]; long[] val2 = get1(); 9.282 9.283 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 9.284 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 9.285 } 9.286 9.287 { 9.288 c.v = new long[1][1][1]; c.v[0] = new long[0][0]; long[][] val1 = get2(); 9.289 c.v[0] = new long[0][0]; long[][] val2 = get2(); 9.290 9.291 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 9.292 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 9.293 } 9.294 9.295 { 9.296 @@ -582,7 +622,7 @@ 9.297 elem.a = 2; long val3 = get(); long val4 = get1(); 9.298 9.299 assertEquals(val1, 1); 9.300 - assertEquals(val3, (isStableEnabled ? 1 : 2)); 9.301 + assertEquals(val3, (isServerWithStable ? 1 : 2)); 9.302 9.303 assertEquals(val2, 1); 9.304 assertEquals(val4, 2); 9.305 @@ -616,17 +656,4 @@ 9.306 } 9.307 } 9.308 } 9.309 - 9.310 - static final boolean isStableEnabled; 9.311 - static { 9.312 - HotSpotDiagnosticMXBean diagnostic 9.313 - = ManagementFactoryHelper.getDiagnosticMXBean(); 9.314 - VMOption tmp; 9.315 - try { 9.316 - tmp = diagnostic.getVMOption("FoldStableValues"); 9.317 - } catch (IllegalArgumentException e) { 9.318 - tmp = null; 9.319 - } 9.320 - isStableEnabled = (tmp == null ? false : Boolean.parseBoolean(tmp.getValue())); 9.321 - } 9.322 }
10.1 --- a/test/compiler/stable/TestStableObject.java Wed Jul 02 22:54:18 2014 +0200 10.2 +++ b/test/compiler/stable/TestStableObject.java Thu Jul 10 12:04:43 2014 -0700 10.3 @@ -26,9 +26,11 @@ 10.4 /* 10.5 * @test TestStableObject 10.6 * @summary tests on stable fields and arrays 10.7 - * @library /testlibrary 10.8 - * @compile -XDignore.symbol.file TestStableObject.java 10.9 + * @library /testlibrary /testlibrary/whitebox 10.10 + * @build TestStableObject StableConfiguration sun.hotspot.WhiteBox 10.11 + * @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission 10.12 * @run main ClassFileInstaller 10.13 + * java/lang/invoke/StableConfiguration 10.14 * java/lang/invoke/TestStableObject 10.15 * java/lang/invoke/TestStableObject$ObjectStable 10.16 * java/lang/invoke/TestStableObject$StaticObjectStable 10.17 @@ -49,46 +51,60 @@ 10.18 * java/lang/invoke/TestStableObject$NestedStableField3$A 10.19 * java/lang/invoke/TestStableObject$Values 10.20 * java/lang/invoke/TestStableObject$DefaultValue 10.21 + * java/lang/invoke/TestStableObject$DefaultStaticValue 10.22 * java/lang/invoke/TestStableObject$ObjectArrayLowerDim2 10.23 * 10.24 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 10.25 - * -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:+UseCompressedOop 10.26 - * -server -XX:-TieredCompilation -Xcomp 10.27 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 10.28 + * -server -XX:-TieredCompilation 10.29 + * -XX:+FoldStableValues 10.30 + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 10.31 + * java.lang.invoke.TestStableObject 10.32 + * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 10.33 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 10.34 + * -server -XX:-TieredCompilation 10.35 + * -XX:-FoldStableValues 10.36 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 10.37 * java.lang.invoke.TestStableObject 10.38 * 10.39 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 10.40 - * -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:-UseCompressedOop 10.41 - * -server -XX:-TieredCompilation -Xcomp 10.42 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 10.43 + * -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1 10.44 + * -XX:+FoldStableValues 10.45 + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 10.46 + * java.lang.invoke.TestStableObject 10.47 + * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 10.48 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 10.49 + * -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1 10.50 + * -XX:-FoldStableValues 10.51 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 10.52 * java.lang.invoke.TestStableObject 10.53 * 10.54 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 10.55 - * -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:+UseCompressedOop 10.56 - * -server -XX:-TieredCompilation -Xcomp 10.57 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 10.58 + * -client -XX:-TieredCompilation 10.59 + * -XX:+FoldStableValues 10.60 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 10.61 * java.lang.invoke.TestStableObject 10.62 - * 10.63 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 10.64 - * -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:-UseCompressedOop 10.65 - * -server -XX:-TieredCompilation -Xcomp 10.66 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 10.67 + * -client -XX:-TieredCompilation 10.68 + * -XX:-FoldStableValues 10.69 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 10.70 * java.lang.invoke.TestStableObject 10.71 */ 10.72 package java.lang.invoke; 10.73 10.74 -import com.sun.management.HotSpotDiagnosticMXBean; 10.75 -import com.sun.management.VMOption; 10.76 -import sun.management.ManagementFactoryHelper; 10.77 import java.lang.reflect.InvocationTargetException; 10.78 10.79 public class TestStableObject { 10.80 + static final boolean isStableEnabled = StableConfiguration.isStableEnabled; 10.81 + static final boolean isServerWithStable = StableConfiguration.isServerWithStable; 10.82 + 10.83 public static void main(String[] args) throws Exception { 10.84 - System.out.println("@Stable enabled: "+isStableEnabled); 10.85 - System.out.println(); 10.86 - 10.87 run(DefaultValue.class); 10.88 run(ObjectStable.class); 10.89 + run(DefaultStaticValue.class); 10.90 run(StaticObjectStable.class); 10.91 run(VolatileObjectStable.class); 10.92 10.93 @@ -148,6 +164,21 @@ 10.94 10.95 /* ==================================================== */ 10.96 10.97 + static class DefaultStaticValue { 10.98 + public static @Stable Object v; 10.99 + 10.100 + public static final DefaultStaticValue c = new DefaultStaticValue(); 10.101 + public static Object get() { return c.v; } 10.102 + public static void test() throws Exception { 10.103 + Object val1 = get(); 10.104 + c.v = Values.A; Object val2 = get(); 10.105 + assertEquals(val1, null); 10.106 + assertEquals(val2, Values.A); 10.107 + } 10.108 + } 10.109 + 10.110 + /* ==================================================== */ 10.111 + 10.112 static class StaticObjectStable { 10.113 public static @Stable Values v; 10.114 10.115 @@ -191,20 +222,22 @@ 10.116 c.v = new Object[1]; c.v[0] = Values.A; Object val1 = get(); 10.117 c.v[0] = Values.B; Object val2 = get(); 10.118 assertEquals(val1, Values.A); 10.119 - assertEquals(val2, (isStableEnabled ? Values.A : Values.B)); 10.120 + assertEquals(val2, (isServerWithStable ? Values.A : Values.B)); 10.121 10.122 c.v = new Object[1]; c.v[0] = Values.C; Object val3 = get(); 10.123 - assertEquals(val3, (isStableEnabled ? Values.A : Values.C)); 10.124 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B) 10.125 + : Values.C)); 10.126 } 10.127 10.128 { 10.129 c.v = new Object[20]; c.v[10] = Values.A; Object val1 = get1(); 10.130 c.v[10] = Values.B; Object val2 = get1(); 10.131 assertEquals(val1, Values.A); 10.132 - assertEquals(val2, (isStableEnabled ? Values.A : Values.B)); 10.133 + assertEquals(val2, (isServerWithStable ? Values.A : Values.B)); 10.134 10.135 c.v = new Object[20]; c.v[10] = Values.C; Object val3 = get1(); 10.136 - assertEquals(val3, (isStableEnabled ? Values.A : Values.C)); 10.137 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B) 10.138 + : Values.C)); 10.139 } 10.140 10.141 { 10.142 @@ -229,19 +262,21 @@ 10.143 c.v = new Object[1][1]; c.v[0][0] = Values.A; Object val1 = get(); 10.144 c.v[0][0] = Values.B; Object val2 = get(); 10.145 assertEquals(val1, Values.A); 10.146 - assertEquals(val2, (isStableEnabled ? Values.A : Values.B)); 10.147 + assertEquals(val2, (isServerWithStable ? Values.A : Values.B)); 10.148 10.149 c.v = new Object[1][1]; c.v[0][0] = Values.C; Object val3 = get(); 10.150 - assertEquals(val3, (isStableEnabled ? Values.A : Values.C)); 10.151 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B) 10.152 + : Values.C)); 10.153 10.154 c.v[0] = new Object[1]; c.v[0][0] = Values.D; Object val4 = get(); 10.155 - assertEquals(val4, (isStableEnabled ? Values.A : Values.D)); 10.156 + assertEquals(val4, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B) 10.157 + : Values.D)); 10.158 } 10.159 10.160 { 10.161 c.v = new Object[1][1]; Object[] val1 = get1(); 10.162 c.v[0] = new Object[1]; Object[] val2 = get1(); 10.163 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 10.164 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 10.165 } 10.166 10.167 { 10.168 @@ -267,28 +302,31 @@ 10.169 c.v = new Object[1][1][1]; c.v[0][0][0] = Values.A; Object val1 = get(); 10.170 c.v[0][0][0] = Values.B; Object val2 = get(); 10.171 assertEquals(val1, Values.A); 10.172 - assertEquals(val2, (isStableEnabled ? Values.A : Values.B)); 10.173 + assertEquals(val2, (isServerWithStable ? Values.A : Values.B)); 10.174 10.175 c.v = new Object[1][1][1]; c.v[0][0][0] = Values.C; Object val3 = get(); 10.176 - assertEquals(val3, (isStableEnabled ? Values.A : Values.C)); 10.177 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B) 10.178 + : Values.C)); 10.179 10.180 c.v[0] = new Object[1][1]; c.v[0][0][0] = Values.D; Object val4 = get(); 10.181 - assertEquals(val4, (isStableEnabled ? Values.A : Values.D)); 10.182 + assertEquals(val4, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B) 10.183 + : Values.D)); 10.184 10.185 c.v[0][0] = new Object[1]; c.v[0][0][0] = Values.E; Object val5 = get(); 10.186 - assertEquals(val5, (isStableEnabled ? Values.A : Values.E)); 10.187 + assertEquals(val5, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B) 10.188 + : Values.E)); 10.189 } 10.190 10.191 { 10.192 c.v = new Object[1][1][1]; Object[] val1 = get1(); 10.193 c.v[0][0] = new Object[1]; Object[] val2 = get1(); 10.194 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 10.195 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 10.196 } 10.197 10.198 { 10.199 c.v = new Object[1][1][1]; Object[][] val1 = get2(); 10.200 c.v[0] = new Object[1][1]; Object[][] val2 = get2(); 10.201 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 10.202 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 10.203 } 10.204 10.205 { 10.206 @@ -315,37 +353,41 @@ 10.207 c.v = new Object[1][1][1][1]; c.v[0][0][0][0] = Values.A; Object val1 = get(); 10.208 c.v[0][0][0][0] = Values.B; Object val2 = get(); 10.209 assertEquals(val1, Values.A); 10.210 - assertEquals(val2, (isStableEnabled ? Values.A : Values.B)); 10.211 + assertEquals(val2, (isServerWithStable ? Values.A : Values.B)); 10.212 10.213 c.v = new Object[1][1][1][1]; c.v[0][0][0][0] = Values.C; Object val3 = get(); 10.214 - assertEquals(val3, (isStableEnabled ? Values.A : Values.C)); 10.215 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B) 10.216 + : Values.C)); 10.217 10.218 c.v[0] = new Object[1][1][1]; c.v[0][0][0][0] = Values.D; Object val4 = get(); 10.219 - assertEquals(val4, (isStableEnabled ? Values.A : Values.D)); 10.220 + assertEquals(val4, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B) 10.221 + : Values.D)); 10.222 10.223 c.v[0][0] = new Object[1][1]; c.v[0][0][0][0] = Values.E; Object val5 = get(); 10.224 - assertEquals(val5, (isStableEnabled ? Values.A : Values.E)); 10.225 + assertEquals(val5, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B) 10.226 + : Values.E)); 10.227 10.228 c.v[0][0][0] = new Object[1]; c.v[0][0][0][0] = Values.F; Object val6 = get(); 10.229 - assertEquals(val6, (isStableEnabled ? Values.A : Values.F)); 10.230 + assertEquals(val6, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B) 10.231 + : Values.F)); 10.232 } 10.233 10.234 { 10.235 c.v = new Object[1][1][1][1]; Object[] val1 = get1(); 10.236 c.v[0][0][0] = new Object[1]; Object[] val2 = get1(); 10.237 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 10.238 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 10.239 } 10.240 10.241 { 10.242 c.v = new Object[1][1][1][1]; Object[][] val1 = get2(); 10.243 c.v[0][0] = new Object[1][1]; Object[][] val2 = get2(); 10.244 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 10.245 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 10.246 } 10.247 10.248 { 10.249 c.v = new Object[1][1][1][1]; Object[][][] val1 = get3(); 10.250 c.v[0] = new Object[1][1][1]; Object[][][] val2 = get3(); 10.251 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 10.252 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 10.253 } 10.254 10.255 { 10.256 @@ -353,13 +395,11 @@ 10.257 c.v = new Object[1][1][1][1]; Object[][][][] val2 = get4(); 10.258 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 10.259 } 10.260 - 10.261 } 10.262 } 10.263 10.264 /* ==================================================== */ 10.265 // Dynamic Dim is higher than static 10.266 - 10.267 static class ObjectArrayLowerDim0 { 10.268 public @Stable Object v; 10.269 10.270 @@ -407,7 +447,7 @@ 10.271 c.v = new Object[1][1]; c.v[0] = new Object[0]; Object[] val1 = get1(); 10.272 c.v[0] = new Object[0]; Object[] val2 = get1(); 10.273 10.274 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 10.275 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 10.276 } 10.277 10.278 { 10.279 @@ -443,14 +483,14 @@ 10.280 c.v = new Object[1][1][1]; c.v[0][0] = new Object[0]; Object[] val1 = get1(); 10.281 c.v[0][0] = new Object[0]; Object[] val2 = get1(); 10.282 10.283 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 10.284 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 10.285 } 10.286 10.287 { 10.288 c.v = new Object[1][1][1]; c.v[0] = new Object[0][0]; Object[][] val1 = get2(); 10.289 c.v[0] = new Object[0][0]; Object[][] val2 = get2(); 10.290 10.291 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 10.292 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 10.293 } 10.294 10.295 { 10.296 @@ -585,7 +625,7 @@ 10.297 elem.a = Values.B; Object val3 = get(); Object val4 = get1(); 10.298 10.299 assertEquals(val1, Values.A); 10.300 - assertEquals(val3, (isStableEnabled ? Values.A : Values.B)); 10.301 + assertEquals(val3, (isServerWithStable ? Values.A : Values.B)); 10.302 10.303 assertEquals(val2, Values.A); 10.304 assertEquals(val4, Values.B); 10.305 @@ -619,17 +659,4 @@ 10.306 } 10.307 } 10.308 } 10.309 - 10.310 - static final boolean isStableEnabled; 10.311 - static { 10.312 - HotSpotDiagnosticMXBean diagnostic 10.313 - = ManagementFactoryHelper.getDiagnosticMXBean(); 10.314 - VMOption tmp; 10.315 - try { 10.316 - tmp = diagnostic.getVMOption("FoldStableValues"); 10.317 - } catch (IllegalArgumentException e) { 10.318 - tmp = null; 10.319 - } 10.320 - isStableEnabled = (tmp == null ? false : Boolean.parseBoolean(tmp.getValue())); 10.321 - } 10.322 }
11.1 --- a/test/compiler/stable/TestStableShort.java Wed Jul 02 22:54:18 2014 +0200 11.2 +++ b/test/compiler/stable/TestStableShort.java Thu Jul 10 12:04:43 2014 -0700 11.3 @@ -26,9 +26,11 @@ 11.4 /* 11.5 * @test TestStableShort 11.6 * @summary tests on stable fields and arrays 11.7 - * @library /testlibrary 11.8 - * @compile -XDignore.symbol.file TestStableShort.java 11.9 + * @library /testlibrary /testlibrary/whitebox 11.10 + * @build TestStableShort StableConfiguration sun.hotspot.WhiteBox 11.11 + * @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission 11.12 * @run main ClassFileInstaller 11.13 + * java/lang/invoke/StableConfiguration 11.14 * java/lang/invoke/TestStableShort 11.15 * java/lang/invoke/TestStableShort$ShortStable 11.16 * java/lang/invoke/TestStableShort$StaticShortStable 11.17 @@ -48,46 +50,60 @@ 11.18 * java/lang/invoke/TestStableShort$NestedStableField3 11.19 * java/lang/invoke/TestStableShort$NestedStableField3$A 11.20 * java/lang/invoke/TestStableShort$DefaultValue 11.21 + * java/lang/invoke/TestStableShort$DefaultStaticValue 11.22 * java/lang/invoke/TestStableShort$ObjectArrayLowerDim2 11.23 * 11.24 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 11.25 - * -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:+UseCompressedOop 11.26 - * -server -XX:-TieredCompilation -Xcomp 11.27 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 11.28 + * -server -XX:-TieredCompilation 11.29 + * -XX:+FoldStableValues 11.30 + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 11.31 + * java.lang.invoke.TestStableShort 11.32 + * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 11.33 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 11.34 + * -server -XX:-TieredCompilation 11.35 + * -XX:-FoldStableValues 11.36 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 11.37 * java.lang.invoke.TestStableShort 11.38 * 11.39 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 11.40 - * -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:-UseCompressedOop 11.41 - * -server -XX:-TieredCompilation -Xcomp 11.42 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 11.43 + * -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1 11.44 + * -XX:+FoldStableValues 11.45 + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 11.46 + * java.lang.invoke.TestStableShort 11.47 + * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 11.48 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 11.49 + * -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1 11.50 + * -XX:-FoldStableValues 11.51 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 11.52 * java.lang.invoke.TestStableShort 11.53 * 11.54 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 11.55 - * -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:+UseCompressedOop 11.56 - * -server -XX:-TieredCompilation -Xcomp 11.57 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 11.58 + * -client -XX:-TieredCompilation 11.59 + * -XX:+FoldStableValues 11.60 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 11.61 * java.lang.invoke.TestStableShort 11.62 - * 11.63 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 11.64 - * -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:-UseCompressedOop 11.65 - * -server -XX:-TieredCompilation -Xcomp 11.66 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 11.67 + * -client -XX:-TieredCompilation 11.68 + * -XX:-FoldStableValues 11.69 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 11.70 * java.lang.invoke.TestStableShort 11.71 */ 11.72 package java.lang.invoke; 11.73 11.74 -import com.sun.management.HotSpotDiagnosticMXBean; 11.75 -import com.sun.management.VMOption; 11.76 -import sun.management.ManagementFactoryHelper; 11.77 import java.lang.reflect.InvocationTargetException; 11.78 11.79 public class TestStableShort { 11.80 + static final boolean isStableEnabled = StableConfiguration.isStableEnabled; 11.81 + static final boolean isServerWithStable = StableConfiguration.isServerWithStable; 11.82 + 11.83 public static void main(String[] args) throws Exception { 11.84 - System.out.println("@Stable enabled: "+isStableEnabled); 11.85 - System.out.println(); 11.86 - 11.87 run(DefaultValue.class); 11.88 run(ShortStable.class); 11.89 + run(DefaultStaticValue.class); 11.90 run(StaticShortStable.class); 11.91 run(VolatileShortStable.class); 11.92 11.93 @@ -145,6 +161,21 @@ 11.94 11.95 /* ==================================================== */ 11.96 11.97 + static class DefaultStaticValue { 11.98 + public static @Stable short v; 11.99 + 11.100 + public static final DefaultStaticValue c = new DefaultStaticValue(); 11.101 + public static short get() { return c.v; } 11.102 + public static void test() throws Exception { 11.103 + short val1 = get(); 11.104 + c.v = 1; short val2 = get(); 11.105 + assertEquals(val1, 0); 11.106 + assertEquals(val2, 1); 11.107 + } 11.108 + } 11.109 + 11.110 + /* ==================================================== */ 11.111 + 11.112 static class StaticShortStable { 11.113 public static @Stable short v; 11.114 11.115 @@ -188,20 +219,22 @@ 11.116 c.v = new short[1]; c.v[0] = 1; short val1 = get(); 11.117 c.v[0] = 2; short val2 = get(); 11.118 assertEquals(val1, 1); 11.119 - assertEquals(val2, (isStableEnabled ? 1 : 2)); 11.120 + assertEquals(val2, (isServerWithStable ? 1 : 2)); 11.121 11.122 c.v = new short[1]; c.v[0] = 3; short val3 = get(); 11.123 - assertEquals(val3, (isStableEnabled ? 1 : 3)); 11.124 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2) 11.125 + : 3)); 11.126 } 11.127 11.128 { 11.129 c.v = new short[20]; c.v[10] = 1; short val1 = get1(); 11.130 c.v[10] = 2; short val2 = get1(); 11.131 assertEquals(val1, 1); 11.132 - assertEquals(val2, (isStableEnabled ? 1 : 2)); 11.133 + assertEquals(val2, (isServerWithStable ? 1 : 2)); 11.134 11.135 c.v = new short[20]; c.v[10] = 3; short val3 = get1(); 11.136 - assertEquals(val3, (isStableEnabled ? 1 : 3)); 11.137 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2) 11.138 + : 3)); 11.139 } 11.140 11.141 { 11.142 @@ -226,19 +259,21 @@ 11.143 c.v = new short[1][1]; c.v[0][0] = 1; short val1 = get(); 11.144 c.v[0][0] = 2; short val2 = get(); 11.145 assertEquals(val1, 1); 11.146 - assertEquals(val2, (isStableEnabled ? 1 : 2)); 11.147 + assertEquals(val2, (isServerWithStable ? 1 : 2)); 11.148 11.149 c.v = new short[1][1]; c.v[0][0] = 3; short val3 = get(); 11.150 - assertEquals(val3, (isStableEnabled ? 1 : 3)); 11.151 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2) 11.152 + : 3)); 11.153 11.154 c.v[0] = new short[1]; c.v[0][0] = 4; short val4 = get(); 11.155 - assertEquals(val4, (isStableEnabled ? 1 : 4)); 11.156 + assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2) 11.157 + : 4)); 11.158 } 11.159 11.160 { 11.161 c.v = new short[1][1]; short[] val1 = get1(); 11.162 c.v[0] = new short[1]; short[] val2 = get1(); 11.163 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 11.164 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 11.165 } 11.166 11.167 { 11.168 @@ -264,28 +299,31 @@ 11.169 c.v = new short[1][1][1]; c.v[0][0][0] = 1; short val1 = get(); 11.170 c.v[0][0][0] = 2; short val2 = get(); 11.171 assertEquals(val1, 1); 11.172 - assertEquals(val2, (isStableEnabled ? 1 : 2)); 11.173 + assertEquals(val2, (isServerWithStable ? 1 : 2)); 11.174 11.175 c.v = new short[1][1][1]; c.v[0][0][0] = 3; short val3 = get(); 11.176 - assertEquals(val3, (isStableEnabled ? 1 : 3)); 11.177 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2) 11.178 + : 3)); 11.179 11.180 c.v[0] = new short[1][1]; c.v[0][0][0] = 4; short val4 = get(); 11.181 - assertEquals(val4, (isStableEnabled ? 1 : 4)); 11.182 + assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2) 11.183 + : 4)); 11.184 11.185 c.v[0][0] = new short[1]; c.v[0][0][0] = 5; short val5 = get(); 11.186 - assertEquals(val5, (isStableEnabled ? 1 : 5)); 11.187 + assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1 : 2) 11.188 + : 5)); 11.189 } 11.190 11.191 { 11.192 c.v = new short[1][1][1]; short[] val1 = get1(); 11.193 c.v[0][0] = new short[1]; short[] val2 = get1(); 11.194 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 11.195 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 11.196 } 11.197 11.198 { 11.199 c.v = new short[1][1][1]; short[][] val1 = get2(); 11.200 c.v[0] = new short[1][1]; short[][] val2 = get2(); 11.201 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 11.202 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 11.203 } 11.204 11.205 { 11.206 @@ -312,37 +350,41 @@ 11.207 c.v = new short[1][1][1][1]; c.v[0][0][0][0] = 1; short val1 = get(); 11.208 c.v[0][0][0][0] = 2; short val2 = get(); 11.209 assertEquals(val1, 1); 11.210 - assertEquals(val2, (isStableEnabled ? 1 : 2)); 11.211 + assertEquals(val2, (isServerWithStable ? 1 : 2)); 11.212 11.213 c.v = new short[1][1][1][1]; c.v[0][0][0][0] = 3; short val3 = get(); 11.214 - assertEquals(val3, (isStableEnabled ? 1 : 3)); 11.215 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2) 11.216 + : 3)); 11.217 11.218 c.v[0] = new short[1][1][1]; c.v[0][0][0][0] = 4; short val4 = get(); 11.219 - assertEquals(val4, (isStableEnabled ? 1 : 4)); 11.220 + assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2) 11.221 + : 4)); 11.222 11.223 c.v[0][0] = new short[1][1]; c.v[0][0][0][0] = 5; short val5 = get(); 11.224 - assertEquals(val5, (isStableEnabled ? 1 : 5)); 11.225 + assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1 : 2) 11.226 + : 5)); 11.227 11.228 c.v[0][0][0] = new short[1]; c.v[0][0][0][0] = 6; short val6 = get(); 11.229 - assertEquals(val6, (isStableEnabled ? 1 : 6)); 11.230 + assertEquals(val6, (isStableEnabled ? (isServerWithStable ? 1 : 2) 11.231 + : 6)); 11.232 } 11.233 11.234 { 11.235 c.v = new short[1][1][1][1]; short[] val1 = get1(); 11.236 c.v[0][0][0] = new short[1]; short[] val2 = get1(); 11.237 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 11.238 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 11.239 } 11.240 11.241 { 11.242 c.v = new short[1][1][1][1]; short[][] val1 = get2(); 11.243 c.v[0][0] = new short[1][1]; short[][] val2 = get2(); 11.244 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 11.245 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 11.246 } 11.247 11.248 { 11.249 c.v = new short[1][1][1][1]; short[][][] val1 = get3(); 11.250 c.v[0] = new short[1][1][1]; short[][][] val2 = get3(); 11.251 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 11.252 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 11.253 } 11.254 11.255 { 11.256 @@ -350,13 +392,11 @@ 11.257 c.v = new short[1][1][1][1]; short[][][][] val2 = get4(); 11.258 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 11.259 } 11.260 - 11.261 } 11.262 } 11.263 11.264 /* ==================================================== */ 11.265 // Dynamic Dim is higher than static 11.266 - 11.267 static class ObjectArrayLowerDim0 { 11.268 public @Stable Object v; 11.269 11.270 @@ -404,7 +444,7 @@ 11.271 c.v = new short[1][1]; c.v[0] = new short[0]; short[] val1 = get1(); 11.272 c.v[0] = new short[0]; short[] val2 = get1(); 11.273 11.274 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 11.275 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 11.276 } 11.277 11.278 { 11.279 @@ -440,14 +480,14 @@ 11.280 c.v = new short[1][1][1]; c.v[0][0] = new short[0]; short[] val1 = get1(); 11.281 c.v[0][0] = new short[0]; short[] val2 = get1(); 11.282 11.283 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 11.284 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 11.285 } 11.286 11.287 { 11.288 c.v = new short[1][1][1]; c.v[0] = new short[0][0]; short[][] val1 = get2(); 11.289 c.v[0] = new short[0][0]; short[][] val2 = get2(); 11.290 11.291 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 11.292 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 11.293 } 11.294 11.295 { 11.296 @@ -582,7 +622,7 @@ 11.297 elem.a = 2; short val3 = get(); short val4 = get1(); 11.298 11.299 assertEquals(val1, 1); 11.300 - assertEquals(val3, (isStableEnabled ? 1 : 2)); 11.301 + assertEquals(val3, (isServerWithStable ? 1 : 2)); 11.302 11.303 assertEquals(val2, 1); 11.304 assertEquals(val4, 2); 11.305 @@ -616,17 +656,4 @@ 11.306 } 11.307 } 11.308 } 11.309 - 11.310 - static final boolean isStableEnabled; 11.311 - static { 11.312 - HotSpotDiagnosticMXBean diagnostic 11.313 - = ManagementFactoryHelper.getDiagnosticMXBean(); 11.314 - VMOption tmp; 11.315 - try { 11.316 - tmp = diagnostic.getVMOption("FoldStableValues"); 11.317 - } catch (IllegalArgumentException e) { 11.318 - tmp = null; 11.319 - } 11.320 - isStableEnabled = (tmp == null ? false : Boolean.parseBoolean(tmp.getValue())); 11.321 - } 11.322 }