Java Code Examples for sun.hotspot.code.NMethod#get()

The following examples show how to use sun.hotspot.code.NMethod#get() . 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: CastNullCheckDroppingsTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
static void checkDeoptimization(Method method, NMethod nmOrig, boolean deopt) {
    // Check deoptimization event (intrinsic Class.cast() works).
    if (WHITE_BOX.isMethodCompiled(method) == deopt) {
        throw new AssertionError(method + " was" + (deopt ? " not" : "") + " deoptimized");
    }
    if (deopt) {
        return;
    }
    // Ensure no recompilation when no deoptimization is expected.
    NMethod nm = NMethod.get(method, false); // not OSR nmethod
    if (nm == null) {
        throw new AssertionError(method + " missing nmethod?");
    }
    if (nm.comp_level != 4) {
        throw new AssertionError(method + " compiled by not C2: " + nm);
    }
    if (nm.compile_id != nmOrig.compile_id) {
        throw new AssertionError(method + " was recompiled: old nmethod=" + nmOrig + ", new nmethod=" + nm);
    }
}
 
Example 2
Source File: GetNMethodTest.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void test() throws Exception {
    checkNotCompiled();

    compile();
    checkCompiled();
    NMethod nmethod = NMethod.get(method, testCase.isOsr());
    if (IS_VERBOSE) {
        System.out.println("nmethod = " + nmethod);
    }
    if (nmethod == null) {
        throw new RuntimeException("nmethod of compiled method is null");
    }
    if (nmethod.insts.length == 0) {
        throw new RuntimeException("compiled method's instructions is empty");
    }
    deoptimize();
    checkNotCompiled();
    nmethod = NMethod.get(method, testCase.isOsr());
    if (nmethod != null) {
        throw new RuntimeException("nmethod of non-compiled method isn't null");
    }
}
 
Example 3
Source File: GetNMethodTest.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void test() throws Exception {
    checkNotCompiled();

    compile();
    checkCompiled();
    NMethod nmethod = NMethod.get(method, testCase.isOsr());
    if (IS_VERBOSE) {
        System.out.println("nmethod = " + nmethod);
    }
    if (nmethod == null) {
        throw new RuntimeException("nmethod of compiled method is null");
    }
    if (nmethod.insts.length == 0) {
        throw new RuntimeException("compiled method's instructions is empty");
    }
    deoptimize();
    checkNotCompiled();
    nmethod = NMethod.get(method, testCase.isOsr());
    if (nmethod != null) {
        throw new RuntimeException("nmethod of non-compiled method isn't null");
    }
}
 
Example 4
Source File: GetNMethodTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void test() throws Exception {
    checkNotCompiled();

    compile();
    checkCompiled();
    NMethod nmethod = NMethod.get(method, testCase.isOsr());
    if (IS_VERBOSE) {
        System.out.println("nmethod = " + nmethod);
    }
    if (nmethod == null) {
        throw new RuntimeException("nmethod of compiled method is null");
    }
    if (nmethod.insts.length == 0) {
        throw new RuntimeException("compiled method's instructions is empty");
    }
    deoptimize();
    checkNotCompiled();
    nmethod = NMethod.get(method, testCase.isOsr());
    if (nmethod != null) {
        throw new RuntimeException("nmethod of non-compiled method isn't null");
    }
}
 
Example 5
Source File: GetNMethodTest.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void test() throws Exception {
    checkNotCompiled();

    compile();
    checkCompiled();
    NMethod nmethod = NMethod.get(method, testCase.isOsr());
    if (IS_VERBOSE) {
        System.out.println("nmethod = " + nmethod);
    }
    if (nmethod == null) {
        throw new RuntimeException("nmethod of compiled method is null");
    }
    if (nmethod.insts.length == 0) {
        throw new RuntimeException("compiled method's instructions is empty");
    }
    deoptimize();
    checkNotCompiled();
    nmethod = NMethod.get(method, testCase.isOsr());
    if (nmethod != null) {
        throw new RuntimeException("nmethod of non-compiled method isn't null");
    }
}
 
Example 6
Source File: GetNMethodTest.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void test() throws Exception {
    checkNotCompiled();

    compile();
    checkCompiled();
    NMethod nmethod = NMethod.get(method, testCase.isOsr());
    if (IS_VERBOSE) {
        System.out.println("nmethod = " + nmethod);
    }
    if (nmethod == null) {
        throw new RuntimeException("nmethod of compiled method is null");
    }
    if (nmethod.insts.length == 0) {
        throw new RuntimeException("compiled method's instructions is empty");
    }
    deoptimize();
    checkNotCompiled();
    nmethod = NMethod.get(method, testCase.isOsr());
    if (nmethod != null) {
        throw new RuntimeException("nmethod of non-compiled method isn't null");
    }
}
 
Example 7
Source File: CompileCodeTestCase.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public NMethod compile(int level) {
    String directive = "[{ match: \"" + executable.getDeclaringClass().getName().replace('.', '/')
            + "." + (executable instanceof Constructor ? "<init>" : executable.getName())
            + "\", " + "BackgroundCompilation: false }]";
    if (WB.addCompilerDirective(directive) != 1) {
        throw new Error("Failed to add compiler directive: " + directive);
    }
    boolean enqueued = WB.enqueueMethodForCompilation(executable,
            level, bci);
    if (!enqueued) {
        throw new Error(String.format(
                "%s can't be enqueued for %scompilation on level %d",
                executable, bci >= 0 ? "osr-" : "", level));
    }
    Utils.waitForCondition(() -> WB.isMethodCompiled(executable, isOsr));
    return NMethod.get(executable, isOsr);
}
 
