sun.hotspot.code.NMethod Java Examples
The following examples show how to use
sun.hotspot.code.NMethod.
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: CompileCodeTestCase.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
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 #2
Source File: GetNMethodTest.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
@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 TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@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 with GNU General Public License v2.0 | 6 votes |
@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 hottub with GNU General Public License v2.0 | 6 votes |
@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: DisassembleCodeBlobTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
private void check(CompileCodeTestCase testCase) { System.out.println(testCase); // to have a clean state NMethod nMethod = testCase.deoptimizeAndCompile(); if (nMethod == null) { throw new Error(testCase + " : method is not compiled"); } InstalledCode installedCode = testCase.toInstalledCode(); String str = CompilerToVMHelper.disassembleCodeBlob(installedCode); if (str != null) { Asserts.assertGT(str.length(), 0, testCase + " : returned string has to be non-zero length"); } String str2 = CompilerToVMHelper.disassembleCodeBlob(installedCode); Asserts.assertEQ(str, str2, testCase + " : 2nd invocation returned different value"); }
Example #7
Source File: GetNMethodTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
@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 #8
Source File: CastNullCheckDroppingsTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
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 #9
Source File: CompileCodeTestCase.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public InstalledCode toInstalledCode() { NMethod nmethod = toNMethod(); long address = nmethod == null ? 0L : nmethod.address; long entryPoint = nmethod == null ? 0L : nmethod.entry_point; return CTVMUtilities.getInstalledCode( executable.getName(), address, entryPoint); }
Example #10
Source File: AllocateCompileIdTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private int getWBCompileID(CompileCodeTestCase testCase) { NMethod nm = testCase.deoptimizeAndCompile(); if (nm == null || nm.compile_id <= 0) { throw new Error("TEST BUG : cannot compile method " + testCase); } return nm.compile_id; }
Example #11
Source File: InvalidateInstalledCodeTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private void check(CompileCodeTestCase testCase) { System.out.println(testCase); HotSpotResolvedJavaMethod javaMethod = CTVMUtilities.getResolvedMethod(testCase.executable); HotSpotCompilationRequest compRequest = new HotSpotCompilationRequest( javaMethod, testCase.bci, /* jvmciEnv = */ 0L); String name = testCase.executable.getName(); CompilationResult compResult = new CompilationResult(name); // to pass sanity check of default -1 compResult.setTotalFrameSize(0); compResult.close(); InstalledCode installedCode = CACHE_PROVIDER.installCode( compRequest, compResult, new InstalledCode(name), /* speculationLog = */ null, /* isDefault = */ false); Asserts.assertTrue(installedCode.isValid(), testCase + " : code is invalid even before invalidation"); NMethod beforeInvalidation = testCase.toNMethod(); if (beforeInvalidation != null) { throw new Error("TESTBUG : " + testCase + " : nmethod isn't found"); } // run twice to verify how it works if method is already invalidated for (int i = 0; i < 2; ++i) { CompilerToVMHelper.invalidateInstalledCode(installedCode); Asserts.assertFalse(installedCode.isValid(), testCase + " : code is valid after invalidation, i = " + i); NMethod afterInvalidation = testCase.toNMethod(); if (afterInvalidation != null) { System.err.println("before: " + beforeInvalidation); System.err.println("after: " + afterInvalidation); throw new AssertionError(testCase + " : method hasn't been invalidated, i = " + i); } } }
Example #12
Source File: CompilerWhiteBoxTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Prints information about {@linkplain #method}. */ protected final void printInfo() { System.out.printf("%n%s:%n", method); System.out.printf("\tcompilable:\t%b%n", WHITE_BOX.isMethodCompilable(method, COMP_LEVEL_ANY, false)); boolean isCompiled = WHITE_BOX.isMethodCompiled(method, false); System.out.printf("\tcompiled:\t%b%n", isCompiled); if (isCompiled) { System.out.printf("\tcompile_id:\t%d%n", NMethod.get(method, false).compile_id); } System.out.printf("\tcomp_level:\t%d%n", WHITE_BOX.getMethodCompilationLevel(method, false)); System.out.printf("\tosr_compilable:\t%b%n", WHITE_BOX.isMethodCompilable(method, COMP_LEVEL_ANY, true)); isCompiled = WHITE_BOX.isMethodCompiled(method, true); System.out.printf("\tosr_compiled:\t%b%n", isCompiled); if (isCompiled) { System.out.printf("\tosr_compile_id:\t%d%n", NMethod.get(method, true).compile_id); } System.out.printf("\tosr_comp_level:\t%d%n", WHITE_BOX.getMethodCompilationLevel(method, true)); System.out.printf("\tin_queue:\t%b%n", WHITE_BOX.isMethodQueuedForCompilation(method)); System.out.printf("compile_queues_size:\t%d%n%n", WHITE_BOX.getCompileQueuesSize()); }
Example #13
Source File: BmiIntrinsicBase.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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: CastNullCheckDroppingsTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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 #15
Source File: BmiIntrinsicBase.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
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 #16
Source File: BmiIntrinsicBase.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
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 #17
Source File: CompilerWhiteBoxTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Prints information about {@linkplain #method}. */ protected final void printInfo() { System.out.printf("%n%s:%n", method); System.out.printf("\tcompilable:\t%b%n", WHITE_BOX.isMethodCompilable(method, COMP_LEVEL_ANY, false)); boolean isCompiled = WHITE_BOX.isMethodCompiled(method, false); System.out.printf("\tcompiled:\t%b%n", isCompiled); if (isCompiled) { System.out.printf("\tcompile_id:\t%d%n", NMethod.get(method, false).compile_id); } System.out.printf("\tcomp_level:\t%d%n", WHITE_BOX.getMethodCompilationLevel(method, false)); System.out.printf("\tosr_compilable:\t%b%n", WHITE_BOX.isMethodCompilable(method, COMP_LEVEL_ANY, true)); isCompiled = WHITE_BOX.isMethodCompiled(method, true); System.out.printf("\tosr_compiled:\t%b%n", isCompiled); if (isCompiled) { System.out.printf("\tosr_compile_id:\t%d%n", NMethod.get(method, true).compile_id); } System.out.printf("\tosr_comp_level:\t%d%n", WHITE_BOX.getMethodCompilationLevel(method, true)); System.out.printf("\tin_queue:\t%b%n", WHITE_BOX.isMethodQueuedForCompilation(method)); System.out.printf("compile_queues_size:\t%d%n%n", WHITE_BOX.getCompileQueuesSize()); }
Example #18
Source File: BmiIntrinsicBase.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
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 #19
Source File: BmiIntrinsicBase.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
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 #20
Source File: CompilerWhiteBoxTest.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Prints information about {@linkplain #method}. */ protected final void printInfo() { System.out.printf("%n%s:%n", method); System.out.printf("\tcompilable:\t%b%n", WHITE_BOX.isMethodCompilable(method, COMP_LEVEL_ANY, false)); boolean isCompiled = WHITE_BOX.isMethodCompiled(method, false); System.out.printf("\tcompiled:\t%b%n", isCompiled); if (isCompiled) { System.out.printf("\tcompile_id:\t%d%n", NMethod.get(method, false).compile_id); } System.out.printf("\tcomp_level:\t%d%n", WHITE_BOX.getMethodCompilationLevel(method, false)); System.out.printf("\tosr_compilable:\t%b%n", WHITE_BOX.isMethodCompilable(method, COMP_LEVEL_ANY, true)); isCompiled = WHITE_BOX.isMethodCompiled(method, true); System.out.printf("\tosr_compiled:\t%b%n", isCompiled); if (isCompiled) { System.out.printf("\tosr_compile_id:\t%d%n", NMethod.get(method, true).compile_id); } System.out.printf("\tosr_comp_level:\t%d%n", WHITE_BOX.getMethodCompilationLevel(method, true)); System.out.printf("\tin_queue:\t%b%n", WHITE_BOX.isMethodQueuedForCompilation(method)); System.out.printf("compile_queues_size:\t%d%n%n", WHITE_BOX.getCompileQueuesSize()); }
Example #21
Source File: BmiIntrinsicBase.java From hottub with GNU General Public License v2.0 | 5 votes |
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 #22
Source File: CompilerWhiteBoxTest.java From hottub with GNU General Public License v2.0 | 4 votes |
protected final int getCompLevel() { NMethod nm = NMethod.get(method, testCase.isOsr()); return nm == null ? COMP_LEVEL_NONE : nm.comp_level; }
Example #23
Source File: CompileCodeTestCase.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public NMethod deoptimizeAndCompile() { deoptimize(); return compile(); }
Example #24
Source File: CompilerWhiteBoxTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
protected final int getCompLevel() { NMethod nm = NMethod.get(method, testCase.isOsr()); return nm == null ? COMP_LEVEL_NONE : nm.comp_level; }
Example #25
Source File: CompileCodeTestCase.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public NMethod toNMethod() { return NMethod.get(executable, isOsr); }
Example #26
Source File: CompileCodeTestCase.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public NMethod compile() { return compile(COMP_LEVEL); }
Example #27
Source File: ExecuteInstalledCodeTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
private void checkSanity(CompileCodeTestCase testCase) { System.out.println(testCase); // to have a clean state testCase.deoptimize(); Pair<Object, ? extends Throwable> reflectionResult; Object[] args = Utils.getNullValues( testCase.executable.getParameterTypes()); reflectionResult = testCase.invoke(args); NMethod nMethod = testCase.compile(); if (nMethod == null) { throw new Error(testCase + " : nmethod is null"); } InstalledCode installedCode = testCase.toInstalledCode(); Object result = null; Throwable expectedException = reflectionResult.second; boolean gotException = true; try { args = addReceiver(testCase, args); result = CompilerToVMHelper.executeInstalledCode( args, installedCode); if (testCase.executable instanceof Constructor) { // <init> doesn't have return value, it changes receiver result = args[0]; } gotException = false; } catch (InvalidInstalledCodeException e) { throw new AssertionError( testCase + " : unexpected InvalidInstalledCodeException", e); } catch (Throwable t) { if (expectedException == null) { throw new AssertionError(testCase + " : got unexpected execption : " + t.getMessage(), t); } if (expectedException.getClass() != t.getClass()) { System.err.println("exception from CompilerToVM:"); t.printStackTrace(); System.err.println("exception from reflection:"); expectedException.printStackTrace(); throw new AssertionError(String.format( "%s : got unexpected different exceptions : %s != %s", testCase, expectedException.getClass(), t.getClass())); } } Asserts.assertEQ(reflectionResult.first, result, testCase + " : different return value"); if (!gotException) { Asserts.assertNull(expectedException, testCase + " : expected exception hasn't been thrown"); } }
Example #28
Source File: DeoptimizeFramesTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Override protected void test() throws Exception { compile(); checkCompiled(); NMethod nm = NMethod.get(method, testCase.isOsr()); WHITE_BOX.deoptimizeFrames(makeNotEntrant); // #method should still be compiled, since it didn't have frames on stack checkCompiled(); NMethod nm2 = NMethod.get(method, testCase.isOsr()); Asserts.assertEQ(nm.compile_id, nm2.compile_id, "should be the same nmethod"); phaser.register(); Thread t = new Thread(() -> compile(1)); t.start(); // pass 1st phase, #method is on stack int p = phaser.arriveAndAwaitAdvance(); WHITE_BOX.deoptimizeFrames(makeNotEntrant); // pass 2nd phase, #method can exit phaser.awaitAdvance(phaser.arriveAndDeregister()); try { t.join(); } catch (InterruptedException e) { throw new Error("method '" + method + "' is still executing", e); } // invoke one more time to recompile not entrant if any compile(1); nm2 = NMethod.get(method, testCase.isOsr()); if (makeNotEntrant) { if (nm2 != null) { Asserts.assertNE(nm.compile_id, nm2.compile_id, String.format("compilation %d can't be available", nm.compile_id)); } } else { Asserts.assertEQ(nm.compile_id, nm2.compile_id, "should be the same nmethod"); } }
Example #29
Source File: GetNMethodTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
private void checkBlockType(NMethod nmethod, BlobType expectedType) { Asserts.assertEQ(nmethod.code_blob_type, expectedType, String.format("blob_type[%s] for %d level isn't %s", nmethod.code_blob_type, nmethod.comp_level, expectedType)); }
Example #30
Source File: GetNMethodTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@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"); }