changeset 6424:be2f614bdeac

fixed bug in MonitorSnippets and enabled them for general use
author Doug Simon <doug.simon@oracle.com>
date Thu, 20 Sep 2012 17:11:41 +0200
parents 13a08f5bb120
children 72538e7f5f83
files graal/com.oracle.graal.compiler.phases/src/com/oracle/graal/compiler/GraalOptions.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/MonitorSnippets.java
diffstat 2 files changed, 22 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- 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.
--- 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 {