author | michaelm |
Thu, 25 Feb 2016 23:14:22 +0000 | |
changeset 36131 | 379db4b2f95d |
parent 34151 | 8e0bebdbc29e |
child 40059 | c2304140ed64 |
permissions | -rw-r--r-- |
34151
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
1 |
/* |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
2 |
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
4 |
* |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
8 |
* |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
13 |
* accompanied this code). |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
14 |
* |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
18 |
* |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
21 |
* questions. |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
22 |
*/ |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
23 |
|
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
24 |
/* |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
25 |
* @test |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
26 |
* @bug 8140574 |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
27 |
* @summary Verify proper re-execution of checks after merging of uncommon traps |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
28 |
* @run main/othervm -Xcomp -XX:-TieredCompilation -XX:CompileCommand=compileonly,TestUncommonTrapMerging::test* TestUncommonTrapMerging Test1 |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
29 |
* @run main/othervm -XX:CompileCommand=compileonly,TestUncommonTrapMerging::test* TestUncommonTrapMerging Test2 |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
30 |
*/ |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
31 |
public class TestUncommonTrapMerging { |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
32 |
|
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
33 |
public static void main(String[] args) throws Throwable { |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
34 |
if (args.length < 1) { |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
35 |
throw new RuntimeException("Not enough arguments!"); |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
36 |
} |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
37 |
TestUncommonTrapMerging mytest = new TestUncommonTrapMerging(); |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
38 |
String testcase = args[0]; |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
39 |
if (testcase.equals("Test1")) { |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
40 |
try { |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
41 |
// '42' should hit the 'arg > 0' check |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
42 |
mytest.test(42); |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
43 |
|
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
44 |
} catch (OutOfMemoryError e) { |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
45 |
// expected |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
46 |
} |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
47 |
} else if (testcase.equals("Test2")) { |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
48 |
// Compile test2 with uncommon traps at path 1 and path 2 |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
49 |
for (int i = 0; i < 100_000; i++) { |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
50 |
mytest.test2(-1, 0); |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
51 |
} |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
52 |
|
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
53 |
// Compile test3 which inlines test2 with uncommon traps at |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
54 |
// path 1 and path 2. Because test3 always passes 'value = 1', |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
55 |
// C2 will remove the 'value > 0' check and then merge the two |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
56 |
// uncommon traps. |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
57 |
for (int i = 0; i < 100_000; i++) { |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
58 |
mytest.test3(0); |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
59 |
} |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
60 |
|
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
61 |
// This should return through path 2 |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
62 |
if (!mytest.test3(42)) { |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
63 |
throw new RuntimeException("test2 returned through wrong path!"); |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
64 |
} |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
65 |
} |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
66 |
} |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
67 |
|
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
68 |
public void test(int arg) throws Throwable { |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
69 |
// The following two checks should not be merged if the |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
70 |
// uncommon trap of the dominating if has 'Reason_unloaded' |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
71 |
// because we need to re-execute both checks after deopt. |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
72 |
if (arg < 0) { |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
73 |
throw new RuntimeException("Should not reach here"); |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
74 |
} else if (arg > 0) { |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
75 |
throw new OutOfMemoryError(); |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
76 |
} |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
77 |
throw new RuntimeException("Should not reach here"); |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
78 |
} |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
79 |
|
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
80 |
public boolean test2(int arg, int value) { |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
81 |
if (arg < 0) { |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
82 |
if (value > 0) { |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
83 |
// path 1 |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
84 |
return false; |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
85 |
} |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
86 |
} else if (arg > 0) { |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
87 |
// path 2 |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
88 |
return true; |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
89 |
} |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
90 |
// path 3 |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
91 |
return false; |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
92 |
} |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
93 |
|
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
94 |
public boolean test3(int arg) { |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
95 |
int i; |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
96 |
for (i = 0; i < 1; ++i) { } |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
97 |
// i == 1 |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
98 |
return test2(arg, i); |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
99 |
} |
8e0bebdbc29e
8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents:
diff
changeset
|
100 |
} |