author | tpivovarova |
Sat, 19 Sep 2015 12:03:36 +0300 | |
changeset 33072 | 71f9b0782023 |
parent 30604 | b8d532cb6420 |
child 40059 | c2304140ed64 |
permissions | -rw-r--r-- |
28392
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
1 |
/* |
30604
b8d532cb6420
8067013: Rename the com.oracle.java.testlibary package
ykantser
parents:
28392
diff
changeset
|
2 |
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. |
28392
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
4 |
* |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
8 |
* |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
13 |
* accompanied this code). |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
14 |
* |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
18 |
* |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
21 |
* questions. |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
22 |
*/ |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
23 |
|
30604
b8d532cb6420
8067013: Rename the com.oracle.java.testlibary package
ykantser
parents:
28392
diff
changeset
|
24 |
import jdk.test.lib.Utils; |
28392
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
25 |
import java.lang.reflect.Executable; |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
26 |
import java.util.ArrayList; |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
27 |
import java.util.Arrays; |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
28 |
import java.util.Collections; |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
29 |
import java.util.List; |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
30 |
import sun.hotspot.WhiteBox; |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
31 |
|
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
32 |
public class SegmentedCodeCacheDtraceTestWorker { |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
33 |
|
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
34 |
private static final String METHOD1_NAME = "foo"; |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
35 |
private static final String METHOD2_NAME = "bar"; |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
36 |
private static final String METHOD3_NAME = "baz"; |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
37 |
public static final List<Executable> TESTED_METHODS_LIST; |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
38 |
private final WhiteBox wb; |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
39 |
private final int compLevels[]; |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
40 |
|
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
41 |
static { |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
42 |
List<Executable> methods = new ArrayList<>(); |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
43 |
try { |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
44 |
// method order is important. Need to place methods in call order, |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
45 |
// to be able to verify results later |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
46 |
methods.add(SegmentedCodeCacheDtraceTestWorker.class.getMethod(METHOD1_NAME)); |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
47 |
methods.add(SegmentedCodeCacheDtraceTestWorker.class.getMethod(METHOD2_NAME)); |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
48 |
methods.add(SegmentedCodeCacheDtraceTestWorker.class.getMethod(METHOD3_NAME)); |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
49 |
} catch (NoSuchMethodException e) { |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
50 |
throw new Error("TESTBUG: no expected method found", e); |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
51 |
} |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
52 |
TESTED_METHODS_LIST = Collections.unmodifiableList(methods); |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
53 |
} |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
54 |
|
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
55 |
protected static final boolean BACKGROUND_COMPILATION |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
56 |
= WhiteBox.getWhiteBox().getBooleanVMFlag("BackgroundCompilation"); |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
57 |
|
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
58 |
public static void main(String[] args) { |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
59 |
if (args.length != 2 * TESTED_METHODS_LIST.size()) { |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
60 |
throw new Error("Usage: java <thisClass> <fooCompLevel> <fooInlined>" |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
61 |
+ "<barCompLevel> <barInlined> " |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
62 |
+ "<bazCompLevel> <bazInlined>"); |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
63 |
} else { |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
64 |
int compLevels[] = new int[TESTED_METHODS_LIST.size()]; |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
65 |
boolean inlines[] = new boolean[TESTED_METHODS_LIST.size()]; |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
66 |
for (int i = 0; i < TESTED_METHODS_LIST.size(); i++) { |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
67 |
compLevels[i] = Integer.parseInt(args[2 * i]); |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
68 |
inlines[i] = Boolean.parseBoolean(args[2 * i + 1]); |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
69 |
} |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
70 |
new SegmentedCodeCacheDtraceTestWorker(compLevels, inlines).test(); |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
71 |
} |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
72 |
} |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
73 |
|
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
74 |
public SegmentedCodeCacheDtraceTestWorker(int compLevels[], boolean inlines[]) { |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
75 |
wb = WhiteBox.getWhiteBox(); |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
76 |
this.compLevels = Arrays.copyOf(compLevels, compLevels.length); |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
77 |
for (int i = 0; i < compLevels.length; i++) { |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
78 |
if (inlines[i]) { |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
79 |
wb.testSetForceInlineMethod(TESTED_METHODS_LIST.get(i), true); |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
80 |
} else { |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
81 |
wb.testSetDontInlineMethod(TESTED_METHODS_LIST.get(i), true); |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
82 |
} |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
83 |
} |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
84 |
} |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
85 |
|
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
86 |
private void waitForCompilation(Executable executable, int compLevel) { |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
87 |
if (compLevel > 0) { |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
88 |
Utils.waitForCondition(() -> wb.isMethodCompiled(executable)); |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
89 |
} |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
90 |
} |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
91 |
|
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
92 |
protected void test() { |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
93 |
for (int i = 0; i < TESTED_METHODS_LIST.size(); i++) { |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
94 |
Executable method = TESTED_METHODS_LIST.get(i); |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
95 |
int compLevel = compLevels[i]; |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
96 |
wb.enqueueMethodForCompilation(method, compLevel); |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
97 |
waitForCompilation(method, compLevel); |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
98 |
} |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
99 |
foo(); |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
100 |
} |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
101 |
|
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
102 |
public static void foo() { |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
103 |
bar(); |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
104 |
} |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
105 |
|
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
106 |
public static void bar() { |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
107 |
baz(); |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
108 |
} |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
109 |
|
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
110 |
public static void baz() { |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
111 |
System.out.println("Reached baz method"); |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
112 |
} |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
113 |
} |