author | lana |
Thu, 23 Feb 2017 17:30:12 +0000 | |
changeset 44011 | 5eea3031ae7b |
parent 43462 | cde11973a86a |
permissions | -rw-r--r-- |
43462
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
1 |
/* |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
2 |
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
4 |
* |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
8 |
* |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
13 |
* accompanied this code). |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
14 |
* |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
18 |
* |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
21 |
* questions. |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
22 |
*/ |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
23 |
|
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
24 |
/** |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
25 |
* @test |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
26 |
* @bug 8172751 |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
27 |
* @summary OSR compilation at unreachable bci causes C1 crash |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
28 |
* |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
29 |
* @run main/othervm -XX:-BackgroundCompilation compiler.c1.Test8172751 |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
30 |
*/ |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
31 |
|
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
32 |
package compiler.c1; |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
33 |
|
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
34 |
import java.lang.invoke.MethodHandle; |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
35 |
import java.lang.invoke.MethodHandles; |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
36 |
import java.lang.invoke.MutableCallSite; |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
37 |
|
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
38 |
public class Test8172751 { |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
39 |
private static final MethodHandle CONSTANT_TRUE = MethodHandles.constant(boolean.class, true); |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
40 |
private static final MethodHandle CONSTANT_FALSE = MethodHandles.constant(boolean.class, false); |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
41 |
private static final MutableCallSite CALL_SITE = new MutableCallSite(CONSTANT_FALSE); |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
42 |
private static final int LIMIT = 1_000_000; |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
43 |
private static volatile int counter; |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
44 |
|
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
45 |
private static boolean doSomething() { |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
46 |
return counter++ < LIMIT; |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
47 |
} |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
48 |
|
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
49 |
private static void executeLoop() { |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
50 |
/* |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
51 |
* Start off with executing the first loop, then change the call site |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
52 |
* target so as to switch over to the second loop but continue running |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
53 |
* in the first loop. Eventually, an OSR compilation of the first loop |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
54 |
* is triggered. Yet C1 will not find the OSR entry, since it will |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
55 |
* have optimized out the first loop already during parsing. |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
56 |
*/ |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
57 |
if (CALL_SITE.getTarget() == CONSTANT_FALSE) { |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
58 |
int count = 0; |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
59 |
while (doSomething()) { |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
60 |
if (count++ == 1) { |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
61 |
flipSwitch(); |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
62 |
} |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
63 |
} |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
64 |
} else { |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
65 |
while (doSomething()) { |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
66 |
} |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
67 |
} |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
68 |
} |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
69 |
|
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
70 |
private static void flipSwitch() { |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
71 |
CALL_SITE.setTarget(CONSTANT_TRUE); |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
72 |
} |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
73 |
|
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
74 |
public static void main(String[] args) { |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
75 |
executeLoop(); |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
76 |
} |
cde11973a86a
8172751: OSR compilation at unreachable bci causes C1 crash
thartmann
parents:
diff
changeset
|
77 |
} |