# HG changeset patch # User Christos Kotselidis # Date 1364522733 -3600 # Node ID 0bacc5564d18b7ae67d38d3b3c5845806ada4f30 # Parent 1c181c2cfb68b743ae8aac6933613c227cb4b3e5 Revert WB refactoring diff -r 1c181c2cfb68 -r 0bacc5564d18 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Thu Mar 28 23:57:27 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Fri Mar 29 03:05:33 2013 +0100 @@ -610,12 +610,18 @@ FixedWithNextNode first = memoryWrite; if (field.getKind() == Kind.Object && !memoryWrite.value().objectStamp().alwaysNull()) { - WriteBarrierPre writeBarrierPre = graph.add(new WriteBarrierPre(memoryWrite.object(), null, memoryWrite.location(), true)); - WriteBarrierPost writeBarrierPost = graph.add(new WriteBarrierPost(memoryWrite.object(), memoryWrite.value(), memoryWrite.location(), false)); - graph.addBeforeFixed(memoryWrite, writeBarrierPre); - graph.addAfterFixed(memoryWrite, writeBarrierPost); - first = writeBarrierPre; - last = writeBarrierPost; + if (config.useG1GC) { + WriteBarrierPre writeBarrierPre = graph.add(new WriteBarrierPre(memoryWrite.object(), null, memoryWrite.location(), true)); + WriteBarrierPost writeBarrierPost = graph.add(new WriteBarrierPost(memoryWrite.object(), memoryWrite.value(), memoryWrite.location(), false)); + graph.addBeforeFixed(memoryWrite, writeBarrierPre); + graph.addAfterFixed(memoryWrite, writeBarrierPost); + first = writeBarrierPre; + last = writeBarrierPost; + } else { + FieldWriteBarrier writeBarrier = graph.add(new FieldWriteBarrier(memoryWrite.object())); + graph.addAfterFixed(memoryWrite, writeBarrier); + last = writeBarrier; + } } if (storeField.isVolatile()) { MembarNode preMembar = graph.add(new MembarNode(JMM_PRE_VOLATILE_WRITE)); @@ -630,14 +636,25 @@ LocationNode location = IndexedLocationNode.create(LocationNode.ANY_LOCATION, cas.expected().kind(), cas.displacement(), cas.offset(), graph, 1); if (expected.kind() == Kind.Object && !cas.newValue().objectStamp().alwaysNull()) { ResolvedJavaType type = cas.object().objectStamp().type(); - WriteBarrierPre writeBarrierPre = graph.add(new WriteBarrierPre(cas.object(), null, location, true)); - graph.addBeforeFixed(cas, writeBarrierPre); if (type != null && !type.isArray() && !MetaUtil.isJavaLangObject(type)) { - WriteBarrierPost writeBarrierPost = graph.add(new WriteBarrierPost(cas.object(), cas.newValue(), location, false)); - graph.addAfterFixed(cas, writeBarrierPost); + // Use a field write barrier since it's not an array store + if (config.useG1GC) { + WriteBarrierPre writeBarrierPre = graph.add(new WriteBarrierPre(cas.object(), null, location, true)); + WriteBarrierPost writeBarrierPost = graph.add(new WriteBarrierPost(cas.object(), cas.newValue(), location, false)); + graph.addBeforeFixed(cas, writeBarrierPre); + graph.addAfterFixed(cas, writeBarrierPost); + } else { + graph.addAfterFixed(cas, graph.add(new FieldWriteBarrier(cas.object()))); + } } else { - WriteBarrierPost writeBarrierPost = graph.add(new WriteBarrierPost(cas.object(), cas.newValue(), location, true)); - graph.addAfterFixed(cas, writeBarrierPost); + // This may be an array store so use an array write barrier + if (config.useG1GC) { + WriteBarrierPre writeBarrierPre = graph.add(new WriteBarrierPre(cas.object(), null, location, true)); + graph.addBeforeFixed(cas, writeBarrierPre); + graph.addAfterFixed(cas, graph.add(new WriteBarrierPost(cas.object(), cas.newValue(), location, true))); + } else { + graph.addAfterFixed(cas, graph.add(new ArrayWriteBarrier(cas.object(), location))); + } } } } else if (n instanceof LoadIndexedNode) { @@ -681,10 +698,14 @@ graph.replaceFixedWithFixed(storeIndexed, memoryWrite); if (elementKind == Kind.Object && !value.objectStamp().alwaysNull()) { - WriteBarrierPre writeBarrierPre = graph.add(new WriteBarrierPre(array, null, arrayLocation, true)); - graph.addBeforeFixed(memoryWrite, writeBarrierPre); - WriteBarrierPost writeBarrierPost = graph.add(new WriteBarrierPost(array, value, arrayLocation, true)); - graph.addAfterFixed(memoryWrite, writeBarrierPost); + if (config.useG1GC) { + WriteBarrierPre writeBarrierPre = graph.add(new WriteBarrierPre(array, null, arrayLocation, true)); + graph.addBeforeFixed(memoryWrite, writeBarrierPre); + WriteBarrierPost writeBarrierPost = graph.add(new WriteBarrierPost(array, value, arrayLocation, true)); + graph.addAfterFixed(memoryWrite, writeBarrierPost); + } else { + graph.addAfterFixed(memoryWrite, graph.add(new ArrayWriteBarrier(array, arrayLocation))); + } } } else if (n instanceof UnsafeLoadNode) { UnsafeLoadNode load = (UnsafeLoadNode) n; @@ -704,12 +725,25 @@ graph.replaceFixedWithFixed(store, write); if (write.value().kind() == Kind.Object && !write.value().objectStamp().alwaysNull()) { ResolvedJavaType type = object.objectStamp().type(); - WriteBarrierPre writeBarrierPre = new WriteBarrierPre(object, null, location, true); - graph.addBeforeFixed(write, graph.add(writeBarrierPre)); + // WriteBarrier writeBarrier; if (type != null && !type.isArray() && !MetaUtil.isJavaLangObject(type)) { - graph.addAfterFixed(write, graph.add(new WriteBarrierPost(object, write.value(), location, false))); + // Use a field write barrier since it's not an array store + if (config.useG1GC) { + WriteBarrierPre writeBarrierPre = new WriteBarrierPre(object, null, location, true); + graph.addBeforeFixed(write, graph.add(writeBarrierPre)); + graph.addAfterFixed(write, graph.add(new WriteBarrierPost(object, write.value(), location, false))); + } else { + graph.addAfterFixed(write, graph.add(new FieldWriteBarrier(object))); + } } else { - graph.addAfterFixed(write, graph.add(new WriteBarrierPost(object, write.value(), location, true))); + // This may be an array store so use an array write barrier + if (config.useG1GC) { + WriteBarrierPre writeBarrierPre = graph.add(new WriteBarrierPre(object, null, location, true)); + graph.addBeforeFixed(write, writeBarrierPre); + graph.addAfterFixed(write, graph.add(new WriteBarrierPost(object, write.value(), location, true))); + } else { + graph.addAfterFixed(write, graph.add(new ArrayWriteBarrier(object, location))); + } } } } else if (n instanceof LoadHubNode) { @@ -742,12 +776,14 @@ monitorSnippets.lower((MonitorEnterNode) n, tool); } else if (n instanceof MonitorExitNode) { monitorSnippets.lower((MonitorExitNode) n, tool); - } else if (n instanceof SerialWriteBarrierPost) { - writeBarrierSnippets.lower((SerialWriteBarrierPost) n, tool); - } else if (n instanceof G1WriteBarrierPre) { - writeBarrierSnippets.lower((G1WriteBarrierPre) n, tool); - } else if (n instanceof G1WriteBarrierPost) { - writeBarrierSnippets.lower((G1WriteBarrierPost) n, tool); + } else if (n instanceof FieldWriteBarrier) { + writeBarrierSnippets.lower((FieldWriteBarrier) n, tool); + } else if (n instanceof ArrayWriteBarrier) { + writeBarrierSnippets.lower((ArrayWriteBarrier) n, tool); + } else if (n instanceof WriteBarrierPre) { + writeBarrierSnippets.lower((WriteBarrierPre) n, tool); + } else if (n instanceof WriteBarrierPost) { + writeBarrierSnippets.lower((WriteBarrierPost) n, tool); } else if (n instanceof TLABAllocateNode) { newObjectSnippets.lower((TLABAllocateNode) n, tool); } else if (n instanceof InitializeObjectNode) { diff -r 1c181c2cfb68 -r 0bacc5564d18 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/ArrayWriteBarrier.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/ArrayWriteBarrier.java Fri Mar 29 03:05:33 2013 +0100 @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.hotspot.nodes; + +import com.oracle.graal.nodes.*; +import com.oracle.graal.nodes.extended.*; +import com.oracle.graal.nodes.spi.*; +import com.oracle.graal.nodes.type.*; + +public final class ArrayWriteBarrier extends FixedWithNextNode implements Lowerable { + + @Input private ValueNode object; + @Input private LocationNode location; + + public ValueNode getObject() { + return object; + } + + public LocationNode getLocation() { + return location; + } + + public ArrayWriteBarrier(ValueNode object, LocationNode location) { + super(StampFactory.forVoid()); + this.object = object; + this.location = location; + } + + public void lower(LoweringTool generator) { + generator.getRuntime().lower(this, generator); + } +} diff -r 1c181c2cfb68 -r 0bacc5564d18 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/FieldWriteBarrier.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/FieldWriteBarrier.java Fri Mar 29 03:05:33 2013 +0100 @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.hotspot.nodes; + +import com.oracle.graal.nodes.*; +import com.oracle.graal.nodes.spi.*; +import com.oracle.graal.nodes.type.*; + +public final class FieldWriteBarrier extends FixedWithNextNode implements Lowerable { + + @Input private ValueNode object; + + public ValueNode getObject() { + return object; + } + + public FieldWriteBarrier(ValueNode object) { + super(StampFactory.forVoid()); + this.object = object; + } + + public void lower(LoweringTool generator) { + generator.getRuntime().lower(this, generator); + } +} diff -r 1c181c2cfb68 -r 0bacc5564d18 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/G1WriteBarrierPost.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/G1WriteBarrierPost.java Thu Mar 28 23:57:27 2013 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.oracle.graal.hotspot.nodes; - -import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.extended.*; -import com.oracle.graal.nodes.spi.*; - -public class G1WriteBarrierPost extends WriteBarrierPost implements Lowerable { - - @Input private ValueNode object; - @Input private ValueNode value; - @Input private LocationNode location; - private final boolean precise; - - @Override - public ValueNode getObject() { - return object; - } - - @Override - public ValueNode getValue() { - return value; - } - - @Override - public LocationNode getLocation() { - return location; - } - - @Override - public boolean usePrecise() { - return precise; - } - - public G1WriteBarrierPost(ValueNode object, ValueNode value, LocationNode location, boolean precise) { - this.object = object; - this.value = value; - this.location = location; - this.precise = precise; - } - - @Override - public void lower(LoweringTool generator) { - generator.getRuntime().lower(this, generator); - } - -} diff -r 1c181c2cfb68 -r 0bacc5564d18 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/G1WriteBarrierPre.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/G1WriteBarrierPre.java Thu Mar 28 23:57:27 2013 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.oracle.graal.hotspot.nodes; - -import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.extended.*; -import com.oracle.graal.nodes.spi.*; - -public final class G1WriteBarrierPre extends WriteBarrierPre implements Lowerable { - - @Input private ValueNode object; - @Input private LocationNode location; - @Input private ValueNode expectedObject; - private final boolean doLoad; - - @Override - public ValueNode getObject() { - return object; - } - - @Override - public ValueNode getExpectedObject() { - return expectedObject; - } - - @Override - public boolean doLoad() { - return doLoad; - } - - @Override - public LocationNode getLocation() { - return location; - } - - public G1WriteBarrierPre(ValueNode object, ValueNode expectedObject, LocationNode location, boolean doLoad) { - this.object = object; - this.doLoad = doLoad; - this.location = location; - this.expectedObject = expectedObject; - } - - @Override - public void lower(LoweringTool generator) { - generator.getRuntime().lower(this, generator); - } - -} diff -r 1c181c2cfb68 -r 0bacc5564d18 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/SerialWriteBarrierPost.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/SerialWriteBarrierPost.java Thu Mar 28 23:57:27 2013 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.oracle.graal.hotspot.nodes; - -import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.extended.*; -import com.oracle.graal.nodes.spi.*; - -public class SerialWriteBarrierPost extends WriteBarrierPost implements Lowerable { - - @Input private ValueNode object; - @Input private LocationNode location; - private final boolean usePrecise; - - public SerialWriteBarrierPost(ValueNode object, LocationNode location, boolean usePrecise) { - this.object = object; - this.location = location; - this.usePrecise = usePrecise; - } - - @Override - public ValueNode getObject() { - return object; - } - - @Override - public LocationNode getLocation() { - return location; - } - - @Override - public boolean usePrecise() { - return usePrecise; - } - - @Override - public void lower(LoweringTool generator) { - generator.getRuntime().lower(this, generator); - } - -} diff -r 1c181c2cfb68 -r 0bacc5564d18 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/WriteBarrierPost.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/WriteBarrierPost.java Thu Mar 28 23:57:27 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/WriteBarrierPost.java Fri Mar 29 03:05:33 2013 +0100 @@ -22,19 +22,17 @@ */ package com.oracle.graal.hotspot.nodes; -import static com.oracle.graal.hotspot.replacements.HotSpotSnippetUtils.*; - -import com.oracle.graal.api.meta.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.extended.*; import com.oracle.graal.nodes.spi.*; +import com.oracle.graal.nodes.type.*; -public class WriteBarrierPost extends WriteBarrier implements Lowerable { +public final class WriteBarrierPost extends FixedWithNextNode implements Lowerable { @Input private ValueNode object; @Input private ValueNode value; - @Input private ValueNode index; @Input private LocationNode location; + @Input private ValueNode length; private final boolean precise; public ValueNode getObject() { @@ -45,6 +43,10 @@ return value; } + public ValueNode getLength() { + return length; + } + public LocationNode getLocation() { return location; } @@ -53,45 +55,15 @@ return precise; } - public WriteBarrierPost() { - this.precise = false; - } - - public WriteBarrierPost(ValueNode object, ValueNode value, ValueNode index) { - this.object = object; - this.value = value; - this.index = index; - this.precise = true; - this.location = null; - } - public WriteBarrierPost(ValueNode object, ValueNode value, LocationNode location, boolean precise) { + super(StampFactory.forVoid()); this.object = object; this.value = value; this.location = location; this.precise = precise; } - @Override public void lower(LoweringTool generator) { - StructuredGraph graph = (StructuredGraph) this.graph(); - if (location == null) { // Come from array copy intrinsic - LocationNode arrayLocation = IndexedLocationNode.create(LocationNode.getArrayLocation(Kind.Object), Kind.Object, arrayBaseOffset(Kind.Object), index, graph, arrayIndexScale(Kind.Object)); - if (useG1GC()) { - graph.replaceFixedWithFixed(this, graph().add(new G1WriteBarrierPost(object, value, arrayLocation, true))); - } else { - graph.replaceFixedWithFixed(this, graph().add(new SerialWriteBarrierPost(object, arrayLocation, true))); - } - } else { // Normal WriteBarrier - assert location != null; - if (useG1GC()) { - graph.replaceFixedWithFixed(this, graph().add(new G1WriteBarrierPost(object, value, location, precise))); - } else { - graph.replaceFixedWithFixed(this, graph().add(new SerialWriteBarrierPost(object, location, precise))); - } - } + generator.getRuntime().lower(this, generator); } - - @NodeIntrinsic - public static native void arrayCopyWriteBarrier(Object array, Object value, long index); } diff -r 1c181c2cfb68 -r 0bacc5564d18 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/WriteBarrierPre.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/WriteBarrierPre.java Thu Mar 28 23:57:27 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/WriteBarrierPre.java Fri Mar 29 03:05:33 2013 +0100 @@ -22,13 +22,12 @@ */ package com.oracle.graal.hotspot.nodes; -import static com.oracle.graal.hotspot.replacements.HotSpotSnippetUtils.*; - import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.extended.*; import com.oracle.graal.nodes.spi.*; +import com.oracle.graal.nodes.type.*; -public class WriteBarrierPre extends WriteBarrier implements Lowerable { +public final class WriteBarrierPre extends FixedWithNextNode implements Lowerable { @Input private ValueNode object; @Input private LocationNode location; @@ -51,25 +50,16 @@ return location; } - public WriteBarrierPre() { - this.doLoad = false; - } - public WriteBarrierPre(ValueNode object, ValueNode expectedObject, LocationNode location, boolean doLoad) { + super(StampFactory.forVoid()); this.object = object; this.doLoad = doLoad; this.location = location; this.expectedObject = expectedObject; } - @Override public void lower(LoweringTool generator) { - StructuredGraph graph = (StructuredGraph) this.graph(); - if (useG1GC()) { - graph.replaceFixedWithFixed(this, graph().add(new G1WriteBarrierPre(getObject(), getExpectedObject(), getLocation(), doLoad()))); - } else { - graph.removeFixed(this); - } + generator.getRuntime().lower(this, generator); } } diff -r 1c181c2cfb68 -r 0bacc5564d18 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ArrayCopySnippets.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ArrayCopySnippets.java Thu Mar 28 23:57:27 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ArrayCopySnippets.java Fri Mar 29 03:05:33 2013 +0100 @@ -37,7 +37,7 @@ import com.oracle.graal.nodes.java.*; import com.oracle.graal.phases.*; import com.oracle.graal.replacements.*; -import com.oracle.graal.replacements.Snippet.ConstantParameter; +import com.oracle.graal.replacements.Snippet.*; import com.oracle.graal.replacements.nodes.*; import com.oracle.graal.word.*; @@ -256,6 +256,7 @@ for (long i = 0; i < end; i += scale) { Object a = UnsafeLoadNode.load(src, header, i + (long) srcPos * scale, Kind.Object); DirectObjectStoreNode.storeObject(dest, header, i + (long) destPos * scale, a); + } } if (length > 0) { diff -r 1c181c2cfb68 -r 0bacc5564d18 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/WriteBarrierSnippets.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/WriteBarrierSnippets.java Thu Mar 28 23:57:27 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/WriteBarrierSnippets.java Fri Mar 29 03:05:33 2013 +0100 @@ -40,7 +40,7 @@ public class WriteBarrierSnippets implements Snippets { @Snippet - public static void g1WriteBarrierPre(@Parameter("object") Object obj, @Parameter("expectedObject") Object expobj, @Parameter("location") Object location, + public static void g1PreWriteBarrier(@Parameter("object") Object obj, @Parameter("expectedObject") Object expobj, @Parameter("location") Object location, @ConstantParameter("doLoad") boolean doLoad) { Word thread = thread(); Object object = FixedValueAnchorNode.getObject(obj); @@ -48,9 +48,11 @@ Word field = (Word) Word.fromArray(object, location); Word previousOop = (Word) Word.fromObject(expectedObject); byte markingValue = thread.readByte(HotSpotSnippetUtils.g1SATBQueueMarkingOffset()); + Word bufferAddress = thread.readWord(HotSpotSnippetUtils.g1SATBQueueBufferOffset()); Word indexAddress = thread.add(HotSpotSnippetUtils.g1SATBQueueIndexOffset()); Word indexValue = indexAddress.readWord(0); + if (markingValue != (byte) 0) { if (doLoad) { previousOop = field.readWord(0); @@ -63,13 +65,14 @@ indexAddress.writeWord(0, nextIndex); } else { WriteBarrierPreStubCall.call(previousOop); + } } } } @Snippet - public static void g1WriteBarrierPost(@Parameter("object") Object obj, @Parameter("value") Object value, @Parameter("location") Object location, @ConstantParameter("usePrecise") boolean usePrecise) { + public static void g1PostWriteBarrier(@Parameter("object") Object obj, @Parameter("value") Object value, @Parameter("location") Object location, @ConstantParameter("usePrecise") boolean usePrecise) { Word thread = thread(); Object object = FixedValueAnchorNode.getObject(obj); Object wrObject = FixedValueAnchorNode.getObject(value); @@ -96,6 +99,7 @@ cardBase = cardBase.add(Word.unsigned(cardTableStart())); } Word cardAddress = cardBase.add(displacement); + if (xorResult.notEqual(Word.zero())) { if (writtenValue.notEqual(Word.zero())) { byte cardByte = cardAddress.readByte(0); @@ -115,14 +119,24 @@ } @Snippet - public static void serialWriteBarrierPost(@Parameter("object") Object obj, @Parameter("location") Object location, @ConstantParameter("usePrecise") boolean usePrecise) { + public static void serialFieldWriteBarrier(@Parameter("object") Object obj) { Object object = FixedValueAnchorNode.getObject(obj); - Pointer oop; - if (usePrecise) { - oop = Word.fromArray(object, location); + Pointer oop = Word.fromObject(object); + Word base = (Word) oop.unsignedShiftRight(cardTableShift()); + long startAddress = cardTableStart(); + int displacement = 0; + if (((int) startAddress) == startAddress) { + displacement = (int) startAddress; } else { - oop = Word.fromObject(object); + base = base.add(Word.unsigned(cardTableStart())); } + base.writeByte(displacement, (byte) 0); + } + + @Snippet + public static void serialArrayWriteBarrier(@Parameter("object") Object obj, @Parameter("location") Object location) { + Object object = FixedValueAnchorNode.getObject(obj); + Pointer oop = Word.fromArray(object, location); Word base = (Word) oop.unsignedShiftRight(cardTableShift()); long startAddress = cardTableStart(); int displacement = 0; @@ -136,30 +150,40 @@ public static class Templates extends AbstractTemplates { - private final ResolvedJavaMethod serialWriteBarrierPost; - private final ResolvedJavaMethod g1WriteBarrierPre; - private final ResolvedJavaMethod g1WriteBarrierPost; + private final ResolvedJavaMethod serialFieldWriteBarrier; + private final ResolvedJavaMethod serialArrayWriteBarrier; + private final ResolvedJavaMethod g1PreWriteBarrier; + private final ResolvedJavaMethod g1PostWriteBarrier; public Templates(CodeCacheProvider runtime, Assumptions assumptions, TargetDescription target) { super(runtime, assumptions, target, WriteBarrierSnippets.class); - serialWriteBarrierPost = snippet("serialWriteBarrierPost", Object.class, Object.class, boolean.class); - g1WriteBarrierPre = snippet("g1WriteBarrierPre", Object.class, Object.class, Object.class, boolean.class); - g1WriteBarrierPost = snippet("g1WriteBarrierPost", Object.class, Object.class, Object.class, boolean.class); + serialFieldWriteBarrier = snippet("serialFieldWriteBarrier", Object.class); + serialArrayWriteBarrier = snippet("serialArrayWriteBarrier", Object.class, Object.class); + g1PreWriteBarrier = snippet("g1PreWriteBarrier", Object.class, Object.class, Object.class, boolean.class); + g1PostWriteBarrier = snippet("g1PostWriteBarrier", Object.class, Object.class, Object.class, boolean.class); } - public void lower(SerialWriteBarrierPost fieldWriteBarrier, @SuppressWarnings("unused") LoweringTool tool) { - ResolvedJavaMethod method = serialWriteBarrierPost; + public void lower(ArrayWriteBarrier arrayWriteBarrier, @SuppressWarnings("unused") LoweringTool tool) { + ResolvedJavaMethod method = serialArrayWriteBarrier; Key key = new Key(method); - key.add("usePrecise", fieldWriteBarrier.usePrecise()); + Arguments arguments = new Arguments(); + arguments.add("object", arrayWriteBarrier.getObject()); + arguments.add("location", arrayWriteBarrier.getLocation()); + SnippetTemplate template = cache.get(key, assumptions); + template.instantiate(runtime, arrayWriteBarrier, DEFAULT_REPLACER, arguments); + } + + public void lower(FieldWriteBarrier fieldWriteBarrier, @SuppressWarnings("unused") LoweringTool tool) { + ResolvedJavaMethod method = serialFieldWriteBarrier; + Key key = new Key(method); Arguments arguments = new Arguments(); arguments.add("object", fieldWriteBarrier.getObject()); - arguments.add("location", fieldWriteBarrier.getLocation()); SnippetTemplate template = cache.get(key, assumptions); template.instantiate(runtime, fieldWriteBarrier, DEFAULT_REPLACER, arguments); } - public void lower(G1WriteBarrierPre writeBarrierPre, @SuppressWarnings("unused") LoweringTool tool) { - ResolvedJavaMethod method = g1WriteBarrierPre; + public void lower(WriteBarrierPre writeBarrierPre, @SuppressWarnings("unused") LoweringTool tool) { + ResolvedJavaMethod method = g1PreWriteBarrier; Key key = new Key(method); key.add("doLoad", writeBarrierPre.doLoad()); Arguments arguments = new Arguments(); @@ -170,8 +194,8 @@ template.instantiate(runtime, writeBarrierPre, DEFAULT_REPLACER, arguments); } - public void lower(G1WriteBarrierPost writeBarrierPost, @SuppressWarnings("unused") LoweringTool tool) { - ResolvedJavaMethod method = g1WriteBarrierPost; + public void lower(WriteBarrierPost writeBarrierPost, @SuppressWarnings("unused") LoweringTool tool) { + ResolvedJavaMethod method = g1PostWriteBarrier; Key key = new Key(method); key.add("usePrecise", writeBarrierPost.usePrecise()); Arguments arguments = new Arguments();