Java Code Examples for jdk.test.lib.Platform#isEmulatedClient()

The following examples show how to use jdk.test.lib.Platform#isEmulatedClient() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestAESIntrinsicsOnSupportedConfig.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Test checks following situation: <br/>
 * UseAES flag is set to true, TestAESMain is executed <br/>
 * Expected result: UseAESIntrinsics flag is set to true <br/>
 * If vm type is server then output should contain intrinsics usage <br/>
 *
 * @throws Throwable
 */
private void testUseAES() throws Throwable {
    OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJvm(
            prepareArguments(prepareBooleanFlag(AESIntrinsicsBase
                    .USE_AES, true)));
    final String errorMessage = "Case testUseAES failed";
    if (Platform.isServer() && !Platform.isEmulatedClient()) {
        verifyOutput(new String[]{AESIntrinsicsBase.CIPHER_INTRINSIC,
                AESIntrinsicsBase.AES_INTRINSIC}, null, errorMessage,
                outputAnalyzer);
    } else {
        verifyOutput(null, new String[]{AESIntrinsicsBase.CIPHER_INTRINSIC,
                AESIntrinsicsBase.AES_INTRINSIC}, errorMessage,
                outputAnalyzer);
    }
    verifyOptionValue(AESIntrinsicsBase.USE_AES, "true", errorMessage,
            outputAnalyzer);
    verifyOptionValue(AESIntrinsicsBase.USE_AES_INTRINSICS, "true",
            errorMessage, outputAnalyzer);
}
 
Example 2
Source File: TestJFRIntrinsic.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns available compilation levels
 *
 * @return int array with compilation levels
 */
public static int[] getAvailableCompilationLevels() {
    if (!WhiteBox.getWhiteBox().getBooleanVMFlag("UseCompiler")) {
        return new int[0];
    }
    if (WhiteBox.getWhiteBox().getBooleanVMFlag("TieredCompilation")) {
        Long flagValue = WhiteBox.getWhiteBox()
                .getIntxVMFlag("TieredStopAtLevel");
        int maxLevel = flagValue.intValue();
        return IntStream.rangeClosed(1, maxLevel).toArray();
    } else {
        if (Platform.isServer() && !Platform.isEmulatedClient()) {
            return new int[]{4};
        }
        if (Platform.isClient() || Platform.isMinimal() || Platform.isEmulatedClient()) {
            return new int[]{1};
        }
    }
    return new int[0];
}
 
Example 3
Source File: CompilerUtils.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns available compilation levels
 *
 * @return int array with compilation levels
 */
public static int[] getAvailableCompilationLevels() {
    if (!WhiteBox.getWhiteBox().getBooleanVMFlag("UseCompiler")) {
        return new int[0];
    }
    if (WhiteBox.getWhiteBox().getBooleanVMFlag("TieredCompilation")) {
        Long flagValue = WhiteBox.getWhiteBox()
                .getIntxVMFlag("TieredStopAtLevel");
        int maxLevel = flagValue.intValue();
        Asserts.assertEQ(new Long(maxLevel), flagValue,
                "TieredStopAtLevel has value out of int capacity");
        return IntStream.rangeClosed(1, maxLevel).toArray();
    } else {
        if (Platform.isServer() && !Platform.isEmulatedClient()) {
            return new int[]{4};
        }
        if (Platform.isClient() || Platform.isMinimal() || Platform.isEmulatedClient()) {
            return new int[]{1};
        }
    }
    return new int[0];
}
 
Example 4
Source File: TestJFRIntrinsic.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns available compilation levels
 *
 * @return int array with compilation levels
 */
public static int[] getAvailableCompilationLevels() {
    if (!WhiteBox.getWhiteBox().getBooleanVMFlag("UseCompiler")) {
        return new int[0];
    }
    if (WhiteBox.getWhiteBox().getBooleanVMFlag("TieredCompilation")) {
        Long flagValue = WhiteBox.getWhiteBox()
                .getIntxVMFlag("TieredStopAtLevel");
        int maxLevel = flagValue.intValue();
        return IntStream.rangeClosed(1, maxLevel).toArray();
    } else {
        if (Platform.isServer() && !Platform.isEmulatedClient()) {
            return new int[]{4};
        }
        if (Platform.isClient() || Platform.isMinimal() || Platform.isEmulatedClient()) {
            return new int[]{1};
        }
    }
    return new int[0];
}
 
