changeset 14996:88d77743dff3

do not implicitly set guard to null in LoadHubNode
author Lukas Stadler <lukas.stadler@oracle.com>
date Mon, 07 Apr 2014 10:40:37 +0200
parents 4976f469670e
children 5e4ae8709830
files graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotReplacementsUtil.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/LoadHubNode.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java
diffstat 3 files changed, 25 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotReplacementsUtil.java	Mon Apr 07 10:35:16 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotReplacementsUtil.java	Mon Apr 07 10:40:37 2014 +0200
@@ -164,7 +164,7 @@
 
     /**
      * Clears the pending exception for the given thread.
-     * 
+     *
      * @return {@code true} if there was a pending exception
      */
     public static boolean clearPendingException(Word thread) {
@@ -175,7 +175,7 @@
 
     /**
      * Gets and clears the object result from a runtime call stored in a thread local.
-     * 
+     *
      * @return the object that was in the thread local
      */
     public static Object getAndClearObjectResult(Word thread) {
@@ -247,9 +247,9 @@
 
     /**
      * Checks if class {@code klass} is an array.
-     * 
+     *
      * See: Klass::layout_helper_is_array
-     * 
+     *
      * @param klass the class to be checked
      * @return true if klass is an array, false otherwise
      */
@@ -299,13 +299,13 @@
 
     /**
      * Mask for a biasable, locked or unlocked mark word.
-     * 
+     *
      * <pre>
      * +----------------------------------+-+-+
      * |                                 1|1|1|
      * +----------------------------------+-+-+
      * </pre>
-     * 
+     *
      */
     @Fold
     public static int biasedLockMaskInPlace() {
@@ -319,13 +319,13 @@
 
     /**
      * Pattern for a biasable, unlocked mark word.
-     * 
+     *
      * <pre>
      * +----------------------------------+-+-+
      * |                                 1|0|1|
      * +----------------------------------+-+-+
      * </pre>
-     * 
+     *
      */
     @Fold
     public static int biasedLockPattern() {
@@ -467,7 +467,7 @@
      * Loads the hub of an object (without null checking it first).
      */
     public static Word loadHub(Object object) {
-        return loadHubIntrinsic(object, getWordKind(), null);
+        return loadHubIntrinsic(object, getWordKind());
     }
 
     public static Object verifyOop(Object object) {
@@ -487,7 +487,7 @@
 
     /**
      * Reads the value of a given register.
-     * 
+     *
      * @param register a register which must not be available to the register allocator
      * @return the value of {@code register} as a word
      */
@@ -510,6 +510,12 @@
         return Word.unsigned(unsafeReadKlassPointer(object));
     }
 
+    @SuppressWarnings("unused")
+    @NodeIntrinsic(value = LoadHubNode.class, setStampFromReturnType = true)
+    public static Word loadHubIntrinsic(Object object, @ConstantNodeParameter Kind word) {
+        return Word.unsigned(unsafeReadKlassPointer(object));
+    }
+
     @Fold
     public static int log2WordSize() {
         return CodeUtil.log2(wordSize());
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/LoadHubNode.java	Mon Apr 07 10:35:16 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/LoadHubNode.java	Mon Apr 07 10:40:37 2014 +0200
@@ -42,9 +42,15 @@
         return object;
     }
 
+    public LoadHubNode(ValueNode object, Kind kind) {
+        super(getKind(kind), null);
+        this.object = object;
+    }
+
     public LoadHubNode(ValueNode object, Kind kind, ValueNode guard) {
-        super(getKind(kind), asGuard(guard));
+        super(getKind(kind), (GuardingNode) guard);
         assert object != guard;
+        assert guard != null;
         this.object = object;
     }
 
@@ -52,13 +58,6 @@
         return kind == Kind.Object ? StampFactory.objectNonNull() : StampFactory.forKind(kind);
     }
 
-    private static GuardingNode asGuard(ValueNode guard) {
-        if (guard instanceof GuardingNode) {
-            return (GuardingNode) guard;
-        }
-        return null;
-    }
-
     @Override
     public void lower(LoweringTool tool) {
         tool.getLowerer().lower(this, tool);
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java	Mon Apr 07 10:35:16 2014 +0200
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java	Mon Apr 07 10:40:37 2014 +0200
@@ -485,7 +485,7 @@
         private void createGuard(StructuredGraph graph, MetaAccessProvider metaAccess) {
             ValueNode nonNullReceiver = InliningUtil.nonNullReceiver(invoke);
             ConstantNode typeHub = ConstantNode.forConstant(type.getEncoding(Representation.ObjectHub), metaAccess, graph);
-            LoadHubNode receiverHub = graph.unique(new LoadHubNode(nonNullReceiver, typeHub.getKind(), null));
+            LoadHubNode receiverHub = graph.unique(new LoadHubNode(nonNullReceiver, typeHub.getKind()));
 
             CompareNode typeCheck = CompareNode.createCompareNode(graph, Condition.EQ, receiverHub, typeHub);
             FixedGuardNode guard = graph.add(new FixedGuardNode(typeCheck, DeoptimizationReason.TypeCheckedInliningViolated, DeoptimizationAction.InvalidateReprofile));
@@ -785,7 +785,7 @@
             assert ptypes.size() >= 1;
             ValueNode nonNullReceiver = nonNullReceiver(invoke);
             Kind hubKind = ((MethodCallTargetNode) invoke.callTarget()).targetMethod().getDeclaringClass().getEncoding(Representation.ObjectHub).getKind();
-            LoadHubNode hub = graph.unique(new LoadHubNode(nonNullReceiver, hubKind, null));
+            LoadHubNode hub = graph.unique(new LoadHubNode(nonNullReceiver, hubKind));
 
             if (!invokeIsOnlySuccessor && chooseMethodDispatch()) {
                 assert successors.length == concretes.size() + 1;