# HG changeset patch # User Doug Simon # Date 1390253419 -3600 # Node ID a65486301b313e59bdfb5a579f1e1e44e1fb24a0 # Parent 984782c1211c6304be43df55296154c225e78650# Parent 810f2c413ace761f5bdb213c3821de405244e92c Merge. diff -r 810f2c413ace -r a65486301b31 graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/PTXMethodInvalidation2Test.java --- a/graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/PTXMethodInvalidation2Test.java Mon Jan 20 19:50:17 2014 +0100 +++ b/graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/PTXMethodInvalidation2Test.java Mon Jan 20 22:30:19 2014 +0100 @@ -22,6 +22,8 @@ */ package com.oracle.graal.compiler.ptx.test; +import java.lang.ref.*; + import org.junit.*; import com.oracle.graal.api.code.*; @@ -31,26 +33,32 @@ import com.oracle.graal.nodes.*; /** - * A full GC on HotSpot will unload an nmethod that has an embedded oop that is only referenced from - * the nmethod. The nmethod created for a {@linkplain PTXWrapperBuilder PTX kernel wrapper} has an - * embedded oop referring to the {@link HotSpotNmethod} linked with the nmethod for the installed - * PTX kernel. This embedded oop is a weak as described above sp there must be another strong - * reference from the wrapper to the {@link HotSpotNmethod} object. + * A full GC on HotSpot will unload an nmethod that contains an embedded oop which is the only + * reference to its referent. The nmethod created for a {@linkplain PTXWrapperBuilder PTX kernel + * wrapper} has an embedded oop referring to a {@link HotSpotNmethod} object associated with the + * nmethod for the installed PTX kernel. This embedded oop is a weak reference as described above so + * there must be another strong reference from the wrapper to the {@link HotSpotNmethod} object. */ public class PTXMethodInvalidation2Test extends PTXTest { @Test + @Ignore("still need to make a strong reference from a PTX wrapper to a PTX kernel") public void test() { test("testSnippet", 100); } @Override - @Ignore("still need to make a strong reference from a PTX wrapper to a PTX kernel") protected InstalledCode getCode(ResolvedJavaMethod method, StructuredGraph graph) { InstalledCode code = super.getCode(method, graph); - // This seems to result in a full GC on HotSpot but there's no guarantee of that - System.gc(); + // Try hard to force a full GC + int attempts = 0; + WeakReference ref = new WeakReference<>(new Object()); + while (ref.get() != null) { + System.gc(); + // Give up after 1000 attempts + Assume.assumeTrue(attempts++ < 1000); + } Assert.assertFalse(code.getStart() == 0L); return code;