Example 5
Source File: CorrectnessTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    if (!Platform.isServer() || Platform.isEmulatedClient()) {
        throw new Error("TESTBUG: Not server mode");
    }
    Asserts.assertGTE(args.length, 1);
    ProfilingType profilingType = ProfilingType.valueOf(args[0]);
    if (runTests(profilingType)) {
        System.out.println("ALL TESTS PASSED");
    } else {
        throw new RuntimeException("SOME TESTS FAILED");
    }
}
 
Example 6
Source File: IntrinsicAvailableTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void test() throws Exception {
    Executable intrinsicMethod = testCase.getExecutable();
    if (Platform.isServer() && !Platform.isEmulatedClient() && (TIERED_STOP_AT_LEVEL == COMP_LEVEL_FULL_OPTIMIZATION)) {
        if (TIERED_COMPILATION) {
            checkIntrinsicForCompilationLevel(intrinsicMethod, COMP_LEVEL_SIMPLE);
        }
        // Dont bother check JVMCI compiler - returns false on all intrinsics.
        if (!Boolean.valueOf(getVMOption("UseJVMCICompiler"))) {
            checkIntrinsicForCompilationLevel(intrinsicMethod, COMP_LEVEL_FULL_OPTIMIZATION);
        }
    } else {
        checkIntrinsicForCompilationLevel(intrinsicMethod, COMP_LEVEL_SIMPLE);
    }
}
 
Example 7
Source File: CommandLineOptionTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @return addtional VMoptions(Emulated related) required to start a new VM with the same type as current.
 */
private static String getVMTypeOptionForEmulated() {
    if (Platform.isServer() && !Platform.isEmulatedClient()) {
        return "-XX:-NeverActAsServerClassMachine";
    } else if (Platform.isEmulatedClient()) {
        return "-XX:+NeverActAsServerClassMachine";
    }
    return null;
}
 
Example 8
Source File: IntrinsicDisabledTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String args[]) {
    if (Platform.isServer() && !Platform.isEmulatedClient() &&
                               (TIERED_STOP_AT_LEVEL == CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION)) {
        if (TIERED_COMPILATION) {
            test(CompilerWhiteBoxTest.COMP_LEVEL_SIMPLE);
        }
        test(CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION);
    } else {
        test(CompilerWhiteBoxTest.COMP_LEVEL_SIMPLE);
    }
}
 
Example 9
Source File: BmiIntrinsicBase.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void test() throws Exception {
    BmiTestCase bmiTestCase = (BmiTestCase) testCase;

    if (!(Platform.isX86() || Platform.isX64())) {
        System.out.println("Unsupported platform, test SKIPPED");
        return;
    }

    if (!Platform.isServer()) {
        throw new Error("TESTBUG: Not server VM");
    }

    if (Platform.isInt()) {
        throw new Error("TESTBUG: test can not be run in interpreter");
    }

    if (!CPUInfo.hasFeature(bmiTestCase.getCpuFlag())) {
        System.out.println("Unsupported hardware, no required CPU flag " + bmiTestCase.getCpuFlag() + " , test SKIPPED");
        return;
    }

    if (!Boolean.valueOf(getVMOption(bmiTestCase.getVMFlag()))) {
        System.out.println("VM flag " + bmiTestCase.getVMFlag() + " disabled, test SKIPPED");
        return;
    }

    System.out.println(testCase.name());

    if (TIERED_COMPILATION && TIERED_STOP_AT_LEVEL != CompilerWhiteBoxTest.COMP_LEVEL_MAX || Platform.isEmulatedClient()) {
        System.out.println("TieredStopAtLevel value (" + TIERED_STOP_AT_LEVEL + ") is too low, test SKIPPED");
        return;
    }
    deoptimize();
    compileAtLevelAndCheck(CompilerWhiteBoxTest.COMP_LEVEL_MAX);
}
 
Example 10
Source File: CompilerDirectivesDCMDTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void run(CommandExecutor executor) {

        if (Platform.isServer() && !Platform.isEmulatedClient()) {
            filename = System.getProperty("test.src", ".") + File.separator + "control2.txt";
        } else {
            filename = System.getProperty("test.src", ".") + File.separator + "control1.txt";
        }
        testPrintCommand(executor);
        testAddAndRemoveCommand(executor);
    }
 
