# HG changeset patch # User Roland Schatz # Date 1373898243 -7200 # Node ID e82c28e94f08110bdd42f8063c310a460facd88d # Parent f4f46b734a4c73f0bb95bcc06344cabe96b50929 Don't add G1 prebarrier if the written location is uninitialized. diff -r f4f46b734a4c -r e82c28e94f08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/WriteBarrierAdditionPhase.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/WriteBarrierAdditionPhase.java Mon Jul 15 15:29:01 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/WriteBarrierAdditionPhase.java Mon Jul 15 16:24:03 2013 +0200 @@ -69,10 +69,12 @@ WriteBarrierType barrierType = node.getWriteBarrierType(); if (barrierType == WriteBarrierType.PRECISE) { if (useG1GC()) { - G1PreWriteBarrier preBarrier = graph.add(new G1PreWriteBarrier(node.object(), null, node.location(), true, node.getNullCheck())); - preBarrier.setDeoptimizationState(node.getDeoptimizationState()); - node.setNullCheck(false); - graph.addBeforeFixed(node, preBarrier); + if (node.isInitialized()) { + G1PreWriteBarrier preBarrier = graph.add(new G1PreWriteBarrier(node.object(), null, node.location(), true, node.getNullCheck())); + preBarrier.setDeoptimizationState(node.getDeoptimizationState()); + node.setNullCheck(false); + graph.addBeforeFixed(node, preBarrier); + } graph.addAfterFixed(node, graph.add(new G1PostWriteBarrier(node.object(), node.value(), node.location(), true))); } else { graph.addAfterFixed(node, graph.add(new SerialWriteBarrier(node.object(), node.location(), true))); @@ -116,9 +118,11 @@ private static void addArrayRangeBarriers(ArrayRangeWriteNode node, StructuredGraph graph) { if (useG1GC()) { - G1ArrayRangePreWriteBarrier g1ArrayRangePreWriteBarrier = graph.add(new G1ArrayRangePreWriteBarrier(node.getArray(), node.getIndex(), node.getLength())); + if (node.isInitialized()) { + G1ArrayRangePreWriteBarrier g1ArrayRangePreWriteBarrier = graph.add(new G1ArrayRangePreWriteBarrier(node.getArray(), node.getIndex(), node.getLength())); + graph.addBeforeFixed(node, g1ArrayRangePreWriteBarrier); + } G1ArrayRangePostWriteBarrier g1ArrayRangePostWriteBarrier = graph.add(new G1ArrayRangePostWriteBarrier(node.getArray(), node.getIndex(), node.getLength())); - graph.addBeforeFixed(node, g1ArrayRangePreWriteBarrier); graph.addAfterFixed(node, g1ArrayRangePostWriteBarrier); } else { SerialArrayRangeWriteBarrier serialArrayRangeWriteBarrier = graph.add(new SerialArrayRangeWriteBarrier(node.getArray(), node.getIndex(), node.getLength())); diff -r f4f46b734a4c -r e82c28e94f08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/UnsafeArrayCopyNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/UnsafeArrayCopyNode.java Mon Jul 15 15:29:01 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/UnsafeArrayCopyNode.java Mon Jul 15 16:24:03 2013 +0200 @@ -82,6 +82,11 @@ return elementKind == Kind.Object; } + @Override + public boolean isInitialized() { + return true; + } + public Kind getElementKind() { return elementKind; } diff -r f4f46b734a4c -r e82c28e94f08 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ArrayRangeWriteNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ArrayRangeWriteNode.java Mon Jul 15 15:29:01 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ArrayRangeWriteNode.java Mon Jul 15 16:24:03 2013 +0200 @@ -54,4 +54,10 @@ * Return true if the written array is an object array, false if it is a primitive array. */ public abstract boolean isObjectArray(); + + /** + * If {@link #isInitialized()} is true, the memory location contains a valid value. If + * {@link #isInitialized()} is false, the memory location is uninitialized or zero. + */ + public abstract boolean isInitialized(); } diff -r f4f46b734a4c -r e82c28e94f08 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/WriteNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/WriteNode.java Mon Jul 15 15:29:01 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/WriteNode.java Mon Jul 15 16:24:03 2013 +0200 @@ -37,6 +37,7 @@ @Input private ValueNode value; @Input(notDataflow = true) private FrameState stateAfter; + private final boolean initialized; public FrameState stateAfter() { return stateAfter; @@ -56,9 +57,22 @@ return value; } + /** + * If {@link #isInitialized()} is true, the memory location contains a valid value. If + * {@link #isInitialized()} is false, the memory location is uninitialized or zero. + */ + public boolean isInitialized() { + return initialized; + } + public WriteNode(ValueNode object, ValueNode value, ValueNode location, WriteBarrierType barrierType, boolean compress) { + this(object, value, location, barrierType, compress, true); + } + + public WriteNode(ValueNode object, ValueNode value, ValueNode location, WriteBarrierType barrierType, boolean compress, boolean initialized) { super(object, location, StampFactory.forVoid(), barrierType, compress); this.value = value; + this.initialized = initialized; } @Override