Mercurial > hg > truffle
changeset 8498:c158d128fae9
-More porting and bug fixing
author | Christos Kotselidis <christos.kotselidis@oracle.com> |
---|---|
date | Thu, 28 Feb 2013 17:39:48 +0100 |
parents | 96ccefe5ab4e |
children | 96a337d307bd |
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.word/src/com/oracle/graal/word/phases/WordTypeRewriterPhase.java |
diffstat | 4 files changed, 105 insertions(+), 37 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Wed Feb 27 18:41:37 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Thu Feb 28 17:39:48 2013 +0100 @@ -615,6 +615,7 @@ last = writeBarrier; } else { WriteBarrierPre writeBarrierPre = graph.add(new WriteBarrierPre(memoryWrite.object(), LocationNode.create(field, field.getKind(), field.offset(), graph), true)); + writeBarrierPre.setName(storeField.toString()); WriteBarrierPost writeBarrierPost = graph.add(new WriteBarrierPost(memoryWrite.object(), memoryWrite.value(), memoryWrite.location())); graph.addBeforeFixed(memoryWrite, writeBarrierPre); graph.addAfterFixed(memoryWrite, writeBarrierPost); @@ -644,7 +645,7 @@ cas.offset(), graph, false), true)); WriteBarrierPost writeBarrierPost = graph.add(new WriteBarrierPost(cas.object(), cas.newValue(), IndexedLocationNode.create(LocationNode.ANY_LOCATION, cas.expected().kind(), cas.displacement(), cas.offset(), graph, false))); - graph.addAfterFixed(cas, writeBarrierPre); + graph.addBeforeFixed(cas, writeBarrierPre); graph.addAfterFixed(cas, writeBarrierPost); } } else {
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/WriteBarrierPre.java Wed Feb 27 18:41:37 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/WriteBarrierPre.java Thu Feb 28 17:39:48 2013 +0100 @@ -31,6 +31,7 @@ @Input private ValueNode object; @Input private LocationNode location; private boolean doLoad; + private String name; public ValueNode object() { return object; @@ -53,4 +54,12 @@ public void lower(LoweringTool generator) { generator.getRuntime().lower(this, generator); } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/WriteBarrierSnippets.java Wed Feb 27 18:41:37 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/WriteBarrierSnippets.java Thu Feb 28 17:39:48 2013 +0100 @@ -28,35 +28,51 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.hotspot.nodes.*; -import com.oracle.graal.nodes.extended.*; import com.oracle.graal.nodes.spi.*; +import com.oracle.graal.phases.*; import com.oracle.graal.snippets.*; import com.oracle.graal.snippets.Snippet.ConstantParameter; import com.oracle.graal.snippets.Snippet.Parameter; import com.oracle.graal.snippets.SnippetTemplate.AbstractTemplates; import com.oracle.graal.snippets.SnippetTemplate.Arguments; import com.oracle.graal.snippets.SnippetTemplate.Key; -import com.oracle.graal.snippets.nodes.*; import com.oracle.graal.word.*; public class WriteBarrierSnippets implements SnippetsInterface { private static final boolean TRACE = true; + private static final SnippetCounter.Group counters = WriteBarrierSnippets.TRACE ? new SnippetCounter.Group("GC") : null; + + private static final SnippetCounter g1PreCounter = new SnippetCounter(counters, "G1-PRE", "G1-PRE"); + private static final SnippetCounter g1PostCounter = new SnippetCounter(counters, "G1-POST", "G1-POST"); + + private static void traceObject(boolean enabled, String action, Object object) { + if (enabled) { + Log.print(action); + Log.print(' '); + Log.printlnObject(object); + } + } @Snippet - public static void g1PreWriteBarrier(@Parameter("object") Object object, @Parameter("location") Object location, @ConstantParameter("doLoad") boolean doLoad) { + public static void g1PreWriteBarrier(@Parameter("object") Object object, @Parameter("location") Object location, @ConstantParameter("doLoad") boolean doLoad, @ConstantParameter("kind") int kind, + @Parameter("fieldName") String fn) { Word thread = thread(); - trace(WriteBarrierSnippets.TRACE, "---------------G1 PRE Enter: 0x%016lx\n", thread); + trace(WriteBarrierSnippets.TRACE, "---------------G1 PRE Enter: %lu\n", Word.unsigned(g1PreCounter.value())); Pointer oop = Word.fromObject(object); Pointer field = Word.fromArray(object, location); Pointer previousOop = field.readWord(0); - byte markingValue = thread.add(HotSpotSnippetUtils.g1SATBQueueMarkingOffset()).readByte(0); + byte markingValue = thread.readByte(HotSpotSnippetUtils.g1SATBQueueMarkingOffset()); Word bufferAddress = thread.readWord(HotSpotSnippetUtils.g1SATBQueueBufferOffset()); Word indexAddress = thread.add(HotSpotSnippetUtils.g1SATBQueueIndexOffset()); Word indexValue = thread.readWord(HotSpotSnippetUtils.g1SATBQueueIndexOffset()); + Log.print(fn); + traceObject(WriteBarrierSnippets.TRACE, "In PRE WB", object); + // traceObject(WriteBarrierSnippets.TRACE, "WriteField" + fn, object); + trace(WriteBarrierSnippets.TRACE, " G1 PRE KIND: %d\n", Word.signed(kind)); trace(WriteBarrierSnippets.TRACE, " G1 PRE thread address: 0x%16lx\n", thread); trace(WriteBarrierSnippets.TRACE, " G1 PRE oop: 0x%16lx\n", oop); trace(WriteBarrierSnippets.TRACE, " G1 PRE field: 0x%16lx\n", field); @@ -77,9 +93,8 @@ } if (previousOop.notEqual(Word.zero())) { if (indexValue.notEqual(Word.zero())) { - Word nextIndex = indexValue.subtract(Word.signed(HotSpotSnippetUtils.wordSize())); - Word nextIndexX = nextIndex; - Word logAddress = bufferAddress.add(nextIndexX); + Word nextIndex = indexValue.subtract(HotSpotSnippetUtils.wordSize()); + Word logAddress = bufferAddress.add(nextIndex); logAddress.writeWord(0, previousOop); indexAddress.writeWord(0, nextIndex); trace(WriteBarrierSnippets.TRACE, " G1 PRE nextIndexindex: 0x%016lx\n", nextIndex); @@ -89,14 +104,15 @@ } } - trace(WriteBarrierSnippets.TRACE, "---------------G1 PRE Exit: 0x%016lx\n", indexValue); + trace(WriteBarrierSnippets.TRACE, "---------------G1 PRE Exit: %lu\n", Word.unsigned(g1PreCounter.value())); + g1PreCounter.inc(); } @Snippet public static void g1PostWriteBarrier(@Parameter("object") Object object, @Parameter("value") Object value, @Parameter("location") Object location) { Word thread = thread(); - trace(WriteBarrierSnippets.TRACE, "##############G1 POST Enter: 0x%016lx\n", thread); + trace(WriteBarrierSnippets.TRACE, "---------------G1 POST Enter: %lu\n", Word.unsigned(g1PostCounter.value())); Pointer oop = Word.fromObject(object); Pointer field = Word.fromArray(object, location); @@ -113,50 +129,54 @@ trace(WriteBarrierSnippets.TRACE, " G1 POST bufferAddress: 0x%016lx\n", bufferAddress); trace(WriteBarrierSnippets.TRACE, " G1 POST indexAddress: 0x%016lx\n", indexAddress); trace(WriteBarrierSnippets.TRACE, " G1 POST indexValue: 0x%016lx\n", indexValue); + trace(WriteBarrierSnippets.TRACE, " G1 POST existing value: 0x%016lx\n", field.readWord(0)); trace(WriteBarrierSnippets.TRACE, " G1 POST written value: 0x%016lx\n", writtenValue); + trace(WriteBarrierSnippets.TRACE, " G1 POST logHR int: 0x%016lx\n", Word.signed(HotSpotSnippetUtils.logOfHRGrainBytes())); + trace(WriteBarrierSnippets.TRACE, " G1 POST Card Start: 0x%016lx\n", Word.unsigned(cardTableStart())); + trace(WriteBarrierSnippets.TRACE, " G1 POST Word.size 0x%016lx\n", Word.signed(HotSpotSnippetUtils.wordSize())); // Card Table - Word base = (Word) oop.unsignedShiftRight(cardTableShift()); + Word cardBase = (Word) oop.unsignedShiftRight(cardTableShift()); long startAddress = cardTableStart(); int displacement = 0; if (((int) startAddress) == startAddress) { displacement = (int) startAddress; } else { - base = base.add(Word.unsigned(cardTableStart())); + cardBase = cardBase.add(Word.unsigned(cardTableStart())); } + Word cardAddress = cardBase.add(displacement); // if (writtenValue.notEqual(Word.zero())) { - Word xorResult = (((Word) field.xor(writtenValue)).unsignedShiftRight(HotSpotSnippetUtils.logOfHRGrainBytes())); + Word xorResult = ((Word) oop.xor(writtenValue)).unsignedShiftRight(HotSpotSnippetUtils.logOfHRGrainBytes()); trace(WriteBarrierSnippets.TRACE, " G1 POST xor result: 0x%016lx\n", xorResult); if (xorResult.notEqual(Word.zero())) { if (writtenValue.notEqual(Word.zero())) { // Word cardValue = base.readWord(displacement); - short cardByte = base.readShort(displacement); - trace(WriteBarrierSnippets.TRACE, " G1 POST cardValue: 0x%016lx\n", Word.signed((int) cardByte)); + byte cardByte = cardAddress.readByte(0); + trace(WriteBarrierSnippets.TRACE, " G1 POST cardAddress: 0x%016lx\n", cardAddress); + trace(WriteBarrierSnippets.TRACE, " G1 POST cardValue: %d\n", Word.signed(cardByte)); - if (cardByte != 0) { - base.writeWord(displacement, Word.zero()); // smash zero into card + if (cardByte != (byte) 0) { + cardAddress.writeByte(0, (byte) 0); // smash zero into card if (indexValue.notEqual(Word.zero())) { Word nextIndex = indexValue.subtract(HotSpotSnippetUtils.wordSize()); + Word logAddress = bufferAddress.add(nextIndex); + logAddress.writeWord(0, cardAddress); + indexAddress.writeWord(0, nextIndex); trace(WriteBarrierSnippets.TRACE, " G1 POST nextIndex: 0x%016lx\n", nextIndex); - - Word nextIndexX = nextIndex; - Word logAddress = bufferAddress.add(nextIndexX); trace(WriteBarrierSnippets.TRACE, " G1 POST logAddress: 0x%016lx\n", logAddress); - - logAddress.writeWord(0, base.add(displacement)); - indexAddress.writeWord(0, nextIndex); } else { - trace(WriteBarrierSnippets.TRACE, " G1 POST Card Address: 0x%016lx\n", base.add(displacement)); - WriteBarrierPostStubCall.call(object, base.add(displacement)); + trace(WriteBarrierSnippets.TRACE, " G1 POST Card Address: 0x%016lx\n", cardAddress); + WriteBarrierPostStubCall.call(object, cardAddress); } } } } // } else { Object clone intrinsic(?!) // } - trace(WriteBarrierSnippets.TRACE, "#################G1 POST Exit: 0x%016lx\n", thread); + trace(WriteBarrierSnippets.TRACE, "---------------G1 POST EXIT: %lu\n", Word.unsigned(g1PostCounter.value())); + g1PostCounter.inc(); } @@ -168,6 +188,7 @@ @Snippet public static void serialFieldWriteBarrier(@Parameter("object") Object object) { + assert true; verifyOop(object); Pointer oop = Word.fromObject(object); Word base = (Word) oop.unsignedShiftRight(cardTableShift()); @@ -183,6 +204,8 @@ @Snippet public static void serialArrayWriteBarrier(@Parameter("object") Object object, @Parameter("location") Object location) { + assert true; + Pointer oop = Word.fromArray(object, location); Word base = (Word) oop.unsignedShiftRight(cardTableShift()); long startAddress = cardTableStart(); @@ -207,10 +230,12 @@ super(runtime, assumptions, target, WriteBarrierSnippets.class); serialFieldWriteBarrier = snippet("serialFieldWriteBarrier", Object.class); serialArrayWriteBarrier = snippet("serialArrayWriteBarrier", Object.class, Object.class); - g1PreWriteBarrier = snippet("g1PreWriteBarrier", Object.class, Object.class, boolean.class); + g1PreWriteBarrier = snippet("g1PreWriteBarrier", Object.class, Object.class, boolean.class, int.class, String.class); g1PostWriteBarrier = snippet("g1PostWriteBarrier", Object.class, Object.class, Object.class); this.useG1GC = useG1GC; System.out.println(" useG1GC? " + (useG1GC ? "true" : "false")); + System.out.println("logHRBytes " + HotSpotSnippetUtils.logOfHRGrainBytes()); + System.out.println("wordsize " + HotSpotSnippetUtils.wordSize()); } public void lower(ArrayWriteBarrier arrayWriteBarrier, @SuppressWarnings("unused") LoweringTool tool) { @@ -236,9 +261,13 @@ ResolvedJavaMethod method = g1PreWriteBarrier; Key key = new Key(method); key.add("doLoad", writeBarrierPre.doLoad()); + key.add("kind", writeBarrierPre.location().getValueKind().ordinal()); + Arguments arguments = new Arguments(); arguments.add("object", writeBarrierPre.object()); arguments.add("location", writeBarrierPre.location()); + arguments.add("fieldName", writeBarrierPre.getName()); + SnippetTemplate template = cache.get(key, assumptions); template.instantiate(runtime, writeBarrierPre, DEFAULT_REPLACER, arguments); }
--- a/graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeRewriterPhase.java Wed Feb 27 18:41:37 2013 +0100 +++ b/graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeRewriterPhase.java Thu Feb 28 17:39:48 2013 +0100 @@ -139,17 +139,28 @@ case READ: assert arguments.size() == 2; - replace(invoke, readOp(graph, arguments.get(0), arguments.get(1), invoke, LocationNode.ANY_LOCATION)); + // replace(invoke, readOp(graph, arguments.get(0), arguments.get(1), invoke, +// LocationNode.ANY_LOCATION)); + Kind readKind = asKind(callTargetNode.returnType()); + replace(invoke, readOp(graph, arguments.get(0), arguments.get(1), invoke, readKind, LocationNode.ANY_LOCATION)); + break; case READ_FINAL: assert arguments.size() == 2; - replace(invoke, readOp(graph, arguments.get(0), arguments.get(1), invoke, LocationNode.FINAL_LOCATION)); + // replace(invoke, readOp(graph, arguments.get(0), arguments.get(1), invoke, +// LocationNode.FINAL_LOCATION)); + Kind readKind1 = asKind(callTargetNode.returnType()); + replace(invoke, readOp(graph, arguments.get(0), arguments.get(1), invoke, readKind1, LocationNode.ANY_LOCATION)); + break; case WRITE: assert arguments.size() == 3; - replace(invoke, writeOp(graph, arguments.get(0), arguments.get(1), arguments.get(2), invoke, LocationNode.ANY_LOCATION)); + // replace(invoke, writeOp(graph, arguments.get(0), arguments.get(1), +// arguments.get(2), invoke, LocationNode.ANY_LOCATION)); + Kind writeKind = asKind(targetMethod.getSignature().getParameterType(1, null)); + replace(invoke, writeOp(graph, arguments.get(0), arguments.get(1), arguments.get(2), invoke, writeKind, LocationNode.ANY_LOCATION)); break; case ZERO: @@ -264,11 +275,17 @@ return op; } - private static ValueNode readOp(StructuredGraph graph, ValueNode base, ValueNode offset, Invoke invoke, Object locationIdentity) { - // IndexedLocationNode location = IndexedLocationNode.create(locationIdentity, + // private static ValueNode readOp(StructuredGraph graph, ValueNode base, ValueNode offset, +// Invoke invoke, Object locationIdentity) { + // IndexedLocationNode location = IndexedLocationNode.create(locationIdentity, // invoke.methodCallTarget().returnKind(), 0, offset, graph, false); - Kind resultKind = invoke.node().kind() == Kind.Int ? invoke.methodCallTarget().returnKind() : invoke.node().kind(); - IndexedLocationNode location = IndexedLocationNode.create(locationIdentity, resultKind, 0, offset, graph, false); + // Kind resultKind = invoke.node().kind() == Kind.Int ? invoke.methodCallTarget().returnKind() : +// invoke.node().kind(); + + // IndexedLocationNode location = IndexedLocationNode.create(locationIdentity, resultKind, 0, +// offset, graph, false); + private static ValueNode readOp(StructuredGraph graph, ValueNode base, ValueNode offset, Invoke invoke, Kind readKind, Object locationIdentity) { + IndexedLocationNode location = IndexedLocationNode.create(locationIdentity, readKind, 0, offset, graph, false); ReadNode read = graph.add(new ReadNode(base, location, invoke.node().stamp())); graph.addBeforeFixed(invoke.node(), read); // The read must not float outside its block otherwise it may float above an explicit zero @@ -277,8 +294,12 @@ return read; } - private static ValueNode writeOp(StructuredGraph graph, ValueNode base, ValueNode offset, ValueNode value, Invoke invoke, Object locationIdentity) { - IndexedLocationNode location = IndexedLocationNode.create(locationIdentity, value.kind(), 0, offset, graph, false); + // private static ValueNode writeOp(StructuredGraph graph, ValueNode base, ValueNode offset, +// ValueNode value, Invoke invoke, Object locationIdentity) { + // IndexedLocationNode location = IndexedLocationNode.create(locationIdentity, value.kind(), 0, +// offset, graph, false); + private static ValueNode writeOp(StructuredGraph graph, ValueNode base, ValueNode offset, ValueNode value, Invoke invoke, Kind writeKind, Object locationIdentity) { + IndexedLocationNode location = IndexedLocationNode.create(locationIdentity, writeKind, 0, offset, graph, false); WriteNode write = graph.add(new WriteNode(base, value, location)); graph.addBeforeFixed(invoke.node(), write); return write; @@ -332,6 +353,14 @@ return false; } + public Kind asKind(JavaType type) { + if (type instanceof ResolvedJavaType) { + return isWord((ResolvedJavaType) type) ? wordKind : type.getKind(); + } else { + return Kind.Object; + } + } + private void changeToWord(ValueNode valueNode) { if (valueNode.isConstant() && valueNode.asConstant().getKind() == Kind.Object) { WordBase value = (WordBase) valueNode.asConstant().asObject();