# HG changeset patch # User Christos Kotselidis # Date 1363950504 -3600 # Node ID c92949b1ec8a467051260f4f3ca36ab296d0a2e5 # Parent c3657d00e343c110c86990cd00ecc227355e763d -Changes after CR-243 diff -r c3657d00e343 -r c92949b1ec8a 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 21 14:11:13 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Fri Mar 22 12:08:24 2013 +0100 @@ -588,8 +588,7 @@ memoryRead.dependencies().add(tool.createNullCheckGuard(object)); graph.replaceFixedWithFixed(loadField, memoryRead); - if (HotSpotSnippetUtils.useG1GC() && field.getKind() == Kind.Object && field.getDeclaringClass().getName().toString().equals("Ljava/lang/ref/Reference;") && - field.getName().equals("referent")) { + if (config.useG1GC && field.getKind() == Kind.Object && field.getDeclaringClass().getName().toString().equals("Ljava/lang/ref/Reference;") && field.getName().equals("referent")) { WriteBarrierPre writeBarrierPre = graph.add(new WriteBarrierPre(memoryRead.object(), memoryRead, location, false)); graph.addAfterFixed(memoryRead, writeBarrierPre); } @@ -613,17 +612,17 @@ FixedWithNextNode first = memoryWrite; if (field.getKind() == Kind.Object && !memoryWrite.value().objectStamp().alwaysNull()) { - if (!HotSpotSnippetUtils.useG1GC()) { - FieldWriteBarrier writeBarrier = graph.add(new FieldWriteBarrier(memoryWrite.object())); - graph.addAfterFixed(memoryWrite, writeBarrier); - last = writeBarrier; - } else { + 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()) { @@ -641,23 +640,23 @@ ResolvedJavaType type = cas.object().objectStamp().type(); if (type != null && !type.isArray() && !MetaUtil.isJavaLangObject(type)) { // Use a field write barrier since it's not an array store - if (!HotSpotSnippetUtils.useG1GC()) { - FieldWriteBarrier writeBarrier = graph.add(new FieldWriteBarrier(cas.object())); - graph.addAfterFixed(cas, writeBarrier); - } else { + 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 { + FieldWriteBarrier writeBarrier = graph.add(new FieldWriteBarrier(cas.object())); + graph.addAfterFixed(cas, writeBarrier); } } else { // This may be an array store so use an array write barrier - if (!HotSpotSnippetUtils.useG1GC()) { - graph.addAfterFixed(cas, graph.add(new ArrayWriteBarrier(cas.object(), (IndexedLocationNode) location))); - } else { + 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(), (IndexedLocationNode) location))); } } } @@ -703,13 +702,13 @@ graph.replaceFixedWithFixed(storeIndexed, memoryWrite); if (elementKind == Kind.Object && !value.objectStamp().alwaysNull()) { - if (!HotSpotSnippetUtils.useG1GC()) { - graph.addAfterFixed(memoryWrite, graph.add(new ArrayWriteBarrier(array, (IndexedLocationNode) arrayLocation))); - } else { + 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, (IndexedLocationNode) arrayLocation))); } } } else if (n instanceof UnsafeLoadNode) { @@ -733,23 +732,23 @@ // WriteBarrier writeBarrier; if (type != null && !type.isArray() && !MetaUtil.isJavaLangObject(type)) { // Use a field write barrier since it's not an array store - if (!HotSpotSnippetUtils.useG1GC()) { - FieldWriteBarrier writeBarrier = graph.add(new FieldWriteBarrier(object)); - graph.addAfterFixed(write, writeBarrier); - } else { + 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 { + FieldWriteBarrier writeBarrier = graph.add(new FieldWriteBarrier(object)); + graph.addAfterFixed(write, writeBarrier); } } else { // This may be an array store so use an array write barrier - if (!HotSpotSnippetUtils.useG1GC()) { - ArrayWriteBarrier writeBarrier = graph.add(new ArrayWriteBarrier(object, location)); - graph.addAfterFixed(write, writeBarrier); - } else { + 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 { + ArrayWriteBarrier writeBarrier = graph.add(new ArrayWriteBarrier(object, location)); + graph.addAfterFixed(write, writeBarrier); } } } diff -r c3657d00e343 -r c92949b1ec8a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/InitializeArrayNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/InitializeArrayNode.java Thu Mar 21 14:11:13 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/InitializeArrayNode.java Fri Mar 22 12:08:24 2013 +0100 @@ -73,6 +73,8 @@ } public boolean fillContents() { + // We fill contents when G1 GC is used since we want to record + // the original field values prior to stores return HotSpotSnippetUtils.useG1GC() ? true : fillContents; } diff -r c3657d00e343 -r c92949b1ec8a 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 21 14:11:13 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/WriteBarrierPost.java Fri Mar 22 12:08:24 2013 +0100 @@ -32,17 +32,17 @@ @Input private ValueNode object; @Input private ValueNode value; @Input private LocationNode location; - private boolean precise; + private final boolean precise; - public ValueNode object() { + public ValueNode getObject() { return object; } - public ValueNode value() { + public ValueNode getValue() { return value; } - public LocationNode location() { + public LocationNode getLocation() { return location; } diff -r c3657d00e343 -r c92949b1ec8a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/WriteBarrierPostStubCall.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/WriteBarrierPostStubCall.java Thu Mar 21 14:11:13 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/WriteBarrierPostStubCall.java Fri Mar 22 12:08:24 2013 +0100 @@ -35,8 +35,8 @@ */ public class WriteBarrierPostStubCall extends FixedWithNextNode implements LIRGenLowerable { - @Input private final ValueNode object; - @Input private final ValueNode card; + @Input private ValueNode object; + @Input private ValueNode card; public static final Descriptor WBPOSTCALL = new Descriptor("wbpostcall", true, void.class, Object.class, Word.class); public WriteBarrierPostStubCall(ValueNode object, ValueNode card) { diff -r c3657d00e343 -r c92949b1ec8a 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 21 14:11:13 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/WriteBarrierPre.java Fri Mar 22 12:08:24 2013 +0100 @@ -32,13 +32,13 @@ @Input private ValueNode object; @Input private LocationNode location; @Input private ValueNode expectedObject; - private boolean doLoad; + private final boolean doLoad; - public ValueNode object() { + public ValueNode getObject() { return object; } - public ValueNode expectedObject() { + public ValueNode getExpectedObject() { return expectedObject; } @@ -46,7 +46,7 @@ return doLoad; } - public LocationNode location() { + public LocationNode getLocation() { return location; } diff -r c3657d00e343 -r c92949b1ec8a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/WriteBarrierPreStubCall.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/WriteBarrierPreStubCall.java Thu Mar 21 14:11:13 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/WriteBarrierPreStubCall.java Fri Mar 22 12:08:24 2013 +0100 @@ -34,7 +34,7 @@ */ public class WriteBarrierPreStubCall extends FixedWithNextNode implements LIRGenLowerable { - @Input private final ValueNode object; + @Input private ValueNode object; public static final Descriptor WBPRECALL = new Descriptor("wbprecall", true, void.class, Object.class); public WriteBarrierPreStubCall(ValueNode object) { diff -r c3657d00e343 -r c92949b1ec8a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/WriteBarrierStubCall.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/WriteBarrierStubCall.java Thu Mar 21 14:11:13 2013 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +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.api.code.*; -import com.oracle.graal.api.code.RuntimeCallTarget.Descriptor; -import com.oracle.graal.compiler.gen.*; -import com.oracle.graal.compiler.target.*; -import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.type.*; - -/** - * Node implementing a call to HotSpot's {@code graal_monitorenter} stub. - */ -public class WriteBarrierStubCall extends FixedWithNextNode implements LIRGenLowerable { - - @Input private final ValueNode object; - public static final Descriptor G1_WB_SLOW = new Descriptor("g1_wb_slow", true, void.class, Object.class); - - public WriteBarrierStubCall(ValueNode object) { - super(StampFactory.forVoid()); - this.object = object; - } - - @Override - public void generate(LIRGenerator gen) { - RuntimeCallTarget stub = gen.getRuntime().lookupRuntimeCall(WriteBarrierStubCall.G1_WB_SLOW); - gen.emitCall(stub, stub.getCallingConvention(), true, gen.operand(object)); - } - - @NodeIntrinsic - public static native void call(Object hub); -} diff -r c3657d00e343 -r c92949b1ec8a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/WriteBarrierSnippets.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/WriteBarrierSnippets.java Thu Mar 21 14:11:13 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/WriteBarrierSnippets.java Fri Mar 22 12:08:24 2013 +0100 @@ -185,9 +185,9 @@ Key key = new Key(method); key.add("doLoad", writeBarrierPre.doLoad()); Arguments arguments = new Arguments(); - arguments.add("object", writeBarrierPre.object()); - arguments.add("expectedObject", writeBarrierPre.expectedObject()); - arguments.add("location", writeBarrierPre.location()); + arguments.add("object", writeBarrierPre.getObject()); + arguments.add("expectedObject", writeBarrierPre.getExpectedObject()); + arguments.add("location", writeBarrierPre.getLocation()); SnippetTemplate template = cache.get(key, assumptions); template.instantiate(runtime, writeBarrierPre, DEFAULT_REPLACER, arguments); } @@ -197,9 +197,9 @@ Key key = new Key(method); key.add("usePrecise", writeBarrierPost.usePrecise()); Arguments arguments = new Arguments(); - arguments.add("object", writeBarrierPost.object()); - arguments.add("location", writeBarrierPost.location()); - arguments.add("value", writeBarrierPost.value()); + arguments.add("object", writeBarrierPost.getObject()); + arguments.add("location", writeBarrierPost.getLocation()); + arguments.add("value", writeBarrierPost.getValue()); SnippetTemplate template = cache.get(key, assumptions); template.instantiate(runtime, writeBarrierPost, DEFAULT_REPLACER, arguments); } diff -r c3657d00e343 -r c92949b1ec8a graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ComputeAddressNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ComputeAddressNode.java Fri Mar 22 12:08:24 2013 +0100 @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2009, 2011, 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.nodes.extended; + +import com.oracle.graal.api.meta.*; +import com.oracle.graal.nodes.*; +import com.oracle.graal.nodes.calc.*; +import com.oracle.graal.nodes.spi.*; +import com.oracle.graal.nodes.type.*; + +public class ComputeAddressNode extends FloatingNode implements LIRLowerable { + + @Input private ValueNode object; + @Input private ValueNode location; + + public ValueNode getObject() { + return object; + } + + public LocationNode getLocation() { + return (LocationNode) location; + } + + public ComputeAddressNode(ValueNode object, ValueNode location, Stamp stamp) { + super(stamp); + this.object = object; + this.location = location; + } + + @Override + public void generate(LIRGeneratorTool gen) { + Value addr = getLocation().generateLea(gen, getObject()); + gen.setResult(this, addr); + } +} diff -r c3657d00e343 -r c92949b1ec8a graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/GenerateLEANode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/GenerateLEANode.java Thu Mar 21 14:11:13 2013 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2009, 2011, 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.nodes.extended; - -import com.oracle.graal.api.meta.*; -import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.calc.*; -import com.oracle.graal.nodes.spi.*; -import com.oracle.graal.nodes.type.*; - -/** - * The {@code UnsafeCastNode} produces the same value as its input, but with a different type. - */ -public class GenerateLEANode extends FloatingNode implements Canonicalizable, LIRLowerable { - - @Input private ValueNode object; - @Input private ValueNode location; - - public ValueNode object() { - return object; - } - - public LocationNode location() { - return (LocationNode) location; - } - - public GenerateLEANode(ValueNode object, ValueNode location, Stamp stamp) { - super(stamp); - this.object = object; - this.location = location; - } - - @Override - public ValueNode canonical(CanonicalizerTool tool) { - return this; - } - - @Override - public void generate(LIRGeneratorTool gen) { - Value addr = location().generateLea(gen, object()); - gen.setResult(this, addr); - } -} diff -r c3657d00e343 -r c92949b1ec8a graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeRewriterPhase.java --- a/graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeRewriterPhase.java Thu Mar 21 14:11:13 2013 +0100 +++ b/graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeRewriterPhase.java Fri Mar 22 12:08:24 2013 +0100 @@ -178,7 +178,7 @@ case FROM_ARRAY: assert arguments.size() == 2; - replace(invoke, graph.unique(new GenerateLEANode(arguments.get(0), arguments.get(1), StampFactory.forKind(wordKind)))); + replace(invoke, graph.unique(new ComputeAddressNode(arguments.get(0), arguments.get(1), StampFactory.forKind(wordKind)))); break; case TO_OBJECT: diff -r c3657d00e343 -r c92949b1ec8a src/share/vm/gc_implementation/g1/heapRegion.cpp --- a/src/share/vm/gc_implementation/g1/heapRegion.cpp Thu Mar 21 14:11:13 2013 +0100 +++ b/src/share/vm/gc_implementation/g1/heapRegion.cpp Fri Mar 22 12:08:24 2013 +0100 @@ -119,8 +119,6 @@ gclog_or_tty->print_cr("points to obj "PTR_FORMAT" not in the heap", (void*) obj); } else { - printf("Paok VO %d\n", _vo); - HeapRegion* from = _g1h->heap_region_containing((HeapWord*)p); HeapRegion* to = _g1h->heap_region_containing((HeapWord*)obj); gclog_or_tty->print_cr("Field "PTR_FORMAT diff -r c3657d00e343 -r c92949b1ec8a src/share/vm/runtime/arguments.cpp --- a/src/share/vm/runtime/arguments.cpp Thu Mar 21 14:11:13 2013 +0100 +++ b/src/share/vm/runtime/arguments.cpp Fri Mar 22 12:08:24 2013 +0100 @@ -2096,6 +2096,18 @@ // This prevents the flag being set to true by set_ergonomics_flags() FLAG_SET_CMDLINE(bool, UseCompressedKlassPointers, false); } + if (UseG1GC) { + if (IgnoreUnrecognizedVMOptions) { + warning("UseG1GC is still experimental in Graal, use SerialGC instead "); + FLAG_SET_CMDLINE(bool, UseG1GC, true); + } else { + warning("UseG1GC is still experimental in Graal, use SerialGC instead "); + status = true; + } + } else { + // This prevents the flag being set to true by set_ergonomics_flags() + FLAG_SET_CMDLINE(bool, UseG1GC, false); + } if (!ScavengeRootsInCode) { warning("forcing ScavengeRootsInCode non-zero because Graal is enabled");