changeset 15005:9fa900dd3f96

create special-purpose SnippetAnchorNode to replace usages of BeginNode in snippets
author Lukas Stadler <lukas.stadler@oracle.com>
date Mon, 07 Apr 2014 11:32:08 +0200
parents 9ecd3da04309
children e60ea0bf468d
files graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/SnippetAnchorNode.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CheckCastDynamicSnippets.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/InstanceOfSnippets.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MonitorSnippets.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/StubUtil.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/BeginNode.java
diffstat 6 files changed, 74 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/SnippetAnchorNode.java	Mon Apr 07 11:32:08 2014 +0200
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2013, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.hotspot.nodes;
+
+import com.oracle.graal.graph.*;
+import com.oracle.graal.graph.spi.*;
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.extended.*;
+import com.oracle.graal.nodes.type.*;
+
+@NodeInfo(allowedUsageTypes = {InputType.Value, InputType.Anchor, InputType.Guard})
+public final class SnippetAnchorNode extends FixedWithNextNode implements Simplifiable, GuardingNode {
+
+    public SnippetAnchorNode() {
+        super(StampFactory.dependency());
+    }
+
+    @Override
+    public void simplify(SimplifierTool tool) {
+        AbstractBeginNode prevBegin = BeginNode.prevBegin(this);
+        replaceAtUsages(InputType.Anchor, prevBegin);
+        replaceAtUsages(InputType.Guard, prevBegin);
+        if (usages().isEmpty()) {
+            graph().removeFixed(this);
+        }
+    }
+
+    @NodeIntrinsic
+    public static native GuardingNode anchor();
+}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CheckCastDynamicSnippets.java	Mon Apr 07 11:32:08 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CheckCastDynamicSnippets.java	Mon Apr 07 11:32:08 2014 +0200
@@ -32,7 +32,9 @@
 
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.debug.*;
+import com.oracle.graal.hotspot.nodes.*;
 import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.nodes.java.*;
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.nodes.type.*;
@@ -53,13 +55,13 @@
         if (probability(NOT_FREQUENT_PROBABILITY, object == null)) {
             isNull.inc();
         } else {
-            BeginNode anchorNode = BeginNode.anchor();
+            GuardingNode anchorNode = SnippetAnchorNode.anchor();
             Word objectHub = loadHubIntrinsic(object, getWordKind(), anchorNode);
             if (!checkUnknownSubType(hub, objectHub)) {
                 DeoptimizeNode.deopt(InvalidateReprofile, ClassCastException);
             }
         }
-        BeginNode anchorNode = BeginNode.anchor();
+        GuardingNode anchorNode = SnippetAnchorNode.anchor();
         return piCast(verifyOop(object), StampFactory.forNodeIntrinsic(), anchorNode);
     }
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/InstanceOfSnippets.java	Mon Apr 07 11:32:08 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/InstanceOfSnippets.java	Mon Apr 07 11:32:08 2014 +0200
@@ -34,8 +34,10 @@
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.api.meta.ProfilingInfo.TriState;
 import com.oracle.graal.hotspot.meta.*;
+import com.oracle.graal.hotspot.nodes.*;
 import com.oracle.graal.hotspot.replacements.TypeCheckSnippetUtils.Hints;
 import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.nodes.java.*;
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.nodes.type.*;
@@ -52,7 +54,7 @@
 /**
  * Snippets used for implementing the type test of an instanceof instruction. Since instanceof is a
  * floating node, it is lowered separately for each of its usages.
- * 
+ *
  * The type tests implemented are described in the paper <a
  * href="http://dl.acm.org/citation.cfm?id=583821"> Fast subtype checking in the HotSpot JVM</a> by
  * Cliff Click and John Rose.
@@ -75,7 +77,7 @@
     /**
      * A test against a set of hints derived from a profile with very close to 100% precise coverage
      * of seen types. This snippet deoptimizes on hint miss paths.
-     * 
+     *
      * @see #hintHitProbabilityThresholdForDeoptimizingSnippet()
      */
     @Snippet
@@ -90,7 +92,7 @@
             }
             return falseValue;
         }
-        BeginNode anchorNode = BeginNode.anchor();
+        GuardingNode anchorNode = SnippetAnchorNode.anchor();
         Word objectHub = loadHubIntrinsic(object, getWordKind(), anchorNode);
         // if we get an exact match: succeed immediately
         ExplodeLoopNode.explodeLoop();
@@ -119,7 +121,7 @@
             isNull.inc();
             return falseValue;
         }
-        BeginNode anchorNode = BeginNode.anchor();
+        GuardingNode anchorNode = SnippetAnchorNode.anchor();
         Word objectHub = loadHubIntrinsic(object, getWordKind(), anchorNode);
         if (probability(LIKELY_PROBABILITY, objectHub.notEqual(exactHub))) {
             exactMiss.inc();
@@ -138,7 +140,7 @@
             isNull.inc();
             return falseValue;
         }
-        BeginNode anchorNode = BeginNode.anchor();
+        GuardingNode anchorNode = SnippetAnchorNode.anchor();
         Word objectHub = loadHubIntrinsic(object, getWordKind(), anchorNode);
         if (probability(NOT_LIKELY_PROBABILITY, objectHub.readWord(superCheckOffset, LocationIdentity.FINAL_LOCATION).notEqual(hub))) {
             displayMiss.inc();
@@ -157,7 +159,7 @@
             isNull.inc();
             return falseValue;
         }
