Mercurial > hg > truffle
changeset 18580:b76489300efa
generalized assertion regarding code that can/cannot execute in replay compilation context
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Sun, 30 Nov 2014 21:14:13 +0100 |
parents | 77b55091cca1 |
children | d24328ea36a7 68814fb4bbe4 |
files | graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/remote/Context.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMetaspaceConstantImpl.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotObjectConstantImpl.java |
diffstat | 4 files changed, 28 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/remote/Context.java Sun Nov 30 21:12:06 2014 +0100 +++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/remote/Context.java Sun Nov 30 21:14:13 2014 +0100 @@ -37,6 +37,10 @@ /** * Manages a context for replay or remote compilation. + * + * With respect to replay or remote compilation, certain objects only exist on the VM side of the + * VM-compiler boundary. These are objects that encapsulate compiler references to user heap objects + * or other VM data such as native VM objects representing Java classes and methods. */ public class Context implements AutoCloseable { @@ -463,6 +467,24 @@ return true; } + /** + * Asserts that the current caller is in code that is on the VM side. + * + * @param errorMessage the error message used for the {@link GraalInternalError} thrown if the + * check fails + * @return true if the check succeeds + * @throw AssertionError if the check fails + */ + public static boolean assertInLocal(String errorMessage) { + Context c = Context.getCurrent(); + if (c != null) { + if (!c.inProxyInvocation()) { + throw new AssertionError(errorMessage); + } + } + return true; + } + private NoContext leave; int activeInvocations;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java Sun Nov 30 21:12:06 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java Sun Nov 30 21:14:13 2014 +0100 @@ -85,14 +85,8 @@ * through references to a captured {@link HotSpotGraalRuntimeProvider}, not through the static * {@link HotSpotGraalRuntimeProvider} instance of the runtime hosting the replay. */ - private static boolean checkRuntimeAccess() { - Context c = Context.getCurrent(); - if (c != null) { - if (!c.inProxyInvocation()) { - throw new GraalInternalError("Cannot access HotSpotGraalRuntime statically in replay/remote context"); - } - } - return true; + public static boolean checkRuntimeAccess() { + return Context.assertInLocal("Cannot access HotSpotGraalRuntime statically in replay/remote context"); } /**
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMetaspaceConstantImpl.java Sun Nov 30 21:12:06 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMetaspaceConstantImpl.java Sun Nov 30 21:14:13 2014 +0100 @@ -25,6 +25,7 @@ import java.util.*; import com.oracle.graal.api.meta.*; +import com.oracle.graal.compiler.common.remote.*; import com.oracle.graal.hotspot.HotSpotVMConfig.CompressEncoding; public final class HotSpotMetaspaceConstantImpl extends PrimitiveConstant implements HotSpotMetaspaceConstant, VMConstant, Remote { @@ -46,6 +47,7 @@ super(kind, primitive); this.metaspaceObject = metaspaceObject; this.compressed = compressed; + assert Context.assertInLocal("Should not create metaspace constants here"); } @Override
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotObjectConstantImpl.java Sun Nov 30 21:12:06 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotObjectConstantImpl.java Sun Nov 30 21:14:13 2014 +0100 @@ -28,6 +28,7 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; +import com.oracle.graal.compiler.common.remote.*; import com.oracle.graal.graph.*; import com.oracle.graal.lir.*; @@ -95,6 +96,7 @@ assert stableDimension == 0 || (object != null && object.getClass().isArray()); assert stableDimension >= 0 && stableDimension <= 255; assert !isDefaultStable || stableDimension > 0; + assert Context.assertInLocal("Should not create object constants here"); } private HotSpotObjectConstantImpl(Object object, boolean compressed) {