Mercurial > hg > truffle
changeset 16476:92f75d104b4b
moved getElementalType() from MetaUtil to be a default method in JavaType
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Thu, 10 Jul 2014 21:20:26 +0200 |
parents | f681a647246c |
children | 46397dc87086 |
files | graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/Assumptions.java graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/TypeCheckHints.java graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/JavaType.java 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/ResolvedJavaType.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java |
diffstat | 6 files changed, 28 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/Assumptions.java Thu Jul 10 20:43:26 2014 +0200 +++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/Assumptions.java Thu Jul 10 21:20:26 2014 +0200 @@ -97,7 +97,7 @@ this.context = context; this.subtype = subtype; assert !subtype.isAbstract() : subtype.toString() + " : " + context.toString(); - assert !subtype.isArray() || getElementalType(subtype).isFinal() : subtype.toString() + " : " + context.toString(); + assert !subtype.isArray() || subtype.getElementalType().isFinal() : subtype.toString() + " : " + context.toString(); } @Override
--- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/TypeCheckHints.java Thu Jul 10 20:43:26 2014 +0200 +++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/TypeCheckHints.java Thu Jul 10 21:20:26 2014 +0200 @@ -22,7 +22,6 @@ */ package com.oracle.graal.api.code; -import static com.oracle.graal.api.meta.MetaUtil.*; import java.util.*; import com.oracle.graal.api.meta.*; @@ -153,6 +152,6 @@ * @return true if {@code type} can have subtypes */ public static boolean canHaveSubtype(ResolvedJavaType type) { - return !getElementalType(type).isFinal(); + return !type.getElementalType().isFinal(); } }
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/JavaType.java Thu Jul 10 20:43:26 2014 +0200 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/JavaType.java Thu Jul 10 21:20:26 2014 +0200 @@ -31,7 +31,7 @@ /** * Returns the name of this type in internal form. The following are examples of strings * returned by this method: - * + * * <pre> * "Ljava/lang/Object;" * "I" @@ -47,6 +47,19 @@ JavaType getComponentType(); /** + * Gets the elemental type for this given type. The elemental type is the corresponding zero + * dimensional type of an array type. For example, the elemental type of {@code int[][][]} is + * {@code int}. A non-array type is its own elemental type. + */ + default JavaType getElementalType() { + JavaType t = this; + while (t.getComponentType() != null) { + t = t.getComponentType(); + } + return t; + } + + /** * Gets the array class type representing an array with elements of this type. */ JavaType getArrayClass(); @@ -59,7 +72,7 @@ /** * Resolved this type and returns a {@link ResolvedJavaType}. If this type is already a * {@link ResolvedJavaType}, it returns this type. - * + * * @param accessingClass the class that requests resolving this type * @return the resolved Java type */
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/MetaUtil.java Thu Jul 10 20:43:26 2014 +0200 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/MetaUtil.java Thu Jul 10 21:20:26 2014 +0200 @@ -165,19 +165,6 @@ } /** - * Gets the elemental type for a given type. The elemental type of an array type is the - * corresponding zero dimensional (e.g., the elemental type of {@code int[][][]} is {@code int} - * ). A non-array type is its own elemental type. - */ - public static ResolvedJavaType getElementalType(ResolvedJavaType type) { - ResolvedJavaType t = type; - while (t.getComponentType() != null) { - t = t.getComponentType(); - } - return t; - } - - /** * Extends the functionality of {@link Class#getSimpleName()} to include a non-empty string for * anonymous and local classes. *
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaType.java Thu Jul 10 20:43:26 2014 +0200 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaType.java Thu Jul 10 21:20:26 2014 +0200 @@ -183,8 +183,8 @@ * Attempts to get a unique concrete subclass of this type. * <p> * For an {@linkplain #isArray() array} type A, the unique concrete subclass is A if the - * {@linkplain MetaUtil#getElementalType(ResolvedJavaType) elemental} type of A is final (which - * includes primitive types). Otherwise {@code null} is returned for A. + * {@linkplain #getElementalType() elemental} type of A is final (which includes primitive + * types). Otherwise {@code null} is returned for A. * <p> * For a non-array type T, the result is the unique concrete type in the current hierarchy of T. * <p> @@ -202,6 +202,14 @@ ResolvedJavaType getComponentType(); + default ResolvedJavaType getElementalType() { + ResolvedJavaType t = this; + while (t.getComponentType() != null) { + t = t.getComponentType(); + } + return t; + } + ResolvedJavaType getArrayClass(); /**
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java Thu Jul 10 20:43:26 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java Thu Jul 10 21:20:26 2014 +0200 @@ -22,7 +22,6 @@ */ package com.oracle.graal.hotspot.meta; -import static com.oracle.graal.api.meta.MetaUtil.*; import static com.oracle.graal.compiler.common.UnsafeAccess.*; import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; @@ -140,7 +139,7 @@ public ResolvedJavaType findUniqueConcreteSubtype() { HotSpotVMConfig config = runtime().getConfig(); if (isArray()) { - return getElementalType(this).isFinal() ? this : null; + return getElementalType().isFinal() ? this : null; } else if (isInterface()) { final long implementorMetaspaceKlass = runtime().getCompilerToVM().getKlassImplementor(getMetaspaceKlass());