changeset 18244:691e2b53dc63

Merge.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Wed, 30 Jul 2014 22:28:09 +0200
parents 4221c8332c34 (current diff) b363053f6cac (diff)
children 137f4cf8204a
files graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/JavaType.java graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/Stamp.java graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/StampFactory.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/StructuredGraph.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MethodCallTargetNode.java
diffstat 5 files changed, 80 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/JavaType.java	Tue Nov 04 14:06:35 2014 +0100
+++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/JavaType.java	Wed Jul 30 22:28:09 2014 +0200
@@ -43,6 +43,25 @@
     String getName();
 
     /**
+     * Returns an unqualified name of this type.
+     *
+     * <pre>
+     *     "Object"
+     *     "Integer"
+     * </pre>
+     */
+    default String getUnqualifiedName() {
+        String name = getName();
+        if (name.indexOf('/') != -1) {
+            name = name.substring(name.lastIndexOf('/') + 1);
+        }
+        if (name.endsWith(";")) {
+            name = name.substring(0, name.length() - 1);
+        }
+        return name;
+    }
+
+    /**
      * For array types, gets the type of the components, or {@code null} if this is not an array
      * type. This method is analogous to {@link Class#getComponentType()}.
      */
--- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/Stamp.java	Tue Nov 04 14:06:35 2014 +0100
+++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/Stamp.java	Wed Jul 30 22:28:09 2014 +0200
@@ -115,4 +115,19 @@
     public Constant asConstant() {
         return null;
     }
+
+    /**
+     * Tries to improve this stamp with the stamp given as parameter. If successful, returns the new
+     * improved stamp. Otherwise, returns null.
+     * 
+     * @param other the stamp that should be used to improve this stamp
+     * @return the newly improved stamp of null if an improvement was not possible
+     */
+    public Stamp tryImprove(Stamp other) {
+        Stamp newStamp = this.join(other);
+        if (newStamp.equals(this)) {
+            return null;
+        }
+        return newStamp;
+    }
 }
--- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/StampFactory.java	Tue Nov 04 14:06:35 2014 +0100
+++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/StampFactory.java	Wed Jul 30 22:28:09 2014 +0200
@@ -284,4 +284,30 @@
             return illegal(Kind.Object);
         }
     }
+
+    public static Stamp[] createParameterStamps(ResolvedJavaMethod method) {
+        Signature sig = method.getSignature();
+        Stamp[] result = new Stamp[sig.getParameterCount(!method.isStatic())];
+        int index = 0;
+
+        if (!method.isStatic()) {
+            result[index++] = StampFactory.declaredNonNull(method.getDeclaringClass());
+        }
+
+        int max = sig.getParameterCount(false);
+        ResolvedJavaType accessingClass = method.getDeclaringClass();
+        for (int i = 0; i < max; i++) {
+            JavaType type = sig.getParameterType(i, accessingClass);
+            Kind kind = type.getKind();
+            Stamp stamp;
+            if (kind == Kind.Object && type instanceof ResolvedJavaType) {
+                stamp = StampFactory.declared((ResolvedJavaType) type);
+            } else {
+                stamp = StampFactory.forKind(kind);
+            }
+            result[index++] = stamp;
+        }
+
+        return result;
+    }
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/StructuredGraph.java	Tue Nov 04 14:06:35 2014 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/StructuredGraph.java	Wed Jul 30 22:28:09 2014 +0200
@@ -26,6 +26,7 @@
 import java.util.concurrent.atomic.*;
 
 import com.oracle.graal.api.meta.*;
+import com.oracle.graal.compiler.common.type.*;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.graph.spi.*;
 import com.oracle.graal.nodes.calc.*;
@@ -110,6 +111,21 @@
         this.entryBCI = entryBCI;
     }
 
+    public Stamp getReturnStamp() {
+        Stamp returnStamp = null;
+        for (ReturnNode returnNode : getNodes(ReturnNode.class)) {
+            ValueNode result = returnNode.result();
+            if (result != null) {
+                if (returnStamp == null) {
+                    returnStamp = result.stamp();
+                } else {
+                    returnStamp = returnStamp.meet(result.stamp());
+                }
+            }
+        }
+        return returnStamp;
+    }
+
     @Override
     public String toString() {
         StringBuilder buf = new StringBuilder(getClass().getSimpleName() + ":" + graphId);
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MethodCallTargetNode.java	Tue Nov 04 14:06:35 2014 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MethodCallTargetNode.java	Wed Jul 30 22:28:09 2014 +0200
@@ -113,6 +113,10 @@
             // check if the type of the receiver can narrow the result
             ValueNode receiver = receiver();
             ResolvedJavaType type = StampTool.typeOrNull(receiver);
+            if (type == null && invokeKind == InvokeKind.Virtual) {
+                // For virtual calls, we are guaranteed to receive a correct receiver type.
+                type = targetMethod.getDeclaringClass();
+            }
             if (type != null && (invoke().stateAfter() != null || invoke().stateDuring() != null)) {
                 /*
                  * either the holder class is exact, or the receiver object has an exact type, or