# HG changeset patch # User Thomas Wuerthinger # Date 1371994059 -7200 # Node ID dd3333e4f182b03641bdb4ba99634f5d782a240d # Parent 7943479d36f340d492416fd4e6df8ba23212e997 Improve HotSpotNMethodTest. diff -r 7943479d36f3 -r dd3333e4f182 graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotNmethodTest.java --- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotNmethodTest.java Fri Jun 21 22:09:25 2013 +0200 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotNmethodTest.java Sun Jun 23 15:27:39 2013 +0200 @@ -42,7 +42,7 @@ Assert.assertTrue(nmethod.isValid()); Object result; try { - result = nmethod.execute("a", "b", "c"); + result = nmethod.execute(null, "b", "c"); assertEquals(43, result); } catch (InvalidInstalledCodeException e) { Assert.fail("Code was invalidated"); @@ -59,6 +59,21 @@ } @Test + public void testInstallCodeInvalidationWhileRunning() { + final ResolvedJavaMethod testJavaMethod = runtime.lookupJavaMethod(getMethod("foo")); + final StructuredGraph graph = parse("otherFoo"); + final HotSpotNmethod nmethod = (HotSpotNmethod) getCode(testJavaMethod, graph); + Object result; + try { + result = nmethod.execute(nmethod, null, null); + assertEquals(43, result); + } catch (InvalidInstalledCodeException e) { + Assert.fail("Code was invalidated"); + } + Assert.assertFalse(nmethod.isValid()); + } + + @Test public void testInstalledCodeCalledFromCompiledCode() { final ResolvedJavaMethod testJavaMethod = runtime.lookupJavaMethod(getMethod("foo")); final StructuredGraph graph = parse("otherFoo"); @@ -66,7 +81,7 @@ Assert.assertTrue(nmethod.isValid()); try { for (int i = 0; i < ITERATION_COUNT; ++i) { - nmethod.execute("a", "b", "c"); + nmethod.execute(null, "b", "c"); } } catch (InvalidInstalledCodeException e) { Assert.fail("Code was invalidated"); @@ -74,12 +89,15 @@ } @SuppressWarnings("unused") - public static Object foo(Object a1, Object a2, Object a3) { + public static Object foo(HotSpotNmethod method, Object a2, Object a3) { return 42; } @SuppressWarnings("unused") - public static Object otherFoo(Object a1, Object a2, Object a3) { + public static Object otherFoo(HotSpotNmethod method, Object a2, Object a3) { + if (method != null) { + method.invalidate(); + } return 43; } }