changeset 11384:5e99a0628192

Add javadoc for ObjectStamp.castTo. Fix javadoc typo. Add some stamp related asserts
author Gilles Duboscq <duboscq@ssw.jku.at>
date Wed, 21 Aug 2013 16:17:10 +0200
parents 423c53e2fa7e
children e119ba892b45
files graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ConvertNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/InstanceOfDynamicNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/ObjectStamp.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/Stamp.java
diffstat 4 files changed, 21 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ConvertNode.java	Wed Aug 21 08:29:07 2013 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ConvertNode.java	Wed Aug 21 16:17:10 2013 +0200
@@ -207,6 +207,7 @@
             if (stamp instanceof FloatStamp) {
                 return false;
             }
+            assert stamp == StampFactory.illegal();
             return updateStamp(StampFactory.illegal());
         }
         Stamp newStamp;
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/InstanceOfDynamicNode.java	Wed Aug 21 08:29:07 2013 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/InstanceOfDynamicNode.java	Wed Aug 21 16:17:10 2013 +0200
@@ -47,8 +47,8 @@
         this.mirror = mirror;
         this.object = object;
         assert mirror.kind() == Kind.Object : mirror.kind();
-        assert mirror.stamp() instanceof ObjectStamp;
-        assert ((ObjectStamp) mirror.stamp()).type().getName().equals("Ljava/lang/Class;");
+        assert ObjectStamp.isExactType(mirror);
+        assert ObjectStamp.typeOrNull(mirror).getName().equals("Ljava/lang/Class;");
     }
 
     @Override
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/ObjectStamp.java	Wed Aug 21 08:29:07 2013 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/ObjectStamp.java	Wed Aug 21 16:17:10 2013 +0200
@@ -23,6 +23,7 @@
 package com.oracle.graal.nodes.type;
 
 import java.lang.reflect.*;
+import java.util.*;
 
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.nodes.*;
@@ -121,11 +122,26 @@
         return join0(otherStamp, false);
     }
 
+    /**
+     * Returns the stamp representing the type of this stamp after a cast to the type represented by
+     * the {@code to} stamp. While this is very similar to a {@link #join} operation, in the case
+     * where both types are not obviously related, the cast operation will prefer the type of the
+     * {@code to} stamp. This is necessary as long as ObjectStamps are not able to accurately
+     * represent union types.
+     * 
+     * For example when joining the {@link RandomAccess} type with the {@link AbstractList} type,
+     * without union types, this would result in the most generic type ({@link Object}). For this
+     * reason, in some cases a {@code castTo} operation is preferable in order to keep at least the
+     * {@link AbstractList} type.
+     * 
+     * @param to the stamp this stamp should be casted to
+     * @return This stamp casted to the {@code to} stamp
+     */
     public Stamp castTo(ObjectStamp to) {
         return join0(to, true);
     }
 
-    public Stamp join0(Stamp otherStamp, boolean castToOther) {
+    private Stamp join0(Stamp otherStamp, boolean castToOther) {
         if (this == otherStamp) {
             return this;
         }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/Stamp.java	Wed Aug 21 08:29:07 2013 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/Stamp.java	Wed Aug 21 16:17:10 2013 +0200
@@ -71,7 +71,7 @@
      * If this stamp represents a single value, the methods returns this single value. It returns
      * null otherwise.
      * 
-     * @return the constant corresponding to the single value of this stamp and null if this tamp
+     * @return the constant corresponding to the single value of this stamp and null if this stamp
      *         can represent less or more than one value.
      */
     public Constant asConstant() {