changeset 7676:ca9061b6694c

getMethodDescriptor does not need to be in the Signature interface
author Christian Wimmer <christian.wimmer@oracle.com>
date Mon, 04 Feb 2013 06:26:47 -0800
parents 31d0b30b30a3
children 20cc221ed5ca
files graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/MetaUtil.java graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Signature.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSignature.java graal/com.oracle.graal.snippets/src/com/oracle/graal/snippets/ClassSubstitution.java
diffstat 5 files changed, 31 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/MetaUtil.java	Mon Feb 04 05:59:06 2013 -0800
+++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/MetaUtil.java	Mon Feb 04 06:26:47 2013 -0800
@@ -212,7 +212,7 @@
                 return result;
             }
             case '[':
-                return classForNameCompatible ? name.replace('/',  '.') : internalNameToJava(name.substring(1), qualified, classForNameCompatible) + "[]";
+                return classForNameCompatible ? name.replace('/', '.') : internalNameToJava(name.substring(1), qualified, classForNameCompatible) + "[]";
             default:
                 if (name.length() != 1) {
                     throw new IllegalArgumentException("Illegal internal name: " + name);
@@ -221,7 +221,7 @@
         }
     }
 
-   /**
+    /**
      * Turns an class name in internal format into a resolved Java type.
      */
     public static ResolvedJavaType classForName(String internal, MetaAccessProvider metaAccess, ClassLoader cl) {
@@ -515,6 +515,29 @@
     }
 
     /**
+     * Gets the <a
+     * href="http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.3.3">method
+     * descriptor</a> corresponding to this signature. For example:
+     * 
+     * <pre>
+     * (ILjava/lang/String;D)V
+     * </pre>
+     * 
+     * .
+     * 
+     * @param sig the {@link Signature} to be converted.
+     * @return the signature as a string
+     */
+    public static String signatureToMethodDescriptor(Signature sig) {
+        StringBuilder sb = new StringBuilder("(");
+        for (int i = 0; i < sig.getParameterCount(false); ++i) {
+            sb.append(sig.getParameterType(i, null).getName());
+        }
+        sb.append(')').append(sig.getReturnType(null).getName());
+        return sb.toString();
+    }
+
+    /**
      * Formats some profiling information associated as a string.
      * 
      * @param info the profiling info to format
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Signature.java	Mon Feb 04 05:59:06 2013 -0800
+++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Signature.java	Mon Feb 04 06:26:47 2013 -0800
@@ -86,19 +86,4 @@
      * @return the size of the parameters in slots
      */
     int getParameterSlots(boolean withReceiver);
-
-    /**
-     * Gets the <a
-     * href="http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.3.3">method
-     * descriptor</a> corresponding to this signature. For example:
-     * 
-     * <pre>
-     * (ILjava/lang/String;D)V
-     * </pre>
-     * 
-     * .
-     * 
-     * @return the signature as a string
-     */
-    String getMethodDescriptor();
 }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java	Mon Feb 04 05:59:06 2013 -0800
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java	Mon Feb 04 06:26:47 2013 -0800
@@ -52,7 +52,7 @@
     private final HotSpotResolvedObjectType holder;
     private/* final */int codeSize;
     private/* final */int exceptionHandlerCount;
-    private Signature signature;
+    private HotSpotSignature signature;
     private Boolean hasBalancedMonitors;
     private Map<Object, Object> compilerStorage;
     private HotSpotMethodData methodData;
@@ -162,7 +162,7 @@
     }
 
     @Override
-    public Signature getSignature() {
+    public HotSpotSignature getSignature() {
         if (signature == null) {
             signature = new HotSpotSignature(HotSpotGraalRuntime.getInstance().getCompilerToVM().getSignature(metaspaceMethod));
         }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSignature.java	Mon Feb 04 05:59:06 2013 -0800
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSignature.java	Mon Feb 04 06:26:47 2013 -0800
@@ -124,8 +124,8 @@
         return type;
     }
 
-    @Override
     public String getMethodDescriptor() {
+        assert originalString.equals(MetaUtil.signatureToMethodDescriptor(this));
         return originalString;
     }
 
--- a/graal/com.oracle.graal.snippets/src/com/oracle/graal/snippets/ClassSubstitution.java	Mon Feb 04 05:59:06 2013 -0800
+++ b/graal/com.oracle.graal.snippets/src/com/oracle/graal/snippets/ClassSubstitution.java	Mon Feb 04 06:26:47 2013 -0800
@@ -77,7 +77,8 @@
         boolean isStatic() default true;
 
         /**
-         * Gets the {@linkplain Signature#getMethodDescriptor() signature} of the original method.
+         * Gets the {@linkplain MetaUtil#signatureToMethodDescriptor signature} of the original
+         * method.
          * <p>
          * If the default value is specified for this element, then the signature of the original
          * method is the same as the substitute method.
@@ -110,7 +111,7 @@
         boolean isStatic() default true;
 
         /**
-         * Gets the {@linkplain Signature#getMethodDescriptor() signature} of the substituted
+         * Gets the {@linkplain MetaUtil#signatureToMethodDescriptor signature} of the substituted
          * method.
          * <p>
          * If the default value is specified for this element, then the signature of the substituted