Mercurial > hg > graal-compiler
changeset 23233:7ba20dadcc84
Remove simplification for AbstractNewObjectNode. This optimization is handled by partial escape analysis.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Fri, 01 Jan 2016 15:36:22 +0100 |
parents | 9787a53c5345 |
children | c46d6c55f921 |
files | graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/AbstractNewArrayNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/AbstractNewObjectNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/DynamicNewArrayNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/DynamicNewInstanceNode.java |
diffstat | 4 files changed, 1 insertions(+), 90 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/AbstractNewArrayNode.java Fri Jan 01 15:29:38 2016 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/AbstractNewArrayNode.java Fri Jan 01 15:36:22 2016 +0100 @@ -22,10 +22,8 @@ */ package com.oracle.graal.nodes.java; -import com.oracle.graal.compiler.common.type.IntegerStamp; import com.oracle.graal.compiler.common.type.Stamp; import com.oracle.graal.graph.NodeClass; -import com.oracle.graal.graph.spi.SimplifierTool; import com.oracle.graal.nodeinfo.NodeInfo; import com.oracle.graal.nodes.FrameState; import com.oracle.graal.nodes.ValueNode; @@ -64,13 +62,4 @@ public int dimensionCount() { return 1; } - - @Override - public void simplify(SimplifierTool tool) { - Stamp lengthStamp = length.stamp(); - if (lengthStamp instanceof IntegerStamp && ((IntegerStamp) lengthStamp).isPositive()) { - // otherwise, removing the allocation might swallow a NegativeArraySizeException - super.simplify(tool); - } - } }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/AbstractNewObjectNode.java Fri Jan 01 15:29:38 2016 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/AbstractNewObjectNode.java Fri Jan 01 15:36:22 2016 +0100 @@ -22,20 +22,11 @@ */ package com.oracle.graal.nodes.java; -import java.util.List; - import com.oracle.graal.compiler.common.type.Stamp; -import com.oracle.graal.graph.Node; import com.oracle.graal.graph.NodeClass; -import com.oracle.graal.graph.spi.Simplifiable; -import com.oracle.graal.graph.spi.SimplifierTool; import com.oracle.graal.nodeinfo.NodeInfo; import com.oracle.graal.nodes.DeoptimizingFixedWithNextNode; -import com.oracle.graal.nodes.FixedWithNextNode; import com.oracle.graal.nodes.FrameState; -import com.oracle.graal.nodes.extended.FixedValueAnchorNode; -import com.oracle.graal.nodes.memory.WriteNode; -import com.oracle.graal.nodes.memory.address.OffsetAddressNode; import com.oracle.graal.nodes.spi.Lowerable; import com.oracle.graal.nodes.spi.LoweringTool; @@ -43,7 +34,7 @@ * The {@code AbstractNewObjectNode} is the base class for the new instance and new array nodes. */ @NodeInfo -public abstract class AbstractNewObjectNode extends DeoptimizingFixedWithNextNode implements Simplifiable, Lowerable { +public abstract class AbstractNewObjectNode extends DeoptimizingFixedWithNextNode implements Lowerable { public static final NodeClass<AbstractNewObjectNode> TYPE = NodeClass.create(AbstractNewObjectNode.class); protected final boolean fillContents; @@ -61,56 +52,6 @@ } @Override - public void simplify(SimplifierTool tool) { - // poor man's escape analysis: check if the object can be trivially removed - for (Node usage : usages()) { - if (usage instanceof FixedValueAnchorNode) { - if (((FixedValueAnchorNode) usage).usages().isNotEmpty()) { - return; - } - } else if (usage instanceof OffsetAddressNode) { - if (((OffsetAddressNode) usage).getBase() != this) { - return; - } - for (Node access : usage.usages()) { - if (access instanceof WriteNode) { - if (access.usages().isNotEmpty()) { - // we would need to fix up the memory graph if the write has usages - return; - } - } else { - return; - } - } - } else { - return; - } - } - for (Node usage : usages().distinct().snapshot()) { - if (usage instanceof OffsetAddressNode) { - for (Node access : usage.usages().snapshot()) { - removeUsage(tool, (FixedWithNextNode) access); - } - } else { - removeUsage(tool, (FixedWithNextNode) usage); - } - } - List<Node> snapshot = inputs().snapshot(); - graph().removeFixed(this); - for (Node input : snapshot) { - tool.removeIfUnused(input); - } - } - - private void removeUsage(SimplifierTool tool, FixedWithNextNode usage) { - List<Node> snapshot = usage.inputs().snapshot(); - graph().removeFixed(usage); - for (Node input : snapshot) { - tool.removeIfUnused(input); - } - } - - @Override public void lower(LoweringTool tool) { tool.getLowerer().lower(this, tool); }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/DynamicNewArrayNode.java Fri Jan 01 15:29:38 2016 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/DynamicNewArrayNode.java Fri Jan 01 15:36:22 2016 +0100 @@ -33,7 +33,6 @@ import com.oracle.graal.graph.NodeClass; import com.oracle.graal.graph.spi.Canonicalizable; import com.oracle.graal.graph.spi.CanonicalizerTool; -import com.oracle.graal.graph.spi.SimplifierTool; import com.oracle.graal.nodeinfo.NodeInfo; import com.oracle.graal.nodes.FrameState; import com.oracle.graal.nodes.ValueNode; @@ -87,15 +86,6 @@ } @Override - public void simplify(SimplifierTool tool) { - /* - * Do not call the super implementation: we must not eliminate unused allocations because - * throwing a NullPointerException or IllegalArgumentException is a possible side effect of - * an unused allocation. - */ - } - - @Override public Node canonical(CanonicalizerTool tool) { if (elementType.isConstant()) { ResolvedJavaType type = tool.getConstantReflection().asJavaType(elementType.asConstant());
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/DynamicNewInstanceNode.java Fri Jan 01 15:29:38 2016 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/DynamicNewInstanceNode.java Fri Jan 01 15:36:22 2016 +0100 @@ -32,7 +32,6 @@ import com.oracle.graal.graph.NodeClass; import com.oracle.graal.graph.spi.Canonicalizable; import com.oracle.graal.graph.spi.CanonicalizerTool; -import com.oracle.graal.graph.spi.SimplifierTool; import com.oracle.graal.nodeinfo.NodeInfo; import com.oracle.graal.nodes.FrameState; import com.oracle.graal.nodes.ValueNode; @@ -57,14 +56,6 @@ } @Override - public void simplify(SimplifierTool tool) { - /* - * Do not call the super implementation: we must not eliminate unused allocations because - * throwing an InstantiationException is a possible side effect of an unused allocation. - */ - } - - @Override public Node canonical(CanonicalizerTool tool) { if (clazz.isConstant()) { ResolvedJavaType type = tool.getConstantReflection().asJavaType(clazz.asConstant());