-        BeginNode anchorNode = BeginNode.anchor();
+        GuardingNode anchorNode = SnippetAnchorNode.anchor();
         Word objectHub = loadHubIntrinsic(object, getWordKind(), anchorNode);
         // if we get an exact match: succeed immediately
         ExplodeLoopNode.explodeLoop();
@@ -184,7 +186,7 @@
             isNull.inc();
             return falseValue;
         }
-        BeginNode anchorNode = BeginNode.anchor();
+        GuardingNode anchorNode = SnippetAnchorNode.anchor();
         Word hub = loadWordFromObject(mirror, klassOffset());
         Word objectHub = loadHubIntrinsic(object, getWordKind(), anchorNode);
         if (hub.equal(0) || !checkUnknownSubType(hub, objectHub)) {
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MonitorSnippets.java	Mon Apr 07 11:32:08 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MonitorSnippets.java	Mon Apr 07 11:32:08 2014 +0200
@@ -103,7 +103,7 @@
         if (object == null) {
             DeoptimizeNode.deopt(DeoptimizationAction.InvalidateReprofile, DeoptimizationReason.NullCheckException);
         }
-        BeginNode anchorNode = BeginNode.anchor();
+        GuardingNode anchorNode = SnippetAnchorNode.anchor();
 
         // Load the mark word - this includes a null-check on object
         final Word mark = loadWordFromObject(object, markOffset());
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/StubUtil.java	Mon Apr 07 11:32:08 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/StubUtil.java	Mon Apr 07 11:32:08 2014 +0200
@@ -36,7 +36,7 @@
 import com.oracle.graal.graph.Node.ConstantNodeParameter;
 import com.oracle.graal.graph.Node.NodeIntrinsic;
 import com.oracle.graal.hotspot.nodes.*;
-import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.replacements.*;
 import com.oracle.graal.replacements.Snippet.Fold;
 import com.oracle.graal.word.*;
@@ -98,7 +98,7 @@
      * <p>
      * <b>Stubs must use this instead of {@link Log#printf(String, long)} to avoid an object
      * constant in a RuntimeStub.</b>
-     * 
+     *
      * @param message a message string
      */
     public static void printf(String message) {
@@ -110,7 +110,7 @@
      * <p>
      * <b>Stubs must use this instead of {@link Log#printf(String, long)} to avoid an object
      * constant in a RuntimeStub.</b>
-     * 
+     *
      * @param format a C style printf format value
      * @param value the value associated with the first conversion specifier in {@code format}
      */
@@ -123,7 +123,7 @@
      * <p>
      * <b>Stubs must use this instead of {@link Log#printf(String, long, long)} to avoid an object
      * constant in a RuntimeStub.</b>
-     * 
+     *
      * @param format a C style printf format value
      * @param v1 the value associated with the first conversion specifier in {@code format}
      * @param v2 the value associated with the second conversion specifier in {@code format}
@@ -137,7 +137,7 @@
      * <p>
      * <b>Stubs must use this instead of {@link Log#printf(String, long, long, long)} to avoid an
      * object constant in a RuntimeStub.</b>
-     * 
+     *
      * @param format a C style printf format value
      * @param v1 the value associated with the first conversion specifier in {@code format}
      * @param v2 the value associated with the second conversion specifier in {@code format}
@@ -159,7 +159,7 @@
      * <p>
      * <b>Stubs must use this instead of {@link VMErrorNode#vmError(String, long)} to avoid an
      * object constant in a RuntimeStub.</b>
-     * 
+     *
      * @param message an error message
      */
     public static void fatal(String message) {
@@ -171,7 +171,7 @@
      * <p>
      * <b>Stubs must use this instead of {@link Log#printf(String, long, long, long)} to avoid an
      * object constant in a RuntimeStub.</b>
-     * 
+     *
      * @param format a C style printf format value
      * @param value the value associated with the first conversion specifier in {@code format}
      */
@@ -184,7 +184,7 @@
      * <p>
      * <b>Stubs must use this instead of {@link Log#printf(String, long, long, long)} to avoid an
      * object constant in a RuntimeStub.</b>
-     * 
+     *
      * @param format a C style printf format value
      * @param v1 the value associated with the first conversion specifier in {@code format}
      * @param v2 the value associated with the second conversion specifier in {@code format}
@@ -198,7 +198,7 @@
      * <p>
      * <b>Stubs must use this instead of {@link Log#printf(String, long, long, long)} to avoid an
      * object constant in a RuntimeStub.</b>
-     * 
+     *
      * @param format a C style printf format value
      * @param v1 the value associated with the first conversion specifier in {@code format}
      * @param v2 the value associated with the second conversion specifier in {@code format}
@@ -218,7 +218,7 @@
 
             Pointer oop = Word.fromObject(object);
             if (object != null) {
-                BeginNode anchorNode = BeginNode.anchor();
+                GuardingNode anchorNode = SnippetAnchorNode.anchor();
                 // make sure object is 'reasonable'
                 if (!oop.and(unsigned(verifyOopMask())).equal(unsigned(verifyOopBits()))) {
                     fatal("oop not in heap: %p", oop.rawValue());
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/BeginNode.java	Mon Apr 07 11:32:08 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/BeginNode.java	Mon Apr 07 11:32:08 2014 +0200
@@ -29,7 +29,4 @@
     public BeginNode() {
         super(StampFactory.dependency());
     }
-
-    @NodeIntrinsic
-    public static native BeginNode anchor();
 }