# HG changeset patch # User Christian Wimmer # Date 1354212603 28800 # Node ID 6644cecbd3a70d33eeaa8d98b3d01143bfd54147 # Parent 585fc9f79ebcafa90f688dd9013fb3e3a5d16eda Replace ResolvedJavaType.isAssignableTo with isAssignableFrom to be consistent with java.lang.Class diff -r 585fc9f79ebc -r 6644cecbd3a7 graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/TypeCheckHints.java --- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/TypeCheckHints.java Thu Nov 29 09:13:59 2012 -0800 +++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/TypeCheckHints.java Thu Nov 29 10:10:03 2012 -0800 @@ -86,7 +86,7 @@ double totalHintProbability = 0.0d; for (ProfiledType ptype : ptypes) { ResolvedJavaType hint = ptype.getType(); - if (type != null && hint.isAssignableTo(type)) { + if (type != null && type.isAssignableFrom(hint)) { hintTypes[hintCount++] = hint; totalHintProbability += ptype.getProbability(); } diff -r 585fc9f79ebc -r 6644cecbd3a7 graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TestResolvedJavaType.java --- a/graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TestResolvedJavaType.java Thu Nov 29 09:13:59 2012 -0800 +++ b/graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TestResolvedJavaType.java Thu Nov 29 10:10:03 2012 -0800 @@ -111,10 +111,10 @@ ResolvedJavaType t1 = runtime.lookupJavaType(c1); ResolvedJavaType t2 = runtime.lookupJavaType(c2); boolean expected = c1.isAssignableFrom(c2); - boolean actual = t2.isAssignableTo(t1); + boolean actual = t1.isAssignableFrom(t2); assertEquals(expected, actual); if (expected && t1 != t2) { - assertFalse(t1.isAssignableTo(t2)); + assertFalse(t2.isAssignableFrom(t1)); } } } diff -r 585fc9f79ebc -r 6644cecbd3a7 graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaType.java --- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaType.java Thu Nov 29 09:13:59 2012 -0800 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaType.java Thu Nov 29 10:10:03 2012 -0800 @@ -130,13 +130,11 @@ void initialize(); /** - * Checks whether this type is a subtype of another type. - * - * @param other the type to test - * @return {@code true} if this type a subtype of the specified type - * @see Class#isAssignableFrom(Class) + * Determines if this type is either the same as, or is a superclass or superinterface of, the type represented by + * the specified parameter. This method is identical to {@link Class#isAssignableFrom(Class)} in terms of the value + * return for this type. */ - boolean isAssignableTo(ResolvedJavaType other); + boolean isAssignableFrom(ResolvedJavaType other); /** * Checks whether the specified object is an instance of this type. diff -r 585fc9f79ebc -r 6644cecbd3a7 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java Thu Nov 29 09:13:59 2012 -0800 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java Thu Nov 29 10:10:03 2012 -0800 @@ -222,10 +222,10 @@ HotSpotResolvedObjectType t1 = this; HotSpotResolvedObjectType t2 = (HotSpotResolvedObjectType) otherType; while (true) { - if (t2.isAssignableTo(t1)) { + if (t1.isAssignableFrom(t2)) { return t1; } - if (t1.isAssignableTo(t2)) { + if (t2.isAssignableFrom(t1)) { return t2; } t1 = t1.getSupertype(); @@ -314,10 +314,10 @@ } @Override - public boolean isAssignableTo(ResolvedJavaType other) { + public boolean isAssignableFrom(ResolvedJavaType other) { if (other instanceof HotSpotResolvedObjectType) { HotSpotResolvedObjectType otherType = (HotSpotResolvedObjectType) other; - return otherType.javaMirror.isAssignableFrom(javaMirror); + return javaMirror.isAssignableFrom(otherType.javaMirror); } return false; } diff -r 585fc9f79ebc -r 6644cecbd3a7 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedPrimitiveType.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedPrimitiveType.java Thu Nov 29 09:13:59 2012 -0800 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedPrimitiveType.java Thu Nov 29 10:10:03 2012 -0800 @@ -127,7 +127,7 @@ } @Override - public boolean isAssignableTo(ResolvedJavaType other) { + public boolean isAssignableFrom(ResolvedJavaType other) { return other == this; } diff -r 585fc9f79ebc -r 6644cecbd3a7 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/IntrinsifyArrayCopyPhase.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/IntrinsifyArrayCopyPhase.java Thu Nov 29 09:13:59 2012 -0800 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/IntrinsifyArrayCopyPhase.java Thu Nov 29 10:10:03 2012 -0800 @@ -108,7 +108,7 @@ snippetMethod = objectArrayCopy; } } else if (componentKind == Kind.Object - && srcType.getComponentType().isAssignableTo(destType.getComponentType())) { + && destType.getComponentType().isAssignableFrom(srcType.getComponentType())) { snippetMethod = objectArrayCopy; } } diff -r 585fc9f79ebc -r 6644cecbd3a7 graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java --- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Thu Nov 29 09:13:59 2012 -0800 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Thu Nov 29 10:10:03 2012 -0800 @@ -1442,7 +1442,7 @@ if (initialized && graphBuilderConfig.getSkippedExceptionTypes() != null) { ResolvedJavaType resolvedCatchType = (ResolvedJavaType) catchType; for (ResolvedJavaType skippedType : graphBuilderConfig.getSkippedExceptionTypes()) { - initialized &= !resolvedCatchType.isAssignableTo(skippedType); + initialized &= !skippedType.isAssignableFrom(resolvedCatchType); if (!initialized) { break; } diff -r 585fc9f79ebc -r 6644cecbd3a7 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeCastNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeCastNode.java Thu Nov 29 09:13:59 2012 -0800 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeCastNode.java Thu Nov 29 10:10:03 2012 -0800 @@ -68,7 +68,7 @@ if (my.nonNull() && !other.nonNull()) { return this; } - if (my.type() != other.type() && my.type().isAssignableTo(other.type())) { + if (my.type() != other.type() && other.type().isAssignableFrom(my.type())) { return this; } } diff -r 585fc9f79ebc -r 6644cecbd3a7 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java Thu Nov 29 09:13:59 2012 -0800 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java Thu Nov 29 10:10:03 2012 -0800 @@ -72,7 +72,7 @@ if (type != null) { ResolvedJavaType objectType = object().objectStamp().type(); - if (objectType != null && objectType.isAssignableTo(type)) { + if (objectType != null && type.isAssignableFrom(objectType)) { // we don't have to check for null types here because they will also pass the checkcast. return object(); } @@ -102,7 +102,7 @@ @Override public void virtualize(VirtualizerTool tool) { VirtualObjectNode virtual = tool.getVirtualState(object()); - if (virtual != null && virtual.type().isAssignableTo(type())) { + if (virtual != null && type().isAssignableFrom(virtual.type())) { tool.replaceWithVirtual(virtual); } } diff -r 585fc9f79ebc -r 6644cecbd3a7 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/InstanceOfNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/InstanceOfNode.java Thu Nov 29 09:13:59 2012 -0800 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/InstanceOfNode.java Thu Nov 29 10:10:03 2012 -0800 @@ -70,7 +70,7 @@ ResolvedJavaType stampType = stamp.type(); if (stamp.isExactType()) { - boolean subType = stampType.isAssignableTo(type()); + boolean subType = type().isAssignableFrom(stampType); if (subType) { if (stamp.nonNull()) { @@ -87,7 +87,7 @@ return ConstantNode.forBoolean(false, graph()); } } else if (stampType != null) { - boolean subType = stampType.isAssignableTo(type()); + boolean subType = type().isAssignableFrom(stampType); if (subType) { if (stamp.nonNull()) { @@ -135,7 +135,7 @@ public void virtualize(VirtualizerTool tool) { VirtualObjectNode virtual = tool.getVirtualState(object()); if (virtual != null) { - tool.replaceWithValue(ConstantNode.forBoolean(virtual.type().isAssignableTo(type()), graph())); + tool.replaceWithValue(ConstantNode.forBoolean(type().isAssignableFrom(virtual.type()), graph())); } } } diff -r 585fc9f79ebc -r 6644cecbd3a7 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/TypeSwitchNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/TypeSwitchNode.java Thu Nov 29 09:13:59 2012 -0800 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/TypeSwitchNode.java Thu Nov 29 10:10:03 2012 -0800 @@ -98,7 +98,7 @@ if (stamp.type() != null) { int validKeys = 0; for (int i = 0; i < keyCount(); i++) { - if (keys[i].isAssignableTo(stamp.type())) { + if (stamp.type().isAssignableFrom(keys[i])) { validKeys++; } } @@ -113,7 +113,7 @@ double totalProbability = 0; int current = 0; for (int i = 0; i < keyCount() + 1; i++) { - if (i == keyCount() || keys[i].isAssignableTo(stamp.type())) { + if (i == keyCount() || stamp.type().isAssignableFrom(keys[i])) { int index = newSuccessors.indexOf(keySuccessor(i)); if (index == -1) { index = newSuccessors.size(); diff -r 585fc9f79ebc -r 6644cecbd3a7 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/ObjectStamp.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/ObjectStamp.java Thu Nov 29 09:13:59 2012 -0800 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/ObjectStamp.java Thu Nov 29 10:10:03 2012 -0800 @@ -78,7 +78,7 @@ return false; } else if (other.nonNull || nonNull) { // One of the two values cannot be null. - return !other.type.isInterface() && !type.isInterface() && !other.type.isAssignableTo(type) && !type.isAssignableTo(other.type); + return !other.type.isInterface() && !type.isInterface() && !type.isAssignableFrom(other.type) && !other.type.isAssignableFrom(type); } return false; } @@ -139,7 +139,7 @@ joinType = type; } else { // both types are != null - if (other.type.isAssignableTo(type)) { + if (type.isAssignableFrom(other.type)) { joinType = other.type; } else { joinType = type; diff -r 585fc9f79ebc -r 6644cecbd3a7 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java Thu Nov 29 09:13:59 2012 -0800 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java Thu Nov 29 10:10:03 2012 -0800 @@ -240,9 +240,9 @@ return a; } else if (a == b) { return a; - } else if (a.isAssignableTo(b)) { + } else if (b.isAssignableFrom(a)) { return a; - } else if (b.isAssignableTo(a)) { + } else if (a.isAssignableFrom(b)) { return b; } else { return a; @@ -326,7 +326,7 @@ } else if (node instanceof CheckCastNode) { CheckCastNode checkCast = (CheckCastNode) node; ResolvedJavaType type = state.getNodeType(checkCast.object()); - if (type != null && type.isAssignableTo(checkCast.type())) { + if (type != null && checkCast.type().isAssignableFrom(type)) { PiNode piNode; boolean nonNull = state.knownNotNull.contains(checkCast.object()); piNode = graph.unique(new PiNode(checkCast.object(), lastBegin, nonNull ? StampFactory.declaredNonNull(type) : StampFactory.declared(type))); @@ -351,7 +351,7 @@ replaceWith = ConstantNode.forBoolean(false, graph); } else if (state.knownNotNull.contains(object)) { ResolvedJavaType type = state.getNodeType(object); - if (type != null && type.isAssignableTo(instanceOf.type())) { + if (type != null && instanceOf.type().isAssignableFrom(type)) { replaceWith = ConstantNode.forBoolean(true, graph); } } diff -r 585fc9f79ebc -r 6644cecbd3a7 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java Thu Nov 29 09:13:59 2012 -0800 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java Thu Nov 29 10:10:03 2012 -0800 @@ -658,7 +658,7 @@ ObjectStamp receiverStamp = callTarget.receiver().objectStamp(); ResolvedJavaType receiverType = receiverStamp.type(); if (receiverStamp.isExactType()) { - assert receiverType.isAssignableTo(targetMethod.getDeclaringClass()) : receiverType + " subtype of " + targetMethod.getDeclaringClass() + " for " + targetMethod; + assert targetMethod.getDeclaringClass().isAssignableFrom(receiverType) : receiverType + " subtype of " + targetMethod.getDeclaringClass() + " for " + targetMethod; ResolvedJavaMethod resolved = receiverType.resolveMethod(targetMethod); if (!checkTargetConditions(invoke, resolved, optimisticOpts, runtime)) { return null; @@ -671,7 +671,7 @@ if (receiverStamp.type() != null) { // the invoke target might be more specific than the holder (happens after inlining: locals lose their declared type...) // TODO (lstadler) fix this - if (receiverType != null && receiverType.isAssignableTo(holder)) { + if (receiverType != null && holder.isAssignableFrom(receiverType)) { holder = receiverType; } }