Fri, 03 Dec 2010 06:14:37 -0800
7003798: test/compiler/6991596 fails with true != false
Summary: The test of 6991596 fails on SPARCV9.
Reviewed-by: kvn, never, jrose
src/cpu/sparc/vm/methodHandles_sparc.cpp | file | annotate | diff | comparison | revisions | |
test/compiler/6991596/Test6991596.java | file | annotate | diff | comparison | revisions |
1.1 --- a/src/cpu/sparc/vm/methodHandles_sparc.cpp Fri Dec 03 01:34:31 2010 -0800 1.2 +++ b/src/cpu/sparc/vm/methodHandles_sparc.cpp Fri Dec 03 06:14:37 2010 -0800 1.3 @@ -689,8 +689,8 @@ 1.4 { 1.5 // Perform an in-place conversion to int or an int subword. 1.6 __ ldsw(G3_amh_vmargslot, O0_argslot); 1.7 + Address value; 1.8 Address vmarg = __ argument_address(O0_argslot); 1.9 - Address value; 1.10 bool value_left_justified = false; 1.11 1.12 switch (ek) { 1.13 @@ -700,9 +700,21 @@ 1.14 case _adapter_opt_l2i: 1.15 { 1.16 // just delete the extra slot 1.17 +#ifdef _LP64 1.18 + // In V9, longs are given 2 64-bit slots in the interpreter, but the 1.19 + // data is passed in only 1 slot. 1.20 + // Keep the second slot. 1.21 + __ add(Gargs, __ argument_offset(O0_argslot, -1), O0_argslot); 1.22 + remove_arg_slots(_masm, -stack_move_unit(), O0_argslot, O1_scratch, O2_scratch, O3_scratch); 1.23 + value = Address(O0_argslot, 4); // Get least-significant 32-bit of 64-bit value. 1.24 + vmarg = Address(O0_argslot, Interpreter::stackElementSize); 1.25 +#else 1.26 + // Keep the first slot. 1.27 __ add(Gargs, __ argument_offset(O0_argslot), O0_argslot); 1.28 remove_arg_slots(_masm, -stack_move_unit(), O0_argslot, O1_scratch, O2_scratch, O3_scratch); 1.29 - value = vmarg = Address(O0_argslot, 0); 1.30 + value = Address(O0_argslot, 0); 1.31 + vmarg = value; 1.32 +#endif 1.33 } 1.34 break; 1.35 case _adapter_opt_unboxi:
2.1 --- a/test/compiler/6991596/Test6991596.java Fri Dec 03 01:34:31 2010 -0800 2.2 +++ b/test/compiler/6991596/Test6991596.java Fri Dec 03 06:14:37 2010 -0800 2.3 @@ -35,7 +35,7 @@ 2.4 public class Test6991596 { 2.5 private static final Class CLASS = Test6991596.class; 2.6 private static final String NAME = "foo"; 2.7 - private static final boolean DEBUG = false; 2.8 + private static final boolean DEBUG = System.getProperty("DEBUG", "false").equals("true"); 2.9 2.10 public static void main(String[] args) throws Throwable { 2.11 testboolean(); 2.12 @@ -47,7 +47,7 @@ 2.13 } 2.14 2.15 // Helpers to get various methods. 2.16 - static MethodHandle getmh1(Class ret, Class arg) { 2.17 + static MethodHandle getmh1(Class ret, Class arg) throws NoAccessException { 2.18 return MethodHandles.lookup().findStatic(CLASS, NAME, MethodType.methodType(ret, arg)); 2.19 } 2.20 static MethodHandle getmh2(MethodHandle mh1, Class ret, Class arg) { 2.21 @@ -76,38 +76,38 @@ 2.22 MethodHandle mh2 = getmh2(mh1, boolean.class, boolean.class); 2.23 // TODO add this for all cases when the bugs are fixed. 2.24 //MethodHandle mh3 = getmh3(mh1, boolean.class, boolean.class); 2.25 - boolean a = mh1.<boolean>invokeExact((boolean) x); 2.26 - boolean b = mh2.<boolean>invokeExact(x); 2.27 + boolean a = (boolean) mh1.invokeExact((boolean) x); 2.28 + boolean b = (boolean) mh2.invokeExact(x); 2.29 //boolean c = mh3.<boolean>invokeExact((boolean) x); 2.30 - assert a == b : a + " != " + b; 2.31 - //assert c == x : c + " != " + x; 2.32 + check(x, a, b); 2.33 + //check(x, c, x); 2.34 } 2.35 2.36 // byte 2.37 { 2.38 MethodHandle mh1 = getmh1( byte.class, byte.class ); 2.39 MethodHandle mh2 = getmh2(mh1, byte.class, boolean.class); 2.40 - byte a = mh1.<byte>invokeExact((byte) (x ? 1 : 0)); 2.41 - byte b = mh2.<byte>invokeExact(x); 2.42 - assert a == b : a + " != " + b; 2.43 + byte a = (byte) mh1.invokeExact((byte) (x ? 1 : 0)); 2.44 + byte b = (byte) mh2.invokeExact(x); 2.45 + check(x, a, b); 2.46 } 2.47 2.48 // char 2.49 { 2.50 MethodHandle mh1 = getmh1( char.class, char.class); 2.51 MethodHandle mh2 = getmh2(mh1, char.class, boolean.class); 2.52 - char a = mh1.<char>invokeExact((char) (x ? 1 : 0)); 2.53 - char b = mh2.<char>invokeExact(x); 2.54 - assert a == b : a + " != " + b; 2.55 + char a = (char) mh1.invokeExact((char) (x ? 1 : 0)); 2.56 + char b = (char) mh2.invokeExact(x); 2.57 + check(x, a, b); 2.58 } 2.59 2.60 // short 2.61 { 2.62 MethodHandle mh1 = getmh1( short.class, short.class); 2.63 MethodHandle mh2 = getmh2(mh1, short.class, boolean.class); 2.64 - short a = mh1.<short>invokeExact((short) (x ? 1 : 0)); 2.65 - short b = mh2.<short>invokeExact(x); 2.66 - assert a == b : a + " != " + b; 2.67 + short a = (short) mh1.invokeExact((short) (x ? 1 : 0)); 2.68 + short b = (short) mh2.invokeExact(x); 2.69 + check(x, a, b); 2.70 } 2.71 } 2.72 2.73 @@ -134,36 +134,36 @@ 2.74 { 2.75 MethodHandle mh1 = getmh1( boolean.class, boolean.class); 2.76 MethodHandle mh2 = getmh2(mh1, boolean.class, byte.class); 2.77 - boolean a = mh1.<boolean>invokeExact((x & 1) == 1); 2.78 - boolean b = mh2.<boolean>invokeExact(x); 2.79 - assert a == b : a + " != " + b; 2.80 + boolean a = (boolean) mh1.invokeExact((x & 1) == 1); 2.81 + boolean b = (boolean) mh2.invokeExact(x); 2.82 + check(x, a, b); 2.83 } 2.84 2.85 // byte 2.86 { 2.87 MethodHandle mh1 = getmh1( byte.class, byte.class); 2.88 MethodHandle mh2 = getmh2(mh1, byte.class, byte.class); 2.89 - byte a = mh1.<byte>invokeExact((byte) x); 2.90 - byte b = mh2.<byte>invokeExact(x); 2.91 - assert a == b : a + " != " + b; 2.92 + byte a = (byte) mh1.invokeExact((byte) x); 2.93 + byte b = (byte) mh2.invokeExact(x); 2.94 + check(x, a, b); 2.95 } 2.96 2.97 // char 2.98 { 2.99 MethodHandle mh1 = getmh1( char.class, char.class); 2.100 MethodHandle mh2 = getmh2(mh1, char.class, byte.class); 2.101 - char a = mh1.<char>invokeExact((char) x); 2.102 - char b = mh2.<char>invokeExact(x); 2.103 - assert a == b : a + " != " + b; 2.104 + char a = (char) mh1.invokeExact((char) x); 2.105 + char b = (char) mh2.invokeExact(x); 2.106 + check(x, a, b); 2.107 } 2.108 2.109 // short 2.110 { 2.111 MethodHandle mh1 = getmh1( short.class, short.class); 2.112 MethodHandle mh2 = getmh2(mh1, short.class, byte.class); 2.113 - short a = mh1.<short>invokeExact((short) x); 2.114 - short b = mh2.<short>invokeExact(x); 2.115 - assert a == b : a + " != " + b; 2.116 + short a = (short) mh1.invokeExact((short) x); 2.117 + short b = (short) mh2.invokeExact(x); 2.118 + check(x, a, b); 2.119 } 2.120 } 2.121 2.122 @@ -188,36 +188,36 @@ 2.123 { 2.124 MethodHandle mh1 = getmh1( boolean.class, boolean.class); 2.125 MethodHandle mh2 = getmh2(mh1, boolean.class, char.class); 2.126 - boolean a = mh1.<boolean>invokeExact((x & 1) == 1); 2.127 - boolean b = mh2.<boolean>invokeExact(x); 2.128 - assert a == b : a + " != " + b; 2.129 + boolean a = (boolean) mh1.invokeExact((x & 1) == 1); 2.130 + boolean b = (boolean) mh2.invokeExact(x); 2.131 + check(x, a, b); 2.132 } 2.133 2.134 // byte 2.135 { 2.136 MethodHandle mh1 = getmh1( byte.class, byte.class); 2.137 MethodHandle mh2 = getmh2(mh1, byte.class, char.class); 2.138 - byte a = mh1.<byte>invokeExact((byte) x); 2.139 - byte b = mh2.<byte>invokeExact(x); 2.140 - assert a == b : a + " != " + b; 2.141 + byte a = (byte) mh1.invokeExact((byte) x); 2.142 + byte b = (byte) mh2.invokeExact(x); 2.143 + check(x, a, b); 2.144 } 2.145 2.146 // char 2.147 { 2.148 MethodHandle mh1 = getmh1( char.class, char.class); 2.149 MethodHandle mh2 = getmh2(mh1, char.class, char.class); 2.150 - char a = mh1.<char>invokeExact((char) x); 2.151 - char b = mh2.<char>invokeExact(x); 2.152 - assert a == b : a + " != " + b; 2.153 + char a = (char) mh1.invokeExact((char) x); 2.154 + char b = (char) mh2.invokeExact(x); 2.155 + check(x, a, b); 2.156 } 2.157 2.158 // short 2.159 { 2.160 MethodHandle mh1 = getmh1( short.class, short.class); 2.161 MethodHandle mh2 = getmh2(mh1, short.class, char.class); 2.162 - short a = mh1.<short>invokeExact((short) x); 2.163 - short b = mh2.<short>invokeExact(x); 2.164 - assert a == b : a + " != " + b; 2.165 + short a = (short) mh1.invokeExact((short) x); 2.166 + short b = (short) mh2.invokeExact(x); 2.167 + check(x, a, b); 2.168 } 2.169 } 2.170 2.171 @@ -248,36 +248,36 @@ 2.172 { 2.173 MethodHandle mh1 = getmh1( boolean.class, boolean.class); 2.174 MethodHandle mh2 = getmh2(mh1, boolean.class, short.class); 2.175 - boolean a = mh1.<boolean>invokeExact((x & 1) == 1); 2.176 - boolean b = mh2.<boolean>invokeExact(x); 2.177 - assert a == b : a + " != " + b; 2.178 + boolean a = (boolean) mh1.invokeExact((x & 1) == 1); 2.179 + boolean b = (boolean) mh2.invokeExact(x); 2.180 + check(x, a, b); 2.181 } 2.182 2.183 // byte 2.184 { 2.185 MethodHandle mh1 = getmh1( byte.class, byte.class); 2.186 MethodHandle mh2 = getmh2(mh1, byte.class, short.class); 2.187 - byte a = mh1.<byte>invokeExact((byte) x); 2.188 - byte b = mh2.<byte>invokeExact(x); 2.189 - assert a == b : a + " != " + b; 2.190 + byte a = (byte) mh1.invokeExact((byte) x); 2.191 + byte b = (byte) mh2.invokeExact(x); 2.192 + check(x, a, b); 2.193 } 2.194 2.195 // char 2.196 { 2.197 MethodHandle mh1 = getmh1( char.class, char.class); 2.198 MethodHandle mh2 = getmh2(mh1, char.class, short.class); 2.199 - char a = mh1.<char>invokeExact((char) x); 2.200 - char b = mh2.<char>invokeExact(x); 2.201 - assert a == b : a + " != " + b; 2.202 + char a = (char) mh1.invokeExact((char) x); 2.203 + char b = (char) mh2.invokeExact(x); 2.204 + check(x, a, b); 2.205 } 2.206 2.207 // short 2.208 { 2.209 MethodHandle mh1 = getmh1( short.class, short.class); 2.210 MethodHandle mh2 = getmh2(mh1, short.class, short.class); 2.211 - short a = mh1.<short>invokeExact((short) x); 2.212 - short b = mh2.<short>invokeExact(x); 2.213 - assert a == b : a + " != " + b; 2.214 + short a = (short) mh1.invokeExact((short) x); 2.215 + short b = (short) mh2.invokeExact(x); 2.216 + check(x, a, b); 2.217 } 2.218 } 2.219 2.220 @@ -316,45 +316,46 @@ 2.221 { 2.222 MethodHandle mh1 = getmh1( boolean.class, boolean.class); 2.223 MethodHandle mh2 = getmh2(mh1, boolean.class, int.class); 2.224 - boolean a = mh1.<boolean>invokeExact((x & 1) == 1); 2.225 - boolean b = mh2.<boolean>invokeExact(x); 2.226 - assert a == b : a + " != " + b; 2.227 + boolean a = (boolean) mh1.invokeExact((x & 1) == 1); 2.228 + boolean b = (boolean) mh2.invokeExact(x); 2.229 + check(x, a, b); 2.230 } 2.231 2.232 // byte 2.233 { 2.234 MethodHandle mh1 = getmh1( byte.class, byte.class); 2.235 MethodHandle mh2 = getmh2(mh1, byte.class, int.class); 2.236 - byte a = mh1.<byte>invokeExact((byte) x); 2.237 - byte b = mh2.<byte>invokeExact(x); 2.238 - assert a == b : a + " != " + b; 2.239 + byte a = (byte) mh1.invokeExact((byte) x); 2.240 + byte b = (byte) mh2.invokeExact(x); 2.241 + check(x, a, b); 2.242 } 2.243 2.244 // char 2.245 { 2.246 MethodHandle mh1 = getmh1( char.class, char.class); 2.247 MethodHandle mh2 = getmh2(mh1, char.class, int.class); 2.248 - char a = mh1.<char>invokeExact((char) x); 2.249 - char b = mh2.<char>invokeExact(x); 2.250 - assert a == b : a + " != " + b; 2.251 + char a = (char) mh1.invokeExact((char) x); 2.252 + char b = (char) mh2.invokeExact(x); 2.253 + check(x, a, b); 2.254 } 2.255 2.256 // short 2.257 { 2.258 MethodHandle mh1 = getmh1( short.class, short.class); 2.259 MethodHandle mh2 = getmh2(mh1, short.class, int.class); 2.260 - short a = mh1.<short>invokeExact((short) x); 2.261 - short b = mh2.<short>invokeExact(x); 2.262 + short a = (short) mh1.invokeExact((short) x); 2.263 + short b = (short) mh2.invokeExact(x); 2.264 assert a == b : a + " != " + b; 2.265 + check(x, a, b); 2.266 } 2.267 2.268 // int 2.269 { 2.270 MethodHandle mh1 = getmh1( int.class, int.class); 2.271 MethodHandle mh2 = getmh2(mh1, int.class, int.class); 2.272 - int a = mh1.<int>invokeExact((int) x); 2.273 - int b = mh2.<int>invokeExact(x); 2.274 - assert a == b : a + " != " + b; 2.275 + int a = (int) mh1.invokeExact((int) x); 2.276 + int b = (int) mh2.invokeExact(x); 2.277 + check(x, a, b); 2.278 } 2.279 } 2.280 2.281 @@ -395,48 +396,65 @@ 2.282 { 2.283 MethodHandle mh1 = getmh1( boolean.class, boolean.class); 2.284 MethodHandle mh2 = getmh2(mh1, boolean.class, long.class); 2.285 - boolean a = mh1.<boolean>invokeExact((x & 1L) == 1L); 2.286 - boolean b = mh2.<boolean>invokeExact(x); 2.287 - assert a == b : a + " != " + b; 2.288 + boolean a = (boolean) mh1.invokeExact((x & 1L) == 1L); 2.289 + boolean b = (boolean) mh2.invokeExact(x); 2.290 + check(x, a, b); 2.291 } 2.292 2.293 // byte 2.294 { 2.295 MethodHandle mh1 = getmh1( byte.class, byte.class); 2.296 MethodHandle mh2 = getmh2(mh1, byte.class, long.class); 2.297 - byte a = mh1.<byte>invokeExact((byte) x); 2.298 - byte b = mh2.<byte>invokeExact(x); 2.299 - assert a == b : a + " != " + b; 2.300 + byte a = (byte) mh1.invokeExact((byte) x); 2.301 + byte b = (byte) mh2.invokeExact(x); 2.302 + check(x, a, b); 2.303 } 2.304 2.305 // char 2.306 { 2.307 MethodHandle mh1 = getmh1( char.class, char.class); 2.308 MethodHandle mh2 = getmh2(mh1, char.class, long.class); 2.309 - char a = mh1.<char>invokeExact((char) x); 2.310 - char b = mh2.<char>invokeExact(x); 2.311 - assert a == b : a + " != " + b; 2.312 + char a = (char) mh1.invokeExact((char) x); 2.313 + char b = (char) mh2.invokeExact(x); 2.314 + check(x, a, b); 2.315 } 2.316 2.317 // short 2.318 { 2.319 MethodHandle mh1 = getmh1( short.class, short.class); 2.320 MethodHandle mh2 = getmh2(mh1, short.class, long.class); 2.321 - short a = mh1.<short>invokeExact((short) x); 2.322 - short b = mh2.<short>invokeExact(x); 2.323 - assert a == b : a + " != " + b; 2.324 + short a = (short) mh1.invokeExact((short) x); 2.325 + short b = (short) mh2.invokeExact(x); 2.326 + check(x, a, b); 2.327 } 2.328 2.329 // int 2.330 { 2.331 MethodHandle mh1 = getmh1( int.class, int.class); 2.332 MethodHandle mh2 = getmh2(mh1, int.class, long.class); 2.333 - int a = mh1.<int>invokeExact((int) x); 2.334 - int b = mh2.<int>invokeExact(x); 2.335 - assert a == b : a + " != " + b; 2.336 + int a = (int) mh1.invokeExact((int) x); 2.337 + int b = (int) mh2.invokeExact(x); 2.338 + check(x, a, b); 2.339 } 2.340 + } 2.341 2.342 - } 2.343 + static void check(boolean x, boolean e, boolean a) { p(z2h(x), z2h(e), z2h(a)); assert e == a : z2h(x) + ": " + z2h(e) + " != " + z2h(a); } 2.344 + static void check(boolean x, byte e, byte a) { p(z2h(x), i2h(e), i2h(a)); assert e == a : z2h(x) + ": " + i2h(e) + " != " + i2h(a); } 2.345 + static void check(boolean x, int e, int a) { p(z2h(x), i2h(e), i2h(a)); assert e == a : z2h(x) + ": " + i2h(e) + " != " + i2h(a); } 2.346 + 2.347 + static void check(int x, boolean e, boolean a) { p(i2h(x), z2h(e), z2h(a)); assert e == a : i2h(x) + ": " + z2h(e) + " != " + z2h(a); } 2.348 + static void check(int x, byte e, byte a) { p(i2h(x), i2h(e), i2h(a)); assert e == a : i2h(x) + ": " + i2h(e) + " != " + i2h(a); } 2.349 + static void check(int x, int e, int a) { p(i2h(x), i2h(e), i2h(a)); assert e == a : i2h(x) + ": " + i2h(e) + " != " + i2h(a); } 2.350 + 2.351 + static void check(long x, boolean e, boolean a) { p(l2h(x), z2h(e), z2h(a)); assert e == a : l2h(x) + ": " + z2h(e) + " != " + z2h(a); } 2.352 + static void check(long x, byte e, byte a) { p(l2h(x), i2h(e), i2h(a)); assert e == a : l2h(x) + ": " + i2h(e) + " != " + i2h(a); } 2.353 + static void check(long x, int e, int a) { p(l2h(x), i2h(e), i2h(a)); assert e == a : l2h(x) + ": " + i2h(e) + " != " + i2h(a); } 2.354 + 2.355 + static void p(String x, String e, String a) { if (DEBUG) System.out.println(x + ": expected: " + e + ", actual: " + a); } 2.356 + 2.357 + static String z2h(boolean x) { return x ? "1" : "0"; } 2.358 + static String i2h(int x) { return Integer.toHexString(x); } 2.359 + static String l2h(long x) { return Long.toHexString(x); } 2.360 2.361 // to int 2.362 public static boolean foo(boolean i) { return i; }