hotspot/test/compiler/testlibrary/CompilerUtils.java
author tpivovarova
Tue, 12 Jul 2016 18:24:48 +0300
changeset 40059 c2304140ed64
parent 33072 71f9b0782023
child 40069 5ef5d8dd3d22
permissions -rw-r--r--
8132919: Put compiler tests in packages Reviewed-by: vlivanov, dpochepk Contributed-by: igor.ignatyev@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
30604
b8d532cb6420 8067013: Rename the com.oracle.java.testlibary package
ykantser
parents: 28392
diff changeset
    26
import jdk.test.lib.Asserts;
b8d532cb6420 8067013: Rename the com.oracle.java.testlibary package
ykantser
parents: 28392
diff changeset
    27
import jdk.test.lib.Platform;
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 33072
diff changeset
    28
import sun.hotspot.WhiteBox;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 33072
diff changeset
    29
28392
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    30
import java.util.stream.IntStream;
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 CompilerUtils {
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 CompilerUtils() {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    35
        // to prevent from instantiation
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    36
    }
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
     * Returns available compilation levels
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
     * @return int array with compilation levels
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    42
     */
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    43
    public static int[] getAvailableCompilationLevels() {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    44
        if (!WhiteBox.getWhiteBox().getBooleanVMFlag("UseCompiler")) {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    45
            return new int[0];
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    46
        }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    47
        if (WhiteBox.getWhiteBox().getBooleanVMFlag("TieredCompilation")) {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    48
            Long flagValue = WhiteBox.getWhiteBox()
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    49
                    .getIntxVMFlag("TieredStopAtLevel");
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    50
            int maxLevel = flagValue.intValue();
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    51
            Asserts.assertEQ(new Long(maxLevel), flagValue,
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    52
                    "TieredStopAtLevel has value out of int capacity");
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    53
            return IntStream.rangeClosed(1, maxLevel).toArray();
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    54
        } else {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    55
            if (Platform.isServer()) {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    56
                return new int[]{4};
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
            if (Platform.isClient() || Platform.isMinimal()) {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    59
                return new int[]{1};
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    60
            }
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
        return new int[0];
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    63
    }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    64
}