Mercurial > hg > truffle
changeset 5341:1fbc4a08d029
Merge
author | Lukas Stadler <lukas.stadler@jku.at> |
---|---|
date | Wed, 02 May 2012 15:08:41 +0200 |
parents | 4fb83c633fce (diff) 439ca5ecc7dc (current diff) |
children | 77809963c5cc |
files | graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/util/InliningUtil.java |
diffstat | 10 files changed, 66 insertions(+), 45 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalOptions.java Wed May 02 14:39:45 2012 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalOptions.java Wed May 02 15:08:41 2012 +0200 @@ -85,13 +85,13 @@ // comilation queue public static int TimedBootstrap = -1; - public static boolean PriorityCompileQueue = ____; + public static boolean PriorityCompileQueue = true; public static int SlowQueueCutoff = 100000; public static boolean SlowCompileThreads = ____; public static boolean DynamicCompilePriority = ____; // graph caching - public static boolean CacheGraphs = ____; + public static boolean CacheGraphs = true; public static int GraphCacheSize = 1000; public static boolean PrintGraphCache = ____;
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java Wed May 02 14:39:45 2012 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java Wed May 02 15:08:41 2012 +0200 @@ -509,10 +509,8 @@ @Override public void visitCheckCast(CheckCastNode x) { - if (x.emitCode()) { - XirSnippet snippet = xir.genCheckCast(site(x, x.object()), toXirArgument(x.object()), toXirArgument(x.targetClassInstruction()), x.targetClass(), x.hints(), x.hintsExact()); - emitXir(snippet, x, state(), true); - } + XirSnippet snippet = xir.genCheckCast(site(x, x.object()), toXirArgument(x.object()), toXirArgument(x.targetClassInstruction()), x.targetClass(), x.hints(), x.hintsExact()); + emitXir(snippet, x, state(), true); // The result of a checkcast is the unmodified object, so no need to allocate a new variable for it. setResult(x, operand(x.object())); }
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/CanonicalizerPhase.java Wed May 02 14:39:45 2012 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/CanonicalizerPhase.java Wed May 02 15:08:41 2012 +0200 @@ -70,7 +70,6 @@ METRIC_PROCESSED_NODES.increment(); if (node instanceof Canonicalizable) { METRIC_CANONICALIZATION_CONSIDERED_NODES.increment(); - Debug.log("Canonicalizer: work on %s", node); graph.mark(); ValueNode canonical = ((Canonicalizable) node).canonical(tool); // cases: original node: @@ -85,7 +84,11 @@ // Fixed-connected| 2 | X | 6 | // -------------------------------------------- // X: must not happen (checked with assertions) - if (canonical != node) { + if (canonical == node) { + Debug.log("Canonicalizer: work on %s", node); + } else { + Debug.log("Canonicalizer: replacing %s with %s", node, canonical); + METRIC_CANONICALIZED_NODES.increment(); if (node instanceof FloatingNode) { if (canonical == null) { @@ -122,6 +125,7 @@ nodeWorkList.addAll(graph.getNewNodes()); } } else if (node instanceof Simplifiable) { + Debug.log("Canonicalizer: simplifying %s", node); METRIC_SIMPLIFICATION_CONSIDERED_NODES.increment(); ((Simplifiable) node).simplify(tool); }
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/util/InliningUtil.java Wed May 02 14:39:45 2012 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/util/InliningUtil.java Wed May 02 15:08:41 2012 +0200 @@ -26,10 +26,6 @@ import java.util.*; import java.util.concurrent.*; -import com.oracle.max.cri.ci.*; -import com.oracle.max.cri.ri.*; -import com.oracle.max.cri.ri.RiType.Representation; -import com.oracle.max.cri.ri.RiTypeProfile.ProfiledType; import com.oracle.graal.compiler.*; import com.oracle.graal.compiler.phases.*; import com.oracle.graal.cri.*; @@ -41,7 +37,11 @@ import com.oracle.graal.nodes.extended.*; import com.oracle.graal.nodes.java.*; import com.oracle.graal.nodes.java.MethodCallTargetNode.InvokeKind; +import com.oracle.graal.nodes.type.*; import com.oracle.graal.nodes.util.*; +import com.oracle.max.cri.ci.*; +import com.oracle.max.cri.ri.*; +import com.oracle.max.cri.ri.RiTypeProfile.ProfiledType; public class InliningUtil { @@ -194,8 +194,8 @@ AnchorNode anchor = graph.add(new AnchorNode()); assert invoke.predecessor() != null; - CheckCastNode checkCast = createAnchoredReceiver(graph, runtime, anchor, type, receiver); - invoke.callTarget().replaceFirstInput(receiver, checkCast); + ValueNode anchoredReceiver = createAnchoredReceiver(graph, anchor, type, receiver); + invoke.callTarget().replaceFirstInput(receiver, anchoredReceiver); graph.addBeforeFixed(invoke.node(), objectClass); graph.addBeforeFixed(invoke.node(), guard); @@ -347,8 +347,8 @@ RiResolvedType commonType = getLeastCommonType(i); ValueNode receiver = invokeForInlining.callTarget().receiver(); - CheckCastNode checkCast = createAnchoredReceiver(graph, runtime, node, commonType, receiver); - invokeForInlining.callTarget().replaceFirstInput(receiver, checkCast); + ValueNode anchoredReceiver = createAnchoredReceiver(graph, node, commonType, receiver); + invokeForInlining.callTarget().replaceFirstInput(receiver, anchoredReceiver); RiResolvedMethod concrete = concretes.get(i); StructuredGraph calleeGraph = getGraph(concrete, callback); @@ -690,11 +690,9 @@ } } - private static CheckCastNode createAnchoredReceiver(StructuredGraph graph, GraalRuntime runtime, FixedNode anchor, RiResolvedType commonType, ValueNode receiver) { + private static ValueNode createAnchoredReceiver(StructuredGraph graph, FixedNode anchor, RiResolvedType commonType, ValueNode receiver) { // to avoid that floating reads on receiver fields float above the type check - ConstantNode typeConst = graph.unique(ConstantNode.forCiConstant(commonType.getEncoding(Representation.ObjectHub), runtime, graph)); - CheckCastNode checkCast = graph.unique(new CheckCastNode(anchor, typeConst, commonType, receiver, false)); - return checkCast; + return graph.unique(new PiNode(receiver, anchor, StampFactory.declaredNonNull(commonType))); } private static boolean checkInvokeConditions(Invoke invoke) {
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/PiNode.java Wed May 02 14:39:45 2012 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/PiNode.java Wed May 02 15:08:41 2012 +0200 @@ -30,17 +30,17 @@ public class PiNode extends FloatingNode implements LIRLowerable { @Input private ValueNode object; - @Input private BeginNode anchor; + @Input(notDataflow = true) private final FixedNode anchor; public ValueNode object() { return object; } - public BeginNode anchor() { + public FixedNode anchor() { return anchor; } - public PiNode(ValueNode object, BeginNode anchor, Stamp stamp) { + public PiNode(ValueNode object, FixedNode anchor, Stamp stamp) { super(stamp); this.object = object; this.anchor = anchor;
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/NullCheckNode.java Wed May 02 14:39:45 2012 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/NullCheckNode.java Wed May 02 15:08:41 2012 +0200 @@ -28,6 +28,10 @@ import com.oracle.graal.nodes.spi.types.*; import com.oracle.graal.nodes.type.*; +/** + * A NullCheckNode will be true if the supplied value is non-null, and false if it is null. + * This behavior can be inverted by setting {@link #expectedNull} to true. + */ public final class NullCheckNode extends BooleanNode implements Canonicalizable, LIRLowerable, ConditionalTypeFeedbackProvider, TypeCanonicalizable { @Input private ValueNode object;
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java Wed May 02 14:39:45 2012 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java Wed May 02 15:08:41 2012 +0200 @@ -40,16 +40,11 @@ public final class CheckCastNode extends TypeCheckNode implements Canonicalizable, LIRLowerable, Node.IterableNodeType, TypeFeedbackProvider, TypeCanonicalizable { @Input(notDataflow = true) protected final FixedNode anchor; - protected final boolean emitCode; public FixedNode anchor() { return anchor; } - public boolean emitCode() { - return emitCode; - } - /** * Creates a new CheckCast instruction. * @@ -61,18 +56,9 @@ this(anchor, targetClassInstruction, targetClass, object, EMPTY_HINTS, false); } - public CheckCastNode(FixedNode anchor, ValueNode targetClassInstruction, RiResolvedType targetClass, ValueNode object, boolean emitCode) { - this(anchor, targetClassInstruction, targetClass, object, EMPTY_HINTS, false, emitCode); - } - public CheckCastNode(FixedNode anchor, ValueNode targetClassInstruction, RiResolvedType targetClass, ValueNode object, RiResolvedType[] hints, boolean hintsExact) { - this(anchor, targetClassInstruction, targetClass, object, hints, hintsExact, true); - } - - private CheckCastNode(FixedNode anchor, ValueNode targetClassInstruction, RiResolvedType targetClass, ValueNode object, RiResolvedType[] hints, boolean hintsExact, boolean emitCode) { super(targetClassInstruction, targetClass, object, hints, hintsExact, targetClass == null ? StampFactory.forKind(CiKind.Object) : StampFactory.declared(targetClass)); this.anchor = anchor; - this.emitCode = emitCode; } @Override @@ -82,12 +68,16 @@ @Override public ValueNode canonical(CanonicalizerTool tool) { + assert object() != null : this; + RiResolvedType objectDeclaredType = object().declaredType(); RiResolvedType targetClass = targetClass(); if (objectDeclaredType != null && targetClass != null && objectDeclaredType.isSubtypeOf(targetClass)) { + // we don't have to check for null types here because they will also pass the checkcast. freeAnchor(); return object(); } + CiConstant constant = object().asConstant(); if (constant != null) { assert constant.kind == CiKind.Object;
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/InstanceOfNode.java Wed May 02 14:39:45 2012 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/InstanceOfNode.java Wed May 02 15:08:41 2012 +0200 @@ -65,17 +65,44 @@ @Override public ValueNode canonical(CanonicalizerTool tool) { assert object() != null : this; + RiResolvedType exact = object().exactType(); if (exact != null) { - boolean result = exact.isSubtypeOf(targetClass()); - if (result != negated) { - // The instanceof check reduces to a null check. - return graph().unique(new NullCheckNode(object(), false)); + boolean subType = exact.isSubtypeOf(targetClass()); + + if (subType) { + if (object().stamp().nonNull()) { + // the instanceOf matches, so return true (or false, for the negated case) + return ConstantNode.forBoolean(!negated, graph()); + } else { + // the instanceof matches if the object is non-null, so return true (or false, for the negated case) depending on the null-ness. + return graph().unique(new NullCheckNode(object(), negated)); + } } else { - // The instanceof check can never succeed. - return ConstantNode.forBoolean(false, graph()); + // since this type check failed for an exact type we know that it can never succeed at run time. + // we also don't care about null values, since they will also make the check fail. + // so return false (or true, for the negated case) + return ConstantNode.forBoolean(negated, graph()); + } + } else { + RiResolvedType declared = object().declaredType(); + if (declared != null) { + boolean subType = declared.isSubtypeOf(targetClass()); + + if (subType) { + if (object().stamp().nonNull()) { + // the instanceOf matches, so return true (or false, for the negated case) + return ConstantNode.forBoolean(!negated, graph()); + } else { + // the instanceof matches if the object is non-null, so return true (or false, for the negated case) depending on the null-ness. + return graph().unique(new NullCheckNode(object(), negated)); + } + } else { + // since the subtype comparison was only performed on a declared type we don't really know if it might be true at run time... + } } } + CiConstant constant = object().asConstant(); if (constant != null) { assert constant.kind == CiKind.Object;
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/StampFactory.java Wed May 02 14:39:45 2012 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/StampFactory.java Wed May 02 15:08:41 2012 +0200 @@ -232,7 +232,7 @@ public static Stamp declared(final RiResolvedType type) { assert type != null; assert type.kind(false) == CiKind.Object; - return new BasicValueStamp(CiKind.Object, false, type, null); + return new BasicValueStamp(CiKind.Object, false, type, type.exactType()); } public static Stamp declaredNonNull(final RiResolvedType type) {
--- a/src/share/vm/runtime/globals.hpp Wed May 02 14:39:45 2012 +0200 +++ b/src/share/vm/runtime/globals.hpp Wed May 02 15:08:41 2012 +0200 @@ -2507,7 +2507,7 @@ product(intx, CICompilerCount, CI_COMPILER_COUNT, \ "Number of compiler threads to run") \ \ - product(intx, CompilationPolicyChoice, NOT_GRAAL(0) GRAAL_ONLY(0), \ + product(intx, CompilationPolicyChoice, NOT_GRAAL(0) GRAAL_ONLY(4), \ "which compilation policy (0/1)") \ \ develop(bool, UseStackBanging, true, \