Example 11
Source File: CommandLineOptionTest.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @return addtional VMoptions(Emulated related) required to start a new VM with the same type as current.
 */
private static String getVMTypeOptionForEmulated() {
    if (Platform.isServer() && !Platform.isEmulatedClient()) {
        return "-XX:-NeverActAsServerClassMachine";
    } else if (Platform.isEmulatedClient()) {
        return "-XX:+NeverActAsServerClassMachine";
    }
    return null;
}
 
Example 12
Source File: TestCompilerInlining.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static int[] determineAvailableLevels() {
    if (WHITE_BOX.getBooleanVMFlag("TieredCompilation")) {
        return IntStream.rangeClosed(LEVEL_SIMPLE, WHITE_BOX.getIntxVMFlag("TieredStopAtLevel").intValue()).toArray();
    }
    if (Platform.isServer() && !Platform.isEmulatedClient()) {
        return new int[] { LEVEL_FULL_OPTIMIZATION };
    }
    if (Platform.isClient() || Platform.isEmulatedClient()) {
        return new int[] { LEVEL_SIMPLE };
    }
    throw new Error("TESTBUG: unknown VM");
}
 
Example 13
Source File: TestThrowableInstrumentation.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    // Compile Throwable::<clinit> with C1 (if available)
    if (!WHITE_BOX.enqueueInitializerForCompilation(java.lang.Throwable.class, COMP_LEVEL_SIMPLE)) {
      if (!Platform.isServer() || isTieredCompilationEnabled() || Platform.isEmulatedClient()) {
        throw new RuntimeException("Unable to compile Throwable::<clinit> with C1");
      }
    }
}
 
Example 14
Source File: CommandLineOptionTest.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @return addtional VMoptions(Emulated related) required to start a new VM with the same type as current.
 */
private static String getVMTypeOptionForEmulated() {
    if (Platform.isServer() && !Platform.isEmulatedClient()) {
        return "-XX:-NeverActAsServerClassMachine";
    } else if (Platform.isEmulatedClient()) {
        return "-XX:+NeverActAsServerClassMachine";
    }
    return null;
}
 
Example 15
Source File: TestCompilerInlining.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static int[] determineAvailableLevels() {
    if (WHITE_BOX.getBooleanVMFlag("TieredCompilation")) {
        return IntStream.rangeClosed(LEVEL_SIMPLE, WHITE_BOX.getIntxVMFlag("TieredStopAtLevel").intValue()).toArray();
    }
    if (Platform.isServer() && !Platform.isEmulatedClient()) {
        return new int[] { LEVEL_FULL_OPTIMIZATION };
    }
    if (Platform.isClient() || Platform.isEmulatedClient()) {
        return new int[] { LEVEL_SIMPLE };
    }
    throw new Error("TESTBUG: unknown VM");
}
 
Example 16
Source File: TestThrowableInstrumentation.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    // Compile Throwable::<clinit> with C1 (if available)
    if (!WHITE_BOX.enqueueInitializerForCompilation(java.lang.Throwable.class, COMP_LEVEL_SIMPLE)) {
      if (!Platform.isServer() || isTieredCompilationEnabled() || Platform.isEmulatedClient()) {
        throw new RuntimeException("Unable to compile Throwable::<clinit> with C1");
      }
    }
}
 
Example 17
Source File: IsMethodCompilableTest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Tests {@code WB::isMethodCompilable()} by recompilation of tested method
 * 'PerMethodRecompilationCutoff' times and checks compilation status. Also
 * checks that WB::clearMethodState() clears no-compilable flags. Only
 * applicable to c2 compiled methods.
 *
 * @throws Exception if one of the checks fails.
 */
