# HG changeset patch # User Thomas Wuerthinger # Date 1433630830 -7200 # Node ID a7a1b9b65bce56d474ffffea81509e9000f9253c # Parent cb6d65bcc8cba983bd87d3ee6a7baa4ef825d866 Small improvement and clean up of InstanceOfNode. diff -r cb6d65bcc8cb -r a7a1b9b65bce graal/com.oracle.graal.java/src/com/oracle/graal/java/BytecodeParser.java --- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/BytecodeParser.java Sat Jun 06 23:52:39 2015 +0200 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/BytecodeParser.java Sun Jun 07 00:47:10 2015 +0200 @@ -2203,7 +2203,7 @@ ValueNode exception = frameState.stack[0]; FixedNode trueSuccessor = graph.add(new DeoptimizeNode(InvalidateReprofile, UnreachedCode)); FixedNode nextDispatch = createTarget(nextBlock, frameState); - append(new IfNode(graph.unique(new InstanceOfNode((ResolvedJavaType) catchType, exception, null)), trueSuccessor, nextDispatch, 0)); + append(new IfNode(graph.unique(InstanceOfNode.create((ResolvedJavaType) catchType, exception, null)), trueSuccessor, nextDispatch, 0)); return; } } diff -r cb6d65bcc8cb -r a7a1b9b65bce 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 Sat Jun 06 23:52:39 2015 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java Sun Jun 07 00:47:10 2015 +0200 @@ -126,7 +126,7 @@ condition = LogicConstantNode.contradiction(graph()); newStamp = StampFactory.declaredTrusted(type); } else if (StampTool.isPointerNonNull(object)) { - condition = graph().addWithoutUnique(new InstanceOfNode(type, object, profile)); + condition = graph().addWithoutUnique(InstanceOfNode.create(type, object, profile)); } else { if (profile != null && profile.getNullSeen() == TriState.FALSE) { FixedGuardNode nullCheck = graph().add(new FixedGuardNode(graph().unique(new IsNullNode(object)), UnreachedCode, InvalidateReprofile, true)); diff -r cb6d65bcc8cb -r a7a1b9b65bce graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/InstanceOfDynamicNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/InstanceOfDynamicNode.java Sat Jun 06 23:52:39 2015 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/InstanceOfDynamicNode.java Sun Jun 07 00:47:10 2015 +0200 @@ -69,7 +69,7 @@ if (t.isPrimitive()) { return LogicConstantNode.contradiction(); } else { - return new InstanceOfNode(t, forObject, null); + return InstanceOfNode.create(t, forObject, null); } } } diff -r cb6d65bcc8cb -r a7a1b9b65bce 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 Sat Jun 06 23:52:39 2015 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/InstanceOfNode.java Sun Jun 07 00:47:10 2015 +0200 @@ -42,7 +42,7 @@ protected final ResolvedJavaType type; protected JavaTypeProfile profile; - public InstanceOfNode(ResolvedJavaType type, ValueNode object, JavaTypeProfile profile) { + private InstanceOfNode(ResolvedJavaType type, ValueNode object, JavaTypeProfile profile) { this(TYPE, type, object, profile); } @@ -55,7 +55,7 @@ public static LogicNode create(ResolvedJavaType type, ValueNode object, JavaTypeProfile profile) { ObjectStamp objectStamp = (ObjectStamp) object.stamp(); - LogicNode constantValue = findSynonym(type, objectStamp.type(), objectStamp.nonNull(), objectStamp.isExactType()); + LogicNode constantValue = findSynonym(object, type, objectStamp.type(), objectStamp.nonNull(), objectStamp.isExactType()); if (constantValue != null) { return constantValue; } else { @@ -100,7 +100,7 @@ } private ValueNode checkInstanceOf(ValueNode forValue, ResolvedJavaType inputType, boolean nonNull, boolean exactType) { - ValueNode result = findSynonym(type(), inputType, nonNull, exactType); + ValueNode result = findSynonym(forValue, type(), inputType, nonNull, exactType); if (result != null) { return result; } @@ -114,7 +114,7 @@ return null; } - public static LogicNode findSynonym(ResolvedJavaType type, ResolvedJavaType inputType, boolean nonNull, boolean exactType) { + public static LogicNode findSynonym(ValueNode object, ResolvedJavaType type, ResolvedJavaType inputType, boolean nonNull, boolean exactType) { if (inputType == null) { return null; } @@ -139,6 +139,10 @@ // really know if it might be true at run time... } } + + if (type.isFinal() && nonNull) { + return TypeCheckNode.create(type, object); + } return null; } diff -r cb6d65bcc8cb -r a7a1b9b65bce graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MethodCallTargetNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MethodCallTargetNode.java Sat Jun 06 23:52:39 2015 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MethodCallTargetNode.java Sun Jun 07 00:47:10 2015 +0200 @@ -215,7 +215,7 @@ * an assumption but as we need an instanceof check anyway we can verify both * properties by checking of the receiver is an instance of the single implementor. */ - LogicNode condition = graph().unique(new InstanceOfNode(singleImplementor, receiver, getProfile())); + LogicNode condition = graph().unique(InstanceOfNode.create(singleImplementor, receiver, getProfile())); FixedGuardNode guard = graph().add(new FixedGuardNode(condition, DeoptimizationReason.OptimizedTypeCheckViolated, DeoptimizationAction.InvalidateRecompile, false)); graph().addBeforeFixed(invoke().asNode(), guard); PiNode piNode = graph().unique(new PiNode(receiver, StampFactory.declaredNonNull(singleImplementor), guard)); diff -r cb6d65bcc8cb -r a7a1b9b65bce graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/InstanceOfTest.java --- a/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/InstanceOfTest.java Sat Jun 06 23:52:39 2015 +0200 +++ b/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/InstanceOfTest.java Sun Jun 07 00:47:10 2015 +0200 @@ -50,7 +50,7 @@ protected void replaceProfile(StructuredGraph graph, JavaTypeProfile profile) { InstanceOfNode ion = graph.getNodes().filter(InstanceOfNode.class).first(); if (ion != null) { - InstanceOfNode ionNew = graph.unique(new InstanceOfNode(ion.type(), ion.getValue(), profile)); + LogicNode ionNew = graph.unique(InstanceOfNode.create(ion.type(), ion.getValue(), profile)); graph.replaceFloating(ion, ionNew); } }