Search in sources :

Example 1 with HotSpotNmethod

use of jdk.vm.ci.hotspot.HotSpotNmethod in project graal by oracle.

the class HotSpotNmethodTest method testInstallCodeInvalidation.

@Test
public void testInstallCodeInvalidation() {
    final ResolvedJavaMethod testJavaMethod = getResolvedJavaMethod("foo");
    final HotSpotNmethod nmethod = (HotSpotNmethod) getCode(testJavaMethod, parseEager("otherFoo", AllowAssumptions.YES));
    Assert.assertTrue(nmethod.isValid());
    Object result;
    try {
        result = nmethod.executeVarargs(null, "b", "c");
        assertDeepEquals(43, result);
    } catch (InvalidInstalledCodeException e) {
        Assert.fail("Code was invalidated");
    }
    Assert.assertTrue(nmethod.isValid());
    nmethod.invalidate();
    Assert.assertFalse(nmethod.isValid());
    try {
        result = nmethod.executeVarargs(null, null, null);
        Assert.fail("Code was not invalidated");
    } catch (InvalidInstalledCodeException e) {
    }
    Assert.assertFalse(nmethod.isValid());
}
Also used : HotSpotNmethod(jdk.vm.ci.hotspot.HotSpotNmethod) InvalidInstalledCodeException(jdk.vm.ci.code.InvalidInstalledCodeException) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) Test(org.junit.Test) GraalCompilerTest(org.graalvm.compiler.core.test.GraalCompilerTest)

Example 2 with HotSpotNmethod

use of jdk.vm.ci.hotspot.HotSpotNmethod in project graal by oracle.

the class HotSpotNmethodTest method testInstalledCodeCalledFromCompiledCode.

@Test
public void testInstalledCodeCalledFromCompiledCode() {
    final ResolvedJavaMethod testJavaMethod = getResolvedJavaMethod("foo");
    final HotSpotNmethod nmethod = (HotSpotNmethod) getCode(testJavaMethod, parseEager("otherFoo", AllowAssumptions.YES));
    Assert.assertTrue(nmethod.isValid());
    try {
        for (int i = 0; i < ITERATION_COUNT; ++i) {
            nmethod.executeVarargs(null, "b", "c");
        }
    } catch (InvalidInstalledCodeException e) {
        Assert.fail("Code was invalidated");
    }
}
Also used : HotSpotNmethod(jdk.vm.ci.hotspot.HotSpotNmethod) InvalidInstalledCodeException(jdk.vm.ci.code.InvalidInstalledCodeException) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) Test(org.junit.Test) GraalCompilerTest(org.graalvm.compiler.core.test.GraalCompilerTest)

Example 3 with HotSpotNmethod

use of jdk.vm.ci.hotspot.HotSpotNmethod in project graal by oracle.

the class HotSpotNmethodTest method testInstallCodeInvalidationWhileRunning.

@Test
public void testInstallCodeInvalidationWhileRunning() {
    final ResolvedJavaMethod testJavaMethod = getResolvedJavaMethod("foo");
    final HotSpotNmethod nmethod = (HotSpotNmethod) getCode(testJavaMethod, parseEager("otherFoo", AllowAssumptions.YES));
    Object result;
    try {
        result = nmethod.executeVarargs(nmethod, null, null);
        assertDeepEquals(43, result);
    } catch (InvalidInstalledCodeException e) {
        Assert.fail("Code was invalidated");
    }
    Assert.assertFalse(nmethod.isValid());
}
Also used : HotSpotNmethod(jdk.vm.ci.hotspot.HotSpotNmethod) InvalidInstalledCodeException(jdk.vm.ci.code.InvalidInstalledCodeException) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) Test(org.junit.Test) GraalCompilerTest(org.graalvm.compiler.core.test.GraalCompilerTest)

Aggregations

InvalidInstalledCodeException (jdk.vm.ci.code.InvalidInstalledCodeException)3 HotSpotNmethod (jdk.vm.ci.hotspot.HotSpotNmethod)3 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)3 GraalCompilerTest (org.graalvm.compiler.core.test.GraalCompilerTest)3 Test (org.junit.Test)3