# HG changeset patch # User Christos Kotselidis # Date 1382721851 -7200 # Node ID b81405d42861dfba8edca6cd347511839d3ba7a4 # Parent a2340324fc7951defce560add6eae30d497214ae# Parent 7328f7def427a2f04b8708cedfe5bd704a4ef0a4 Merge diff -r 7328f7def427 -r b81405d42861 graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/WriteBarrierAdditionTest.java --- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/WriteBarrierAdditionTest.java Fri Oct 25 15:44:35 2013 +0200 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/WriteBarrierAdditionTest.java Fri Oct 25 19:24:11 2013 +0200 @@ -73,13 +73,7 @@ */ @Test public void test1() throws Exception { - int expectedBarriers = 0; - if (useG1GC()) { - expectedBarriers = (useDeferredInitBarriers() ? 0 : 4); - } else { - expectedBarriers = (useDeferredInitBarriers() ? 0 : 2); - } - test("test1Snippet", expectedBarriers); + test("test1Snippet", (useG1GC()) ? 4 : 2); } public static void test1Snippet() { @@ -95,13 +89,7 @@ */ @Test public void test2() throws Exception { - int expectedBarriers = 0; - if (useG1GC()) { - expectedBarriers = (useDeferredInitBarriers() ? 0 : 8); - } else { - expectedBarriers = (useDeferredInitBarriers() ? 0 : 4); - } - test("test2Snippet", expectedBarriers); + test("test2Snippet", (useG1GC()) ? 8 : 4); } public static void test2Snippet(boolean test) { @@ -147,13 +135,7 @@ */ @Test public void test4() throws Exception { - int expectedBarriers = 0; - if (useG1GC()) { - expectedBarriers = (useDeferredInitBarriers() ? 1 : 5); - } else { - expectedBarriers = (useDeferredInitBarriers() ? 0 : 2); - } - test("test4Snippet", expectedBarriers); + test("test4Snippet", (useG1GC()) ? 5 : 2); } public static Object test4Snippet() { diff -r 7328f7def427 -r b81405d42861 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotHostLoweringProvider.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotHostLoweringProvider.java Fri Oct 25 15:44:35 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotHostLoweringProvider.java Fri Oct 25 19:24:11 2013 +0200 @@ -33,6 +33,8 @@ import static com.oracle.graal.nodes.java.ArrayLengthNode.*; import static com.oracle.graal.phases.GraalOptions.*; +import java.util.*; + import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.*; @@ -296,61 +298,95 @@ } else if (n instanceof CommitAllocationNode) { if (graph.getGuardsStage() == StructuredGraph.GuardsStage.FIXED_DEOPTS) { CommitAllocationNode commit = (CommitAllocationNode) n; - ValueNode[] allocations = new ValueNode[commit.getVirtualObjects().size()]; - for (int objIndex = 0; objIndex < commit.getVirtualObjects().size(); objIndex++) { - VirtualObjectNode virtual = commit.getVirtualObjects().get(objIndex); - int entryCount = virtual.entryCount(); - - FixedWithNextNode newObject; - if (virtual instanceof VirtualInstanceNode) { - newObject = graph.add(new NewInstanceNode(virtual.type(), true)); - } else { - ResolvedJavaType element = ((VirtualArrayNode) virtual).componentType(); - newObject = graph.add(new NewArrayNode(element, ConstantNode.forInt(entryCount, graph), true)); - } - graph.addBeforeFixed(commit, newObject); - allocations[objIndex] = newObject; - } + BitSet omittedValues = new BitSet(); int valuePos = 0; for (int objIndex = 0; objIndex < commit.getVirtualObjects().size(); objIndex++) { VirtualObjectNode virtual = commit.getVirtualObjects().get(objIndex); int entryCount = virtual.entryCount(); - - ValueNode newObject = allocations[objIndex]; + FixedWithNextNode newObject; if (virtual instanceof VirtualInstanceNode) { - VirtualInstanceNode virtualInstance = (VirtualInstanceNode) virtual; + newObject = graph.add(new NewInstanceNode(virtual.type(), true)); + graph.addBeforeFixed(commit, newObject); + allocations[objIndex] = newObject; for (int i = 0; i < entryCount; i++) { - ValueNode value = commit.getValues().get(valuePos++); + ValueNode value = commit.getValues().get(valuePos); + if (value instanceof VirtualObjectNode) { + value = allocations[commit.getVirtualObjects().indexOf(value)]; + } + if (value == null) { + omittedValues.set(valuePos); + } else if (!(value.isConstant() && value.asConstant().isDefaultForKind())) { + VirtualInstanceNode virtualInstance = (VirtualInstanceNode) virtual; + WriteNode write = new WriteNode(newObject, value, createFieldLocation(graph, (HotSpotResolvedJavaField) virtualInstance.field(i), true), + (virtualInstance.field(i).getKind() == Kind.Object && !useDeferredInitBarriers()) ? BarrierType.IMPRECISE : BarrierType.NONE, + virtualInstance.field(i).getKind() == Kind.Object); + graph.addAfterFixed(newObject, graph.add(write)); + } + valuePos++; + } + } else { + ResolvedJavaType element = ((VirtualArrayNode) virtual).componentType(); + newObject = graph.add(new NewArrayNode(element, ConstantNode.forInt(entryCount, graph), true)); + graph.addBeforeFixed(commit, newObject); + allocations[objIndex] = newObject; + for (int i = 0; i < entryCount; i++) { + ValueNode value = commit.getValues().get(valuePos); if (value instanceof VirtualObjectNode) { value = allocations[commit.getVirtualObjects().indexOf(value)]; } - if (!(value.isConstant() && value.asConstant().isDefaultForKind())) { - WriteNode write = new WriteNode(newObject, value, createFieldLocation(graph, (HotSpotResolvedJavaField) virtualInstance.field(i), true), - (virtualInstance.field(i).getKind() == Kind.Object && !deferInitBarrier(newObject)) ? BarrierType.IMPRECISE : BarrierType.NONE, - virtualInstance.field(i).getKind() == Kind.Object); - graph.addBeforeFixed(commit, graph.add(write)); + if (value == null) { + omittedValues.set(valuePos); + } else if (!(value.isConstant() && value.asConstant().isDefaultForKind())) { + WriteNode write = new WriteNode(newObject, value, createArrayLocation(graph, element.getKind(), ConstantNode.forInt(i, graph), true), + (value.kind() == Kind.Object && !useDeferredInitBarriers()) ? BarrierType.PRECISE : BarrierType.NONE, value.kind() == Kind.Object); + graph.addAfterFixed(newObject, graph.add(write)); } - } - - } else { - VirtualArrayNode array = (VirtualArrayNode) virtual; - ResolvedJavaType element = array.componentType(); - for (int i = 0; i < entryCount; i++) { - ValueNode value = commit.getValues().get(valuePos++); - if (value instanceof VirtualObjectNode) { - int indexOf = commit.getVirtualObjects().indexOf(value); - assert indexOf != -1 : commit + " " + value; - value = allocations[indexOf]; - } - if (!(value.isConstant() && value.asConstant().isDefaultForKind())) { - WriteNode write = new WriteNode(newObject, value, createArrayLocation(graph, element.getKind(), ConstantNode.forInt(i, graph), true), - (value.kind() == Kind.Object && !deferInitBarrier(newObject)) ? BarrierType.PRECISE : BarrierType.NONE, value.kind() == Kind.Object); - graph.addBeforeFixed(commit, graph.add(write)); - } + valuePos++; } } } + valuePos = 0; + + for (int objIndex = 0; objIndex < commit.getVirtualObjects().size(); objIndex++) { + VirtualObjectNode virtual = commit.getVirtualObjects().get(objIndex); + int entryCount = virtual.entryCount(); + ValueNode newObject = allocations[objIndex]; + if (virtual instanceof VirtualInstanceNode) { + for (int i = 0; i < entryCount; i++) { + if (omittedValues.get(valuePos)) { + ValueNode value = commit.getValues().get(valuePos); + assert value instanceof VirtualObjectNode; + ValueNode allocValue = allocations[commit.getVirtualObjects().indexOf(value)]; + if (!(allocValue.isConstant() && allocValue.asConstant().isDefaultForKind())) { + VirtualInstanceNode virtualInstance = (VirtualInstanceNode) virtual; + assert virtualInstance.field(i).getKind() == Kind.Object; + WriteNode write = new WriteNode(newObject, allocValue, createFieldLocation(graph, (HotSpotResolvedJavaField) virtualInstance.field(i), true), + BarrierType.IMPRECISE, true); + graph.addBeforeFixed(commit, graph.add(write)); + } + } + valuePos++; + } + } else { + ResolvedJavaType element = ((VirtualArrayNode) virtual).componentType(); + for (int i = 0; i < entryCount; i++) { + if (omittedValues.get(valuePos)) { + ValueNode value = commit.getValues().get(valuePos); + assert value instanceof VirtualObjectNode; + ValueNode allocValue = allocations[commit.getVirtualObjects().indexOf(value)]; + if (!(allocValue.isConstant() && allocValue.asConstant().isDefaultForKind())) { + assert allocValue.kind() == Kind.Object; + WriteNode write = new WriteNode(newObject, allocValue, createArrayLocation(graph, element.getKind(), ConstantNode.forInt(i, graph), true), BarrierType.PRECISE, + true); + graph.addBeforeFixed(commit, graph.add(write)); + } + } + valuePos++; + } + } + } + for (int objIndex = 0; objIndex < commit.getVirtualObjects().size(); objIndex++) { FixedValueAnchorNode anchor = graph.add(new FixedValueAnchorNode(allocations[objIndex])); allocations[objIndex] = anchor; @@ -549,7 +585,7 @@ private static BarrierType getFieldStoreBarrierType(StoreFieldNode storeField) { BarrierType barrierType = BarrierType.NONE; - if (storeField.field().getKind() == Kind.Object && !deferInitBarrier(storeField.object())) { + if (storeField.field().getKind() == Kind.Object) { barrierType = BarrierType.IMPRECISE; } return barrierType; @@ -557,16 +593,12 @@ private static BarrierType getArrayStoreBarrierType(StoreIndexedNode store) { BarrierType barrierType = BarrierType.NONE; - if (store.elementKind() == Kind.Object && !deferInitBarrier(store.array())) { + if (store.elementKind() == Kind.Object) { barrierType = BarrierType.PRECISE; } return barrierType; } - private static boolean deferInitBarrier(ValueNode object) { - return useDeferredInitBarriers() && (object instanceof NewInstanceNode || object instanceof NewArrayNode); - } - private static BarrierType getUnsafeStoreBarrierType(UnsafeStoreNode store) { BarrierType barrierType = BarrierType.NONE; if (store.value().kind() == Kind.Object) { diff -r 7328f7def427 -r b81405d42861 mx/commands.py --- a/mx/commands.py Fri Oct 25 15:44:35 2013 +0200 +++ b/mx/commands.py Fri Oct 25 19:24:11 2013 +0200 @@ -961,7 +961,7 @@ with VM('graal', 'product'): t = Task('BootstrapWithG1GCVerification:product') out = mx.DuplicateSuppressingStream(['VerifyAfterGC:', 'VerifyBeforeGC:']).write - vm(['-XX:+UnlockDiagnosticVMOptions', '-XX:-UseSerialGC', '-XX:+UseG1GC', '-XX:+UseNewCode', '-XX:+VerifyBeforeGC', '-XX:+VerifyAfterGC', '-version'], out=out) + vm(['-XX:+UnlockDiagnosticVMOptions', '-XX:-UseSerialGC', '-XX:+UseG1GC', '-XX:+VerifyBeforeGC', '-XX:+VerifyAfterGC', '-version'], out=out) tasks.append(t.stop()) with VM('graal', 'product'): diff -r 7328f7def427 -r b81405d42861 src/share/vm/graal/graalGlobals.hpp --- a/src/share/vm/graal/graalGlobals.hpp Fri Oct 25 15:44:35 2013 +0200 +++ b/src/share/vm/graal/graalGlobals.hpp Fri Oct 25 19:24:11 2013 +0200 @@ -55,7 +55,7 @@ product(intx, TraceGraal, 0, \ "Trace level for Graal") \ \ - product(bool, GraalDeferredInitBarriers, false, \ + product(bool, GraalDeferredInitBarriers, true, \ "Defer write barriers of young objects") \ \ develop(bool, GraalUseFastLocking, true, \