Mercurial > hg > graal-compiler
annotate test/compiler/EliminateAutoBox/UnsignedLoads.java @ 21918:0ab08be12bbb
Merge
author | Stefan Anzinger <stefan.anzinger@oracle.com> |
---|---|
date | Thu, 11 Jun 2015 11:35:55 +0200 |
parents | abb8b1de96ff |
children |
rev | line source |
---|---|
20669
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
1 /* |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
4 * |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
7 * published by the Free Software Foundation. Oracle designates this |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
8 * particular file as subject to the "Classpath" exception as provided |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
9 * by Oracle in the LICENSE file that accompanied this code. |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
10 * |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
11 * This code is distributed in the hope that it will be useful, but WITHOUT |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
14 * version 2 for more details (a copy is included in the LICENSE file that |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
15 * accompanied this code). |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
16 * |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
17 * You should have received a copy of the GNU General Public License version |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
18 * 2 along with this work; if not, write to the Free Software Foundation, |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
20 * |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
22 * or visit www.oracle.com if you need additional information or have any |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
23 * questions. |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
24 */ |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
25 |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
26 /* |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
27 * @test |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
28 * @library /testlibrary |
20683
abb8b1de96ff
8062742: compiler/EliminateAutoBox/UnsignedLoads.java fails with client vm
iignatyev
parents:
20669
diff
changeset
|
29 * @run main/othervm -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:+EliminateAutoBox |
20669
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
30 * -XX:CompileOnly=::valueOf,::byteValue,::shortValue,::testUnsignedByte,::testUnsignedShort |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
31 * UnsignedLoads |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
32 */ |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
33 import static com.oracle.java.testlibrary.Asserts.assertEQ; |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
34 |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
35 public class UnsignedLoads { |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
36 public static int testUnsignedByte() { |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
37 byte[] bytes = new byte[] {-1}; |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
38 int res = 0; |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
39 for (int i = 0; i < 100000; i++) { |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
40 for (Byte b : bytes) { |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
41 res = b & 0xff; |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
42 } |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
43 } |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
44 return res; |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
45 } |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
46 |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
47 public static int testUnsignedShort() { |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
48 int res = 0; |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
49 short[] shorts = new short[] {-1}; |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
50 for (int i = 0; i < 100000; i++) { |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
51 for (Short s : shorts) { |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
52 res = s & 0xffff; |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
53 } |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
54 } |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
55 return res; |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
56 } |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
57 |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
58 public static void main(String[] args) { |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
59 assertEQ(testUnsignedByte(), 255); |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
60 assertEQ(testUnsignedShort(), 65535); |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
61 System.out.println("TEST PASSED"); |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
62 } |
e194d26c9f4e
8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff
changeset
|
63 } |