@Override
protected void test() throws Exception {

    // Only c2 compilations can be disabled through PerMethodRecompilationCutoff
    if (!Platform.isServer() || Platform.isEmulatedClient()) {
        throw new Error("TESTBUG: Not server mode");
    }

    if (skipXcompOSR()) {
        return;
    }
    if (!isCompilable(COMP_LEVEL_FULL_OPTIMIZATION)) {
        throw new RuntimeException(method + " must be compilable");
    }
    System.out.println("PerMethodRecompilationCutoff = "
            + PER_METHOD_RECOMPILATION_CUTOFF);
    if (PER_METHOD_RECOMPILATION_CUTOFF == -1) {
        System.err.println(
                "Warning: test is not applicable if PerMethodRecompilationCutoff == Inf");
        return;
    }

    // deoptimize 'PerMethodRecompilationCutoff' times
    for (long attempts = 0, successes = 0;
           (successes < PER_METHOD_RECOMPILATION_CUTOFF)  &&
           (attempts < PER_METHOD_RECOMPILATION_CUTOFF*2) &&
           isCompilable(COMP_LEVEL_FULL_OPTIMIZATION); attempts++) {
        if (compileAndDeoptimize() == COMP_LEVEL_FULL_OPTIMIZATION) {
            successes++;
        }
    }

    if (!testCase.isOsr() && !isCompilable(COMP_LEVEL_FULL_OPTIMIZATION)) {
        // in osr test case count of deopt maybe more than iterations
        throw new RuntimeException(method + " is not compilable after "
                + PER_METHOD_RECOMPILATION_CUTOFF + " iterations");
    }

    // Now compile once more
    compileAndDeoptimize();

    if (isCompilable(COMP_LEVEL_FULL_OPTIMIZATION)) {
        throw new RuntimeException(method + " is still compilable after "
                + PER_METHOD_RECOMPILATION_CUTOFF + " iterations");
    }
    checkNotCompiled();
    compile();
    waitBackgroundCompilation();
    checkNotCompiled(COMP_LEVEL_FULL_OPTIMIZATION);

    // WB.clearMethodState() must reset no-compilable flags
    WHITE_BOX.clearMethodState(method);
    if (!isCompilable(COMP_LEVEL_FULL_OPTIMIZATION)) {
        throw new RuntimeException(method
                + " is not compilable after clearMethodState()");
    }
    compile();
    checkCompiled();
}
 
Example 18
Source File: CastNullCheckDroppingsTest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    if (!Platform.isServer() || Platform.isEmulatedClient()) {
        throw new Error("TESTBUG: Not server mode");
    }
    // Make sure background compilation is disabled
    if (WHITE_BOX.getBooleanVMFlag("BackgroundCompilation")) {
        throw new Error("TESTBUG: Background compilation enabled");
    }
    // Make sure Tiered compilation is disabled
    if (WHITE_BOX.getBooleanVMFlag("TieredCompilation")) {
        throw new Error("TESTBUG: Tiered compilation enabled");
    }

    Method methodClassCast = CastNullCheckDroppingsTest.class.getDeclaredMethod("testClassCast", String.class);
    Method methodMHCast    = CastNullCheckDroppingsTest.class.getDeclaredMethod("testMHCast",    String.class);
    Method methodMHSetter  = CastNullCheckDroppingsTest.class.getDeclaredMethod("testMHSetter",  String.class);
    Method methodFunction  = CastNullCheckDroppingsTest.class.getDeclaredMethod("testFunction",  String.class);

    CastNullCheckDroppingsTest t = new CastNullCheckDroppingsTest();
    t.runTest(methodClassCast, false);
    t.runTest(methodMHCast,    false);
    t.runTest(methodMHSetter,  false);
    t.runTest(methodFunction,  false);

    // Edge cases
    Method methodClassCastNull = CastNullCheckDroppingsTest.class.getDeclaredMethod("testClassCastNull", String.class);
    Method methodNullClassCast = CastNullCheckDroppingsTest.class.getDeclaredMethod("testNullClassCast", String.class);
    Method methodClassCastObj  = CastNullCheckDroppingsTest.class.getDeclaredMethod("testClassCastObj",  Object.class);
    Method methodObjClassCast  = CastNullCheckDroppingsTest.class.getDeclaredMethod("testObjClassCast",  String.class);
    Method methodVarClassCast  = CastNullCheckDroppingsTest.class.getDeclaredMethod("testVarClassCast",  String.class);
    Method methodClassCastInt  = CastNullCheckDroppingsTest.class.getDeclaredMethod("testClassCastInt",  Object.class);
    Method methodIntClassCast  = CastNullCheckDroppingsTest.class.getDeclaredMethod("testIntClassCast",  Object.class);
    Method methodClassCastint  = CastNullCheckDroppingsTest.class.getDeclaredMethod("testClassCastint",  Object.class);
    Method methodintClassCast  = CastNullCheckDroppingsTest.class.getDeclaredMethod("testintClassCast",  Object.class);
    Method methodClassCastPrim = CastNullCheckDroppingsTest.class.getDeclaredMethod("testClassCastPrim", Object.class);
    Method methodPrimClassCast = CastNullCheckDroppingsTest.class.getDeclaredMethod("testPrimClassCast", Object.class);

    t.runTest(methodClassCastNull, false);
    t.runTest(methodNullClassCast, false);
    t.runTest(methodClassCastObj,  false);
    t.runTest(methodObjClassCast,  true);
    t.runTest(methodVarClassCast,  true);
    t.runTest(methodClassCastInt,  false);
    t.runTest(methodIntClassCast,  true);
    t.runTest(methodClassCastint,  false);
    t.runTest(methodintClassCast,  false);
    t.runTest(methodClassCastPrim, false);
    t.runTest(methodPrimClassCast, true);
}
 
