Mon, 14 Jul 2014 15:48:49 -0700
Merge
.hgtags | file | annotate | diff | comparison | revisions | |
make/hotspot_version | file | annotate | diff | comparison | revisions |
1.1 --- a/.hgtags Mon Jul 14 07:41:47 2014 -0700 1.2 +++ b/.hgtags Mon Jul 14 15:48:49 2014 -0700 1.3 @@ -495,6 +495,7 @@ 1.4 4828415ebbf11e205dcc08e97ad5ae7dd03522f9 jdk8u20-b21 1.5 e4a6e7f1b90b85270aee1c54edaca3ef737082f1 hs25.20-b21 1.6 f7429096a202cab5c36a0f20dea33c554026010f jdk8u20-b22 1.7 +7c56530b11496459e66cb9ea933035002311672c hs25.20-b22 1.8 a4d44dfb7d30eea54bc172e4429a655454ae0bbf jdk8u25-b00 1.9 9a2152fbd929b0d8b2f5c326a5526214ae71731a jdk8u25-b01 1.10 d3d5604ea0dea3812e87ba76ac199d0a8be6f49f jdk8u25-b02 1.11 @@ -502,4 +503,5 @@ 1.12 220eefb3609e250a0bb0ed26236c1213b8000050 jdk8u25-b04 1.13 db8383148bc9417dd4c38fa4cea39510f17325f3 jdk8u25-b05 1.14 605df8463453628df49351fa63632666f18698cd jdk8u25-b06 1.15 +520188d4bade17dbe75163d1f635c08168ea560c jdk8u25-b07 1.16 5bb683bbe2c74876d585b5c3232fc3aab7b23e97 jdk8u31-b00
2.1 --- a/src/share/vm/c1/c1_GraphBuilder.cpp Mon Jul 14 07:41:47 2014 -0700 2.2 +++ b/src/share/vm/c1/c1_GraphBuilder.cpp Mon Jul 14 15:48:49 2014 -0700 2.3 @@ -1569,6 +1569,7 @@ 2.4 default: 2.5 constant = new Constant(as_ValueType(field_val)); 2.6 } 2.7 + // Stable static fields are checked for non-default values in ciField::initialize_from(). 2.8 } 2.9 if (constant != NULL) { 2.10 push(type, append(constant)); 2.11 @@ -1610,6 +1611,10 @@ 2.12 default: 2.13 constant = new Constant(as_ValueType(field_val)); 2.14 } 2.15 + if (FoldStableValues && field->is_stable() && field_val.is_null_or_zero()) { 2.16 + // Stable field with default value can't be constant. 2.17 + constant = NULL; 2.18 + } 2.19 } else { 2.20 // For CallSite objects treat the target field as a compile time constant. 2.21 if (const_oop->is_call_site()) { 2.22 @@ -1993,7 +1998,13 @@ 2.23 if (!UseInlineCaches && is_loaded && code == Bytecodes::_invokevirtual 2.24 && !target->can_be_statically_bound()) { 2.25 // Find a vtable index if one is available 2.26 - vtable_index = target->resolve_vtable_index(calling_klass, callee_holder); 2.27 + // For arrays, callee_holder is Object. Resolving the call with 2.28 + // Object would allow an illegal call to finalize() on an 2.29 + // array. We use holder instead: illegal calls to finalize() won't 2.30 + // be compiled as vtable calls (IC call resolution will catch the 2.31 + // illegal call) and the few legal calls on array types won't be 2.32 + // either. 2.33 + vtable_index = target->resolve_vtable_index(calling_klass, holder); 2.34 } 2.35 #endif 2.36
3.1 --- a/src/share/vm/opto/callGenerator.cpp Mon Jul 14 07:41:47 2014 -0700 3.2 +++ b/src/share/vm/opto/callGenerator.cpp Mon Jul 14 15:48:49 2014 -0700 3.3 @@ -837,8 +837,11 @@ 3.4 Node* receiver_node = kit.argument(0); 3.5 const TypeOopPtr* receiver_type = gvn.type(receiver_node)->isa_oopptr(); 3.6 // call_does_dispatch and vtable_index are out-parameters. They might be changed. 3.7 - target = C->optimize_virtual_call(caller, jvms->bci(), klass, target, receiver_type, 3.8 - is_virtual, 3.9 + // optimize_virtual_call() takes 2 different holder 3.10 + // arguments for a corner case that doesn't apply here (see 3.11 + // Parse::do_call()) 3.12 + target = C->optimize_virtual_call(caller, jvms->bci(), klass, klass, 3.13 + target, receiver_type, is_virtual, 3.14 call_does_dispatch, vtable_index); // out-parameters 3.15 // We lack profiling at this call but type speculation may 3.16 // provide us with a type
4.1 --- a/src/share/vm/opto/compile.hpp Mon Jul 14 07:41:47 2014 -0700 4.2 +++ b/src/share/vm/opto/compile.hpp Mon Jul 14 15:48:49 2014 -0700 4.3 @@ -854,8 +854,8 @@ 4.4 4.5 // Helper functions to identify inlining potential at call-site 4.6 ciMethod* optimize_virtual_call(ciMethod* caller, int bci, ciInstanceKlass* klass, 4.7 - ciMethod* callee, const TypeOopPtr* receiver_type, 4.8 - bool is_virtual, 4.9 + ciKlass* holder, ciMethod* callee, 4.10 + const TypeOopPtr* receiver_type, bool is_virtual, 4.11 bool &call_does_dispatch, int &vtable_index); 4.12 ciMethod* optimize_inlining(ciMethod* caller, int bci, ciInstanceKlass* klass, 4.13 ciMethod* callee, const TypeOopPtr* receiver_type);
5.1 --- a/src/share/vm/opto/doCall.cpp Mon Jul 14 07:41:47 2014 -0700 5.2 +++ b/src/share/vm/opto/doCall.cpp Mon Jul 14 15:48:49 2014 -0700 5.3 @@ -460,8 +460,14 @@ 5.4 Node* receiver_node = stack(sp() - nargs); 5.5 const TypeOopPtr* receiver_type = _gvn.type(receiver_node)->isa_oopptr(); 5.6 // call_does_dispatch and vtable_index are out-parameters. They might be changed. 5.7 - callee = C->optimize_virtual_call(method(), bci(), klass, orig_callee, receiver_type, 5.8 - is_virtual, 5.9 + // For arrays, klass below is Object. When vtable calls are used, 5.10 + // resolving the call with Object would allow an illegal call to 5.11 + // finalize() on an array. We use holder instead: illegal calls to 5.12 + // finalize() won't be compiled as vtable calls (IC call 5.13 + // resolution will catch the illegal call) and the few legal calls 5.14 + // on array types won't be either. 5.15 + callee = C->optimize_virtual_call(method(), bci(), klass, holder, orig_callee, 5.16 + receiver_type, is_virtual, 5.17 call_does_dispatch, vtable_index); // out-parameters 5.18 speculative_receiver_type = receiver_type != NULL ? receiver_type->speculative_type() : NULL; 5.19 } 5.20 @@ -937,8 +943,8 @@ 5.21 5.22 5.23 ciMethod* Compile::optimize_virtual_call(ciMethod* caller, int bci, ciInstanceKlass* klass, 5.24 - ciMethod* callee, const TypeOopPtr* receiver_type, 5.25 - bool is_virtual, 5.26 + ciKlass* holder, ciMethod* callee, 5.27 + const TypeOopPtr* receiver_type, bool is_virtual, 5.28 bool& call_does_dispatch, int& vtable_index) { 5.29 // Set default values for out-parameters. 5.30 call_does_dispatch = true; 5.31 @@ -953,7 +959,7 @@ 5.32 call_does_dispatch = false; 5.33 } else if (!UseInlineCaches && is_virtual && callee->is_loaded()) { 5.34 // We can make a vtable call at this site 5.35 - vtable_index = callee->resolve_vtable_index(caller->holder(), klass); 5.36 + vtable_index = callee->resolve_vtable_index(caller->holder(), holder); 5.37 } 5.38 return callee; 5.39 } 5.40 @@ -976,8 +982,10 @@ 5.41 ciInstanceKlass* actual_receiver = klass; 5.42 if (receiver_type != NULL) { 5.43 // Array methods are all inherited from Object, and are monomorphic. 5.44 + // finalize() call on array is not allowed. 5.45 if (receiver_type->isa_aryptr() && 5.46 - callee->holder() == env()->Object_klass()) { 5.47 + callee->holder() == env()->Object_klass() && 5.48 + callee->name() != ciSymbol::finalize_method_name()) { 5.49 return callee; 5.50 } 5.51
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 6.2 +++ b/test/compiler/stable/StableConfiguration.java Mon Jul 14 15:48:49 2014 -0700 6.3 @@ -0,0 +1,62 @@ 6.4 +/* 6.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 6.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6.7 + * 6.8 + * This code is free software; you can redistribute it and/or modify it 6.9 + * under the terms of the GNU General Public License version 2 only, as 6.10 + * published by the Free Software Foundation. Oracle designates this 6.11 + * particular file as subject to the "Classpath" exception as provided 6.12 + * by Oracle in the LICENSE file that accompanied this code. 6.13 + * 6.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 6.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 6.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 6.17 + * version 2 for more details (a copy is included in the LICENSE file that 6.18 + * accompanied this code). 6.19 + * 6.20 + * You should have received a copy of the GNU General Public License version 6.21 + * 2 along with this work; if not, write to the Free Software Foundation, 6.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 6.23 + * 6.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 6.25 + * or visit www.oracle.com if you need additional information or have any 6.26 + * questions. 6.27 + */ 6.28 +package java.lang.invoke; 6.29 + 6.30 +import java.lang.reflect.Method; 6.31 +import java.util.Properties; 6.32 +import sun.hotspot.WhiteBox; 6.33 + 6.34 +public class StableConfiguration { 6.35 + static final WhiteBox WB = WhiteBox.getWhiteBox(); 6.36 + static final boolean isStableEnabled; 6.37 + static final boolean isServerWithStable; 6.38 + 6.39 + static { 6.40 + Boolean value = WB.getBooleanVMFlag("FoldStableValues"); 6.41 + isStableEnabled = (value == null ? false : value); 6.42 + isServerWithStable = isStableEnabled && get(); 6.43 + System.out.println("@Stable: " + (isStableEnabled ? "enabled" : "disabled")); 6.44 + System.out.println("Server Compiler: " + get()); 6.45 + } 6.46 + 6.47 + // ::get() is among immediately compiled methods. 6.48 + static boolean get() { 6.49 + try { 6.50 + Method m = StableConfiguration.class.getDeclaredMethod("get"); 6.51 + int level = WB.getMethodCompilationLevel(m); 6.52 + if (level > 0) { 6.53 + return (level == 4); 6.54 + } else { 6.55 + String javaVM = System.getProperty("java.vm.name", ""); 6.56 + if (javaVM.contains("Server")) return true; 6.57 + if (javaVM.contains("Client")) return false; 6.58 + throw new Error("Unknown VM type: "+javaVM); 6.59 + } 6.60 + } catch (NoSuchMethodException e) { 6.61 + throw new Error(e); 6.62 + } 6.63 + } 6.64 + 6.65 +}
7.1 --- a/test/compiler/stable/TestStableBoolean.java Mon Jul 14 07:41:47 2014 -0700 7.2 +++ b/test/compiler/stable/TestStableBoolean.java Mon Jul 14 15:48:49 2014 -0700 7.3 @@ -26,9 +26,11 @@ 7.4 /* 7.5 * @test TestStableBoolean 7.6 * @summary tests on stable fields and arrays 7.7 - * @library /testlibrary 7.8 - * @compile -XDignore.symbol.file TestStableBoolean.java 7.9 + * @library /testlibrary /testlibrary/whitebox 7.10 + * @build TestStableBoolean 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/TestStableBoolean 7.15 * java/lang/invoke/TestStableBoolean$BooleanStable 7.16 * java/lang/invoke/TestStableBoolean$StaticBooleanStable 7.17 @@ -48,46 +50,60 @@ 7.18 * java/lang/invoke/TestStableBoolean$NestedStableField3 7.19 * java/lang/invoke/TestStableBoolean$NestedStableField3$A 7.20 * java/lang/invoke/TestStableBoolean$DefaultValue 7.21 + * java/lang/invoke/TestStableBoolean$DefaultStaticValue 7.22 * java/lang/invoke/TestStableBoolean$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.TestStableBoolean 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.TestStableBoolean 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.TestStableBoolean 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.TestStableBoolean 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.TestStableBoolean 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.TestStableBoolean 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 TestStableBoolean { 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(BooleanStable.class); 7.89 + run(DefaultStaticValue.class); 7.90 run(StaticBooleanStable.class); 7.91 run(VolatileBooleanStable.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 boolean v; 7.99 + 7.100 + public static final DefaultStaticValue c = new DefaultStaticValue(); 7.101 + public static boolean get() { return c.v; } 7.102 + public static void test() throws Exception { 7.103 + boolean val1 = get(); 7.104 + c.v = true; boolean val2 = get(); 7.105 + assertEquals(val1, false); 7.106 + assertEquals(val2, true); 7.107 + } 7.108 + } 7.109 + 7.110 + /* ==================================================== */ 7.111 + 7.112 static class StaticBooleanStable { 7.113 public static @Stable boolean v; 7.114 7.115 @@ -188,14 +219,14 @@ 7.116 c.v = new boolean[1]; c.v[0] = true; boolean val1 = get(); 7.117 c.v[0] = false; boolean val2 = get(); 7.118 assertEquals(val1, true); 7.119 - assertEquals(val2, (isStableEnabled ? true : false)); 7.120 + assertEquals(val2, (isServerWithStable ? true : false)); 7.121 } 7.122 7.123 { 7.124 c.v = new boolean[20]; c.v[10] = true; boolean val1 = get1(); 7.125 c.v[10] = false; boolean val2 = get1(); 7.126 assertEquals(val1, true); 7.127 - assertEquals(val2, (isStableEnabled ? true : false)); 7.128 + assertEquals(val2, (isServerWithStable ? true : false)); 7.129 } 7.130 7.131 { 7.132 @@ -220,19 +251,19 @@ 7.133 c.v = new boolean[1][1]; c.v[0][0] = true; boolean val1 = get(); 7.134 c.v[0][0] = false; boolean val2 = get(); 7.135 assertEquals(val1, true); 7.136 - assertEquals(val2, (isStableEnabled ? true : false)); 7.137 + assertEquals(val2, (isServerWithStable ? true : false)); 7.138 7.139 c.v = new boolean[1][1]; c.v[0][0] = false; boolean val3 = get(); 7.140 - assertEquals(val3, (isStableEnabled ? true : false)); 7.141 + assertEquals(val3, (isServerWithStable ? true : false)); 7.142 7.143 c.v[0] = new boolean[1]; c.v[0][0] = false; boolean val4 = get(); 7.144 - assertEquals(val4, (isStableEnabled ? true : false)); 7.145 + assertEquals(val4, (isServerWithStable ? true : false)); 7.146 } 7.147 7.148 { 7.149 c.v = new boolean[1][1]; boolean[] val1 = get1(); 7.150 c.v[0] = new boolean[1]; boolean[] val2 = get1(); 7.151 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 7.152 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 7.153 } 7.154 7.155 { 7.156 @@ -258,28 +289,28 @@ 7.157 c.v = new boolean[1][1][1]; c.v[0][0][0] = true; boolean val1 = get(); 7.158 c.v[0][0][0] = false; boolean val2 = get(); 7.159 assertEquals(val1, true); 7.160 - assertEquals(val2, (isStableEnabled ? true : false)); 7.161 + assertEquals(val2, (isServerWithStable ? true : false)); 7.162 7.163 c.v = new boolean[1][1][1]; c.v[0][0][0] = false; boolean val3 = get(); 7.164 - assertEquals(val3, (isStableEnabled ? true : false)); 7.165 + assertEquals(val3, (isServerWithStable ? true : false)); 7.166 7.167 c.v[0] = new boolean[1][1]; c.v[0][0][0] = false; boolean val4 = get(); 7.168 - assertEquals(val4, (isStableEnabled ? true : false)); 7.169 + assertEquals(val4, (isServerWithStable ? true : false)); 7.170 7.171 c.v[0][0] = new boolean[1]; c.v[0][0][0] = false; boolean val5 = get(); 7.172 - assertEquals(val5, (isStableEnabled ? true : false)); 7.173 + assertEquals(val5, (isServerWithStable ? true : false)); 7.174 } 7.175 7.176 { 7.177 c.v = new boolean[1][1][1]; boolean[] val1 = get1(); 7.178 c.v[0][0] = new boolean[1]; boolean[] val2 = get1(); 7.179 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 7.180 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 7.181 } 7.182 7.183 { 7.184 c.v = new boolean[1][1][1]; boolean[][] val1 = get2(); 7.185 c.v[0] = new boolean[1][1]; boolean[][] val2 = get2(); 7.186 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 7.187 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 7.188 } 7.189 7.190 { 7.191 @@ -306,37 +337,37 @@ 7.192 c.v = new boolean[1][1][1][1]; c.v[0][0][0][0] = true; boolean val1 = get(); 7.193 c.v[0][0][0][0] = false; boolean val2 = get(); 7.194 assertEquals(val1, true); 7.195 - assertEquals(val2, (isStableEnabled ? true : false)); 7.196 + assertEquals(val2, (isServerWithStable ? true : false)); 7.197 7.198 c.v = new boolean[1][1][1][1]; c.v[0][0][0][0] = false; boolean val3 = get(); 7.199 - assertEquals(val3, (isStableEnabled ? true : false)); 7.200 + assertEquals(val3, (isServerWithStable ? true : false)); 7.201 7.202 c.v[0] = new boolean[1][1][1]; c.v[0][0][0][0] = false; boolean val4 = get(); 7.203 - assertEquals(val4, (isStableEnabled ? true : false)); 7.204 + assertEquals(val4, (isServerWithStable ? true : false)); 7.205 7.206 c.v[0][0] = new boolean[1][1]; c.v[0][0][0][0] = false; boolean val5 = get(); 7.207 - assertEquals(val5, (isStableEnabled ? true : false)); 7.208 + assertEquals(val5, (isServerWithStable ? true : false)); 7.209 7.210 c.v[0][0][0] = new boolean[1]; c.v[0][0][0][0] = false; boolean val6 = get(); 7.211 - assertEquals(val6, (isStableEnabled ? true : false)); 7.212 + assertEquals(val6, (isServerWithStable ? true : false)); 7.213 } 7.214 7.215 { 7.216 c.v = new boolean[1][1][1][1]; boolean[] val1 = get1(); 7.217 c.v[0][0][0] = new boolean[1]; boolean[] val2 = get1(); 7.218 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 7.219 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 7.220 } 7.221 7.222 { 7.223 c.v = new boolean[1][1][1][1]; boolean[][] val1 = get2(); 7.224 c.v[0][0] = new boolean[1][1]; boolean[][] val2 = get2(); 7.225 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 7.226 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 7.227 } 7.228 7.229 { 7.230 c.v = new boolean[1][1][1][1]; boolean[][][] val1 = get3(); 7.231 c.v[0] = new boolean[1][1][1]; boolean[][][] val2 = get3(); 7.232 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 7.233 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 7.234 } 7.235 7.236 { 7.237 @@ -399,7 +430,7 @@ 7.238 c.v = new boolean[1][1]; c.v[0] = new boolean[0]; boolean[] val1 = get1(); 7.239 c.v[0] = new boolean[0]; boolean[] val2 = get1(); 7.240 7.241 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 7.242 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 7.243 } 7.244 7.245 { 7.246 @@ -435,14 +466,14 @@ 7.247 c.v = new boolean[1][1][1]; c.v[0][0] = new boolean[0]; boolean[] val1 = get1(); 7.248 c.v[0][0] = new boolean[0]; boolean[] val2 = get1(); 7.249 7.250 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 7.251 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 7.252 } 7.253 7.254 { 7.255 c.v = new boolean[1][1][1]; c.v[0] = new boolean[0][0]; boolean[][] val1 = get2(); 7.256 c.v[0] = new boolean[0][0]; boolean[][] val2 = get2(); 7.257 7.258 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 7.259 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 7.260 } 7.261 7.262 { 7.263 @@ -577,7 +608,7 @@ 7.264 elem.a = false; boolean val3 = get(); boolean val4 = get1(); 7.265 7.266 assertEquals(val1, true); 7.267 - assertEquals(val3, (isStableEnabled ? true : false)); 7.268 + assertEquals(val3, (isServerWithStable ? true : false)); 7.269 7.270 assertEquals(val2, true); 7.271 assertEquals(val4, false); 7.272 @@ -611,17 +642,4 @@ 7.273 } 7.274 } 7.275 } 7.276 - 7.277 - static final boolean isStableEnabled; 7.278 - static { 7.279 - HotSpotDiagnosticMXBean diagnostic 7.280 - = ManagementFactoryHelper.getDiagnosticMXBean(); 7.281 - VMOption tmp; 7.282 - try { 7.283 - tmp = diagnostic.getVMOption("FoldStableValues"); 7.284 - } catch (IllegalArgumentException e) { 7.285 - tmp = null; 7.286 - } 7.287 - isStableEnabled = (tmp == null ? false : Boolean.parseBoolean(tmp.getValue())); 7.288 - } 7.289 }
8.1 --- a/test/compiler/stable/TestStableByte.java Mon Jul 14 07:41:47 2014 -0700 8.2 +++ b/test/compiler/stable/TestStableByte.java Mon Jul 14 15:48:49 2014 -0700 8.3 @@ -26,9 +26,11 @@ 8.4 /* 8.5 * @test TestStableByte 8.6 * @summary tests on stable fields and arrays 8.7 - * @library /testlibrary 8.8 - * @compile -XDignore.symbol.file TestStableByte.java 8.9 + * @library /testlibrary /testlibrary/whitebox 8.10 + * @build TestStableByte 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/TestStableByte 8.15 * java/lang/invoke/TestStableByte$ByteStable 8.16 * java/lang/invoke/TestStableByte$StaticByteStable 8.17 @@ -48,46 +50,60 @@ 8.18 * java/lang/invoke/TestStableByte$NestedStableField3 8.19 * java/lang/invoke/TestStableByte$NestedStableField3$A 8.20 * java/lang/invoke/TestStableByte$DefaultValue 8.21 + * java/lang/invoke/TestStableByte$DefaultStaticValue 8.22 * java/lang/invoke/TestStableByte$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.TestStableByte 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.TestStableByte 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.TestStableByte 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.TestStableByte 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.TestStableByte 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.TestStableByte 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 TestStableByte { 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(ByteStable.class); 8.89 + run(DefaultStaticValue.class); 8.90 run(StaticByteStable.class); 8.91 run(VolatileByteStable.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 byte v; 8.99 + 8.100 + public static final DefaultStaticValue c = new DefaultStaticValue(); 8.101 + public static byte get() { return c.v; } 8.102 + public static void test() throws Exception { 8.103 + byte val1 = get(); 8.104 + c.v = 1; byte 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 StaticByteStable { 8.113 public static @Stable byte v; 8.114 8.115 @@ -188,20 +219,22 @@ 8.116 c.v = new byte[1]; c.v[0] = 1; byte val1 = get(); 8.117 c.v[0] = 2; byte 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 byte[1]; c.v[0] = 3; byte 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 byte[20]; c.v[10] = 1; byte val1 = get1(); 8.130 c.v[10] = 2; byte 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 byte[20]; c.v[10] = 3; byte 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 byte[1][1]; c.v[0][0] = 1; byte val1 = get(); 8.144 c.v[0][0] = 2; byte 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 byte[1][1]; c.v[0][0] = 3; byte 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 byte[1]; c.v[0][0] = 4; byte 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 byte[1][1]; byte[] val1 = get1(); 8.162 c.v[0] = new byte[1]; byte[] 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 byte[1][1][1]; c.v[0][0][0] = 1; byte val1 = get(); 8.170 c.v[0][0][0] = 2; byte 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 byte[1][1][1]; c.v[0][0][0] = 3; byte 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 byte[1][1]; c.v[0][0][0] = 4; byte 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 byte[1]; c.v[0][0][0] = 5; byte 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 byte[1][1][1]; byte[] val1 = get1(); 8.193 c.v[0][0] = new byte[1]; byte[] 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 byte[1][1][1]; byte[][] val1 = get2(); 8.200 c.v[0] = new byte[1][1]; byte[][] 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 byte[1][1][1][1]; c.v[0][0][0][0] = 1; byte val1 = get(); 8.208 c.v[0][0][0][0] = 2; byte 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 byte[1][1][1][1]; c.v[0][0][0][0] = 3; byte 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 byte[1][1][1]; c.v[0][0][0][0] = 4; byte 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 byte[1][1]; c.v[0][0][0][0] = 5; byte 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 byte[1]; c.v[0][0][0][0] = 6; byte 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 byte[1][1][1][1]; byte[] val1 = get1(); 8.236 c.v[0][0][0] = new byte[1]; byte[] 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 byte[1][1][1][1]; byte[][] val1 = get2(); 8.243 c.v[0][0] = new byte[1][1]; byte[][] 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 byte[1][1][1][1]; byte[][][] val1 = get3(); 8.250 c.v[0] = new byte[1][1][1]; byte[][][] 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 @@ -404,7 +446,7 @@ 8.257 c.v = new byte[1][1]; c.v[0] = new byte[0]; byte[] val1 = get1(); 8.258 c.v[0] = new byte[0]; byte[] val2 = get1(); 8.259 8.260 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 8.261 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 8.262 } 8.263 8.264 { 8.265 @@ -440,14 +482,14 @@ 8.266 c.v = new byte[1][1][1]; c.v[0][0] = new byte[0]; byte[] val1 = get1(); 8.267 c.v[0][0] = new byte[0]; byte[] val2 = get1(); 8.268 8.269 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 8.270 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 8.271 } 8.272 8.273 { 8.274 c.v = new byte[1][1][1]; c.v[0] = new byte[0][0]; byte[][] val1 = get2(); 8.275 c.v[0] = new byte[0][0]; byte[][] val2 = get2(); 8.276 8.277 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 8.278 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 8.279 } 8.280 8.281 { 8.282 @@ -582,7 +624,7 @@ 8.283 elem.a = 2; byte val3 = get(); byte val4 = get1(); 8.284 8.285 assertEquals(val1, 1); 8.286 - assertEquals(val3, (isStableEnabled ? 1 : 2)); 8.287 + assertEquals(val3, (isServerWithStable ? 1 : 2)); 8.288 8.289 assertEquals(val2, 1); 8.290 assertEquals(val4, 2); 8.291 @@ -616,17 +658,4 @@ 8.292 } 8.293 } 8.294 } 8.295 - 8.296 - static final boolean isStableEnabled; 8.297 - static { 8.298 - HotSpotDiagnosticMXBean diagnostic 8.299 - = ManagementFactoryHelper.getDiagnosticMXBean(); 8.300 - VMOption tmp; 8.301 - try { 8.302 - tmp = diagnostic.getVMOption("FoldStableValues"); 8.303 - } catch (IllegalArgumentException e) { 8.304 - tmp = null; 8.305 - } 8.306 - isStableEnabled = (tmp == null ? false : Boolean.parseBoolean(tmp.getValue())); 8.307 - } 8.308 }
9.1 --- a/test/compiler/stable/TestStableChar.java Mon Jul 14 07:41:47 2014 -0700 9.2 +++ b/test/compiler/stable/TestStableChar.java Mon Jul 14 15:48:49 2014 -0700 9.3 @@ -26,9 +26,11 @@ 9.4 /* 9.5 * @test TestStableChar 9.6 * @summary tests on stable fields and arrays 9.7 - * @library /testlibrary 9.8 - * @compile -XDignore.symbol.file TestStableChar.java 9.9 + * @library /testlibrary /testlibrary/whitebox 9.10 + * @build TestStableChar 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/TestStableChar 9.15 * java/lang/invoke/TestStableChar$CharStable 9.16 * java/lang/invoke/TestStableChar$StaticCharStable 9.17 @@ -48,46 +50,60 @@ 9.18 * java/lang/invoke/TestStableChar$NestedStableField3 9.19 * java/lang/invoke/TestStableChar$NestedStableField3$A 9.20 * java/lang/invoke/TestStableChar$DefaultValue 9.21 + * java/lang/invoke/TestStableChar$DefaultStaticValue 9.22 * java/lang/invoke/TestStableChar$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.TestStableChar 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.TestStableChar 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.TestStableChar 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.TestStableChar 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.TestStableChar 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.TestStableChar 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 TestStableChar { 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(CharStable.class); 9.89 + run(DefaultStaticValue.class); 9.90 run(StaticCharStable.class); 9.91 run(VolatileCharStable.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 char v; 9.99 + 9.100 + public static final DefaultStaticValue c = new DefaultStaticValue(); 9.101 + public static char get() { return c.v; } 9.102 + public static void test() throws Exception { 9.103 + char val1 = get(); 9.104 + c.v = 'a'; char val2 = get(); 9.105 + assertEquals(val1, 0); 9.106 + assertEquals(val2, 'a'); 9.107 + } 9.108 + } 9.109 + 9.110 + /* ==================================================== */ 9.111 + 9.112 static class StaticCharStable { 9.113 public @Stable char v; 9.114 9.115 @@ -188,20 +219,22 @@ 9.116 c.v = new char[1]; c.v[0] = 'a'; char val1 = get(); 9.117 c.v[0] = 'b'; char val2 = get(); 9.118 assertEquals(val1, 'a'); 9.119 - assertEquals(val2, (isStableEnabled ? 'a' : 'b')); 9.120 + assertEquals(val2, (isServerWithStable ? 'a' : 'b')); 9.121 9.122 c.v = new char[1]; c.v[0] = 'c'; char val3 = get(); 9.123 - assertEquals(val3, (isStableEnabled ? 'a' : 'c')); 9.124 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 'a' : 'b') 9.125 + : 'c')); 9.126 } 9.127 9.128 { 9.129 c.v = new char[20]; c.v[10] = 'a'; char val1 = get1(); 9.130 c.v[10] = 'b'; char val2 = get1(); 9.131 assertEquals(val1, 'a'); 9.132 - assertEquals(val2, (isStableEnabled ? 'a' : 'b')); 9.133 + assertEquals(val2, (isServerWithStable ? 'a' : 'b')); 9.134 9.135 c.v = new char[20]; c.v[10] = 'c'; char val3 = get1(); 9.136 - assertEquals(val3, (isStableEnabled ? 'a' : 'c')); 9.137 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 'a' : 'b') 9.138 + : 'c')); 9.139 } 9.140 9.141 { 9.142 @@ -226,19 +259,21 @@ 9.143 c.v = new char[1][1]; c.v[0][0] = 'a'; char val1 = get(); 9.144 c.v[0][0] = 'b'; char val2 = get(); 9.145 assertEquals(val1, 'a'); 9.146 - assertEquals(val2, (isStableEnabled ? 'a' : 'b')); 9.147 + assertEquals(val2, (isServerWithStable ? 'a' : 'b')); 9.148 9.149 c.v = new char[1][1]; c.v[0][0] = 'c'; char val3 = get(); 9.150 - assertEquals(val3, (isStableEnabled ? 'a' : 'c')); 9.151 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 'a' : 'b') 9.152 + : 'c')); 9.153 9.154 c.v[0] = new char[1]; c.v[0][0] = 'd'; char val4 = get(); 9.155 - assertEquals(val4, (isStableEnabled ? 'a' : 'd')); 9.156 + assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 'a' : 'b') 9.157 + : 'd')); 9.158 } 9.159 9.160 { 9.161 c.v = new char[1][1]; char[] val1 = get1(); 9.162 c.v[0] = new char[1]; char[] 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 char[1][1][1]; c.v[0][0][0] = 'a'; char val1 = get(); 9.170 c.v[0][0][0] = 'b'; char val2 = get(); 9.171 assertEquals(val1, 'a'); 9.172 - assertEquals(val2, (isStableEnabled ? 'a' : 'b')); 9.173 + assertEquals(val2, (isServerWithStable ? 'a' : 'b')); 9.174 9.175 c.v = new char[1][1][1]; c.v[0][0][0] = 'c'; char val3 = get(); 9.176 - assertEquals(val3, (isStableEnabled ? 'a' : 'c')); 9.177 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 'a' : 'b') 9.178 + : 'c')); 9.179 9.180 c.v[0] = new char[1][1]; c.v[0][0][0] = 'd'; char val4 = get(); 9.181 - assertEquals(val4, (isStableEnabled ? 'a' : 'd')); 9.182 + assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 'a' : 'b') 9.183 + : 'd')); 9.184 9.185 c.v[0][0] = new char[1]; c.v[0][0][0] = 'e'; char val5 = get(); 9.186 - assertEquals(val5, (isStableEnabled ? 'a' : 'e')); 9.187 + assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 'a' : 'b') 9.188 + : 'e')); 9.189 } 9.190 9.191 { 9.192 c.v = new char[1][1][1]; char[] val1 = get1(); 9.193 c.v[0][0] = new char[1]; char[] 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 char[1][1][1]; char[][] val1 = get2(); 9.200 c.v[0] = new char[1][1]; char[][] 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 char[1][1][1][1]; c.v[0][0][0][0] = 'a'; char val1 = get(); 9.208 c.v[0][0][0][0] = 'b'; char val2 = get(); 9.209 assertEquals(val1, 'a'); 9.210 - assertEquals(val2, (isStableEnabled ? 'a' : 'b')); 9.211 + assertEquals(val2, (isServerWithStable ? 'a' : 'b')); 9.212 9.213 c.v = new char[1][1][1][1]; c.v[0][0][0][0] = 'c'; char val3 = get(); 9.214 - assertEquals(val3, (isStableEnabled ? 'a' : 'c')); 9.215 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 'a' : 'b') 9.216 + : 'c')); 9.217 9.218 c.v[0] = new char[1][1][1]; c.v[0][0][0][0] = 'd'; char val4 = get(); 9.219 - assertEquals(val4, (isStableEnabled ? 'a' : 'd')); 9.220 + assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 'a' : 'b') 9.221 + : 'd')); 9.222 9.223 c.v[0][0] = new char[1][1]; c.v[0][0][0][0] = 'e'; char val5 = get(); 9.224 - assertEquals(val5, (isStableEnabled ? 'a' : 'e')); 9.225 + assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 'a' : 'b') 9.226 + : 'e')); 9.227 9.228 c.v[0][0][0] = new char[1]; c.v[0][0][0][0] = 'f'; char val6 = get(); 9.229 - assertEquals(val6, (isStableEnabled ? 'a' : 'f')); 9.230 + assertEquals(val6, (isStableEnabled ? (isServerWithStable ? 'a' : 'b') 9.231 + : 'f')); 9.232 } 9.233 9.234 { 9.235 c.v = new char[1][1][1][1]; char[] val1 = get1(); 9.236 c.v[0][0][0] = new char[1]; char[] 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 char[1][1][1][1]; char[][] val1 = get2(); 9.243 c.v[0][0] = new char[1][1]; char[][] 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 char[1][1][1][1]; char[][][] val1 = get3(); 9.250 c.v[0] = new char[1][1][1]; char[][][] 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,7 +392,6 @@ 9.257 c.v = new char[1][1][1][1]; char[][][][] val2 = get4(); 9.258 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 9.259 } 9.260 - 9.261 } 9.262 } 9.263 9.264 @@ -403,7 +444,7 @@ 9.265 c.v = new char[1][1]; c.v[0] = new char[0]; char[] val1 = get1(); 9.266 c.v[0] = new char[0]; char[] val2 = get1(); 9.267 9.268 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 9.269 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 9.270 } 9.271 9.272 { 9.273 @@ -439,14 +480,14 @@ 9.274 c.v = new char[1][1][1]; c.v[0][0] = new char[0]; char[] val1 = get1(); 9.275 c.v[0][0] = new char[0]; char[] val2 = get1(); 9.276 9.277 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 9.278 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 9.279 } 9.280 9.281 { 9.282 c.v = new char[1][1][1]; c.v[0] = new char[0][0]; char[][] val1 = get2(); 9.283 c.v[0] = new char[0][0]; char[][] val2 = get2(); 9.284 9.285 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 9.286 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 9.287 } 9.288 9.289 { 9.290 @@ -581,7 +622,7 @@ 9.291 elem.a = 'b'; char val3 = get(); char val4 = get1(); 9.292 9.293 assertEquals(val1, 'a'); 9.294 - assertEquals(val3, (isStableEnabled ? 'a' : 'b')); 9.295 + assertEquals(val3, (isServerWithStable ? 'a' : 'b')); 9.296 9.297 assertEquals(val2, 'a'); 9.298 assertEquals(val4, 'b'); 9.299 @@ -615,17 +656,4 @@ 9.300 } 9.301 } 9.302 } 9.303 - 9.304 - static final boolean isStableEnabled; 9.305 - static { 9.306 - HotSpotDiagnosticMXBean diagnostic 9.307 - = ManagementFactoryHelper.getDiagnosticMXBean(); 9.308 - VMOption tmp; 9.309 - try { 9.310 - tmp = diagnostic.getVMOption("FoldStableValues"); 9.311 - } catch (IllegalArgumentException e) { 9.312 - tmp = null; 9.313 - } 9.314 - isStableEnabled = (tmp == null ? false : Boolean.parseBoolean(tmp.getValue())); 9.315 - } 9.316 }
10.1 --- a/test/compiler/stable/TestStableDouble.java Mon Jul 14 07:41:47 2014 -0700 10.2 +++ b/test/compiler/stable/TestStableDouble.java Mon Jul 14 15:48:49 2014 -0700 10.3 @@ -26,9 +26,11 @@ 10.4 /* 10.5 * @test TestStableDouble 10.6 * @summary tests on stable fields and arrays 10.7 - * @library /testlibrary 10.8 - * @compile -XDignore.symbol.file TestStableDouble.java 10.9 + * @library /testlibrary /testlibrary/whitebox 10.10 + * @build TestStableDouble 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/TestStableDouble 10.15 * java/lang/invoke/TestStableDouble$DoubleStable 10.16 * java/lang/invoke/TestStableDouble$StaticDoubleStable 10.17 @@ -48,46 +50,60 @@ 10.18 * java/lang/invoke/TestStableDouble$NestedStableField3 10.19 * java/lang/invoke/TestStableDouble$NestedStableField3$A 10.20 * java/lang/invoke/TestStableDouble$DefaultValue 10.21 + * java/lang/invoke/TestStableDouble$DefaultStaticValue 10.22 * java/lang/invoke/TestStableDouble$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.TestStableDouble 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.TestStableDouble 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.TestStableDouble 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.TestStableDouble 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.TestStableDouble 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.TestStableDouble 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 TestStableDouble { 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(DoubleStable.class); 10.89 + run(DefaultStaticValue.class); 10.90 run(StaticDoubleStable.class); 10.91 run(VolatileDoubleStable.class); 10.92 10.93 @@ -145,6 +161,21 @@ 10.94 10.95 /* ==================================================== */ 10.96 10.97 + static class DefaultStaticValue { 10.98 + public static @Stable double v; 10.99 + 10.100 + public static final DefaultStaticValue c = new DefaultStaticValue(); 10.101 + public static double get() { return c.v; } 10.102 + public static void test() throws Exception { 10.103 + double val1 = get(); 10.104 + c.v = 1.0; double val2 = get(); 10.105 + assertEquals(val1, 0); 10.106 + assertEquals(val2, 1.0); 10.107 + } 10.108 + } 10.109 + 10.110 + /* ==================================================== */ 10.111 + 10.112 static class StaticDoubleStable { 10.113 public static @Stable double v; 10.114 10.115 @@ -188,20 +219,22 @@ 10.116 c.v = new double[1]; c.v[0] = 1.0; double val1 = get(); 10.117 c.v[0] = 2.0; double val2 = get(); 10.118 assertEquals(val1, 1.0); 10.119 - assertEquals(val2, (isStableEnabled ? 1.0 : 2.0)); 10.120 + assertEquals(val2, (isServerWithStable ? 1.0 : 2.0)); 10.121 10.122 c.v = new double[1]; c.v[0] = 3.0; double val3 = get(); 10.123 - assertEquals(val3, (isStableEnabled ? 1.0 : 3.0)); 10.124 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0) 10.125 + : 3.0)); 10.126 } 10.127 10.128 { 10.129 c.v = new double[20]; c.v[10] = 1.0; double val1 = get1(); 10.130 c.v[10] = 2.0; double val2 = get1(); 10.131 assertEquals(val1, 1.0); 10.132 - assertEquals(val2, (isStableEnabled ? 1.0 : 2.0)); 10.133 + assertEquals(val2, (isServerWithStable ? 1.0 : 2.0)); 10.134 10.135 c.v = new double[20]; c.v[10] = 3.0; double val3 = get1(); 10.136 - assertEquals(val3, (isStableEnabled ? 1.0 : 3.0)); 10.137 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0) 10.138 + : 3.0)); 10.139 } 10.140 10.141 { 10.142 @@ -226,19 +259,21 @@ 10.143 c.v = new double[1][1]; c.v[0][0] = 1.0; double val1 = get(); 10.144 c.v[0][0] = 2.0; double val2 = get(); 10.145 assertEquals(val1, 1.0); 10.146 - assertEquals(val2, (isStableEnabled ? 1.0 : 2.0)); 10.147 + assertEquals(val2, (isServerWithStable ? 1.0 : 2.0)); 10.148 10.149 c.v = new double[1][1]; c.v[0][0] = 3.0; double val3 = get(); 10.150 - assertEquals(val3, (isStableEnabled ? 1.0 : 3.0)); 10.151 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0) 10.152 + : 3.0)); 10.153 10.154 c.v[0] = new double[1]; c.v[0][0] = 4.0; double val4 = get(); 10.155 - assertEquals(val4, (isStableEnabled ? 1.0 : 4.0)); 10.156 + assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0) 10.157 + : 4.0)); 10.158 } 10.159 10.160 { 10.161 c.v = new double[1][1]; double[] val1 = get1(); 10.162 c.v[0] = new double[1]; double[] 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 @@ -264,28 +299,31 @@ 10.169 c.v = new double[1][1][1]; c.v[0][0][0] = 1.0; double val1 = get(); 10.170 c.v[0][0][0] = 2.0; double val2 = get(); 10.171 assertEquals(val1, 1.0); 10.172 - assertEquals(val2, (isStableEnabled ? 1.0 : 2.0)); 10.173 + assertEquals(val2, (isServerWithStable ? 1.0 : 2.0)); 10.174 10.175 c.v = new double[1][1][1]; c.v[0][0][0] = 3.0; double val3 = get(); 10.176 - assertEquals(val3, (isStableEnabled ? 1.0 : 3.0)); 10.177 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0) 10.178 + : 3.0)); 10.179 10.180 c.v[0] = new double[1][1]; c.v[0][0][0] = 4.0; double val4 = get(); 10.181 - assertEquals(val4, (isStableEnabled ? 1.0 : 4.0)); 10.182 + assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0) 10.183 + : 4.0)); 10.184 10.185 c.v[0][0] = new double[1]; c.v[0][0][0] = 5.0; double val5 = get(); 10.186 - assertEquals(val5, (isStableEnabled ? 1.0 : 5.0)); 10.187 + assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0) 10.188 + : 5.0)); 10.189 } 10.190 10.191 { 10.192 c.v = new double[1][1][1]; double[] val1 = get1(); 10.193 c.v[0][0] = new double[1]; double[] 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 double[1][1][1]; double[][] val1 = get2(); 10.200 c.v[0] = new double[1][1]; double[][] 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 @@ -312,37 +350,41 @@ 10.207 c.v = new double[1][1][1][1]; c.v[0][0][0][0] = 1.0; double val1 = get(); 10.208 c.v[0][0][0][0] = 2.0; double val2 = get(); 10.209 assertEquals(val1, 1.0); 10.210 - assertEquals(val2, (isStableEnabled ? 1.0 : 2.0)); 10.211 + assertEquals(val2, (isServerWithStable ? 1.0 : 2.0)); 10.212 10.213 c.v = new double[1][1][1][1]; c.v[0][0][0][0] = 3.0; double val3 = get(); 10.214 - assertEquals(val3, (isStableEnabled ? 1.0 : 3.0)); 10.215 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0) 10.216 + : 3.0)); 10.217 10.218 c.v[0] = new double[1][1][1]; c.v[0][0][0][0] = 4.0; double val4 = get(); 10.219 - assertEquals(val4, (isStableEnabled ? 1.0 : 4.0)); 10.220 + assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0) 10.221 + : 4.0)); 10.222 10.223 c.v[0][0] = new double[1][1]; c.v[0][0][0][0] = 5.0; double val5 = get(); 10.224 - assertEquals(val5, (isStableEnabled ? 1.0 : 5.0)); 10.225 + assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0) 10.226 + : 5.0)); 10.227 10.228 c.v[0][0][0] = new double[1]; c.v[0][0][0][0] = 6.0; double val6 = get(); 10.229 - assertEquals(val6, (isStableEnabled ? 1.0 : 6.0)); 10.230 + assertEquals(val6, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0) 10.231 + : 6.0)); 10.232 } 10.233 10.234 { 10.235 c.v = new double[1][1][1][1]; double[] val1 = get1(); 10.236 c.v[0][0][0] = new double[1]; double[] 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 double[1][1][1][1]; double[][] val1 = get2(); 10.243 c.v[0][0] = new double[1][1]; double[][] 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 double[1][1][1][1]; double[][][] val1 = get3(); 10.250 c.v[0] = new double[1][1][1]; double[][][] 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 @@ -350,13 +392,11 @@ 10.257 c.v = new double[1][1][1][1]; double[][][][] 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 @@ -404,7 +444,7 @@ 10.271 c.v = new double[1][1]; c.v[0] = new double[0]; double[] val1 = get1(); 10.272 c.v[0] = new double[0]; double[] 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 @@ -440,14 +480,14 @@ 10.280 c.v = new double[1][1][1]; c.v[0][0] = new double[0]; double[] val1 = get1(); 10.281 c.v[0][0] = new double[0]; double[] 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 double[1][1][1]; c.v[0] = new double[0][0]; double[][] val1 = get2(); 10.289 c.v[0] = new double[0][0]; double[][] 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 @@ -582,7 +622,7 @@ 10.297 elem.a = 2.0; double val3 = get(); double val4 = get1(); 10.298 10.299 assertEquals(val1, 1.0); 10.300 - assertEquals(val3, (isStableEnabled ? 1.0 : 2.0)); 10.301 + assertEquals(val3, (isServerWithStable ? 1.0 : 2.0)); 10.302 10.303 assertEquals(val2, 1.0); 10.304 assertEquals(val4, 2.0); 10.305 @@ -616,17 +656,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/TestStableFloat.java Mon Jul 14 07:41:47 2014 -0700 11.2 +++ b/test/compiler/stable/TestStableFloat.java Mon Jul 14 15:48:49 2014 -0700 11.3 @@ -26,9 +26,11 @@ 11.4 /* 11.5 * @test TestStableFloat 11.6 * @summary tests on stable fields and arrays 11.7 - * @library /testlibrary 11.8 - * @compile -XDignore.symbol.file TestStableFloat.java 11.9 + * @library /testlibrary /testlibrary/whitebox 11.10 + * @build TestStableFloat 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/TestStableFloat 11.15 * java/lang/invoke/TestStableFloat$FloatStable 11.16 * java/lang/invoke/TestStableFloat$StaticFloatStable 11.17 @@ -48,46 +50,60 @@ 11.18 * java/lang/invoke/TestStableFloat$NestedStableField3 11.19 * java/lang/invoke/TestStableFloat$NestedStableField3$A 11.20 * java/lang/invoke/TestStableFloat$DefaultValue 11.21 + * java/lang/invoke/TestStableFloat$DefaultStaticValue 11.22 * java/lang/invoke/TestStableFloat$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.TestStableFloat 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.TestStableFloat 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.TestStableFloat 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.TestStableFloat 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.TestStableFloat 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.TestStableFloat 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 TestStableFloat { 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(FloatStable.class); 11.89 + run(DefaultStaticValue.class); 11.90 run(StaticFloatStable.class); 11.91 run(VolatileFloatStable.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 float v; 11.99 + 11.100 + public static final DefaultStaticValue c = new DefaultStaticValue(); 11.101 + public static float get() { return c.v; } 11.102 + public static void test() throws Exception { 11.103 + float val1 = get(); 11.104 + c.v = 1.0F; float val2 = get(); 11.105 + assertEquals(val1, 0F); 11.106 + assertEquals(val2, 1.0F); 11.107 + } 11.108 + } 11.109 + 11.110 + /* ==================================================== */ 11.111 + 11.112 static class StaticFloatStable { 11.113 public static @Stable float v; 11.114 11.115 @@ -188,20 +219,22 @@ 11.116 c.v = new float[1]; c.v[0] = 1.0F; float val1 = get(); 11.117 c.v[0] = 2.0F; float val2 = get(); 11.118 assertEquals(val1, 1.0F); 11.119 - assertEquals(val2, (isStableEnabled ? 1.0F : 2.0F)); 11.120 + assertEquals(val2, (isServerWithStable ? 1.0F : 2.0F)); 11.121 11.122 c.v = new float[1]; c.v[0] = 3.0F; float val3 = get(); 11.123 - assertEquals(val3, (isStableEnabled ? 1.0F : 3.0F)); 11.124 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0F : 2.0F) 11.125 + : 3.0F)); 11.126 } 11.127 11.128 { 11.129 c.v = new float[20]; c.v[10] = 1.0F; float val1 = get1(); 11.130 c.v[10] = 2.0F; float val2 = get1(); 11.131 assertEquals(val1, 1.0F); 11.132 - assertEquals(val2, (isStableEnabled ? 1.0F : 2.0F)); 11.133 + assertEquals(val2, (isServerWithStable ? 1.0F : 2.0F)); 11.134 11.135 c.v = new float[20]; c.v[10] = 3.0F; float val3 = get1(); 11.136 - assertEquals(val3, (isStableEnabled ? 1.0F : 3.0F)); 11.137 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0F : 2.0F) 11.138 + : 3.0F)); 11.139 } 11.140 11.141 { 11.142 @@ -226,19 +259,21 @@ 11.143 c.v = new float[1][1]; c.v[0][0] = 1.0F; float val1 = get(); 11.144 c.v[0][0] = 2.0F; float val2 = get(); 11.145 assertEquals(val1, 1.0F); 11.146 - assertEquals(val2, (isStableEnabled ? 1.0F : 2.0F)); 11.147 + assertEquals(val2, (isServerWithStable ? 1.0F : 2.0F)); 11.148 11.149 c.v = new float[1][1]; c.v[0][0] = 3.0F; float val3 = get(); 11.150 - assertEquals(val3, (isStableEnabled ? 1.0F : 3.0F)); 11.151 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0F : 2.0F) 11.152 + : 3.0F)); 11.153 11.154 c.v[0] = new float[1]; c.v[0][0] = 4.0F; float val4 = get(); 11.155 - assertEquals(val4, (isStableEnabled ? 1.0F : 4.0F)); 11.156 + assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1.0F : 2.0F) 11.157 + : 4.0F)); 11.158 } 11.159 11.160 { 11.161 c.v = new float[1][1]; float[] val1 = get1(); 11.162 c.v[0] = new float[1]; float[] 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 float[1][1][1]; c.v[0][0][0] = 1.0F; float val1 = get(); 11.170 c.v[0][0][0] = 2.0F; float val2 = get(); 11.171 assertEquals(val1, 1.0F); 11.172 - assertEquals(val2, (isStableEnabled ? 1.0F : 2.0F)); 11.173 + assertEquals(val2, (isServerWithStable ? 1.0F : 2.0F)); 11.174 11.175 c.v = new float[1][1][1]; c.v[0][0][0] = 3.0F; float val3 = get(); 11.176 - assertEquals(val3, (isStableEnabled ? 1.0F : 3.0F)); 11.177 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0F : 2.0F) 11.178 + : 3.0F)); 11.179 11.180 c.v[0] = new float[1][1]; c.v[0][0][0] = 4.0F; float val4 = get(); 11.181 - assertEquals(val4, (isStableEnabled ? 1.0F : 4.0F)); 11.182 + assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1.0F : 2.0F) 11.183 + : 4.0F)); 11.184 11.185 c.v[0][0] = new float[1]; c.v[0][0][0] = 5.0F; float val5 = get(); 11.186 - assertEquals(val5, (isStableEnabled ? 1.0F : 5.0F)); 11.187 + assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1.0F : 2.0F) 11.188 + : 5.0F)); 11.189 } 11.190 11.191 { 11.192 c.v = new float[1][1][1]; float[] val1 = get1(); 11.193 c.v[0][0] = new float[1]; float[] 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 float[1][1][1]; float[][] val1 = get2(); 11.200 c.v[0] = new float[1][1]; float[][] 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 float[1][1][1][1]; c.v[0][0][0][0] = 1.0F; float val1 = get(); 11.208 c.v[0][0][0][0] = 2.0F; float val2 = get(); 11.209 assertEquals(val1, 1.0F); 11.210 - assertEquals(val2, (isStableEnabled ? 1.0F : 2.0F)); 11.211 + assertEquals(val2, (isServerWithStable ? 1.0F : 2.0F)); 11.212 11.213 c.v = new float[1][1][1][1]; c.v[0][0][0][0] = 3.0F; float val3 = get(); 11.214 - assertEquals(val3, (isStableEnabled ? 1.0F : 3.0F)); 11.215 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0F : 2.0F) 11.216 + : 3.0F)); 11.217 11.218 c.v[0] = new float[1][1][1]; c.v[0][0][0][0] = 4.0F; float val4 = get(); 11.219 - assertEquals(val4, (isStableEnabled ? 1.0F : 4.0F)); 11.220 + assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1.0F : 2.0F) 11.221 + : 4.0F)); 11.222 11.223 c.v[0][0] = new float[1][1]; c.v[0][0][0][0] = 5.0F; float val5 = get(); 11.224 - assertEquals(val5, (isStableEnabled ? 1.0F : 5.0F)); 11.225 + assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1.0F : 2.0F) 11.226 + : 5.0F)); 11.227 11.228 c.v[0][0][0] = new float[1]; c.v[0][0][0][0] = 6.0F; float val6 = get(); 11.229 - assertEquals(val6, (isStableEnabled ? 1.0F : 6.0F)); 11.230 + assertEquals(val6, (isStableEnabled ? (isServerWithStable ? 1.0F : 2.0F) 11.231 + : 6.0F)); 11.232 } 11.233 11.234 { 11.235 c.v = new float[1][1][1][1]; float[] val1 = get1(); 11.236 c.v[0][0][0] = new float[1]; float[] 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 float[1][1][1][1]; float[][] val1 = get2(); 11.243 c.v[0][0] = new float[1][1]; float[][] 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 float[1][1][1][1]; float[][][] val1 = get3(); 11.250 c.v[0] = new float[1][1][1]; float[][][] 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 float[1][1][1][1]; float[][][][] 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 float[1][1]; c.v[0] = new float[0]; float[] val1 = get1(); 11.272 c.v[0] = new float[0]; float[] 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 float[1][1][1]; c.v[0][0] = new float[0]; float[] val1 = get1(); 11.281 c.v[0][0] = new float[0]; float[] 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 float[1][1][1]; c.v[0] = new float[0][0]; float[][] val1 = get2(); 11.289 c.v[0] = new float[0][0]; float[][] 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.0F; float val3 = get(); float val4 = get1(); 11.298 11.299 assertEquals(val1, 1.0F); 11.300 - assertEquals(val3, (isStableEnabled ? 1.0F : 2.0F)); 11.301 + assertEquals(val3, (isServerWithStable ? 1.0F : 2.0F)); 11.302 11.303 assertEquals(val2, 1.0F); 11.304 assertEquals(val4, 2.0F); 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 }
12.1 --- a/test/compiler/stable/TestStableInt.java Mon Jul 14 07:41:47 2014 -0700 12.2 +++ b/test/compiler/stable/TestStableInt.java Mon Jul 14 15:48:49 2014 -0700 12.3 @@ -26,9 +26,11 @@ 12.4 /* 12.5 * @test TestStableInt 12.6 * @summary tests on stable fields and arrays 12.7 - * @library /testlibrary 12.8 - * @compile -XDignore.symbol.file TestStableInt.java 12.9 + * @library /testlibrary /testlibrary/whitebox 12.10 + * @build TestStableInt StableConfiguration sun.hotspot.WhiteBox 12.11 + * @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission 12.12 * @run main ClassFileInstaller 12.13 + * java/lang/invoke/StableConfiguration 12.14 * java/lang/invoke/TestStableInt 12.15 * java/lang/invoke/TestStableInt$IntStable 12.16 * java/lang/invoke/TestStableInt$StaticIntStable 12.17 @@ -48,46 +50,60 @@ 12.18 * java/lang/invoke/TestStableInt$NestedStableField3 12.19 * java/lang/invoke/TestStableInt$NestedStableField3$A 12.20 * java/lang/invoke/TestStableInt$DefaultValue 12.21 + * java/lang/invoke/TestStableInt$DefaultStaticValue 12.22 * java/lang/invoke/TestStableInt$ObjectArrayLowerDim2 12.23 * 12.24 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 12.25 - * -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:+UseCompressedOop 12.26 - * -server -XX:-TieredCompilation -Xcomp 12.27 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 12.28 + * -server -XX:-TieredCompilation 12.29 + * -XX:+FoldStableValues 12.30 + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 12.31 + * java.lang.invoke.TestStableInt 12.32 + * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 12.33 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 12.34 + * -server -XX:-TieredCompilation 12.35 + * -XX:-FoldStableValues 12.36 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 12.37 * java.lang.invoke.TestStableInt 12.38 * 12.39 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 12.40 - * -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:-UseCompressedOop 12.41 - * -server -XX:-TieredCompilation -Xcomp 12.42 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 12.43 + * -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1 12.44 + * -XX:+FoldStableValues 12.45 + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 12.46 + * java.lang.invoke.TestStableInt 12.47 + * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 12.48 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 12.49 + * -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1 12.50 + * -XX:-FoldStableValues 12.51 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 12.52 * java.lang.invoke.TestStableInt 12.53 * 12.54 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 12.55 - * -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:+UseCompressedOop 12.56 - * -server -XX:-TieredCompilation -Xcomp 12.57 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 12.58 + * -client -XX:-TieredCompilation 12.59 + * -XX:+FoldStableValues 12.60 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 12.61 * java.lang.invoke.TestStableInt 12.62 - * 12.63 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 12.64 - * -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:-UseCompressedOop 12.65 - * -server -XX:-TieredCompilation -Xcomp 12.66 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 12.67 + * -client -XX:-TieredCompilation 12.68 + * -XX:-FoldStableValues 12.69 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 12.70 * java.lang.invoke.TestStableInt 12.71 */ 12.72 package java.lang.invoke; 12.73 12.74 -import com.sun.management.HotSpotDiagnosticMXBean; 12.75 -import com.sun.management.VMOption; 12.76 -import sun.management.ManagementFactoryHelper; 12.77 import java.lang.reflect.InvocationTargetException; 12.78 12.79 public class TestStableInt { 12.80 + static final boolean isStableEnabled = StableConfiguration.isStableEnabled; 12.81 + static final boolean isServerWithStable = StableConfiguration.isServerWithStable; 12.82 + 12.83 public static void main(String[] args) throws Exception { 12.84 - System.out.println("@Stable enabled: "+isStableEnabled); 12.85 - System.out.println(); 12.86 - 12.87 run(DefaultValue.class); 12.88 run(IntStable.class); 12.89 + run(DefaultStaticValue.class); 12.90 run(StaticIntStable.class); 12.91 run(VolatileIntStable.class); 12.92 12.93 @@ -145,6 +161,21 @@ 12.94 12.95 /* ==================================================== */ 12.96 12.97 + static class DefaultStaticValue { 12.98 + public static @Stable int v; 12.99 + 12.100 + public static final DefaultStaticValue c = new DefaultStaticValue(); 12.101 + public static int get() { return c.v; } 12.102 + public static void test() throws Exception { 12.103 + int val1 = get(); 12.104 + c.v = 1; int val2 = get(); 12.105 + assertEquals(val1, 0); 12.106 + assertEquals(val2, 1); 12.107 + } 12.108 + } 12.109 + 12.110 + /* ==================================================== */ 12.111 + 12.112 static class StaticIntStable { 12.113 public static @Stable int v; 12.114 12.115 @@ -188,20 +219,22 @@ 12.116 c.v = new int[1]; c.v[0] = 1; int val1 = get(); 12.117 c.v[0] = 2; int val2 = get(); 12.118 assertEquals(val1, 1); 12.119 - assertEquals(val2, (isStableEnabled ? 1 : 2)); 12.120 + assertEquals(val2, (isServerWithStable ? 1 : 2)); 12.121 12.122 c.v = new int[1]; c.v[0] = 3; int val3 = get(); 12.123 - assertEquals(val3, (isStableEnabled ? 1 : 3)); 12.124 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2) 12.125 + : 3)); 12.126 } 12.127 12.128 { 12.129 c.v = new int[20]; c.v[10] = 1; int val1 = get1(); 12.130 c.v[10] = 2; int val2 = get1(); 12.131 assertEquals(val1, 1); 12.132 - assertEquals(val2, (isStableEnabled ? 1 : 2)); 12.133 + assertEquals(val2, (isServerWithStable ? 1 : 2)); 12.134 12.135 c.v = new int[20]; c.v[10] = 3; int val3 = get1(); 12.136 - assertEquals(val3, (isStableEnabled ? 1 : 3)); 12.137 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2) 12.138 + : 3)); 12.139 } 12.140 12.141 { 12.142 @@ -226,19 +259,21 @@ 12.143 c.v = new int[1][1]; c.v[0][0] = 1; int val1 = get(); 12.144 c.v[0][0] = 2; int val2 = get(); 12.145 assertEquals(val1, 1); 12.146 - assertEquals(val2, (isStableEnabled ? 1 : 2)); 12.147 + assertEquals(val2, (isServerWithStable ? 1 : 2)); 12.148 12.149 c.v = new int[1][1]; c.v[0][0] = 3; int val3 = get(); 12.150 - assertEquals(val3, (isStableEnabled ? 1 : 3)); 12.151 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2) 12.152 + : 3)); 12.153 12.154 c.v[0] = new int[1]; c.v[0][0] = 4; int val4 = get(); 12.155 - assertEquals(val4, (isStableEnabled ? 1 : 4)); 12.156 + assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2) 12.157 + : 4)); 12.158 } 12.159 12.160 { 12.161 c.v = new int[1][1]; int[] val1 = get1(); 12.162 c.v[0] = new int[1]; int[] val2 = get1(); 12.163 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 12.164 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 12.165 } 12.166 12.167 { 12.168 @@ -264,28 +299,31 @@ 12.169 c.v = new int[1][1][1]; c.v[0][0][0] = 1; int val1 = get(); 12.170 c.v[0][0][0] = 2; int val2 = get(); 12.171 assertEquals(val1, 1); 12.172 - assertEquals(val2, (isStableEnabled ? 1 : 2)); 12.173 + assertEquals(val2, (isServerWithStable ? 1 : 2)); 12.174 12.175 c.v = new int[1][1][1]; c.v[0][0][0] = 3; int val3 = get(); 12.176 - assertEquals(val3, (isStableEnabled ? 1 : 3)); 12.177 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2) 12.178 + : 3)); 12.179 12.180 c.v[0] = new int[1][1]; c.v[0][0][0] = 4; int val4 = get(); 12.181 - assertEquals(val4, (isStableEnabled ? 1 : 4)); 12.182 + assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2) 12.183 + : 4)); 12.184 12.185 c.v[0][0] = new int[1]; c.v[0][0][0] = 5; int val5 = get(); 12.186 - assertEquals(val5, (isStableEnabled ? 1 : 5)); 12.187 + assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1 : 2) 12.188 + : 5)); 12.189 } 12.190 12.191 { 12.192 c.v = new int[1][1][1]; int[] val1 = get1(); 12.193 c.v[0][0] = new int[1]; int[] val2 = get1(); 12.194 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 12.195 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 12.196 } 12.197 12.198 { 12.199 c.v = new int[1][1][1]; int[][] val1 = get2(); 12.200 c.v[0] = new int[1][1]; int[][] val2 = get2(); 12.201 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 12.202 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 12.203 } 12.204 12.205 { 12.206 @@ -312,37 +350,41 @@ 12.207 c.v = new int[1][1][1][1]; c.v[0][0][0][0] = 1; int val1 = get(); 12.208 c.v[0][0][0][0] = 2; int val2 = get(); 12.209 assertEquals(val1, 1); 12.210 - assertEquals(val2, (isStableEnabled ? 1 : 2)); 12.211 + assertEquals(val2, (isServerWithStable ? 1 : 2)); 12.212 12.213 c.v = new int[1][1][1][1]; c.v[0][0][0][0] = 3; int val3 = get(); 12.214 - assertEquals(val3, (isStableEnabled ? 1 : 3)); 12.215 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2) 12.216 + : 3)); 12.217 12.218 c.v[0] = new int[1][1][1]; c.v[0][0][0][0] = 4; int val4 = get(); 12.219 - assertEquals(val4, (isStableEnabled ? 1 : 4)); 12.220 + assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2) 12.221 + : 4)); 12.222 12.223 c.v[0][0] = new int[1][1]; c.v[0][0][0][0] = 5; int val5 = get(); 12.224 - assertEquals(val5, (isStableEnabled ? 1 : 5)); 12.225 + assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1 : 2) 12.226 + : 5)); 12.227 12.228 c.v[0][0][0] = new int[1]; c.v[0][0][0][0] = 6; int val6 = get(); 12.229 - assertEquals(val6, (isStableEnabled ? 1 : 6)); 12.230 + assertEquals(val6, (isStableEnabled ? (isServerWithStable ? 1 : 2) 12.231 + : 6)); 12.232 } 12.233 12.234 { 12.235 c.v = new int[1][1][1][1]; int[] val1 = get1(); 12.236 c.v[0][0][0] = new int[1]; int[] val2 = get1(); 12.237 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 12.238 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 12.239 } 12.240 12.241 { 12.242 c.v = new int[1][1][1][1]; int[][] val1 = get2(); 12.243 c.v[0][0] = new int[1][1]; int[][] val2 = get2(); 12.244 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 12.245 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 12.246 } 12.247 12.248 { 12.249 c.v = new int[1][1][1][1]; int[][][] val1 = get3(); 12.250 c.v[0] = new int[1][1][1]; int[][][] val2 = get3(); 12.251 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 12.252 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 12.253 } 12.254 12.255 { 12.256 @@ -350,13 +392,11 @@ 12.257 c.v = new int[1][1][1][1]; int[][][][] val2 = get4(); 12.258 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 12.259 } 12.260 - 12.261 } 12.262 } 12.263 12.264 /* ==================================================== */ 12.265 // Dynamic Dim is higher than static 12.266 - 12.267 static class ObjectArrayLowerDim0 { 12.268 public @Stable Object v; 12.269 12.270 @@ -404,7 +444,7 @@ 12.271 c.v = new int[1][1]; c.v[0] = new int[0]; int[] val1 = get1(); 12.272 c.v[0] = new int[0]; int[] val2 = get1(); 12.273 12.274 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 12.275 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 12.276 } 12.277 12.278 { 12.279 @@ -440,14 +480,14 @@ 12.280 c.v = new int[1][1][1]; c.v[0][0] = new int[0]; int[] val1 = get1(); 12.281 c.v[0][0] = new int[0]; int[] val2 = get1(); 12.282 12.283 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 12.284 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 12.285 } 12.286 12.287 { 12.288 c.v = new int[1][1][1]; c.v[0] = new int[0][0]; int[][] val1 = get2(); 12.289 c.v[0] = new int[0][0]; int[][] val2 = get2(); 12.290 12.291 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 12.292 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 12.293 } 12.294 12.295 { 12.296 @@ -582,7 +622,7 @@ 12.297 elem.a = 2; int val3 = get(); int val4 = get1(); 12.298 12.299 assertEquals(val1, 1); 12.300 - assertEquals(val3, (isStableEnabled ? 1 : 2)); 12.301 + assertEquals(val3, (isServerWithStable ? 1 : 2)); 12.302 12.303 assertEquals(val2, 1); 12.304 assertEquals(val4, 2); 12.305 @@ -616,17 +656,4 @@ 12.306 } 12.307 } 12.308 } 12.309 - 12.310 - static final boolean isStableEnabled; 12.311 - static { 12.312 - HotSpotDiagnosticMXBean diagnostic 12.313 - = ManagementFactoryHelper.getDiagnosticMXBean(); 12.314 - VMOption tmp; 12.315 - try { 12.316 - tmp = diagnostic.getVMOption("FoldStableValues"); 12.317 - } catch (IllegalArgumentException e) { 12.318 - tmp = null; 12.319 - } 12.320 - isStableEnabled = (tmp == null ? false : Boolean.parseBoolean(tmp.getValue())); 12.321 - } 12.322 }
13.1 --- a/test/compiler/stable/TestStableLong.java Mon Jul 14 07:41:47 2014 -0700 13.2 +++ b/test/compiler/stable/TestStableLong.java Mon Jul 14 15:48:49 2014 -0700 13.3 @@ -26,9 +26,11 @@ 13.4 /* 13.5 * @test TestStableLong 13.6 * @summary tests on stable fields and arrays 13.7 - * @library /testlibrary 13.8 - * @compile -XDignore.symbol.file TestStableLong.java 13.9 + * @library /testlibrary /testlibrary/whitebox 13.10 + * @build TestStableLong StableConfiguration sun.hotspot.WhiteBox 13.11 + * @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission 13.12 * @run main ClassFileInstaller 13.13 + * java/lang/invoke/StableConfiguration 13.14 * java/lang/invoke/TestStableLong 13.15 * java/lang/invoke/TestStableLong$LongStable 13.16 * java/lang/invoke/TestStableLong$StaticLongStable 13.17 @@ -48,46 +50,60 @@ 13.18 * java/lang/invoke/TestStableLong$NestedStableField3 13.19 * java/lang/invoke/TestStableLong$NestedStableField3$A 13.20 * java/lang/invoke/TestStableLong$DefaultValue 13.21 + * java/lang/invoke/TestStableLong$DefaultStaticValue 13.22 * java/lang/invoke/TestStableLong$ObjectArrayLowerDim2 13.23 * 13.24 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 13.25 - * -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:+UseCompressedOop 13.26 - * -server -XX:-TieredCompilation -Xcomp 13.27 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 13.28 + * -server -XX:-TieredCompilation 13.29 + * -XX:+FoldStableValues 13.30 + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 13.31 + * java.lang.invoke.TestStableLong 13.32 + * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 13.33 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 13.34 + * -server -XX:-TieredCompilation 13.35 + * -XX:-FoldStableValues 13.36 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 13.37 * java.lang.invoke.TestStableLong 13.38 * 13.39 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 13.40 - * -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:-UseCompressedOop 13.41 - * -server -XX:-TieredCompilation -Xcomp 13.42 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 13.43 + * -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1 13.44 + * -XX:+FoldStableValues 13.45 + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 13.46 + * java.lang.invoke.TestStableLong 13.47 + * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 13.48 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 13.49 + * -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1 13.50 + * -XX:-FoldStableValues 13.51 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 13.52 * java.lang.invoke.TestStableLong 13.53 * 13.54 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 13.55 - * -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:+UseCompressedOop 13.56 - * -server -XX:-TieredCompilation -Xcomp 13.57 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 13.58 + * -client -XX:-TieredCompilation 13.59 + * -XX:+FoldStableValues 13.60 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 13.61 * java.lang.invoke.TestStableLong 13.62 - * 13.63 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 13.64 - * -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:-UseCompressedOop 13.65 - * -server -XX:-TieredCompilation -Xcomp 13.66 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 13.67 + * -client -XX:-TieredCompilation 13.68 + * -XX:-FoldStableValues 13.69 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 13.70 * java.lang.invoke.TestStableLong 13.71 */ 13.72 package java.lang.invoke; 13.73 13.74 -import com.sun.management.HotSpotDiagnosticMXBean; 13.75 -import com.sun.management.VMOption; 13.76 -import sun.management.ManagementFactoryHelper; 13.77 import java.lang.reflect.InvocationTargetException; 13.78 13.79 public class TestStableLong { 13.80 + static final boolean isStableEnabled = StableConfiguration.isStableEnabled; 13.81 + static final boolean isServerWithStable = StableConfiguration.isServerWithStable; 13.82 + 13.83 public static void main(String[] args) throws Exception { 13.84 - System.out.println("@Stable enabled: "+isStableEnabled); 13.85 - System.out.println(); 13.86 - 13.87 run(DefaultValue.class); 13.88 run(LongStable.class); 13.89 + run(DefaultStaticValue.class); 13.90 run(StaticLongStable.class); 13.91 run(VolatileLongStable.class); 13.92 13.93 @@ -145,6 +161,21 @@ 13.94 13.95 /* ==================================================== */ 13.96 13.97 + static class DefaultStaticValue { 13.98 + public static @Stable long v; 13.99 + 13.100 + public static final DefaultStaticValue c = new DefaultStaticValue(); 13.101 + public static long get() { return c.v; } 13.102 + public static void test() throws Exception { 13.103 + long val1 = get(); 13.104 + c.v = 1L; long val2 = get(); 13.105 + assertEquals(val1, 0); 13.106 + assertEquals(val2, 1L); 13.107 + } 13.108 + } 13.109 + 13.110 + /* ==================================================== */ 13.111 + 13.112 static class StaticLongStable { 13.113 public static @Stable long v; 13.114 13.115 @@ -188,20 +219,22 @@ 13.116 c.v = new long[1]; c.v[0] = 1; long val1 = get(); 13.117 c.v[0] = 2; long val2 = get(); 13.118 assertEquals(val1, 1); 13.119 - assertEquals(val2, (isStableEnabled ? 1 : 2)); 13.120 + assertEquals(val2, (isServerWithStable ? 1 : 2)); 13.121 13.122 c.v = new long[1]; c.v[0] = 3; long val3 = get(); 13.123 - assertEquals(val3, (isStableEnabled ? 1 : 3)); 13.124 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2) 13.125 + : 3)); 13.126 } 13.127 13.128 { 13.129 c.v = new long[20]; c.v[10] = 1; long val1 = get1(); 13.130 c.v[10] = 2; long val2 = get1(); 13.131 assertEquals(val1, 1); 13.132 - assertEquals(val2, (isStableEnabled ? 1 : 2)); 13.133 + assertEquals(val2, (isServerWithStable ? 1 : 2)); 13.134 13.135 c.v = new long[20]; c.v[10] = 3; long val3 = get1(); 13.136 - assertEquals(val3, (isStableEnabled ? 1 : 3)); 13.137 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2) 13.138 + : 3)); 13.139 } 13.140 13.141 { 13.142 @@ -226,19 +259,21 @@ 13.143 c.v = new long[1][1]; c.v[0][0] = 1; long val1 = get(); 13.144 c.v[0][0] = 2; long val2 = get(); 13.145 assertEquals(val1, 1); 13.146 - assertEquals(val2, (isStableEnabled ? 1 : 2)); 13.147 + assertEquals(val2, (isServerWithStable ? 1 : 2)); 13.148 13.149 c.v = new long[1][1]; c.v[0][0] = 3; long val3 = get(); 13.150 - assertEquals(val3, (isStableEnabled ? 1 : 3)); 13.151 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2) 13.152 + : 3)); 13.153 13.154 c.v[0] = new long[1]; c.v[0][0] = 4; long val4 = get(); 13.155 - assertEquals(val4, (isStableEnabled ? 1 : 4)); 13.156 + assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2) 13.157 + : 4)); 13.158 } 13.159 13.160 { 13.161 c.v = new long[1][1]; long[] val1 = get1(); 13.162 c.v[0] = new long[1]; long[] val2 = get1(); 13.163 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 13.164 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 13.165 } 13.166 13.167 { 13.168 @@ -264,28 +299,31 @@ 13.169 c.v = new long[1][1][1]; c.v[0][0][0] = 1; long val1 = get(); 13.170 c.v[0][0][0] = 2; long val2 = get(); 13.171 assertEquals(val1, 1); 13.172 - assertEquals(val2, (isStableEnabled ? 1 : 2)); 13.173 + assertEquals(val2, (isServerWithStable ? 1 : 2)); 13.174 13.175 c.v = new long[1][1][1]; c.v[0][0][0] = 3; long val3 = get(); 13.176 - assertEquals(val3, (isStableEnabled ? 1 : 3)); 13.177 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2) 13.178 + : 3)); 13.179 13.180 c.v[0] = new long[1][1]; c.v[0][0][0] = 4; long val4 = get(); 13.181 - assertEquals(val4, (isStableEnabled ? 1 : 4)); 13.182 + assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2) 13.183 + : 4)); 13.184 13.185 c.v[0][0] = new long[1]; c.v[0][0][0] = 5; long val5 = get(); 13.186 - assertEquals(val5, (isStableEnabled ? 1 : 5)); 13.187 + assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1 : 2) 13.188 + : 5)); 13.189 } 13.190 13.191 { 13.192 c.v = new long[1][1][1]; long[] val1 = get1(); 13.193 c.v[0][0] = new long[1]; long[] val2 = get1(); 13.194 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 13.195 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 13.196 } 13.197 13.198 { 13.199 c.v = new long[1][1][1]; long[][] val1 = get2(); 13.200 c.v[0] = new long[1][1]; long[][] val2 = get2(); 13.201 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 13.202 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 13.203 } 13.204 13.205 { 13.206 @@ -312,37 +350,41 @@ 13.207 c.v = new long[1][1][1][1]; c.v[0][0][0][0] = 1; long val1 = get(); 13.208 c.v[0][0][0][0] = 2; long val2 = get(); 13.209 assertEquals(val1, 1); 13.210 - assertEquals(val2, (isStableEnabled ? 1 : 2)); 13.211 + assertEquals(val2, (isServerWithStable ? 1 : 2)); 13.212 13.213 c.v = new long[1][1][1][1]; c.v[0][0][0][0] = 3; long val3 = get(); 13.214 - assertEquals(val3, (isStableEnabled ? 1 : 3)); 13.215 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2) 13.216 + : 3)); 13.217 13.218 c.v[0] = new long[1][1][1]; c.v[0][0][0][0] = 4; long val4 = get(); 13.219 - assertEquals(val4, (isStableEnabled ? 1 : 4)); 13.220 + assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2) 13.221 + : 4)); 13.222 13.223 c.v[0][0] = new long[1][1]; c.v[0][0][0][0] = 5; long val5 = get(); 13.224 - assertEquals(val5, (isStableEnabled ? 1 : 5)); 13.225 + assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1 : 2) 13.226 + : 5)); 13.227 13.228 c.v[0][0][0] = new long[1]; c.v[0][0][0][0] = 6; long val6 = get(); 13.229 - assertEquals(val6, (isStableEnabled ? 1 : 6)); 13.230 + assertEquals(val6, (isStableEnabled ? (isServerWithStable ? 1 : 2) 13.231 + : 6)); 13.232 } 13.233 13.234 { 13.235 c.v = new long[1][1][1][1]; long[] val1 = get1(); 13.236 c.v[0][0][0] = new long[1]; long[] val2 = get1(); 13.237 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 13.238 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 13.239 } 13.240 13.241 { 13.242 c.v = new long[1][1][1][1]; long[][] val1 = get2(); 13.243 c.v[0][0] = new long[1][1]; long[][] val2 = get2(); 13.244 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 13.245 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 13.246 } 13.247 13.248 { 13.249 c.v = new long[1][1][1][1]; long[][][] val1 = get3(); 13.250 c.v[0] = new long[1][1][1]; long[][][] val2 = get3(); 13.251 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 13.252 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 13.253 } 13.254 13.255 { 13.256 @@ -350,13 +392,11 @@ 13.257 c.v = new long[1][1][1][1]; long[][][][] val2 = get4(); 13.258 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 13.259 } 13.260 - 13.261 } 13.262 } 13.263 13.264 /* ==================================================== */ 13.265 // Dynamic Dim is higher than static 13.266 - 13.267 static class ObjectArrayLowerDim0 { 13.268 public @Stable Object v; 13.269 13.270 @@ -404,7 +444,7 @@ 13.271 c.v = new long[1][1]; c.v[0] = new long[0]; long[] val1 = get1(); 13.272 c.v[0] = new long[0]; long[] val2 = get1(); 13.273 13.274 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 13.275 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 13.276 } 13.277 13.278 { 13.279 @@ -440,14 +480,14 @@ 13.280 c.v = new long[1][1][1]; c.v[0][0] = new long[0]; long[] val1 = get1(); 13.281 c.v[0][0] = new long[0]; long[] val2 = get1(); 13.282 13.283 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 13.284 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 13.285 } 13.286 13.287 { 13.288 c.v = new long[1][1][1]; c.v[0] = new long[0][0]; long[][] val1 = get2(); 13.289 c.v[0] = new long[0][0]; long[][] val2 = get2(); 13.290 13.291 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 13.292 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 13.293 } 13.294 13.295 { 13.296 @@ -582,7 +622,7 @@ 13.297 elem.a = 2; long val3 = get(); long val4 = get1(); 13.298 13.299 assertEquals(val1, 1); 13.300 - assertEquals(val3, (isStableEnabled ? 1 : 2)); 13.301 + assertEquals(val3, (isServerWithStable ? 1 : 2)); 13.302 13.303 assertEquals(val2, 1); 13.304 assertEquals(val4, 2); 13.305 @@ -616,17 +656,4 @@ 13.306 } 13.307 } 13.308 } 13.309 - 13.310 - static final boolean isStableEnabled; 13.311 - static { 13.312 - HotSpotDiagnosticMXBean diagnostic 13.313 - = ManagementFactoryHelper.getDiagnosticMXBean(); 13.314 - VMOption tmp; 13.315 - try { 13.316 - tmp = diagnostic.getVMOption("FoldStableValues"); 13.317 - } catch (IllegalArgumentException e) { 13.318 - tmp = null; 13.319 - } 13.320 - isStableEnabled = (tmp == null ? false : Boolean.parseBoolean(tmp.getValue())); 13.321 - } 13.322 }
14.1 --- a/test/compiler/stable/TestStableObject.java Mon Jul 14 07:41:47 2014 -0700 14.2 +++ b/test/compiler/stable/TestStableObject.java Mon Jul 14 15:48:49 2014 -0700 14.3 @@ -26,9 +26,11 @@ 14.4 /* 14.5 * @test TestStableObject 14.6 * @summary tests on stable fields and arrays 14.7 - * @library /testlibrary 14.8 - * @compile -XDignore.symbol.file TestStableObject.java 14.9 + * @library /testlibrary /testlibrary/whitebox 14.10 + * @build TestStableObject StableConfiguration sun.hotspot.WhiteBox 14.11 + * @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission 14.12 * @run main ClassFileInstaller 14.13 + * java/lang/invoke/StableConfiguration 14.14 * java/lang/invoke/TestStableObject 14.15 * java/lang/invoke/TestStableObject$ObjectStable 14.16 * java/lang/invoke/TestStableObject$StaticObjectStable 14.17 @@ -49,46 +51,60 @@ 14.18 * java/lang/invoke/TestStableObject$NestedStableField3$A 14.19 * java/lang/invoke/TestStableObject$Values 14.20 * java/lang/invoke/TestStableObject$DefaultValue 14.21 + * java/lang/invoke/TestStableObject$DefaultStaticValue 14.22 * java/lang/invoke/TestStableObject$ObjectArrayLowerDim2 14.23 * 14.24 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 14.25 - * -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:+UseCompressedOop 14.26 - * -server -XX:-TieredCompilation -Xcomp 14.27 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 14.28 + * -server -XX:-TieredCompilation 14.29 + * -XX:+FoldStableValues 14.30 + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 14.31 + * java.lang.invoke.TestStableObject 14.32 + * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 14.33 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 14.34 + * -server -XX:-TieredCompilation 14.35 + * -XX:-FoldStableValues 14.36 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 14.37 * java.lang.invoke.TestStableObject 14.38 * 14.39 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 14.40 - * -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:-UseCompressedOop 14.41 - * -server -XX:-TieredCompilation -Xcomp 14.42 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 14.43 + * -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1 14.44 + * -XX:+FoldStableValues 14.45 + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 14.46 + * java.lang.invoke.TestStableObject 14.47 + * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 14.48 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 14.49 + * -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1 14.50 + * -XX:-FoldStableValues 14.51 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 14.52 * java.lang.invoke.TestStableObject 14.53 * 14.54 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 14.55 - * -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:+UseCompressedOop 14.56 - * -server -XX:-TieredCompilation -Xcomp 14.57 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 14.58 + * -client -XX:-TieredCompilation 14.59 + * -XX:+FoldStableValues 14.60 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 14.61 * java.lang.invoke.TestStableObject 14.62 - * 14.63 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 14.64 - * -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:-UseCompressedOop 14.65 - * -server -XX:-TieredCompilation -Xcomp 14.66 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 14.67 + * -client -XX:-TieredCompilation 14.68 + * -XX:-FoldStableValues 14.69 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 14.70 * java.lang.invoke.TestStableObject 14.71 */ 14.72 package java.lang.invoke; 14.73 14.74 -import com.sun.management.HotSpotDiagnosticMXBean; 14.75 -import com.sun.management.VMOption; 14.76 -import sun.management.ManagementFactoryHelper; 14.77 import java.lang.reflect.InvocationTargetException; 14.78 14.79 public class TestStableObject { 14.80 + static final boolean isStableEnabled = StableConfiguration.isStableEnabled; 14.81 + static final boolean isServerWithStable = StableConfiguration.isServerWithStable; 14.82 + 14.83 public static void main(String[] args) throws Exception { 14.84 - System.out.println("@Stable enabled: "+isStableEnabled); 14.85 - System.out.println(); 14.86 - 14.87 run(DefaultValue.class); 14.88 run(ObjectStable.class); 14.89 + run(DefaultStaticValue.class); 14.90 run(StaticObjectStable.class); 14.91 run(VolatileObjectStable.class); 14.92 14.93 @@ -148,6 +164,21 @@ 14.94 14.95 /* ==================================================== */ 14.96 14.97 + static class DefaultStaticValue { 14.98 + public static @Stable Object v; 14.99 + 14.100 + public static final DefaultStaticValue c = new DefaultStaticValue(); 14.101 + public static Object get() { return c.v; } 14.102 + public static void test() throws Exception { 14.103 + Object val1 = get(); 14.104 + c.v = Values.A; Object val2 = get(); 14.105 + assertEquals(val1, null); 14.106 + assertEquals(val2, Values.A); 14.107 + } 14.108 + } 14.109 + 14.110 + /* ==================================================== */ 14.111 + 14.112 static class StaticObjectStable { 14.113 public static @Stable Values v; 14.114 14.115 @@ -191,20 +222,22 @@ 14.116 c.v = new Object[1]; c.v[0] = Values.A; Object val1 = get(); 14.117 c.v[0] = Values.B; Object val2 = get(); 14.118 assertEquals(val1, Values.A); 14.119 - assertEquals(val2, (isStableEnabled ? Values.A : Values.B)); 14.120 + assertEquals(val2, (isServerWithStable ? Values.A : Values.B)); 14.121 14.122 c.v = new Object[1]; c.v[0] = Values.C; Object val3 = get(); 14.123 - assertEquals(val3, (isStableEnabled ? Values.A : Values.C)); 14.124 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B) 14.125 + : Values.C)); 14.126 } 14.127 14.128 { 14.129 c.v = new Object[20]; c.v[10] = Values.A; Object val1 = get1(); 14.130 c.v[10] = Values.B; Object val2 = get1(); 14.131 assertEquals(val1, Values.A); 14.132 - assertEquals(val2, (isStableEnabled ? Values.A : Values.B)); 14.133 + assertEquals(val2, (isServerWithStable ? Values.A : Values.B)); 14.134 14.135 c.v = new Object[20]; c.v[10] = Values.C; Object val3 = get1(); 14.136 - assertEquals(val3, (isStableEnabled ? Values.A : Values.C)); 14.137 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B) 14.138 + : Values.C)); 14.139 } 14.140 14.141 { 14.142 @@ -229,19 +262,21 @@ 14.143 c.v = new Object[1][1]; c.v[0][0] = Values.A; Object val1 = get(); 14.144 c.v[0][0] = Values.B; Object val2 = get(); 14.145 assertEquals(val1, Values.A); 14.146 - assertEquals(val2, (isStableEnabled ? Values.A : Values.B)); 14.147 + assertEquals(val2, (isServerWithStable ? Values.A : Values.B)); 14.148 14.149 c.v = new Object[1][1]; c.v[0][0] = Values.C; Object val3 = get(); 14.150 - assertEquals(val3, (isStableEnabled ? Values.A : Values.C)); 14.151 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B) 14.152 + : Values.C)); 14.153 14.154 c.v[0] = new Object[1]; c.v[0][0] = Values.D; Object val4 = get(); 14.155 - assertEquals(val4, (isStableEnabled ? Values.A : Values.D)); 14.156 + assertEquals(val4, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B) 14.157 + : Values.D)); 14.158 } 14.159 14.160 { 14.161 c.v = new Object[1][1]; Object[] val1 = get1(); 14.162 c.v[0] = new Object[1]; Object[] val2 = get1(); 14.163 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 14.164 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 14.165 } 14.166 14.167 { 14.168 @@ -267,28 +302,31 @@ 14.169 c.v = new Object[1][1][1]; c.v[0][0][0] = Values.A; Object val1 = get(); 14.170 c.v[0][0][0] = Values.B; Object val2 = get(); 14.171 assertEquals(val1, Values.A); 14.172 - assertEquals(val2, (isStableEnabled ? Values.A : Values.B)); 14.173 + assertEquals(val2, (isServerWithStable ? Values.A : Values.B)); 14.174 14.175 c.v = new Object[1][1][1]; c.v[0][0][0] = Values.C; Object val3 = get(); 14.176 - assertEquals(val3, (isStableEnabled ? Values.A : Values.C)); 14.177 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B) 14.178 + : Values.C)); 14.179 14.180 c.v[0] = new Object[1][1]; c.v[0][0][0] = Values.D; Object val4 = get(); 14.181 - assertEquals(val4, (isStableEnabled ? Values.A : Values.D)); 14.182 + assertEquals(val4, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B) 14.183 + : Values.D)); 14.184 14.185 c.v[0][0] = new Object[1]; c.v[0][0][0] = Values.E; Object val5 = get(); 14.186 - assertEquals(val5, (isStableEnabled ? Values.A : Values.E)); 14.187 + assertEquals(val5, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B) 14.188 + : Values.E)); 14.189 } 14.190 14.191 { 14.192 c.v = new Object[1][1][1]; Object[] val1 = get1(); 14.193 c.v[0][0] = new Object[1]; Object[] val2 = get1(); 14.194 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 14.195 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 14.196 } 14.197 14.198 { 14.199 c.v = new Object[1][1][1]; Object[][] val1 = get2(); 14.200 c.v[0] = new Object[1][1]; Object[][] val2 = get2(); 14.201 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 14.202 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 14.203 } 14.204 14.205 { 14.206 @@ -315,37 +353,41 @@ 14.207 c.v = new Object[1][1][1][1]; c.v[0][0][0][0] = Values.A; Object val1 = get(); 14.208 c.v[0][0][0][0] = Values.B; Object val2 = get(); 14.209 assertEquals(val1, Values.A); 14.210 - assertEquals(val2, (isStableEnabled ? Values.A : Values.B)); 14.211 + assertEquals(val2, (isServerWithStable ? Values.A : Values.B)); 14.212 14.213 c.v = new Object[1][1][1][1]; c.v[0][0][0][0] = Values.C; Object val3 = get(); 14.214 - assertEquals(val3, (isStableEnabled ? Values.A : Values.C)); 14.215 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B) 14.216 + : Values.C)); 14.217 14.218 c.v[0] = new Object[1][1][1]; c.v[0][0][0][0] = Values.D; Object val4 = get(); 14.219 - assertEquals(val4, (isStableEnabled ? Values.A : Values.D)); 14.220 + assertEquals(val4, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B) 14.221 + : Values.D)); 14.222 14.223 c.v[0][0] = new Object[1][1]; c.v[0][0][0][0] = Values.E; Object val5 = get(); 14.224 - assertEquals(val5, (isStableEnabled ? Values.A : Values.E)); 14.225 + assertEquals(val5, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B) 14.226 + : Values.E)); 14.227 14.228 c.v[0][0][0] = new Object[1]; c.v[0][0][0][0] = Values.F; Object val6 = get(); 14.229 - assertEquals(val6, (isStableEnabled ? Values.A : Values.F)); 14.230 + assertEquals(val6, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B) 14.231 + : Values.F)); 14.232 } 14.233 14.234 { 14.235 c.v = new Object[1][1][1][1]; Object[] val1 = get1(); 14.236 c.v[0][0][0] = new Object[1]; Object[] val2 = get1(); 14.237 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 14.238 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 14.239 } 14.240 14.241 { 14.242 c.v = new Object[1][1][1][1]; Object[][] val1 = get2(); 14.243 c.v[0][0] = new Object[1][1]; Object[][] val2 = get2(); 14.244 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 14.245 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 14.246 } 14.247 14.248 { 14.249 c.v = new Object[1][1][1][1]; Object[][][] val1 = get3(); 14.250 c.v[0] = new Object[1][1][1]; Object[][][] val2 = get3(); 14.251 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 14.252 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 14.253 } 14.254 14.255 { 14.256 @@ -353,13 +395,11 @@ 14.257 c.v = new Object[1][1][1][1]; Object[][][][] val2 = get4(); 14.258 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 14.259 } 14.260 - 14.261 } 14.262 } 14.263 14.264 /* ==================================================== */ 14.265 // Dynamic Dim is higher than static 14.266 - 14.267 static class ObjectArrayLowerDim0 { 14.268 public @Stable Object v; 14.269 14.270 @@ -407,7 +447,7 @@ 14.271 c.v = new Object[1][1]; c.v[0] = new Object[0]; Object[] val1 = get1(); 14.272 c.v[0] = new Object[0]; Object[] val2 = get1(); 14.273 14.274 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 14.275 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 14.276 } 14.277 14.278 { 14.279 @@ -443,14 +483,14 @@ 14.280 c.v = new Object[1][1][1]; c.v[0][0] = new Object[0]; Object[] val1 = get1(); 14.281 c.v[0][0] = new Object[0]; Object[] val2 = get1(); 14.282 14.283 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 14.284 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 14.285 } 14.286 14.287 { 14.288 c.v = new Object[1][1][1]; c.v[0] = new Object[0][0]; Object[][] val1 = get2(); 14.289 c.v[0] = new Object[0][0]; Object[][] val2 = get2(); 14.290 14.291 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 14.292 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 14.293 } 14.294 14.295 { 14.296 @@ -585,7 +625,7 @@ 14.297 elem.a = Values.B; Object val3 = get(); Object val4 = get1(); 14.298 14.299 assertEquals(val1, Values.A); 14.300 - assertEquals(val3, (isStableEnabled ? Values.A : Values.B)); 14.301 + assertEquals(val3, (isServerWithStable ? Values.A : Values.B)); 14.302 14.303 assertEquals(val2, Values.A); 14.304 assertEquals(val4, Values.B); 14.305 @@ -619,17 +659,4 @@ 14.306 } 14.307 } 14.308 } 14.309 - 14.310 - static final boolean isStableEnabled; 14.311 - static { 14.312 - HotSpotDiagnosticMXBean diagnostic 14.313 - = ManagementFactoryHelper.getDiagnosticMXBean(); 14.314 - VMOption tmp; 14.315 - try { 14.316 - tmp = diagnostic.getVMOption("FoldStableValues"); 14.317 - } catch (IllegalArgumentException e) { 14.318 - tmp = null; 14.319 - } 14.320 - isStableEnabled = (tmp == null ? false : Boolean.parseBoolean(tmp.getValue())); 14.321 - } 14.322 }
15.1 --- a/test/compiler/stable/TestStableShort.java Mon Jul 14 07:41:47 2014 -0700 15.2 +++ b/test/compiler/stable/TestStableShort.java Mon Jul 14 15:48:49 2014 -0700 15.3 @@ -26,9 +26,11 @@ 15.4 /* 15.5 * @test TestStableShort 15.6 * @summary tests on stable fields and arrays 15.7 - * @library /testlibrary 15.8 - * @compile -XDignore.symbol.file TestStableShort.java 15.9 + * @library /testlibrary /testlibrary/whitebox 15.10 + * @build TestStableShort StableConfiguration sun.hotspot.WhiteBox 15.11 + * @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission 15.12 * @run main ClassFileInstaller 15.13 + * java/lang/invoke/StableConfiguration 15.14 * java/lang/invoke/TestStableShort 15.15 * java/lang/invoke/TestStableShort$ShortStable 15.16 * java/lang/invoke/TestStableShort$StaticShortStable 15.17 @@ -48,46 +50,60 @@ 15.18 * java/lang/invoke/TestStableShort$NestedStableField3 15.19 * java/lang/invoke/TestStableShort$NestedStableField3$A 15.20 * java/lang/invoke/TestStableShort$DefaultValue 15.21 + * java/lang/invoke/TestStableShort$DefaultStaticValue 15.22 * java/lang/invoke/TestStableShort$ObjectArrayLowerDim2 15.23 * 15.24 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 15.25 - * -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:+UseCompressedOop 15.26 - * -server -XX:-TieredCompilation -Xcomp 15.27 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 15.28 + * -server -XX:-TieredCompilation 15.29 + * -XX:+FoldStableValues 15.30 + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 15.31 + * java.lang.invoke.TestStableShort 15.32 + * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 15.33 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 15.34 + * -server -XX:-TieredCompilation 15.35 + * -XX:-FoldStableValues 15.36 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 15.37 * java.lang.invoke.TestStableShort 15.38 * 15.39 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 15.40 - * -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:-UseCompressedOop 15.41 - * -server -XX:-TieredCompilation -Xcomp 15.42 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 15.43 + * -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1 15.44 + * -XX:+FoldStableValues 15.45 + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 15.46 + * java.lang.invoke.TestStableShort 15.47 + * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 15.48 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 15.49 + * -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1 15.50 + * -XX:-FoldStableValues 15.51 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 15.52 * java.lang.invoke.TestStableShort 15.53 * 15.54 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 15.55 - * -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:+UseCompressedOop 15.56 - * -server -XX:-TieredCompilation -Xcomp 15.57 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 15.58 + * -client -XX:-TieredCompilation 15.59 + * -XX:+FoldStableValues 15.60 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 15.61 * java.lang.invoke.TestStableShort 15.62 - * 15.63 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions 15.64 - * -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:-UseCompressedOop 15.65 - * -server -XX:-TieredCompilation -Xcomp 15.66 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp 15.67 + * -client -XX:-TieredCompilation 15.68 + * -XX:-FoldStableValues 15.69 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 15.70 * java.lang.invoke.TestStableShort 15.71 */ 15.72 package java.lang.invoke; 15.73 15.74 -import com.sun.management.HotSpotDiagnosticMXBean; 15.75 -import com.sun.management.VMOption; 15.76 -import sun.management.ManagementFactoryHelper; 15.77 import java.lang.reflect.InvocationTargetException; 15.78 15.79 public class TestStableShort { 15.80 + static final boolean isStableEnabled = StableConfiguration.isStableEnabled; 15.81 + static final boolean isServerWithStable = StableConfiguration.isServerWithStable; 15.82 + 15.83 public static void main(String[] args) throws Exception { 15.84 - System.out.println("@Stable enabled: "+isStableEnabled); 15.85 - System.out.println(); 15.86 - 15.87 run(DefaultValue.class); 15.88 run(ShortStable.class); 15.89 + run(DefaultStaticValue.class); 15.90 run(StaticShortStable.class); 15.91 run(VolatileShortStable.class); 15.92 15.93 @@ -145,6 +161,21 @@ 15.94 15.95 /* ==================================================== */ 15.96 15.97 + static class DefaultStaticValue { 15.98 + public static @Stable short v; 15.99 + 15.100 + public static final DefaultStaticValue c = new DefaultStaticValue(); 15.101 + public static short get() { return c.v; } 15.102 + public static void test() throws Exception { 15.103 + short val1 = get(); 15.104 + c.v = 1; short val2 = get(); 15.105 + assertEquals(val1, 0); 15.106 + assertEquals(val2, 1); 15.107 + } 15.108 + } 15.109 + 15.110 + /* ==================================================== */ 15.111 + 15.112 static class StaticShortStable { 15.113 public static @Stable short v; 15.114 15.115 @@ -188,20 +219,22 @@ 15.116 c.v = new short[1]; c.v[0] = 1; short val1 = get(); 15.117 c.v[0] = 2; short val2 = get(); 15.118 assertEquals(val1, 1); 15.119 - assertEquals(val2, (isStableEnabled ? 1 : 2)); 15.120 + assertEquals(val2, (isServerWithStable ? 1 : 2)); 15.121 15.122 c.v = new short[1]; c.v[0] = 3; short val3 = get(); 15.123 - assertEquals(val3, (isStableEnabled ? 1 : 3)); 15.124 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2) 15.125 + : 3)); 15.126 } 15.127 15.128 { 15.129 c.v = new short[20]; c.v[10] = 1; short val1 = get1(); 15.130 c.v[10] = 2; short val2 = get1(); 15.131 assertEquals(val1, 1); 15.132 - assertEquals(val2, (isStableEnabled ? 1 : 2)); 15.133 + assertEquals(val2, (isServerWithStable ? 1 : 2)); 15.134 15.135 c.v = new short[20]; c.v[10] = 3; short val3 = get1(); 15.136 - assertEquals(val3, (isStableEnabled ? 1 : 3)); 15.137 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2) 15.138 + : 3)); 15.139 } 15.140 15.141 { 15.142 @@ -226,19 +259,21 @@ 15.143 c.v = new short[1][1]; c.v[0][0] = 1; short val1 = get(); 15.144 c.v[0][0] = 2; short val2 = get(); 15.145 assertEquals(val1, 1); 15.146 - assertEquals(val2, (isStableEnabled ? 1 : 2)); 15.147 + assertEquals(val2, (isServerWithStable ? 1 : 2)); 15.148 15.149 c.v = new short[1][1]; c.v[0][0] = 3; short val3 = get(); 15.150 - assertEquals(val3, (isStableEnabled ? 1 : 3)); 15.151 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2) 15.152 + : 3)); 15.153 15.154 c.v[0] = new short[1]; c.v[0][0] = 4; short val4 = get(); 15.155 - assertEquals(val4, (isStableEnabled ? 1 : 4)); 15.156 + assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2) 15.157 + : 4)); 15.158 } 15.159 15.160 { 15.161 c.v = new short[1][1]; short[] val1 = get1(); 15.162 c.v[0] = new short[1]; short[] val2 = get1(); 15.163 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 15.164 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 15.165 } 15.166 15.167 { 15.168 @@ -264,28 +299,31 @@ 15.169 c.v = new short[1][1][1]; c.v[0][0][0] = 1; short val1 = get(); 15.170 c.v[0][0][0] = 2; short val2 = get(); 15.171 assertEquals(val1, 1); 15.172 - assertEquals(val2, (isStableEnabled ? 1 : 2)); 15.173 + assertEquals(val2, (isServerWithStable ? 1 : 2)); 15.174 15.175 c.v = new short[1][1][1]; c.v[0][0][0] = 3; short val3 = get(); 15.176 - assertEquals(val3, (isStableEnabled ? 1 : 3)); 15.177 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2) 15.178 + : 3)); 15.179 15.180 c.v[0] = new short[1][1]; c.v[0][0][0] = 4; short val4 = get(); 15.181 - assertEquals(val4, (isStableEnabled ? 1 : 4)); 15.182 + assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2) 15.183 + : 4)); 15.184 15.185 c.v[0][0] = new short[1]; c.v[0][0][0] = 5; short val5 = get(); 15.186 - assertEquals(val5, (isStableEnabled ? 1 : 5)); 15.187 + assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1 : 2) 15.188 + : 5)); 15.189 } 15.190 15.191 { 15.192 c.v = new short[1][1][1]; short[] val1 = get1(); 15.193 c.v[0][0] = new short[1]; short[] val2 = get1(); 15.194 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 15.195 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 15.196 } 15.197 15.198 { 15.199 c.v = new short[1][1][1]; short[][] val1 = get2(); 15.200 c.v[0] = new short[1][1]; short[][] val2 = get2(); 15.201 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 15.202 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 15.203 } 15.204 15.205 { 15.206 @@ -312,37 +350,41 @@ 15.207 c.v = new short[1][1][1][1]; c.v[0][0][0][0] = 1; short val1 = get(); 15.208 c.v[0][0][0][0] = 2; short val2 = get(); 15.209 assertEquals(val1, 1); 15.210 - assertEquals(val2, (isStableEnabled ? 1 : 2)); 15.211 + assertEquals(val2, (isServerWithStable ? 1 : 2)); 15.212 15.213 c.v = new short[1][1][1][1]; c.v[0][0][0][0] = 3; short val3 = get(); 15.214 - assertEquals(val3, (isStableEnabled ? 1 : 3)); 15.215 + assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2) 15.216 + : 3)); 15.217 15.218 c.v[0] = new short[1][1][1]; c.v[0][0][0][0] = 4; short val4 = get(); 15.219 - assertEquals(val4, (isStableEnabled ? 1 : 4)); 15.220 + assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2) 15.221 + : 4)); 15.222 15.223 c.v[0][0] = new short[1][1]; c.v[0][0][0][0] = 5; short val5 = get(); 15.224 - assertEquals(val5, (isStableEnabled ? 1 : 5)); 15.225 + assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1 : 2) 15.226 + : 5)); 15.227 15.228 c.v[0][0][0] = new short[1]; c.v[0][0][0][0] = 6; short val6 = get(); 15.229 - assertEquals(val6, (isStableEnabled ? 1 : 6)); 15.230 + assertEquals(val6, (isStableEnabled ? (isServerWithStable ? 1 : 2) 15.231 + : 6)); 15.232 } 15.233 15.234 { 15.235 c.v = new short[1][1][1][1]; short[] val1 = get1(); 15.236 c.v[0][0][0] = new short[1]; short[] val2 = get1(); 15.237 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 15.238 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 15.239 } 15.240 15.241 { 15.242 c.v = new short[1][1][1][1]; short[][] val1 = get2(); 15.243 c.v[0][0] = new short[1][1]; short[][] val2 = get2(); 15.244 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 15.245 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 15.246 } 15.247 15.248 { 15.249 c.v = new short[1][1][1][1]; short[][][] val1 = get3(); 15.250 c.v[0] = new short[1][1][1]; short[][][] val2 = get3(); 15.251 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 15.252 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 15.253 } 15.254 15.255 { 15.256 @@ -350,13 +392,11 @@ 15.257 c.v = new short[1][1][1][1]; short[][][][] val2 = get4(); 15.258 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 15.259 } 15.260 - 15.261 } 15.262 } 15.263 15.264 /* ==================================================== */ 15.265 // Dynamic Dim is higher than static 15.266 - 15.267 static class ObjectArrayLowerDim0 { 15.268 public @Stable Object v; 15.269 15.270 @@ -404,7 +444,7 @@ 15.271 c.v = new short[1][1]; c.v[0] = new short[0]; short[] val1 = get1(); 15.272 c.v[0] = new short[0]; short[] val2 = get1(); 15.273 15.274 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 15.275 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 15.276 } 15.277 15.278 { 15.279 @@ -440,14 +480,14 @@ 15.280 c.v = new short[1][1][1]; c.v[0][0] = new short[0]; short[] val1 = get1(); 15.281 c.v[0][0] = new short[0]; short[] val2 = get1(); 15.282 15.283 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 15.284 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 15.285 } 15.286 15.287 { 15.288 c.v = new short[1][1][1]; c.v[0] = new short[0][0]; short[][] val1 = get2(); 15.289 c.v[0] = new short[0][0]; short[][] val2 = get2(); 15.290 15.291 - assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); 15.292 + assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); 15.293 } 15.294 15.295 { 15.296 @@ -582,7 +622,7 @@ 15.297 elem.a = 2; short val3 = get(); short val4 = get1(); 15.298 15.299 assertEquals(val1, 1); 15.300 - assertEquals(val3, (isStableEnabled ? 1 : 2)); 15.301 + assertEquals(val3, (isServerWithStable ? 1 : 2)); 15.302 15.303 assertEquals(val2, 1); 15.304 assertEquals(val4, 2); 15.305 @@ -616,17 +656,4 @@ 15.306 } 15.307 } 15.308 } 15.309 - 15.310 - static final boolean isStableEnabled; 15.311 - static { 15.312 - HotSpotDiagnosticMXBean diagnostic 15.313 - = ManagementFactoryHelper.getDiagnosticMXBean(); 15.314 - VMOption tmp; 15.315 - try { 15.316 - tmp = diagnostic.getVMOption("FoldStableValues"); 15.317 - } catch (IllegalArgumentException e) { 15.318 - tmp = null; 15.319 - } 15.320 - isStableEnabled = (tmp == null ? false : Boolean.parseBoolean(tmp.getValue())); 15.321 - } 15.322 }