# HG changeset patch # User Doug Simon # Date 1348153901 -7200 # Node ID be2f614bdeacc9189506d490044abdfdb5b74479 # Parent 13a08f5bb1205a01a848c7ee3f1d59614633b52f fixed bug in MonitorSnippets and enabled them for general use diff -r 13a08f5bb120 -r be2f614bdeac graal/com.oracle.graal.compiler.phases/src/com/oracle/graal/compiler/GraalOptions.java --- a/graal/com.oracle.graal.compiler.phases/src/com/oracle/graal/compiler/GraalOptions.java Thu Sep 20 17:10:58 2012 +0200 +++ b/graal/com.oracle.graal.compiler.phases/src/com/oracle/graal/compiler/GraalOptions.java Thu Sep 20 17:11:41 2012 +0200 @@ -267,7 +267,7 @@ public static String HIRLowerInstanceOf = ""; public static String HIRLowerNewInstance = ""; public static String HIRLowerNewArray = ""; - public static String HIRLowerMonitors = "MonitorTest"; + public static String HIRLowerMonitors = ""; /** * Use XIR to lower {@link Invoke} nodes. diff -r 13a08f5bb120 -r be2f614bdeac graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/MonitorSnippets.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/MonitorSnippets.java Thu Sep 20 17:10:58 2012 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/MonitorSnippets.java Thu Sep 20 17:11:41 2012 +0200 @@ -34,6 +34,7 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.graph.*; +import com.oracle.graal.graph.Node.NodeIntrinsic; import com.oracle.graal.hotspot.nodes.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.java.*; @@ -67,6 +68,18 @@ } } + /** + * Leaving the breakpoint code in provides a good example of how to use + * {@link BreakpointNode} as an intrinsic. + */ + private static final boolean ENABLE_BREAKPOINT = false; + + @SuppressWarnings("unused") + @NodeIntrinsic(BreakpointNode.class) + static void bkpt(Object object, Word mark, Word tmp, Word value) { + throw new GraalInternalError(""); + } + @Snippet public static void monitorenter(@Parameter("object") Object object, @ConstantParameter("logEnabled") boolean logEnabled) { verifyOop(object); @@ -132,7 +145,7 @@ // another thread succeeded in biasing it toward itself and we // need to revoke that bias. The revocation will occur in the // interpreter runtime in the slow case. - log(logEnabled, "+lock{stub}", object); + log(logEnabled, "+lock{stub:revoke}", object); MonitorEnterStubCall.call(object, lock); return; } else { @@ -151,7 +164,7 @@ // If the biasing toward our thread failed, then another thread // succeeded in biasing it toward itself and we need to revoke that // bias. The revocation will occur in the runtime in the slow case. - log(logEnabled, "+lock{stub}", object); + log(logEnabled, "+lock{stub:epoch-expired}", object); MonitorEnterStubCall.call(object, lock); return; } @@ -164,11 +177,15 @@ // that another thread raced us for the privilege of revoking the // bias of this particular object, so it's okay to continue in the // normal locking code. - compareAndSwap(object, markOffset(), mark, tmp); + Word result = compareAndSwap(object, markOffset(), mark, prototypeMarkWord); // Fall through to the normal CAS-based lock, because no matter what // the result of the above CAS, some thread must have succeeded in // removing the bias bit from the object's header. + + if (ENABLE_BREAKPOINT) { + bkpt(object, mark, tmp, result); + } } } } @@ -202,7 +219,7 @@ final Word stackPointer = stackPointer(); if (currentMark.minus(stackPointer).and(alignedMask.minus(pageSize())) != Word.zero()) { // Most likely not a recursive lock, go into a slow runtime call - log(logEnabled, "+lock{stub}", object); + log(logEnabled, "+lock{stub:failed-cas}", object); MonitorEnterStubCall.call(object, lock); return; } else {