Mercurial > hg > graal-compiler
changeset 8493:9412b1915547
-More G1 WB Integration-Addition of GenerateLEANode for G1 previous value equalities
author | Christos Kotselidis <christos.kotselidis@oracle.com> |
---|---|
date | Tue, 26 Feb 2013 18:02:06 +0100 |
parents | 286a49d423c9 |
children | 7c9dbc80fd7d |
files | graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/WriteBarrierPre.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/WriteBarrierSnippets.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/GenerateLEANode.java graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeRewriterPhase.java src/share/vm/gc_implementation/g1/g1AllocRegion.hpp src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp src/share/vm/graal/graalCompilerToVM.cpp src/share/vm/memory/universe.cpp src/share/vm/runtime/arguments.cpp |
diffstat | 11 files changed, 177 insertions(+), 62 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Mon Feb 25 11:08:06 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Tue Feb 26 18:02:06 2013 +0100 @@ -614,8 +614,8 @@ graph.addAfterFixed(memoryWrite, writeBarrier); last = writeBarrier; } else { - WriteBarrierPre writeBarrierPre = graph.add(new WriteBarrierPre(memoryWrite.object(), null, null, true)); - WriteBarrierPost writeBarrierPost = graph.add(new WriteBarrierPost(memoryWrite.object(), memoryWrite.value(), null)); + WriteBarrierPre writeBarrierPre = graph.add(new WriteBarrierPre(memoryWrite.object(), LocationNode.create(field, field.getKind(), field.offset(), graph), true)); + WriteBarrierPost writeBarrierPost = graph.add(new WriteBarrierPost(memoryWrite.object(), null, memoryWrite.location())); graph.addBeforeFixed(memoryWrite, writeBarrierPre); graph.addAfterFixed(memoryWrite, writeBarrierPost); last = writeBarrierPost; @@ -640,7 +640,7 @@ FieldWriteBarrier writeBarrier = graph.add(new FieldWriteBarrier(cas.object())); graph.addAfterFixed(cas, writeBarrier); } else { - WriteBarrierPre writeBarrierPre = graph.add(new WriteBarrierPre(cas.object(), cas.expected(), null, false)); + WriteBarrierPre writeBarrierPre = graph.add(new WriteBarrierPre(cas.object(), null, true)); WriteBarrierPost writeBarrierPost = graph.add(new WriteBarrierPost(cas.object(), cas.newValue(), null)); graph.addAfterFixed(cas, writeBarrierPre); graph.addAfterFixed(cas, writeBarrierPost); @@ -651,7 +651,7 @@ if (!config.useG1GC) { graph.addAfterFixed(cas, graph.add(new ArrayWriteBarrier(cas.object(), (IndexedLocationNode) location))); } else { - graph.addBeforeFixed(cas, graph.add(new WriteBarrierPre(cas.object(), cas.expected(), location, false))); + graph.addBeforeFixed(cas, graph.add(new WriteBarrierPre(cas.object(), location, true))); graph.addAfterFixed(cas, graph.add(new WriteBarrierPost(cas.object(), cas.newValue(), location))); } } @@ -702,7 +702,7 @@ if (!config.useG1GC) { graph.addAfterFixed(memoryWrite, graph.add(new ArrayWriteBarrier(array, (IndexedLocationNode) arrayLocation))); } else { - graph.addBeforeFixed(memoryWrite, graph.add(new WriteBarrierPre(array, null, arrayLocation, true))); + graph.addBeforeFixed(memoryWrite, graph.add(new WriteBarrierPre(array, arrayLocation, true))); graph.addAfterFixed(memoryWrite, graph.add(new WriteBarrierPost(array, value, arrayLocation))); } } @@ -731,8 +731,8 @@ FieldWriteBarrier writeBarrier = graph.add(new FieldWriteBarrier(object)); graph.addAfterFixed(write, writeBarrier); } else { - graph.addBeforeFixed(write, graph.add(new WriteBarrierPre(object, null, null, true))); - graph.addAfterFixed(write, graph.add(new WriteBarrierPost(object, write.value(), null))); + graph.addBeforeFixed(write, graph.add(new WriteBarrierPre(object, location, true))); + graph.addAfterFixed(write, graph.add(new WriteBarrierPost(object, write.value(), write.location()))); } } else { // This may be an array store so use an array write barrier @@ -740,7 +740,7 @@ ArrayWriteBarrier writeBarrier = graph.add(new ArrayWriteBarrier(object, location)); graph.addAfterFixed(write, writeBarrier); } else { - graph.addBeforeFixed(write, graph.add(new WriteBarrierPre(object, null, location, true))); + graph.addBeforeFixed(write, graph.add(new WriteBarrierPre(object, location, true))); graph.addAfterFixed(write, graph.add(new WriteBarrierPost(object, store.value(), location))); } }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/WriteBarrierPre.java Mon Feb 25 11:08:06 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/WriteBarrierPre.java Tue Feb 26 18:02:06 2013 +0100 @@ -29,7 +29,6 @@ public final class WriteBarrierPre extends WriteBarrier implements Lowerable { @Input private ValueNode object; - @Input private ValueNode previousValue; @Input private LocationNode location; private boolean doLoad; @@ -37,10 +36,6 @@ return object; } - public ValueNode previousValue() { - return previousValue; - } - public boolean doLoad() { return doLoad; } @@ -49,9 +44,8 @@ return location; } - public WriteBarrierPre(ValueNode object, ValueNode previousValue, LocationNode location, boolean doLoad) { + public WriteBarrierPre(ValueNode object, LocationNode location, boolean doLoad) { this.object = object; - this.previousValue = previousValue; this.doLoad = doLoad; this.location = location; }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/WriteBarrierSnippets.java Mon Feb 25 11:08:06 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/WriteBarrierSnippets.java Tue Feb 26 18:02:06 2013 +0100 @@ -40,42 +40,69 @@ public class WriteBarrierSnippets implements SnippetsInterface { + private static boolean TRACE = false; + @Snippet - public static void g1PreWriteBarrier(@Parameter("object") Object object, @Parameter("previousValue") Word previousValue, @Parameter("doLoad") boolean doLoad) { + public static void g1PreWriteBarrier(@Parameter("object") Object object, @Parameter("location") Object location, @ConstantParameter("doLoad") boolean doLoad) { Word thread = thread(); Pointer oop = Word.fromObject(object); - Word markingAddress = thread.add(HotSpotSnippetUtils.g1SATBQueueMarkingOffset()); - Word bufferAddress = thread.add(HotSpotSnippetUtils.g1SATBQueueBufferOffset()); + Pointer field = Word.fromArray(object, location); + Pointer previousOop = field.readWord(0); + + Word markingAddress = thread.readWord(HotSpotSnippetUtils.g1SATBQueueMarkingOffset()); + Word bufferAddress = thread.readWord(HotSpotSnippetUtils.g1SATBQueueBufferOffset()); Word indexAddress = thread.add(HotSpotSnippetUtils.g1SATBQueueIndexOffset()); - Word prevValue = previousValue; + Word indexValue = thread.readWord(HotSpotSnippetUtils.g1SATBQueueIndexOffset()); - Word marking = markingAddress.readWord(0); - if (marking.notEqual(Word.zero())) { + trace(WriteBarrierSnippets.TRACE, " SATB thread address: 0x%16lx\n", thread); + trace(WriteBarrierSnippets.TRACE, " SATB oop: 0x%16lx\n", oop); + trace(WriteBarrierSnippets.TRACE, " SATB field: 0x%16lx\n", field); + trace(WriteBarrierSnippets.TRACE, " SATB previous OOP: 0x%16lx\n", previousOop); + trace(WriteBarrierSnippets.TRACE, " SATB QueueMarkingOffset: 0x%016lx\n", Word.signed(HotSpotSnippetUtils.g1SATBQueueMarkingOffset())); + trace(WriteBarrierSnippets.TRACE, " SATB QueueBufferOffset: 0x%016lx\n", Word.signed(HotSpotSnippetUtils.g1SATBQueueBufferOffset())); + trace(WriteBarrierSnippets.TRACE, " SATB QueueIndexOffset: 0x%016lx\n", Word.signed(HotSpotSnippetUtils.g1SATBQueueIndexOffset())); + trace(WriteBarrierSnippets.TRACE, " SATB markingAddress: 0x%016lx\n", markingAddress); + trace(WriteBarrierSnippets.TRACE, " SATB bufferAddress: 0x%016lx\n", bufferAddress); + trace(WriteBarrierSnippets.TRACE, " SATB indexAddress: 0x%016lx\n", indexAddress); + trace(WriteBarrierSnippets.TRACE, " SATB indexValue: 0x%016lx\n", indexValue);// in +// bytes + + if (markingAddress.notEqual(Word.zero())) { if (doLoad) { - prevValue = (Word) Word.fromObject(oop.readObject(0)); + previousOop = field.readWord(0); + trace(WriteBarrierSnippets.TRACE, " SATB Do Load previous OOP: 0x%16lx\n", previousOop); } - - if (prevValue.notEqual(Word.zero())) { - if (indexAddress.readInt(0) != 0) { + if (previousOop.notEqual(Word.zero())) { + if (indexValue.readInt(0) != 0) { Word nextIndex = indexAddress.subtract(Word.signed(HotSpotSnippetUtils.wordSize())); Word nextIndexX = nextIndex; Word logAddress = bufferAddress.add(nextIndexX); - logAddress.writeWord(0, prevValue); + logAddress.writeWord(0, previousOop); indexAddress.writeWord(0, nextIndex); + trace(WriteBarrierSnippets.TRACE, " SATB nextIndexindex: 0x%016lx\n", nextIndex); } else { WriteBarrierPostStubCall.call(object); } } } + + trace(WriteBarrierSnippets.TRACE, "---------------SATB Exit: 0x%016lx\n", indexValue); + } @Snippet - public static void g1PostWriteBarrier(@Parameter("object") Object object, @Parameter("value") Word value) { + public static void g1PostWriteBarrier(@Parameter("object") Object object, @Parameter("value") Object value, @Parameter("location") Object location) { Word thread = thread(); Pointer oop = Word.fromObject(object); + Pointer field = Word.fromArray(object, location); + Pointer writtenValue = Word.fromObject(value); - Word bufferAddress = thread.add(HotSpotSnippetUtils.g1CardQueueBufferOffset()); - Word indexAddress = thread.add(HotSpotSnippetUtils.g1CardQueueIndexOffset()); + Word bufferAddress = thread.readWord(HotSpotSnippetUtils.g1CardQueueBufferOffset()); + Word indexAddress = thread.readWord(HotSpotSnippetUtils.g1CardQueueIndexOffset()); + + trace(WriteBarrierSnippets.TRACE, " G1 thread address: 0x%16lx\n", thread); + trace(WriteBarrierSnippets.TRACE, " G1 bufferAddress: 0x%016lx\n", bufferAddress); + trace(WriteBarrierSnippets.TRACE, " G1 indexAddress: 0x%016lx\n", indexAddress); // Card Table Word base = (Word) oop.unsignedShiftRight(cardTableShift()); @@ -87,26 +114,27 @@ base = base.add(Word.unsigned(cardTableStart())); } - if (value.notEqual(0)) { - Word xorResult = (((Word) oop.xor(value)).unsignedShiftRight(HotSpotSnippetUtils.logOfHRGrainBytes())); - if (xorResult.notEqual(Word.zero())) { - if (value.notEqual(Word.zero())) { - Word cardValue = base.readWord(displacement); - if (cardValue.notEqual(Word.zero())) { - base.writeWord(displacement, Word.zero()); // smash zero into card - if (indexAddress.readInt(0) != 0) { - Word nextIndex = indexAddress.subtract(Word.signed(HotSpotSnippetUtils.wordSize())); - Word nextIndexX = nextIndex; - Word logAddress = bufferAddress.add(nextIndexX); - logAddress.writeWord(0, base.add(displacement)); - indexAddress.writeWord(0, nextIndex); - } else { - WriteBarrierPostStubCall.call(object); - } + // if (writtenValue.notEqual(Word.zero())) { + Word xorResult = (((Word) field.xor(writtenValue)).unsignedShiftRight(HotSpotSnippetUtils.logOfHRGrainBytes())); + if (xorResult.notEqual(Word.zero())) { + if (writtenValue.notEqual(Word.zero())) { + Word cardValue = base.readWord(displacement); + if (cardValue.notEqual(Word.zero())) { + base.writeWord(displacement, Word.zero()); // smash zero into card + if (indexAddress.readInt(0) != 0) { + Word nextIndex = indexAddress.subtract(Word.signed(HotSpotSnippetUtils.wordSize())); + Word nextIndexX = nextIndex; + Word logAddress = bufferAddress.add(nextIndexX); + logAddress.writeWord(0, base.add(displacement)); + indexAddress.writeWord(0, nextIndex); + } else { + WriteBarrierPostStubCall.call(object); } } } } + // } else { Object clone intrinsic(?!) + // } } private static void trace(boolean enabled, String format, WordBase value) { @@ -156,9 +184,10 @@ super(runtime, assumptions, target, WriteBarrierSnippets.class); serialFieldWriteBarrier = snippet("serialFieldWriteBarrier", Object.class); serialArrayWriteBarrier = snippet("serialArrayWriteBarrier", Object.class, Object.class); - g1PreWriteBarrier = snippet("g1PreWriteBarrier", Object.class, Word.class, boolean.class); - g1PostWriteBarrier = snippet("g1PostWriteBarrier", Object.class, Word.class); + g1PreWriteBarrier = snippet("g1PreWriteBarrier", Object.class, Object.class, boolean.class); + g1PostWriteBarrier = snippet("g1PostWriteBarrier", Object.class, Object.class, Object.class); this.useG1GC = useG1GC; + System.out.println(" useG1GC? " + (useG1GC ? "true" : "false")); } public void lower(ArrayWriteBarrier arrayWriteBarrier, @SuppressWarnings("unused") LoweringTool tool) { @@ -183,10 +212,10 @@ 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(); arguments.add("object", writeBarrierPre.object()); - arguments.add("previousValue", writeBarrierPre.previousValue()); - arguments.add("doLoad", writeBarrierPre.doLoad()); + arguments.add("location", writeBarrierPre.location()); SnippetTemplate template = cache.get(key, assumptions); template.instantiate(runtime, writeBarrierPre, DEFAULT_REPLACER, arguments); } @@ -196,6 +225,7 @@ Key key = new Key(method); Arguments arguments = new Arguments(); arguments.add("object", writeBarrierPost.object()); + arguments.add("location", writeBarrierPost.location()); arguments.add("value", writeBarrierPost.value()); SnippetTemplate template = cache.get(key, assumptions); template.instantiate(runtime, writeBarrierPost, DEFAULT_REPLACER, arguments);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/GenerateLEANode.java Tue Feb 26 18:02:06 2013 +0100 @@ -0,0 +1,63 @@ +/* + * 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 = gen.emitLea(gen.makeAddress(location(), object())); + gen.setResult(this, addr); + } +}
--- a/graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeRewriterPhase.java Mon Feb 25 11:08:06 2013 +0100 +++ b/graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeRewriterPhase.java Tue Feb 26 18:02:06 2013 +0100 @@ -179,7 +179,7 @@ case FROM_ARRAY: assert arguments.size() == 2; - replace(invoke, graph.unique(new ReadArrayElementAddressNode(arguments.get(0), arguments.get(1), StampFactory.forKind(wordKind)))); + replace(invoke, graph.unique(new GenerateLEANode(arguments.get(0), arguments.get(1), StampFactory.forKind(wordKind)))); break; case TO_OBJECT:
--- a/src/share/vm/gc_implementation/g1/g1AllocRegion.hpp Mon Feb 25 11:08:06 2013 +0100 +++ b/src/share/vm/gc_implementation/g1/g1AllocRegion.hpp Tue Feb 26 18:02:06 2013 +0100 @@ -173,6 +173,15 @@ // Should be called when we want to release the active region which // is returned after it's been retired. HeapRegion* release(); +#ifdef GRAAL + HeapWord** top_addr() const { + return _alloc_region->top_addr(); + } + + HeapWord** end_addr() const { + return _alloc_region->end_addr(); + } +#endif #if G1_ALLOC_REGION_TRACING void trace(const char* str, size_t word_size = 0, HeapWord* result = NULL);
--- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Mon Feb 25 11:08:06 2013 +0100 +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Tue Feb 26 18:02:06 2013 +0100 @@ -2398,6 +2398,17 @@ } #endif // !PRODUCT +#ifdef GRAAL + HeapWord** G1CollectedHeap::top_addr() const { + return _mutator_alloc_region.top_addr(); + } + + HeapWord** G1CollectedHeap::end_addr() const { + return _mutator_alloc_region.end_addr(); + } + +#endif + void G1CollectedHeap::increment_old_marking_cycles_started() { assert(_old_marking_cycles_started == _old_marking_cycles_completed || _old_marking_cycles_started == _old_marking_cycles_completed + 1,
--- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp Mon Feb 25 11:08:06 2013 +0100 +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp Tue Feb 26 18:02:06 2013 +0100 @@ -675,6 +675,15 @@ virtual void gc_prologue(bool full); virtual void gc_epilogue(bool full); + +#ifdef GRAAL + HeapWord** top_addr() const; + + HeapWord** end_addr() const; + +#endif + + // We register a region with the fast "in collection set" test. We // simply set to true the array slot corresponding to this region. void register_region_with_in_cset_fast_test(HeapRegion* r) {
--- a/src/share/vm/graal/graalCompilerToVM.cpp Mon Feb 25 11:08:06 2013 +0100 +++ b/src/share/vm/graal/graalCompilerToVM.cpp Tue Feb 26 18:02:06 2013 +0100 @@ -777,7 +777,9 @@ BarrierSet* bs = Universe::heap()->barrier_set(); switch (bs->kind()) { case BarrierSet::CardTableModRef: - case BarrierSet::CardTableExtension: { + case BarrierSet::CardTableExtension: + case BarrierSet::G1SATBCT: + case BarrierSet::G1SATBCTLogging:{ jlong base = (jlong)((CardTableModRefBS*)bs)->byte_map_base; assert(base != 0, "unexpected byte_map_base"); set_long("cardtableStartAddress", base); @@ -790,10 +792,6 @@ set_int("cardtableShift", 0); // No post barriers break; -#ifndef SERIALGC - case BarrierSet::G1SATBCT: - case BarrierSet::G1SATBCTLogging: -#endif // SERIALGC default: ShouldNotReachHere(); break;
--- a/src/share/vm/memory/universe.cpp Mon Feb 25 11:08:06 2013 +0100 +++ b/src/share/vm/memory/universe.cpp Tue Feb 26 18:02:06 2013 +0100 @@ -750,6 +750,7 @@ #ifndef SERIALGC G1CollectorPolicy* g1p = new G1CollectorPolicy(); G1CollectedHeap* g1h = new G1CollectedHeap(g1p); + printf("MPIKA!"); Universe::_collectedHeap = g1h; #else // SERIALGC fatal("UseG1GC not supported in java kernel vm.");
--- a/src/share/vm/runtime/arguments.cpp Mon Feb 25 11:08:06 2013 +0100 +++ b/src/share/vm/runtime/arguments.cpp Tue Feb 26 18:02:06 2013 +0100 @@ -2064,14 +2064,14 @@ // This prevents the flag being set to true by set_ergonomics_flags() FLAG_SET_CMDLINE(bool, UseCompressedKlassPointers, false); } - if (UseG1GC) { - jio_fprintf(defaultStream::error_stream(), - "G1 is not supported in Graal at the moment\n"); - status = false; - } else { + //if (UseG1GC) { + // jio_fprintf(defaultStream::error_stream(), + // "G1 is not supported in Graal at the moment\n"); + // status = false; + //} else { // This prevents the flag being set to true by set_ergonomics_flags() - FLAG_SET_CMDLINE(bool, UseG1GC, false); - } + // FLAG_SET_CMDLINE(bool, UseG1GC, false); + // } if (!ScavengeRootsInCode) { warning("forcing ScavengeRootsInCode non-zero because Graal is enabled");