Mercurial > hg > graal-jvmci-8
changeset 16483:3c3cd36a3836
moved signatureToMethodDescriptor(Signature sig) from MetaUtil to be a default method in Signature
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Thu, 10 Jul 2014 23:02:34 +0200 |
parents | 162f3f682613 |
children | 27f2ee618883 |
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.api.replacements/src/com/oracle/graal/api/replacements/MethodSubstitution.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationStatistics.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSignature.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/MacroSubstitution.java |
diffstat | 7 files changed, 36 insertions(+), 38 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/MetaUtil.java Thu Jul 10 22:51:38 2014 +0200 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/MetaUtil.java Thu Jul 10 23:02:34 2014 +0200 @@ -321,29 +321,6 @@ } /** - * 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 Thu Jul 10 22:51:38 2014 +0200 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Signature.java Thu Jul 10 23:02:34 2014 +0200 @@ -24,7 +24,7 @@ /** * Represents a method signature provided by the runtime. - * + * * @see <a href="http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.3.3">Method * Descriptors</a> */ @@ -32,7 +32,7 @@ /** * Returns the number of parameters in this signature, adding 1 for a receiver if requested. - * + * * @param receiver true if 1 is to be added to the result for a receiver * @return the number of parameters; + 1 iff {@code receiver == true} */ @@ -42,7 +42,7 @@ * Gets the parameter type at the specified position. This method returns a * {@linkplain ResolvedJavaType resolved} type if possible but without triggering any class * loading or resolution. - * + * * @param index the index into the parameters, with {@code 0} indicating the first parameter * @param accessingClass the context of the type lookup. If accessing class is provided, its * class loader is used to retrieve an existing resolved type. This value can be @@ -54,7 +54,7 @@ /** * Gets the parameter kind at the specified position. This is the same as calling * {@link #getParameterType}. {@link JavaType#getKind getKind}. - * + * * @param index the index into the parameters, with {@code 0} indicating the first parameter * @return the kind of the parameter at the specified position */ @@ -64,7 +64,7 @@ * Gets the return type of this signature. This method will return a * {@linkplain ResolvedJavaType resolved} type if possible but without triggering any class * loading or resolution. - * + * * @param accessingClass the context of the type lookup. If accessing class is provided, its * class loader is used to retrieve an existing resolved type. This value can be * {@code null} if the caller does not care for a resolved type. @@ -80,10 +80,31 @@ /** * Gets the size, in Java slots, of the parameters to this signature. - * + * * @param withReceiver {@code true} if to add a slot for a receiver object; {@code false} not to * include the receiver * @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 + */ + default String toMethodDescriptor() { + StringBuilder sb = new StringBuilder("("); + for (int i = 0; i < getParameterCount(false); ++i) { + sb.append(getParameterType(i, null).getName()); + } + sb.append(')').append(getReturnType(null).getName()); + return sb.toString(); + } + }
--- a/graal/com.oracle.graal.api.replacements/src/com/oracle/graal/api/replacements/MethodSubstitution.java Thu Jul 10 22:51:38 2014 +0200 +++ b/graal/com.oracle.graal.api.replacements/src/com/oracle/graal/api/replacements/MethodSubstitution.java Thu Jul 10 23:02:34 2014 +0200 @@ -48,7 +48,7 @@ boolean isStatic() default true; /** - * Gets the {@linkplain MetaUtil#signatureToMethodDescriptor signature} of the original method. + * Gets the {@linkplain Signature#toMethodDescriptor 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. @@ -58,7 +58,7 @@ /** * Determines if this method should be substituted in all cases, even if inlining thinks it is * not important. - * + * * Note that this is still depending on whether inlining sees the correct call target, so it's * only a hard guarantee for static and special invocations. */
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationStatistics.java Thu Jul 10 22:51:38 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationStatistics.java Thu Jul 10 23:02:34 2014 +0200 @@ -86,7 +86,7 @@ if (method != null) { holder = method.getDeclaringClass().getName(); name = method.getName(); - signature = method.getSignature().getMethodDescriptor(); + signature = method.getSignature().toMethodDescriptor(); startTime = System.nanoTime(); bytecodeCount = method.getCodeSize(); threadAllocatedBytesStart = getThreadAllocatedBytes();
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java Thu Jul 10 22:51:38 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java Thu Jul 10 23:02:34 2014 +0200 @@ -311,7 +311,7 @@ } private String getMethodDescription() { - return String.format("%-6d Graal %-70s %-45s %-50s %s", id, method.getDeclaringClass().getName(), method.getName(), method.getSignature().getMethodDescriptor(), + return String.format("%-6d Graal %-70s %-45s %-50s %s", id, method.getDeclaringClass().getName(), method.getName(), method.getSignature().toMethodDescriptor(), entryBCI == StructuredGraph.INVOCATION_ENTRY_BCI ? "" : "(OSR@" + entryBCI + ") "); }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSignature.java Thu Jul 10 22:51:38 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSignature.java Thu Jul 10 23:02:34 2014 +0200 @@ -157,8 +157,9 @@ return type; } - public String getMethodDescriptor() { - assert originalString.equals(MetaUtil.signatureToMethodDescriptor(this)); + @Override + public String toMethodDescriptor() { + assert originalString.equals(Signature.super.toMethodDescriptor()); return originalString; }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/MacroSubstitution.java Thu Jul 10 22:51:38 2014 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/MacroSubstitution.java Thu Jul 10 23:02:34 2014 +0200 @@ -57,8 +57,7 @@ boolean isStatic() default true; /** - * Gets the {@linkplain MetaUtil#signatureToMethodDescriptor signature} of the substituted - * method. + * Gets the {@linkplain Signature#toMethodDescriptor signature} of the substituted method. * <p> * If the default value is specified for this element, then the signature of the substituted * method is the same as the substitute method. @@ -82,7 +81,7 @@ /** * Determines if this method should be substituted in all cases, even if inlining thinks it is * not important. - * + * * Note that this is still depending on whether inlining sees the correct call target, so it's * only a hard guarantee for static and special invocations. */