changeset 10478:dd3333e4f182

Improve HotSpotNMethodTest.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Sun, 23 Jun 2013 15:27:39 +0200
parents 7943479d36f3
children 40b8c383bc31
files graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotNmethodTest.java
diffstat 1 files changed, 22 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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;
     }
 }