Mercurial > hg > graal-compiler
changeset 7359:6a16788a29a6
added API method for parsing a valid Method Descriptor string (JVMS 4.3.3) into a Signature object
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Sun, 13 Jan 2013 21:14:40 +0100 |
parents | f965b7a96f16 |
children | 12bd634440d0 |
files | graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/MetaAccessProvider.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/HotSpotResolvedObjectType.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.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 | 6 files changed, 21 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/MetaAccessProvider.java Sat Jan 12 22:05:07 2013 +0100 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/MetaAccessProvider.java Sun Jan 13 21:14:40 2013 +0100 @@ -60,6 +60,13 @@ ResolvedJavaType lookupJavaType(Constant constant); /** + * Parses a <a href="http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.3.3">method + * descriptor</a> into a {@link Signature}. The behavior of this method is undefined if + * the method descriptor is not well formed. + */ + Signature parseMethodDescriptor(String methodDescriptor); + + /** * Compares two constants for equality. * This is used instead of {@link Constant#equals(Object)} in case the runtime * has an interpretation for object equality other than {@code x.asObject() == y.asObject()}.
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Signature.java Sat Jan 12 22:05:07 2013 +0100 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Signature.java Sun Jan 13 21:14:40 2013 +0100 @@ -25,7 +25,7 @@ /** * Represents a method signature provided by the runtime. * - * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/ClassFile.doc.html#7035">Method Descriptors</a> + * @see <a href="http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.3.3">Method Descriptors</a> */ public interface Signature { @@ -85,12 +85,13 @@ int getParameterSlots(boolean withReceiver); /** - * Gets this string representation of this signature in the format specified in the JVMS. + * 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 getString(); + String getMethodDescriptor(); }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java Sat Jan 12 22:05:07 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java Sun Jan 13 21:14:40 2013 +0100 @@ -330,7 +330,7 @@ @Override public ResolvedJavaMethod resolveMethod(ResolvedJavaMethod method) { assert method instanceof HotSpotMethod; - return (ResolvedJavaMethod) HotSpotGraalRuntime.getInstance().getCompilerToVM().resolveMethod(this, method.getName(), ((HotSpotSignature) method.getSignature()).getString()); + return (ResolvedJavaMethod) HotSpotGraalRuntime.getInstance().getCompilerToVM().resolveMethod(this, method.getName(), ((HotSpotSignature) method.getSignature()).getMethodDescriptor()); } @Override
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Sat Jan 12 22:05:07 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Sun Jan 13 21:14:40 2013 +0100 @@ -458,6 +458,11 @@ } @Override + public Signature parseMethodDescriptor(String signature) { + return new HotSpotSignature(signature); + } + + @Override public int getSizeOfLockData() { return config.basicLockSize; }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSignature.java Sat Jan 12 22:05:07 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSignature.java Sun Jan 13 21:14:40 2013 +0100 @@ -25,6 +25,7 @@ import java.util.*; import com.oracle.graal.api.meta.*; +import com.oracle.graal.graph.*; import com.oracle.graal.hotspot.*; import com.oracle.graal.java.*; @@ -86,7 +87,7 @@ case 'Z': break; default: - assert false; + throw new GraalInternalError("Invalid character at index " + cur + " in signature: " + signature); } return cur; } @@ -124,7 +125,7 @@ } @Override - public String getString() { + public String getMethodDescriptor() { return originalString; }
--- a/graal/com.oracle.graal.snippets/src/com/oracle/graal/snippets/ClassSubstitution.java Sat Jan 12 22:05:07 2013 +0100 +++ b/graal/com.oracle.graal.snippets/src/com/oracle/graal/snippets/ClassSubstitution.java Sun Jan 13 21:14:40 2013 +0100 @@ -73,7 +73,7 @@ boolean isStatic() default true; /** - * Gets the {@linkplain Signature#getString() signature} of the substituted method. + * Gets the {@linkplain Signature#getMethodDescriptor() 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.