Mercurial > hg > graal-jvmci-8
annotate test/compiler/types/TestTypePropagationToCmpU.java @ 24110:a8378ff1936d
remove use of cache in jdk.vm.ci.services.Services (GR-3293)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 20 Mar 2017 10:46:02 +0100 |
parents | 68c65ae9f5db |
children |
rev | line source |
---|---|
23044
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
1 /* |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
4 * |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
8 * |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
13 * accompanied this code). |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
14 * |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
18 * |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
21 * questions. |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
22 */ |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
23 |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
24 /* |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
25 * @test |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
26 * @bug 8080156 8060036 |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
27 * @summary Test correctness of type propagation to CmpUNodes. |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
28 * @run main TestTypePropagationToCmpU |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
29 */ |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
30 public class TestTypePropagationToCmpU { |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
31 public static void main(String[] args) { |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
32 try { |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
33 // Trigger compilation |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
34 for (int i = 0; i < 100_000; ++i) { |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
35 test(); |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
36 } |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
37 } catch (NullPointerException e) { |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
38 // Test should never throw a NullPointerException |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
39 throw new RuntimeException("Test failed"); |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
40 } |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
41 } |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
42 |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
43 static int global = 42; |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
44 |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
45 public static void test() { |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
46 int a = Integer.MIN_VALUE; |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
47 int b = global; |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
48 char[] buf = { 0 }; |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
49 for (int i = 0; i <= b; ++i) { |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
50 a = i - b; |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
51 } |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
52 // C2 adds a range check and an uncommon trap here to ensure that the array index |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
53 // is in bounds. If type information is not propagated correctly to the corresponding |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
54 // CmpUNode, this trap may be always taken. Because C2 also removes the unnecessary |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
55 // allocation of 'buf', a NullPointerException is thrown in this case. |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
56 char c = buf[(a * 11) / 2 - a]; // a is 0 here if global >= 0 |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
57 buf[0] = 0; |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
58 } |
68c65ae9f5db
8080156: Integer.toString(int value) sometimes throws NPE
thartmann
parents:
diff
changeset
|
59 } |