# HG changeset patch # User Thomas Wuerthinger # Date 1359650741 -3600 # Node ID f1dfa977e2c1b873cf7688623689c955a6cac3e3 # Parent 4b746e9da3b3d8d850d629f89de8a7ed7653a762# Parent e3e8090cb46acbef17bc095c0279c1974c28996f Merge. diff -r 4b746e9da3b3 -r f1dfa977e2c1 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/DebugInfoBuilder.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/DebugInfoBuilder.java Thu Jan 31 17:45:25 2013 +0100 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/DebugInfoBuilder.java Thu Jan 31 17:45:41 2013 +0100 @@ -148,6 +148,7 @@ throw new GraalInternalError("no mapping found for virtual object %s", obj); } if (state instanceof MaterializedObjectState) { + assert !(((MaterializedObjectState) state).materializedValue() instanceof VirtualObjectNode); return toValue(((MaterializedObjectState) state).materializedValue()); } else { assert obj.entryCount() == 0 || state instanceof VirtualObjectState || obj instanceof BoxedVirtualObjectNode; diff -r 4b746e9da3b3 -r f1dfa977e2c1 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/NewArrayNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/NewArrayNode.java Thu Jan 31 17:45:25 2013 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/NewArrayNode.java Thu Jan 31 17:45:41 2013 +0100 @@ -31,7 +31,7 @@ /** * The {@code NewArrayNode} class is the base of all instructions that allocate arrays. */ -public abstract class NewArrayNode extends FixedWithNextNode implements Lowerable, VirtualizableAllocation, ArrayLengthProvider { +public abstract class NewArrayNode extends FixedWithNextNode implements Canonicalizable, Lowerable, VirtualizableAllocation, ArrayLengthProvider { @Input private ValueNode length; private final ResolvedJavaType elementType; @@ -100,6 +100,15 @@ } @Override + public ValueNode canonical(CanonicalizerTool tool) { + if (usages().isEmpty() && length.integerStamp().isPositive()) { + return null; + } else { + return this; + } + } + + @Override public void lower(LoweringTool tool) { tool.getRuntime().lower(this, tool); } diff -r 4b746e9da3b3 -r f1dfa977e2c1 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/NewInstanceNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/NewInstanceNode.java Thu Jan 31 17:45:25 2013 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/NewInstanceNode.java Thu Jan 31 17:45:41 2013 +0100 @@ -33,7 +33,7 @@ * The {@code NewInstanceNode} represents the allocation of an instance class object. */ @NodeInfo(nameTemplate = "New {p#instanceClass/s}") -public final class NewInstanceNode extends FixedWithNextNode implements VirtualizableAllocation, Lowerable, Node.IterableNodeType { +public final class NewInstanceNode extends FixedWithNextNode implements Node.IterableNodeType, Canonicalizable, Lowerable, VirtualizableAllocation { private final ResolvedJavaType instanceClass; private final boolean fillContents; @@ -78,6 +78,15 @@ } @Override + public ValueNode canonical(CanonicalizerTool tool) { + if (usages().isEmpty()) { + return null; + } else { + return this; + } + } + + @Override public void lower(LoweringTool tool) { tool.getRuntime().lower(this, tool); } diff -r 4b746e9da3b3 -r f1dfa977e2c1 graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/nodes/MaterializeObjectNode.java --- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/nodes/MaterializeObjectNode.java Thu Jan 31 17:45:25 2013 +0100 +++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/nodes/MaterializeObjectNode.java Thu Jan 31 17:45:41 2013 +0100 @@ -54,10 +54,11 @@ return ConstantNode.forInt(values.size(), graph()); } - @Override - public void lower(LoweringTool tool) { - StructuredGraph graph = (StructuredGraph) graph(); - + /** + * @return true if the object that will be created is without locks and has only entries that + * are {@link Constant#defaultForKind(Kind)}, false otherwise. + */ + public boolean isDefault() { boolean defaultEntries = true; if (lockCount > 0) { defaultEntries = false; @@ -69,6 +70,14 @@ } } } + return defaultEntries; + } + + @Override + public void lower(LoweringTool tool) { + StructuredGraph graph = (StructuredGraph) graph(); + + boolean defaultEntries = isDefault(); if (virtualObject instanceof VirtualInstanceNode) { VirtualInstanceNode virtual = (VirtualInstanceNode) virtualObject;