author | jiangli |
Fri, 02 Nov 2018 19:30:31 -0400 | |
changeset 52397 | 1322829d1501 |
parent 47216 | 71c04702a3d5 |
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 |
|
33072
71f9b0782023
8136693: add package statement 'compiler.testlibrary' to CompilerUtils
tpivovarova
parents:
30604
diff
changeset
|
24 |
package compiler.testlibrary; |
71f9b0782023
8136693: add package statement 'compiler.testlibrary' to CompilerUtils
tpivovarova
parents:
30604
diff
changeset
|
25 |
|
40069
5ef5d8dd3d22
8157984: [TESTBUG] Several compiler tests fails when are executed with -XX:TieredStopAtLevel=1
dpochepk
parents:
40059
diff
changeset
|
26 |
import java.util.Arrays; |
30604
b8d532cb6420
8067013: Rename the com.oracle.java.testlibary package
ykantser
parents:
28392
diff
changeset
|
27 |
import jdk.test.lib.Asserts; |
b8d532cb6420
8067013: Rename the com.oracle.java.testlibary package
ykantser
parents:
28392
diff
changeset
|
28 |
import jdk.test.lib.Platform; |
40059 | 29 |
import sun.hotspot.WhiteBox; |
30 |
||
28392
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
31 |
import java.util.stream.IntStream; |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
32 |
|
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
33 |
public class CompilerUtils { |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
34 |
|
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
35 |
private CompilerUtils() { |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
36 |
// to prevent from instantiation |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
37 |
} |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
38 |
|
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
39 |
/** |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
40 |
* Returns available compilation levels |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
41 |
* |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
42 |
* @return int array with compilation levels |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
43 |
*/ |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
44 |
public static int[] getAvailableCompilationLevels() { |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
45 |
if (!WhiteBox.getWhiteBox().getBooleanVMFlag("UseCompiler")) { |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
46 |
return new int[0]; |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
47 |
} |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
48 |
if (WhiteBox.getWhiteBox().getBooleanVMFlag("TieredCompilation")) { |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
49 |
Long flagValue = WhiteBox.getWhiteBox() |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
50 |
.getIntxVMFlag("TieredStopAtLevel"); |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
51 |
int maxLevel = flagValue.intValue(); |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
52 |
Asserts.assertEQ(new Long(maxLevel), flagValue, |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
53 |
"TieredStopAtLevel has value out of int capacity"); |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
54 |
return IntStream.rangeClosed(1, maxLevel).toArray(); |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
55 |
} else { |
43455
96560cffef4d
8166002: Emulate client build on platforms with reduced virtual address space
jcm
parents:
40069
diff
changeset
|
56 |
if (Platform.isServer() && !Platform.isEmulatedClient()) { |
28392
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
57 |
return new int[]{4}; |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
58 |
} |
43455
96560cffef4d
8166002: Emulate client build on platforms with reduced virtual address space
jcm
parents:
40069
diff
changeset
|
59 |
if (Platform.isClient() || Platform.isMinimal() || Platform.isEmulatedClient()) { |
28392
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
60 |
return new int[]{1}; |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
61 |
} |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
62 |
} |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
63 |
return new int[0]; |
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
64 |
} |
40069
5ef5d8dd3d22
8157984: [TESTBUG] Several compiler tests fails when are executed with -XX:TieredStopAtLevel=1
dpochepk
parents:
40059
diff
changeset
|
65 |
|
5ef5d8dd3d22
8157984: [TESTBUG] Several compiler tests fails when are executed with -XX:TieredStopAtLevel=1
dpochepk
parents:
40059
diff
changeset
|
66 |
/** |
5ef5d8dd3d22
8157984: [TESTBUG] Several compiler tests fails when are executed with -XX:TieredStopAtLevel=1
dpochepk
parents:
40059
diff
changeset
|
67 |
* Returns maximum compilation level available |
5ef5d8dd3d22
8157984: [TESTBUG] Several compiler tests fails when are executed with -XX:TieredStopAtLevel=1
dpochepk
parents:
40059
diff
changeset
|
68 |
* @return an int value representing maximum compilation level available |
5ef5d8dd3d22
8157984: [TESTBUG] Several compiler tests fails when are executed with -XX:TieredStopAtLevel=1
dpochepk
parents:
40059
diff
changeset
|
69 |
*/ |
5ef5d8dd3d22
8157984: [TESTBUG] Several compiler tests fails when are executed with -XX:TieredStopAtLevel=1
dpochepk
parents:
40059
diff
changeset
|
70 |
public static int getMaxCompilationLevel() { |
5ef5d8dd3d22
8157984: [TESTBUG] Several compiler tests fails when are executed with -XX:TieredStopAtLevel=1
dpochepk
parents:
40059
diff
changeset
|
71 |
return Arrays.stream(getAvailableCompilationLevels()) |
5ef5d8dd3d22
8157984: [TESTBUG] Several compiler tests fails when are executed with -XX:TieredStopAtLevel=1
dpochepk
parents:
40059
diff
changeset
|
72 |
.max() |
5ef5d8dd3d22
8157984: [TESTBUG] Several compiler tests fails when are executed with -XX:TieredStopAtLevel=1
dpochepk
parents:
40059
diff
changeset
|
73 |
.getAsInt(); |
5ef5d8dd3d22
8157984: [TESTBUG] Several compiler tests fails when are executed with -XX:TieredStopAtLevel=1
dpochepk
parents:
40059
diff
changeset
|
74 |
} |
28392
f64a0abbff20
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff
changeset
|
75 |
} |