Example 8
Source File: BmiIntrinsicBase.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
protected void checkEmittedCode(Executable executable) {
    final byte[] nativeCode = NMethod.get(executable, false).insts;
    if (!((BmiTestCase) testCase).verifyPositive(nativeCode)) {
        throw new AssertionError(testCase.name() + "CPU instructions expected not found: " + Utils.toHexString(nativeCode));
    } else {
        System.out.println("CPU instructions found, PASSED");
    }
}
 
Example 9
Source File: CastNullCheckDroppingsTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
static NMethod getNMethod(Method test) {
    // Because background compilation is disabled, method should now be compiled
    if (!WHITE_BOX.isMethodCompiled(test)) {
        throw new AssertionError(test + " not compiled");
    }

    NMethod nm = NMethod.get(test, false); // not OSR nmethod
    if (nm == null) {
        throw new AssertionError(test + " missing nmethod?");
    }
    if (nm.comp_level != 4) {
        throw new AssertionError(test + " compiled by not C2: " + nm);
    }
    return nm;
}
 
Example 10
Source File: BmiIntrinsicBase.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
protected void checkEmittedCode(Executable executable) {
    final byte[] nativeCode = NMethod.get(executable, false).insts;
    if (!((BmiTestCase) testCase).verifyPositive(nativeCode)) {
        throw new AssertionError(testCase.name() + "CPU instructions expected not found: " + Utils.toHexString(nativeCode));
    } else {
        System.out.println("CPU instructions found, PASSED");
    }
}
 
Example 11
Source File: BmiIntrinsicBase.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
protected void checkEmittedCode(Executable executable) {
    final byte[] nativeCode = NMethod.get(executable, false).insts;
    if (!((BmiTestCase) testCase).verifyPositive(nativeCode)) {
        throw new AssertionError(testCase.name() + "CPU instructions expected not found: " + Utils.toHexString(nativeCode));
    } else {
        System.out.println("CPU instructions found, PASSED");
    }
}
 
Example 12
Source File: BmiIntrinsicBase.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
protected void checkEmittedCode(Executable executable) {
    final byte[] nativeCode = NMethod.get(executable, false).insts;
    if (!((BmiTestCase) testCase).verifyPositive(nativeCode)) {
        throw new AssertionError(testCase.name() + "CPU instructions expected not found: " + Utils.toHexString(nativeCode));
    } else {
        System.out.println("CPU instructions found, PASSED");
    }
}
 
Example 13
Source File: BmiIntrinsicBase.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
protected void checkEmittedCode(Executable executable) {
    final byte[] nativeCode = NMethod.get(executable, false).insts;
    if (!((BmiTestCase) testCase).verifyPositive(nativeCode)) {
        throw new AssertionError(testCase.name() + "CPU instructions expected not found: " + Utils.toHexString(nativeCode));
    } else {
        System.out.println("CPU instructions found, PASSED");
    }
}
 
Example 14
Source File: CompilerWhiteBoxTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
protected final int getCompLevel() {
    NMethod nm = NMethod.get(method, testCase.isOsr());
    return nm == null ? COMP_LEVEL_NONE : nm.comp_level;
}
 
Example 15
Source File: CompileCodeTestCase.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public NMethod toNMethod() {
    return NMethod.get(executable, isOsr);
}
 
Example 16
Source File: CompilerWhiteBoxTest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
protected final int getCompLevel() {
    NMethod nm = NMethod.get(method, testCase.isOsr());
    return nm == null ? COMP_LEVEL_NONE : nm.comp_level;
}
 
Example 17
Source File: GetNMethodTest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void test() throws Exception {
    checkNotCompiled();

    compile();
    checkCompiled();

    NMethod nmethod = NMethod.get(method, testCase.isOsr());
    if (IS_VERBOSE) {
        System.out.println("nmethod = " + nmethod);
    }
    Asserts.assertNotNull(nmethod,
            "nmethod of compiled method is null");
    Asserts.assertNotNull(nmethod.insts,
            "nmethod.insts of compiled method is null");
    Asserts.assertGT(nmethod.insts.length, 0,
            "compiled method's instructions is empty");
    Asserts.assertNotNull(nmethod.code_blob_type, "blob type is null");
    if (WHITE_BOX.getBooleanVMFlag("SegmentedCodeCache")) {
        Asserts.assertNE(nmethod.code_blob_type, BlobType.All);
        switch (nmethod.comp_level) {
        case 1:
        case 4:
            checkBlockType(nmethod, BlobType.MethodNonProfiled);
            break;
        case 2:
        case 3:
            checkBlockType(nmethod, BlobType.MethodProfiled);
            break;
        default:
            throw new Error("unexpected comp level " + nmethod);
        }
    } else {
        Asserts.assertEQ(nmethod.code_blob_type, BlobType.All);
    }

    deoptimize();
    checkNotCompiled();
    nmethod = NMethod.get(method, testCase.isOsr());
    Asserts.assertNull(nmethod,
            "nmethod of non-compiled method isn't null");
}
 
Example 18
Source File: CompilerWhiteBoxTest.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
protected final int getCompLevel() {
    NMethod nm = NMethod.get(method, testCase.isOsr());
    return nm == null ? COMP_LEVEL_NONE : nm.comp_level;
}
 
Example 19
Source File: CompilerWhiteBoxTest.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
protected final int getCompLevel() {
    NMethod nm = NMethod.get(method, testCase.isOsr());
    return nm == null ? COMP_LEVEL_NONE : nm.comp_level;
}
 
Example 20
Source File: CompilerWhiteBoxTest.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
protected final int getCompLevel() {
    NMethod nm = NMethod.get(method, testCase.isOsr());
    return nm == null ? COMP_LEVEL_NONE : nm.comp_level;
}