Example 19
Source File: SupportedVM.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean getAsBoolean() {
    return Platform.isServer() && !Platform.isEmulatedClient();
}
 
Example 20
Source File: TestArrayCopyNoInitDeopt.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
static public void main(String[] args) throws Exception {
    if (!Platform.isServer() || Platform.isEmulatedClient()) {
        throw new Error("TESTBUG: Not server mode");
    }
    // Only execute if C2 is available
    if (TIERED_STOP_AT_LEVEL == CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION) {
        int[] src = new int[10];
        Object src_obj = new Object();
        Method method_m1 = TestArrayCopyNoInitDeopt.class.getMethod("m1", Object.class);
        Method method_m2 = TestArrayCopyNoInitDeopt.class.getMethod("m2", Object.class);

        // Warm up
        for (int i = 0; i < 20000; i++) {
            m1(src);
        }

        // And make sure m1 is compiled by C2
        WHITE_BOX.enqueueMethodForCompilation(method_m1, CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION);

        if (!WHITE_BOX.isMethodCompiled(method_m1)) {
            throw new RuntimeException("m1 not compiled");
        }

        // should deoptimize for type check
        if (!deoptimize(method_m1, src_obj)) {
            throw new RuntimeException("m1 not deoptimized");
        }

        WHITE_BOX.enqueueMethodForCompilation(method_m1, CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION);

        if (!WHITE_BOX.isMethodCompiled(method_m1)) {
            throw new RuntimeException("m1 not recompiled");
        }

        if (deoptimize(method_m1, src_obj)) {
            throw new RuntimeException("m1 deoptimized again");
        }

        if (WHITE_BOX.getUintxVMFlag("TypeProfileLevel") == 20) {
            // Same test as above but with speculative types

            // Warm up & make sure we collect type profiling
            for (int i = 0; i < 20000; i++) {
                m2(src);
            }

            // And make sure m2 is compiled by C2
            WHITE_BOX.enqueueMethodForCompilation(method_m2, CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION);

            if (!WHITE_BOX.isMethodCompiled(method_m2)) {
                throw new RuntimeException("m2 not compiled");
            }

            // should deoptimize for speculative type check
            if (!deoptimize(method_m2, src_obj)) {
                throw new RuntimeException("m2 not deoptimized");
            }

            WHITE_BOX.enqueueMethodForCompilation(method_m2, CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION);

            if (!WHITE_BOX.isMethodCompiled(method_m2)) {
                throw new RuntimeException("m2 not recompiled");
            }

            // should deoptimize for actual type check
            if (!deoptimize(method_m2, src_obj)) {
                throw new RuntimeException("m2 not deoptimized");
            }

            WHITE_BOX.enqueueMethodForCompilation(method_m2, CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION);

            if (!WHITE_BOX.isMethodCompiled(method_m2)) {
                throw new RuntimeException("m2 not recompiled");
            }

            if (deoptimize(method_m2, src_obj)) {
                throw new RuntimeException("m2 deoptimized again");
            }
        }
    }
}