author | redestad |
Mon, 18 Apr 2016 16:48:12 +0200 | |
changeset 37370 | 4dcebdd2bbc0 |
parent 36300 | 5b47f168b948 |
child 38152 | 80e5da81fb2c |
permissions | -rw-r--r-- |
36300
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
1 |
/* |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
2 |
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
4 |
* |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
8 |
* |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
13 |
* accompanied this code). |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
14 |
* |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
18 |
* |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
21 |
* questions. |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
22 |
*/ |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
23 |
|
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
24 |
/** |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
25 |
* @test |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
26 |
* @library /testlibrary |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
27 |
* @run main ContinuousCallSiteTargetChange |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
28 |
*/ |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
29 |
import java.lang.invoke.*; |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
30 |
import jdk.test.lib.*; |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
31 |
|
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
32 |
public class ContinuousCallSiteTargetChange { |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
33 |
static void testServer() throws Exception { |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
34 |
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
35 |
"-XX:+IgnoreUnrecognizedVMOptions", |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
36 |
"-server", "-XX:-TieredCompilation", "-Xbatch", |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
37 |
"-XX:PerBytecodeRecompilationCutoff=10", "-XX:PerMethodRecompilationCutoff=10", |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
38 |
"-XX:+PrintCompilation", "-XX:+UnlockDiagnosticVMOptions", "-XX:+PrintInlining", |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
39 |
"ContinuousCallSiteTargetChange$Test", "100"); |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
40 |
|
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
41 |
OutputAnalyzer analyzer = new OutputAnalyzer(pb.start()); |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
42 |
|
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
43 |
analyzer.shouldHaveExitValue(0); |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
44 |
|
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
45 |
analyzer.shouldNotContain("made not compilable"); |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
46 |
analyzer.shouldNotContain("decompile_count > PerMethodRecompilationCutoff"); |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
47 |
} |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
48 |
|
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
49 |
static void testClient() throws Exception { |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
50 |
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
51 |
"-XX:+IgnoreUnrecognizedVMOptions", |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
52 |
"-client", "-XX:+TieredCompilation", "-XX:TieredStopAtLevel=1", "-Xbatch", |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
53 |
"-XX:PerBytecodeRecompilationCutoff=10", "-XX:PerMethodRecompilationCutoff=10", |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
54 |
"-XX:+PrintCompilation", "-XX:+UnlockDiagnosticVMOptions", "-XX:+PrintInlining", |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
55 |
"ContinuousCallSiteTargetChange$Test", "100"); |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
56 |
|
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
57 |
OutputAnalyzer analyzer = new OutputAnalyzer(pb.start()); |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
58 |
|
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
59 |
analyzer.shouldHaveExitValue(0); |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
60 |
|
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
61 |
analyzer.shouldNotContain("made not compilable"); |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
62 |
analyzer.shouldNotContain("decompile_count > PerMethodRecompilationCutoff"); |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
63 |
} |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
64 |
|
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
65 |
public static void main(String[] args) throws Exception { |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
66 |
testServer(); |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
67 |
testClient(); |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
68 |
} |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
69 |
|
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
70 |
static class Test { |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
71 |
static final MethodType mt = MethodType.methodType(void.class); |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
72 |
static final CallSite cs = new MutableCallSite(mt); |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
73 |
|
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
74 |
static final MethodHandle mh = cs.dynamicInvoker(); |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
75 |
|
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
76 |
static void f() { |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
77 |
} |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
78 |
|
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
79 |
static void test1() throws Throwable { |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
80 |
mh.invokeExact(); |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
81 |
} |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
82 |
|
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
83 |
static void test2() throws Throwable { |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
84 |
cs.getTarget().invokeExact(); |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
85 |
} |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
86 |
|
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
87 |
static void iteration() throws Throwable { |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
88 |
MethodHandle mh1 = MethodHandles.lookup().findStatic(ContinuousCallSiteTargetChange.Test.class, "f", mt); |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
89 |
cs.setTarget(mh1); |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
90 |
for (int i = 0; i < 20_000; i++) { |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
91 |
test1(); |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
92 |
test2(); |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
93 |
} |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
94 |
} |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
95 |
|
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
96 |
public static void main(String[] args) throws Throwable { |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
97 |
int iterations = Integer.parseInt(args[0]); |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
98 |
for (int i = 0; i < iterations; i++) { |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
99 |
iteration(); |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
100 |
} |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
101 |
} |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
102 |
} |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
diff
changeset
|
103 |
} |