Mercurial > hg > graal-compiler
changeset 8502:ff4fa8b0516e
-Create push patch
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java Wed Mar 06 19:35:04 2013 +0100 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java Wed Mar 20 20:13:08 2013 +0100 @@ -57,6 +57,8 @@ */ public final GraalCodeCacheProvider runtime; + public static int counter = 0; + /** * The backend that this compiler has been configured for. */ @@ -74,6 +76,7 @@ return Debug.scope("GraalCompiler", new Object[]{graph, method, this}, new Callable<CompilationResult>() { public CompilationResult call() { + System.out.println("Start compile of method " + counter); final Assumptions assumptions = new Assumptions(GraalOptions.OptAssumptions); final LIR lir = Debug.scope("FrontEnd", new Callable<LIR>() { @@ -87,6 +90,8 @@ return emitLIR(lir, graph, method); } }); + System.out.println("Stop compile of method " + counter); + counter++; return Debug.scope("CodeGen", frameMap, new Callable<CompilationResult>() { public CompilationResult call() {
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRuntime.java Wed Mar 06 19:35:04 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRuntime.java Wed Mar 20 20:13:08 2013 +0100 @@ -38,7 +38,6 @@ import static com.oracle.graal.hotspot.nodes.VerifyOopStubCall.*; import static com.oracle.graal.hotspot.nodes.WriteBarrierPreStubCall.*; import static com.oracle.graal.hotspot.nodes.WriteBarrierPostStubCall.*; -import static com.oracle.graal.hotspot.nodes.VerOopStubCall.*; import static com.oracle.graal.hotspot.snippets.AESCryptSubstitutions.DecryptBlockStubCall.*; import static com.oracle.graal.hotspot.snippets.AESCryptSubstitutions.EncryptBlockStubCall.*; import static com.oracle.graal.hotspot.snippets.CipherBlockChainingSubstitutions.DecryptAESCryptStubCall.*; @@ -94,11 +93,6 @@ /* temps */ null, /* ret */ ret(Kind.Void), /* arg0: object */ javaCallingConvention(Kind.Object)); - - addRuntimeCall(VEROOPCALL, config.verOopStub, - /* temps */ null, - /* ret */ ret(Kind.Void), - /* arg0: object */ javaCallingConvention(Kind.Object)); addRuntimeCall(WBPOSTCALL, config.wbPostCallStub, /* temps */ null,
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java Wed Mar 06 19:35:04 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java Wed Mar 20 20:13:08 2013 +0100 @@ -137,14 +137,14 @@ @Override public CompilationResult call() throws Exception { graalRuntime.evictDeoptedGraphs(); - StructuredGraph graph = (StructuredGraph) method.getCompilerStorage().get(Graph.class); - if (graph == null || entryBCI != INVOCATION_ENTRY_BCI) { - graph = new StructuredGraph(method, entryBCI); - } else { - // Compiling an intrinsic graph - must clone the graph - graph = graph.copy(); - // System.out.println("compiling intrinsic " + method); - } +// StructuredGraph graph = (StructuredGraph) method.getCompilerStorage().get(Graph.class); +// if (graph == null || entryBCI != INVOCATION_ENTRY_BCI) { + StructuredGraph graph = new StructuredGraph(method, entryBCI); +// } else { +// // Compiling an intrinsic graph - must clone the graph +// graph = graph.copy(); +// // System.out.println("compiling intrinsic " + method); +// } InlinedBytecodes.add(method.getCodeSize()); return graalRuntime.getCompiler().compileMethod(method, graph, graalRuntime.getCache(), plan, optimisticOpts); }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java Wed Mar 06 19:35:04 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java Wed Mar 20 20:13:08 2013 +0100 @@ -221,6 +221,7 @@ public int g1SATBQueueMarkingOffset; public int g1SATBQueueIndexOffset; public int g1SATBQueueBufferOffset; + public long gcCycleAddress; /** * The offset of the _java_mirror field (of type {@link Class}) in a Klass. @@ -329,6 +330,8 @@ public long wbPreCallStub; public long wbPostCallStub; public long verOopStub; + public long printWriteCardStub; + public long verifyOopStub; public long vmErrorStub; public long deoptimizeStub;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Wed Mar 06 19:35:04 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Wed Mar 20 20:13:08 2013 +0100 @@ -58,6 +58,7 @@ import com.oracle.graal.hotspot.nodes.*; import com.oracle.graal.hotspot.phases.*; import com.oracle.graal.hotspot.snippets.*; +import static com.oracle.graal.hotspot.snippets.WriteBarrierSnippets.*; import com.oracle.graal.hotspot.stubs.*; import com.oracle.graal.java.*; import com.oracle.graal.nodes.*; @@ -68,6 +69,7 @@ import com.oracle.graal.nodes.spi.*; import com.oracle.graal.nodes.type.*; import com.oracle.graal.phases.*; +import com.oracle.graal.phases.common.*; import com.oracle.graal.printer.*; import com.oracle.graal.snippets.*; import com.oracle.graal.word.*; @@ -275,7 +277,6 @@ /* ret */ ret(Kind.Void), /* arg0: object */ javaCallingConvention(Kind.Object, /* arg1: flags */ Kind.Int)); - // @formatter:on } @@ -592,7 +593,19 @@ assert loadField.kind() != Kind.Illegal; ReadNode memoryRead = graph.add(new ReadNode(object, LocationNode.create(field, field.getKind(), field.offset(), graph), loadField.stamp())); 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") && IterativeConditionalEliminationPhase.ISON == true) { + WriteBarrierPre writeBarrierPre = graph.add(new WriteBarrierPre(memoryRead.object(), memoryRead, LocationNode.create(field, field.getKind(), field.offset(), graph), field.getName(), + false)); + graph.addAfterFixed(memoryRead, writeBarrierPre); + MembarNode membar = new MembarNode(LOAD_STORE); + graph.add(membar); + graph.addAfterFixed(writeBarrierPre, membar); + + } + if (loadField.isVolatile()) { MembarNode preMembar = graph.add(new MembarNode(JMM_PRE_VOLATILE_READ)); graph.addBeforeFixed(memoryRead, preMembar); @@ -610,21 +623,33 @@ FixedWithNextNode last = memoryWrite; FixedWithNextNode first = memoryWrite; + FrameState stateAfter = memoryWrite.stateAfter(); if (field.getKind() == Kind.Object && !memoryWrite.value().objectStamp().alwaysNull()) { + + boolean profile = false; + if (HotSpotSnippetUtils.useG1GC() && field.getKind() == Kind.Object && field.getDeclaringClass().getName().toString().equals("Lcom/oracle/graal/phases/graph/PostOrderNodeIterator;") && + field.getName().equals("state")) { + profile = true; + } + if (!HotSpotSnippetUtils.useG1GC()) { FieldWriteBarrier writeBarrier = graph.add(new FieldWriteBarrier(memoryWrite.object())); graph.addAfterFixed(memoryWrite, writeBarrier); 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())); + WriteBarrierPre writeBarrierPre = graph.add(new WriteBarrierPre(memoryWrite.object(), null, LocationNode.create(field, field.getKind(), field.offset(), graph), field.getName(), + true, profile)); + WriteBarrierPost writeBarrierPost = graph.add(new WriteBarrierPost(memoryWrite.object(), memoryWrite.value(), memoryWrite.location(), false, writeBarrierPre, profile)); graph.addBeforeFixed(memoryWrite, writeBarrierPre); graph.addAfterFixed(memoryWrite, writeBarrierPost); + writeBarrierPre.setStateAfter(stateAfter); + writeBarrierPost.setStateAfter(stateAfter); + first = writeBarrierPre; last = writeBarrierPost; } + } if (storeField.isVolatile()) { MembarNode preMembar = graph.add(new MembarNode(JMM_PRE_VOLATILE_WRITE)); @@ -644,11 +669,14 @@ FieldWriteBarrier writeBarrier = graph.add(new FieldWriteBarrier(cas.object())); graph.addAfterFixed(cas, writeBarrier); } else { - WriteBarrierPre writeBarrierPre = graph.add(new WriteBarrierPre(cas.object(), IndexedLocationNode.create(LocationNode.ANY_LOCATION, cas.expected().kind(), cas.displacement(), - cas.offset(), graph, false), true)); + WriteBarrierPre writeBarrierPre = graph.add(new WriteBarrierPre(cas.object(), null, IndexedLocationNode.create(LocationNode.ANY_LOCATION, cas.expected().kind(), + cas.displacement(), cas.offset(), graph, false), "CAS", 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.addBeforeFixed(cas, writeBarrierPre); + cas.displacement(), cas.offset(), graph, false), false, writeBarrierPre)); + MembarNode membar = new MembarNode(LOAD_STORE); + graph.add(membar); + graph.addBeforeFixed(cas, membar); + graph.addBeforeFixed(membar, writeBarrierPre); graph.addAfterFixed(cas, writeBarrierPost); } } else { @@ -657,11 +685,16 @@ if (!HotSpotSnippetUtils.useG1GC()) { graph.addAfterFixed(cas, graph.add(new ArrayWriteBarrier(cas.object(), (IndexedLocationNode) location))); } else { - graph.addBeforeFixed(cas, graph.add(new WriteBarrierPre(cas.object(), location, true))); - graph.addAfterFixed(cas, graph.add(new WriteBarrierPost(cas.object(), cas.newValue(), location))); + WriteBarrierPre writeBarrierPre = graph.add(new WriteBarrierPre(cas.object(), null, location, "CAS", true)); + MembarNode membar = new MembarNode(LOAD_STORE); + graph.add(membar); + graph.addBeforeFixed(cas, membar); + graph.addBeforeFixed(membar, writeBarrierPre); + graph.addAfterFixed(cas, graph.add(new WriteBarrierPost(cas.object(), cas.newValue(), location, true, writeBarrierPre))); } } } + } else if (n instanceof LoadIndexedNode) { LoadIndexedNode loadIndexed = (LoadIndexedNode) n; ValueNode boundsCheck = createBoundsCheck(loadIndexed, tool); @@ -708,8 +741,14 @@ if (!HotSpotSnippetUtils.useG1GC()) { graph.addAfterFixed(memoryWrite, graph.add(new ArrayWriteBarrier(array, (IndexedLocationNode) arrayLocation))); } else { - graph.addBeforeFixed(memoryWrite, graph.add(new WriteBarrierPre(array, arrayLocation, true))); - graph.addAfterFixed(memoryWrite, graph.add(new WriteBarrierPost(array, value, arrayLocation))); + WriteBarrierPre writeBarrierPre = graph.add(new WriteBarrierPre(array, null, arrayLocation, "ARRAY", true)); + writeBarrierPre.dependencies().add(boundsCheck); + graph.addBeforeFixed(memoryWrite, writeBarrierPre); + WriteBarrierPost writeBarrierPost = graph.add(new WriteBarrierPost(array, value, arrayLocation, true, writeBarrierPre)); + graph.addAfterFixed(memoryWrite, writeBarrierPost); + writeBarrierPre.setStateAfter(memoryWrite.stateAfter()); + writeBarrierPost.setStateAfter(memoryWrite.stateAfter()); + } } } else if (n instanceof UnsafeLoadNode) { @@ -737,8 +776,9 @@ FieldWriteBarrier writeBarrier = graph.add(new FieldWriteBarrier(object)); graph.addAfterFixed(write, writeBarrier); } else { - graph.addBeforeFixed(write, graph.add(new WriteBarrierPre(object, location, true))); - graph.addAfterFixed(write, graph.add(new WriteBarrierPost(object, write.value(), location))); + WriteBarrierPre writeBarrierPre = new WriteBarrierPre(object, null, location, "UnsafeStore", true); + graph.addBeforeFixed(write, graph.add(writeBarrierPre)); + graph.addAfterFixed(write, graph.add(new WriteBarrierPost(object, write.value(), location, false, writeBarrierPre))); } } else { // This may be an array store so use an array write barrier @@ -746,8 +786,9 @@ ArrayWriteBarrier writeBarrier = graph.add(new ArrayWriteBarrier(object, location)); graph.addAfterFixed(write, writeBarrier); } else { - graph.addBeforeFixed(write, graph.add(new WriteBarrierPre(object, location, true))); - graph.addAfterFixed(write, graph.add(new WriteBarrierPost(object, write.value(), location))); + WriteBarrierPre writeBarrierPre = graph.add(new WriteBarrierPre(object, null, location, "UnsafeStoreArray", true)); + graph.addBeforeFixed(write, writeBarrierPre); + graph.addAfterFixed(write, graph.add(new WriteBarrierPost(object, write.value(), location, true, writeBarrierPre))); } } }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/WriteBarrierPost.java Wed Mar 06 19:35:04 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/WriteBarrierPost.java Wed Mar 20 20:13:08 2013 +0100 @@ -27,11 +27,14 @@ import com.oracle.graal.nodes.spi.*; import com.oracle.graal.nodes.type.*; -public final class WriteBarrierPost extends FixedWithNextNode implements Lowerable { +public final class WriteBarrierPost extends AbstractStateSplit implements Lowerable { @Input private ValueNode object; @Input private ValueNode value; @Input private LocationNode location; + @Input private ValueNode wbPre; + private boolean precise; + private boolean profile; public ValueNode object() { return object; @@ -41,15 +44,40 @@ return value; } + public ValueNode getPreBarrier() { + return wbPre; + } + public LocationNode location() { return location; } - public WriteBarrierPost(ValueNode object, ValueNode value, LocationNode location) { + public boolean usePrecise() { + return precise; + } + + public boolean profile() { + return profile; + } + + public WriteBarrierPost(ValueNode object, ValueNode value, LocationNode location, boolean precise, ValueNode wbPre) { super(StampFactory.forVoid()); this.object = object; this.value = value; this.location = location; + this.precise = precise; + this.wbPre = wbPre; + this.profile = false; + } + + public WriteBarrierPost(ValueNode object, ValueNode value, LocationNode location, boolean precise, ValueNode wbPre, boolean profile) { + super(StampFactory.forVoid()); + this.object = object; + this.value = value; + this.location = location; + this.precise = precise; + this.wbPre = wbPre; + this.profile = profile; } public void lower(LoweringTool generator) {
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/WriteBarrierPre.java Wed Mar 06 19:35:04 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/WriteBarrierPre.java Wed Mar 20 20:13:08 2013 +0100 @@ -27,41 +27,61 @@ import com.oracle.graal.nodes.spi.*; import com.oracle.graal.nodes.type.*; -public final class WriteBarrierPre extends FixedWithNextNode implements Lowerable { +public final class WriteBarrierPre extends AbstractStateSplit implements Lowerable { @Input private ValueNode object; @Input private LocationNode location; + @Input private ValueNode expectedObject; private boolean doLoad; + private boolean profile; + private String name; public ValueNode object() { return object; } + public ValueNode expectedObject() { + return expectedObject; + } + public boolean doLoad() { return doLoad; } + public boolean profile() { + return profile; + } + + public String getName() { + return name; + } + public LocationNode location() { return location; } - public WriteBarrierPre(ValueNode object, LocationNode location, boolean doLoad) { + public WriteBarrierPre(ValueNode object, ValueNode expectedObject, LocationNode location, String name, boolean doLoad, boolean profile) { super(StampFactory.forVoid()); this.object = object; this.doLoad = doLoad; this.location = location; + this.expectedObject = expectedObject; + this.name = name; + this.profile = profile; + } + + public WriteBarrierPre(ValueNode object, ValueNode expectedObject, LocationNode location, String name, boolean doLoad) { + super(StampFactory.forVoid()); + this.object = object; + this.doLoad = doLoad; + this.location = location; + this.expectedObject = expectedObject; + this.name = name; } 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/HotSpotSnippetUtils.java Wed Mar 06 19:35:04 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/HotSpotSnippetUtils.java Wed Mar 20 20:13:08 2013 +0100 @@ -47,9 +47,13 @@ } @Fold + public static boolean useTLAB() { + return config().useTLAB; + } + + @Fold public static boolean verifyOops() { - return true; - // return config().verifyOops; + return config().verifyOops; } @Fold @@ -243,6 +247,11 @@ } @Fold + public static long gcCycleAddress() { + return config().gcCycleAddress; + } + + @Fold public static int g1SATBQueueMarkingOffset() { return config().g1SATBQueueMarkingOffset; } @@ -480,7 +489,6 @@ @Fold public static int layoutHelperElementTypePrimitiveInPlace() { - System.out.println(String.format("%x", config().layoutHelperElementTypePrimitiveInPlace)); return config().layoutHelperElementTypePrimitiveInPlace; }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/WriteBarrierSnippets.java Wed Mar 06 19:35:04 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/WriteBarrierSnippets.java Wed Mar 20 20:13:08 2013 +0100 @@ -26,10 +26,13 @@ import static com.oracle.graal.snippets.SnippetTemplate.*; import com.oracle.graal.api.code.*; +import com.oracle.graal.api.code.RuntimeCallTarget.*; import com.oracle.graal.api.meta.*; +import com.oracle.graal.graph.Node.*; import 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.phases.*; import com.oracle.graal.snippets.*; import com.oracle.graal.snippets.Snippet.ConstantParameter; import com.oracle.graal.snippets.Snippet.Parameter; @@ -40,100 +43,160 @@ public class WriteBarrierSnippets implements SnippetsInterface { - private static final boolean TRACE = false; - public 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 boolean TRACE_COND = false; @Snippet - public static void g1PreWriteBarrier(@Parameter("object") Object object, @Parameter("location") Object location, @ConstantParameter("doLoad") boolean doLoad) { + public static int g1PreWriteBarrier(@Parameter("object") Object obj, @Parameter("expectedObject") Object expobj, @Parameter("location") Object location, + @ConstantParameter("doLoad") boolean doLoad, @ConstantParameter("name") String name, @ConstantParameter("profile") boolean profile) { + + int gcCycle = Word.unsigned(HotSpotSnippetUtils.gcCycleAddress()).readInt(0); + if (obj == null) { + return gcCycle; + + } + TRACE_COND = profile; + // if (!TRACE_COND) { + // TRACE_COND = Word.unsigned(HotSpotSnippetUtils.gcCycleAddress()).readInt(0) > 650 ? true +// : false; + // } + int cause = 0; Word thread = thread(); - trace(WriteBarrierSnippets.TRACE, "---------------G1 PRE Enter: %lu\n", Word.unsigned(g1PreCounter.value())); + Object object = FixedValueAnchorNode.getObject(obj); + Object expectedObject = FixedValueAnchorNode.getObject(expobj); + Pointer oop = Word.fromObject(object); Pointer field = Word.fromArray(object, location); - Pointer previousOop = field.readWord(0); + Pointer previousOop = Word.fromObject(expectedObject); + long originalOop = oop.rawValue(); + long prevOop = field.readWord(0).rawValue(); + byte markingValue = thread.readByte(HotSpotSnippetUtils.g1SATBQueueMarkingOffset()); - // VerOopStubCall.call(oop); - long oopv = oop.rawValue(); + if (doLoad) { // We need to generate the load of the previous value + if (oop.equal(Word.zero())) { + trace(TRACE_COND, "ERROR Null Object 0x%16lx\n", Word.zero()); + } + if (field.equal(Word.zero())) { + trace(TRACE_COND, "ERROR Null Field 0x%16lx\n", Word.zero()); + } + if (previousOop.notEqual(Word.zero())) { + trace(TRACE_COND, "ERROR Field Loaded already 0x%16lx\n", previousOop); + } + } else { - byte markingValue = thread.readByte(HotSpotSnippetUtils.g1SATBQueueMarkingOffset()); + if (previousOop.equal(Word.zero())) { + trace(TRACE_COND, "ERROR Field is not Loaded already 0x%16lx\n", previousOop); + trace(TRACE_COND, "ERROR Field2 is not Loaded already 0x%16lx\n", oop); + trace(TRACE_COND, name, oop); + trace(TRACE_COND, "\n", oop); + } + + if (previousOop.notEqual(field.readWord(0))) { + trace(TRACE_COND, "ERROR Field is not Loaded already in ref.Reference 0x%16lx\n", previousOop); + } + } Word bufferAddress = thread.readWord(HotSpotSnippetUtils.g1SATBQueueBufferOffset()); Word indexAddress = thread.add(HotSpotSnippetUtils.g1SATBQueueIndexOffset()); - Word indexValue = thread.readWord(HotSpotSnippetUtils.g1SATBQueueIndexOffset()); - - 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); - trace(WriteBarrierSnippets.TRACE, " G1 PRE previous OOP: 0x%16lx\n", previousOop); - trace(WriteBarrierSnippets.TRACE, " G1 PRE QueueMarkingOffset: 0x%016lx\n", Word.signed(HotSpotSnippetUtils.g1SATBQueueMarkingOffset())); - trace(WriteBarrierSnippets.TRACE, " G1 PRE QueueBufferOffset: 0x%016lx\n", Word.signed(HotSpotSnippetUtils.g1SATBQueueBufferOffset())); - trace(WriteBarrierSnippets.TRACE, " G1 PRE QueueIndexOffset: 0x%016lx\n", Word.signed(HotSpotSnippetUtils.g1SATBQueueIndexOffset())); - trace(WriteBarrierSnippets.TRACE, " G1 PRE markingValue: 0x%016lx\n", Word.signed((int) markingValue)); - trace(WriteBarrierSnippets.TRACE, " G1 PRE bufferAddress: 0x%016lx\n", bufferAddress); - trace(WriteBarrierSnippets.TRACE, " G1 PRE indexAddress: 0x%016lx\n", indexAddress); - trace(WriteBarrierSnippets.TRACE, " G1 PRE indexValue: 0x%016lx\n", indexValue);// in + Word indexValue = indexAddress.readWord(0); + trace(TRACE_COND, "TRACE PRE Field oop 0x%16lx prevValue 0x%16lx marking value %d \n", oop, field.readWord(0), Word.unsigned(markingValue)); + trace(TRACE_COND, "TRACE PRE Field oop 0x%16lx field 0x%16lx marking value %d \n", oop, field, Word.unsigned(markingValue)); if (markingValue != (byte) 0) { if (doLoad) { previousOop = field.readWord(0); - trace(WriteBarrierSnippets.TRACE, " G1 PRE Do Load previous OOP: 0x%16lx\n", previousOop); + prevOop = previousOop.rawValue(); + } if (previousOop.notEqual(Word.zero())) { + if (indexValue.notEqual(Word.zero())) { Word nextIndex = indexValue.subtract(HotSpotSnippetUtils.wordSize()); Word logAddress = bufferAddress.add(nextIndex); - trace(WriteBarrierSnippets.TRACE, " G1 PRE logAddress: 0x%016lx\n", logAddress); - logAddress.writeWord(0, previousOop); indexAddress.writeWord(0, nextIndex); + if (field.readWord(0).rawValue() != prevOop) { + trace(TRACE_COND, "ERROR field SATB changed 0x%16lx\n", Word.unsigned(prevOop)); + } - trace(WriteBarrierSnippets.TRACE, " G1 PRE nextIndex: 0x%016lx\n", indexAddress.readWord(0)); - trace(WriteBarrierSnippets.TRACE, " G1 PRE writtenLogValue: 0x%016lx\n", logAddress.readWord(0)); + if (logAddress.readWord(0).rawValue() != prevOop) { + trace(TRACE_COND, "ERROR field SATB changed in buff 0x%16lx\n", Word.unsigned(prevOop)); + } + + if (indexAddress.readWord(0).rawValue() != nextIndex.rawValue()) { + trace(TRACE_COND, "ERROR index SATB changed in buff 0x%16lx\n", Word.unsigned(prevOop)); + } } else { WriteBarrierPreStubCall.call(previousOop); + Word bufferAddress1 = thread.readWord(HotSpotSnippetUtils.g1SATBQueueBufferOffset()); + Word indexAddress1 = thread.add(HotSpotSnippetUtils.g1SATBQueueIndexOffset()); + Word indexValue1 = indexAddress1.readWord(0); + if (bufferAddress1.add(indexValue1).readWord(0).rawValue() != prevOop) { + trace(TRACE_COND, "ERROR field SATB changed native 0x%16lx\n", Word.unsigned(prevOop)); + } + } } } - if (oopv != oop.rawValue()) { - trace(true, "---------------G1 PRE ERROR: %lu\n", Word.unsigned(oopv)); + + if (originalOop != oop.rawValue()) { + trace(TRACE_COND, "ERROR Address changed 0x%16lx\n", Word.unsigned(originalOop)); + trace(TRACE_COND, "ERROR Address changed to 0x%16lx\n", oop); } - trace(WriteBarrierSnippets.TRACE, "---------------G1 PRE Exit: %lu\n", Word.unsigned(g1PreCounter.value())); - g1PreCounter.inc(); + if (prevOop != 0L && (prevOop != field.readWord(0).rawValue())) { + trace(TRACE_COND, "ERROR previousOop changed 0x%16lx\n", Word.unsigned(prevOop)); + } + if (gcCycle != Word.unsigned(HotSpotSnippetUtils.gcCycleAddress()).readInt(0)) { + trace(TRACE_COND, "ERROR gcCycle within PRE changed %lu %lu\n", Word.unsigned(gcCycle), Word.unsigned(cause)); + } + + return gcCycle; } @Snippet - public static void g1PostWriteBarrier(@Parameter("object") Object object, @Parameter("value") Object value, @Parameter("location") Object location) { + public static void g1PostWriteBarrier(@Parameter("object") Object obj, @Parameter("value") Object value, @Parameter("location") Object location, @Parameter("preBarrier") int preBarrier, + @ConstantParameter("usePrecise") boolean usePrecise, @ConstantParameter("profile") boolean profile) { Word thread = thread(); - trace(WriteBarrierSnippets.TRACE, "---------------G1 POST Enter: %lu\n", Word.unsigned(g1PostCounter.value())); + + TRACE_COND = profile; + int gcCycle = Word.unsigned(HotSpotSnippetUtils.gcCycleAddress()).readInt(0); + if (gcCycle != preBarrier) { + trace(TRACE_COND, "ERROR gcCycle from PRE to POST changed %lu %lu\n", Word.unsigned(gcCycle), Word.unsigned(preBarrier)); + } + + Object object = FixedValueAnchorNode.getObject(obj); + Object wrObject = FixedValueAnchorNode.getObject(value); + Pointer oop = Word.fromObject(object); - Pointer field = Word.fromArray(object, location); - Pointer writtenValue = Word.fromObject(value); - // VerOopStubCall.call(oop); - long oopv = oop.rawValue(); + Pointer field1 = Word.fromArray(object, location); + Pointer field; + if (usePrecise) { + field = Word.fromArray(object, location); + } else { + field = oop; + } + + Pointer writtenValue = Word.fromObject(wrObject); + + long originalOop = oop.rawValue(); + long originalWv = writtenValue.rawValue(); Word bufferAddress = thread.readWord(HotSpotSnippetUtils.g1CardQueueBufferOffset()); Word indexAddress = thread.add(HotSpotSnippetUtils.g1CardQueueIndexOffset()); Word indexValue = thread.readWord(HotSpotSnippetUtils.g1CardQueueIndexOffset()); - trace(WriteBarrierSnippets.TRACE, " G1 POST oop: 0x%16lx\n", oop); - trace(WriteBarrierSnippets.TRACE, " G1 POST field: 0x%16lx\n", field); + if (oop.equal(Word.zero())) { + trace(TRACE_COND, "ERROR POST Null Object 0x%16lx\n", Word.zero()); + } + if (field.equal(Word.zero())) { + trace(TRACE_COND, "ERROR POST Null Field 0x%16lx\n", Word.zero()); + } - trace(WriteBarrierSnippets.TRACE, " G1 POST thread address: 0x%16lx\n", thread); - 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())); + Word xorResult = ((Word) field.xor(writtenValue)).unsignedShiftRight(HotSpotSnippetUtils.logOfHRGrainBytes()); // Card Table Word cardBase = (Word) field.unsignedShiftRight(cardTableShift()); @@ -146,14 +209,18 @@ } Word cardAddress = cardBase.add(displacement); - // if (writtenValue.notEqual(Word.zero())) { - Word xorResult = ((Word) field.xor(writtenValue)).unsignedShiftRight(HotSpotSnippetUtils.logOfHRGrainBytes()); - trace(WriteBarrierSnippets.TRACE, " G1 POST xor result: 0x%016lx\n", xorResult); + // trace(TRACE_COND, " G1 POST from field 0x%016lx to obj 0x%16lx, marking %d\n", +// field, writtenValue, Word.signed(cardAddress.readByte(0))); + // trace(TRACE_COND, +// " G1 POST from field 0x%016lx to cardAddress 0x%16lx, xorResults %16lx\n", field, +// cardAddress, xorResult); + + trace(TRACE_COND, "TRACE POST Field oop 0x%16lx writtenValue 0x%16lx card value %d\n", oop, writtenValue, Word.signed(cardAddress.readByte(0))); + trace(TRACE_COND, "TRACE POST Field oop 0x%16lx fieldRead 0x%16lx fieldAddress 0x%16lx\n", oop, field1.readWord(0), field1); if (xorResult.notEqual(Word.zero())) { if (writtenValue.notEqual(Word.zero())) { byte cardByte = cardAddress.readByte(0); - if (cardByte != (byte) 0) { cardAddress.writeByte(0, (byte) 0); // smash zero into card if (indexValue.notEqual(Word.zero())) { @@ -161,13 +228,7 @@ Word logAddress = bufferAddress.add(nextIndex); logAddress.writeWord(0, cardAddress); indexAddress.writeWord(0, nextIndex); - trace(WriteBarrierSnippets.TRACE, " G1 POST cardAddress: 0x%016lx\n", cardAddress); - trace(WriteBarrierSnippets.TRACE, " G1 POST cardValue: %d\n", Word.signed(cardByte)); - - trace(WriteBarrierSnippets.TRACE, " G1 POST nextIndex: 0x%016lx\n", nextIndex); - trace(WriteBarrierSnippets.TRACE, " G1 POST logAddress: 0x%016lx\n", logAddress); } else { - trace(WriteBarrierSnippets.TRACE, " G1 POST Card Address: 0x%016lx\n", cardAddress); WriteBarrierPostStubCall.call(object, cardAddress); } } @@ -175,11 +236,21 @@ } // } else { Object clone intrinsic(?!) // } - trace(WriteBarrierSnippets.TRACE, "---------------G1 POST EXIT: %lu\n", Word.unsigned(g1PostCounter.value())); - g1PostCounter.inc(); - if (oopv != oop.rawValue()) { - trace(true, "---------------G1 POST ERROR: %lu\n", Word.unsigned(oopv)); + // trace(WriteBarrierSnippets.TRACE, "---------------G1 POST EXIT: %lu\n", + if (originalOop != oop.rawValue()) { + trace(TRACE_COND, "ERROR Address changed 0x%16lx\n", Word.unsigned(originalOop)); + trace(TRACE_COND, "ERROR Address changed to 0x%16lx\n", oop); } + + if (originalWv != writtenValue.rawValue()) { + trace(TRACE_COND, "ERROR Written Value changed 0x%16lx\n", Word.unsigned(originalWv)); + trace(TRACE_COND, "ERROR Written Value changed to 0x%16lx\n", writtenValue); + } + + if (gcCycle != Word.unsigned(HotSpotSnippetUtils.gcCycleAddress()).readInt(0)) { + trace(TRACE_COND, "ERROR gcCycle within POST changed %lu\n", Word.unsigned(gcCycle)); + } + } private static void trace(boolean enabled, String format, WordBase value) { @@ -188,6 +259,18 @@ } } + private static void trace(boolean enabled, String format, WordBase value, WordBase value2) { + if (enabled) { + Log.printf(format, value.rawValue(), value2.rawValue()); + } + } + + private static void trace(boolean enabled, String format, WordBase value, WordBase value2, WordBase value3) { + if (enabled) { + Log.printf(format, value.rawValue(), value2.rawValue(), value3.rawValue()); + } + } + @Snippet public static void serialFieldWriteBarrier(@Parameter("object") Object object) { Pointer oop = Word.fromObject(object); @@ -222,15 +305,13 @@ private final ResolvedJavaMethod serialArrayWriteBarrier; private final ResolvedJavaMethod g1PreWriteBarrier; private final ResolvedJavaMethod g1PostWriteBarrier; - private final boolean useG1GC; public Templates(CodeCacheProvider runtime, Assumptions assumptions, TargetDescription target, boolean useG1GC) { 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); - g1PostWriteBarrier = snippet("g1PostWriteBarrier", Object.class, Object.class, Object.class); - this.useG1GC = useG1GC; + g1PreWriteBarrier = snippet("g1PreWriteBarrier", Object.class, Object.class, Object.class, boolean.class, String.class, boolean.class); + g1PostWriteBarrier = snippet("g1PostWriteBarrier", Object.class, Object.class, Object.class, int.class, boolean.class, boolean.class); System.out.println(" useG1GC? " + (useG1GC ? "true" : "false")); } @@ -257,11 +338,12 @@ ResolvedJavaMethod method = g1PreWriteBarrier; Key key = new Key(method); key.add("doLoad", writeBarrierPre.doLoad()); - + key.add("name", writeBarrierPre.getName()); + key.add("profile", writeBarrierPre.profile()); Arguments arguments = new Arguments(); arguments.add("object", writeBarrierPre.object()); + arguments.add("expectedObject", writeBarrierPre.expectedObject()); arguments.add("location", writeBarrierPre.location()); - SnippetTemplate template = cache.get(key, assumptions); template.instantiate(runtime, writeBarrierPre, DEFAULT_REPLACER, arguments); } @@ -269,10 +351,13 @@ public void lower(WriteBarrierPost writeBarrierPost, @SuppressWarnings("unused") LoweringTool tool) { ResolvedJavaMethod method = g1PostWriteBarrier; Key key = new Key(method); + key.add("usePrecise", writeBarrierPost.usePrecise()); + key.add("profile", writeBarrierPost.profile()); Arguments arguments = new Arguments(); arguments.add("object", writeBarrierPost.object()); arguments.add("location", writeBarrierPost.location()); arguments.add("value", writeBarrierPost.value()); + arguments.add("preBarrier", writeBarrierPost.getPreBarrier()); SnippetTemplate template = cache.get(key, assumptions); template.instantiate(runtime, writeBarrierPost, DEFAULT_REPLACER, arguments); }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewInstanceStub.java Wed Mar 06 19:35:04 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewInstanceStub.java Wed Mar 20 20:13:08 2013 +0100 @@ -99,6 +99,9 @@ if (useG1GC()) { return Word.zero(); } + if (!useTLAB()) { + return edenAllocate(Word.unsigned(sizeInBytes), log); + } Word intArrayMarkWord = Word.unsigned(tlabIntArrayMarkWord()); int alignmentReserveInBytes = tlabAlignmentReserveInHeapWords() * wordSize();
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Wed Mar 06 19:35:04 2013 +0100 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Wed Mar 20 20:13:08 2013 +0100 @@ -642,7 +642,9 @@ private JavaMethod lookupMethod(int cpi, int opcode) { eagerResolvingForSnippets(cpi, opcode); JavaMethod result = constantPool.lookupMethod(cpi, opcode); - assert !graphBuilderConfig.eagerResolvingForSnippets() || ((result instanceof ResolvedJavaMethod) && ((ResolvedJavaMethod) result).getDeclaringClass().isInitialized()) : result; + // assert !graphBuilderConfig.eagerResolvingForSnippets() || ((result instanceof +// ResolvedJavaMethod) && ((ResolvedJavaMethod) result).getDeclaringClass().isInitialized()) : +// result; return result; }
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/IterativeConditionalEliminationPhase.java Wed Mar 06 19:35:04 2013 +0100 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/IterativeConditionalEliminationPhase.java Wed Mar 20 20:13:08 2013 +0100 @@ -36,6 +36,7 @@ private final TargetDescription target; private final MetaAccessProvider runtime; private final Assumptions assumptions; + public static boolean ISON = false; public IterativeConditionalEliminationPhase(TargetDescription target, MetaAccessProvider runtime, Assumptions assumptions) { this.target = target; @@ -45,6 +46,7 @@ @Override protected void run(StructuredGraph graph) { + ISON = true; Set<Node> canonicalizationRoots = new HashSet<>(); ConditionalEliminationPhase eliminate = new ConditionalEliminationPhase(runtime); Listener listener = new Listener(canonicalizationRoots); @@ -58,6 +60,7 @@ new CanonicalizerPhase(target, runtime, assumptions, canonicalizationRoots, null).apply(graph); canonicalizationRoots.clear(); } + ISON = false; } private static class Listener implements InputChangedListener {
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/GraalOptions.java Wed Mar 06 19:35:04 2013 +0100 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/GraalOptions.java Wed Mar 20 20:13:08 2013 +0100 @@ -115,7 +115,7 @@ public static String PrintFilter = null; // Debug settings: - public static boolean Debug = true; + public static boolean Debug = false; public static boolean DebugSnippets = false; public static boolean PerThreadDebugValues = ____; public static boolean SummarizeDebugValues = ____; @@ -190,7 +190,7 @@ public static boolean OptLivenessAnalysis = true; public static boolean OptLoopTransform = true; public static boolean OptSafepointElimination = true; - public static boolean OptFloatingReads = true; + public static boolean OptFloatingReads = false; public static boolean OptTailDuplication = true; public static boolean OptEliminatePartiallyRedundantGuards = true; public static boolean OptFilterProfiledTypes = true;
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/PostOrderNodeIterator.java Wed Mar 06 19:35:04 2013 +0100 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/PostOrderNodeIterator.java Wed Mar 20 20:13:08 2013 +0100 @@ -24,6 +24,8 @@ import java.util.*; +import sun.misc.*; + import com.oracle.graal.graph.*; import com.oracle.graal.nodes.*; @@ -69,6 +71,7 @@ state.loopBegin((LoopBeginNode) current); nodeStates.put(current, state); state = state.clone(); + System.out.println("State: " + state.hashCode()); loopBegin((LoopBeginNode) current); current = ((LoopBeginNode) current).next(); assert current != null;
--- a/graal/com.oracle.graal.snippets/src/com/oracle/graal/snippets/GraalIntrinsics.java Wed Mar 06 19:35:04 2013 +0100 +++ b/graal/com.oracle.graal.snippets/src/com/oracle/graal/snippets/GraalIntrinsics.java Wed Mar 20 20:13:08 2013 +0100 @@ -34,7 +34,7 @@ installer.installSubstitutions(MathSubstitutionsX86.class); installer.installSubstitutions(DoubleSubstitutions.class); installer.installSubstitutions(FloatSubstitutions.class); - installer.installSubstitutions(NodeClassSubstitutions.class); + // installer.installSubstitutions(NodeClassSubstitutions.class); installer.installSubstitutions(LongSubstitutions.class); installer.installSubstitutions(IntegerSubstitutions.class); installer.installSubstitutions(UnsignedMathSubstitutions.class);
--- a/src/cpu/x86/vm/graalRuntime_x86.cpp Wed Mar 06 19:35:04 2013 +0100 +++ b/src/cpu/x86/vm/graalRuntime_x86.cpp Wed Mar 20 20:13:08 2013 +0100 @@ -1205,13 +1205,14 @@ oop_maps = new OopMapSet(); oop_maps->add_gc_map(call_offset, map); - restore_live_registers(sasm, save_fpu_registers); + restore_live_registers(sasm); } __ ret(0); break; } case graal_wb_post_call_id: { Register obj = j_rarg0; + Register caddr = j_rarg1; { GraalStubFrame f(sasm, "graal_wb_post_call", dont_gc_arguments); OopMap* map = save_live_registers(sasm, 2, save_fpu_registers); @@ -1219,33 +1220,16 @@ // note: really a leaf routine but must setup last java sp // => use call_RT for now (speed can be improved by // doing last java sp setup manually) - int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, graal_wb_post_call), obj); + int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, graal_wb_post_call), obj, caddr); oop_maps = new OopMapSet(); oop_maps->add_gc_map(call_offset, map); - restore_live_registers(sasm, save_fpu_registers); + restore_live_registers(sasm); } __ ret(0); break; } - case graal_ver_oop_id: { - Register obj = j_rarg0; - { - GraalStubFrame f(sasm, "graal_wb_post_call", dont_gc_arguments); - OopMap* map = save_live_registers(sasm, 2, save_fpu_registers); - // note: really a leaf routine but must setup last java sp - // => use call_RT for now (speed can be improved by - // doing last java sp setup manually) - int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, graal_ver_oop), obj); - - oop_maps = new OopMapSet(); - oop_maps->add_gc_map(call_offset, map); - restore_live_registers(sasm, save_fpu_registers); - } - __ ret(0); - break; - } case graal_identity_hash_code_id: { Register obj = j_rarg0; // Incoming __ set_info("identity_hash_code", dont_gc_arguments);
--- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Wed Mar 06 19:35:04 2013 +0100 +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Wed Mar 20 20:13:08 2013 +0100 @@ -854,7 +854,9 @@ assert(!isHumongous(word_size), "we do not allow humongous TLABs"); unsigned int dummy_gc_count_before; - return attempt_allocation(word_size, &dummy_gc_count_before); + HeapWord* word=attempt_allocation(word_size, &dummy_gc_count_before); + tty->print_cr("Allocate new TLAB at 0x%16lx",(oop) word); + return word; } HeapWord*
--- a/src/share/vm/gc_implementation/g1/heapRegion.cpp Wed Mar 06 19:35:04 2013 +0100 +++ b/src/share/vm/gc_implementation/g1/heapRegion.cpp Wed Mar 20 20:13:08 2013 +0100 @@ -119,6 +119,8 @@ 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
--- a/src/share/vm/gc_interface/collectedHeap.hpp Wed Mar 06 19:35:04 2013 +0100 +++ b/src/share/vm/gc_interface/collectedHeap.hpp Wed Mar 20 20:13:08 2013 +0100 @@ -483,6 +483,7 @@ // Total number of GC collections (started) unsigned int total_collections() const { return _total_collections; } + unsigned int* total_collections_address() { return &_total_collections; } unsigned int total_full_collections() const { return _total_full_collections;} // Increment total number of GC collections (started)
--- a/src/share/vm/graal/graalCompilerToVM.cpp Wed Mar 06 19:35:04 2013 +0100 +++ b/src/share/vm/graal/graalCompilerToVM.cpp Wed Mar 20 20:13:08 2013 +0100 @@ -723,7 +723,7 @@ set_long("monitorExitStub", VmIds::addStub(GraalRuntime::entry_for(GraalRuntime::graal_monitorexit_id))); set_long("wbPreCallStub", VmIds::addStub(GraalRuntime::entry_for(GraalRuntime::graal_wb_pre_call_id))); set_long("wbPostCallStub", VmIds::addStub(GraalRuntime::entry_for(GraalRuntime::graal_wb_post_call_id))); - set_long("verOopStub", VmIds::addStub(GraalRuntime::entry_for(GraalRuntime::graal_ver_oop_id))); + set_long("verifyOopStub", VmIds::addStub(GraalRuntime::entry_for(GraalRuntime::graal_verify_oop_id))); set_long("vmErrorStub", VmIds::addStub(GraalRuntime::entry_for(GraalRuntime::graal_vm_error_id))); set_long("deoptimizeStub", VmIds::addStub(SharedRuntime::deopt_blob()->uncommon_trap())); @@ -771,6 +771,8 @@ set_int("g1CardQueueBufferOffset", in_bytes(JavaThread::dirty_card_queue_offset() + PtrQueue::byte_offset_of_buf())); set_int("logOfHRGrainBytes", HeapRegion::LogOfHRGrainBytes); + set_long("gcCycleAddress", (jlong)(address) Universe::heap()->total_collections_address()); + set_int("g1SATBQueueMarkingOffset", in_bytes(JavaThread::satb_mark_queue_offset() + PtrQueue::byte_offset_of_active())); set_int("g1SATBQueueIndexOffset", in_bytes(JavaThread::satb_mark_queue_offset() + PtrQueue::byte_offset_of_index())); set_int("g1SATBQueueBufferOffset", in_bytes(JavaThread::satb_mark_queue_offset() + PtrQueue::byte_offset_of_buf()));
--- a/src/share/vm/graal/graalRuntime.cpp Wed Mar 06 19:35:04 2013 +0100 +++ b/src/share/vm/graal/graalRuntime.cpp Wed Mar 20 20:13:08 2013 +0100 @@ -137,7 +137,7 @@ case graal_arithmetic_frem_id: case graal_arithmetic_drem_id: case graal_set_deopt_info_id: - break; + break; // All other stubs should have oopmaps default: @@ -234,9 +234,14 @@ #undef FUNCTION_CASE } +static const bool TRACE=true; + + JRT_ENTRY(void, GraalRuntime::new_instance(JavaThread* thread, Klass* klass)) assert(klass->is_klass(), "not a class"); +if(TRACE) tty->print_cr("PreObject Init tlab start 0x%16lx tlab end 0x%16lx", thread->tlab().start(), thread->tlab().end()); + instanceKlassHandle h(thread, klass); h->check_valid_for_instantiation(true, CHECK); // make sure klass is initialized @@ -244,6 +249,9 @@ // allocate instance and return via TLS oop obj = h->allocate_instance(CHECK); thread->set_vm_result(obj); + if(TRACE) tty->print_cr("Allocate new object at 0x%16lx size %d ", obj, obj->size()); + if(TRACE) obj->klass()->print(); + if(TRACE) tty->print_cr("PostObject Init tlab start 0x%16lx tlab end 0x%16lx", thread->tlab().start(), thread->tlab().end()); JRT_END JRT_ENTRY(void, GraalRuntime::new_array(JavaThread* thread, Klass* array_klass, jint length)) @@ -251,6 +259,8 @@ // anymore after new_objArray() and no GC can happen before. // (This may have to change if this code changes!) assert(array_klass->is_klass(), "not a class"); +if(TRACE) tty->print_cr("PreArray Init tlab start 0x%16lx tlab end 0x%16lx", thread->tlab().start(), thread->tlab().end()); + oop obj; if (array_klass->oop_is_typeArray()) { BasicType elt_type = TypeArrayKlass::cast(array_klass)->element_type(); @@ -260,19 +270,31 @@ obj = oopFactory::new_objArray(elem_klass, length, CHECK); } thread->set_vm_result(obj); + if(TRACE) tty->print_cr("Allocate new array at 0x%16lx size %d", obj, obj->size()); + if(TRACE) obj->klass()->print(); + if(TRACE) tty->print_cr("PostArray Init tlab start 0x%16lx tlab end 0x%16lx", thread->tlab().start(), thread->tlab().end()); + // This is pretty rare but this runtime patch is stressful to deoptimization // if we deoptimize here so force a deopt to stress the path. if (DeoptimizeALot) { deopt_caller(); } -JRT_END + + JRT_END + JRT_ENTRY(void, GraalRuntime::new_multi_array(JavaThread* thread, Klass* klass, int rank, jint* dims)) assert(klass->is_klass(), "not a class"); assert(rank >= 1, "rank must be nonzero"); + if(TRACE) tty->print_cr("PreMultiArray Init tlab start 0x%16lx tlab end 0x%16lx", thread->tlab().start(), thread->tlab().end()); + oop obj = ArrayKlass::cast(klass)->multi_allocate(rank, dims, CHECK); thread->set_vm_result(obj); + if(TRACE) tty->print_cr("Allocate new multiarray at 0x%16lx size %d ", obj, obj->size()); + if(TRACE) obj->klass()->print(); + if(TRACE) tty->print_cr("PostMultiArray Init tlab start 0x%16lx tlab end 0x%16lx", thread->tlab().start(), thread->tlab().end()); + JRT_END JRT_ENTRY(void, GraalRuntime::unimplemented_entry(JavaThread* thread, StubID id)) @@ -483,26 +505,12 @@ } JRT_END -static const bool TRACE_WB=true; - JRT_LEAF(void, GraalRuntime::graal_wb_pre_call(JavaThread* thread, oopDesc* obj)) -if(TRACE_WB) tty->print_cr("HELLO1 PRE WRITE BARRIER"); - SharedRuntime::g1_wb_pre(obj, thread); -if(TRACE_WB) tty->print_cr("HELLO2 PRE WRITE BARRIER"); + thread->satb_mark_queue().enqueue(obj); JRT_END JRT_LEAF(void, GraalRuntime::graal_wb_post_call(JavaThread* thread, oopDesc* obj, void* card_addr)) - if(TRACE_WB) tty->print_cr("HELLO1 POST WRITE BARRIER Card address 0x%016lx", card_addr); thread->dirty_card_queue().enqueue(card_addr); - if(TRACE_WB) tty->print_cr("HELLO2 POST WRITE BARRIER Card address 0x%016lx", card_addr); -JRT_END - -JRT_LEAF(void, GraalRuntime::graal_ver_oop(JavaThread* thread, oopDesc* obj)) -if(!TRACE_WB) return; -if(obj==NULL) tty->print_cr("ERROR NULL in verifyoop G1 in method obj " INTPTR_FORMAT, obj); -if (obj!=NULL &&!obj->is_oop()) { - tty->print_cr("ERROR in verifyoop G1 in method obj " INTPTR_FORMAT, obj); -} JRT_END JRT_LEAF(void, GraalRuntime::graal_monitorexit(JavaThread* thread, oopDesc* obj, BasicLock* lock)) @@ -538,13 +546,6 @@ JRT_END JRT_ENTRY(void, GraalRuntime::graal_log_object(JavaThread* thread, oop obj, jint flags)) -if (!obj->is_oop()) { - tty->print_cr("ERROR in verifyoop G1 in method obj " INTPTR_FORMAT, obj); - -}else { - tty->print_cr("WIN in verifyoop G1 in method obj " INTPTR_FORMAT, obj); -} - if(obj==NULL) return; bool string = mask_bits_are_true(flags, LOG_OBJECT_STRING); bool address = mask_bits_are_true(flags, LOG_OBJECT_ADDRESS); @@ -581,10 +582,12 @@ report_vm_error(__FILE__, __LINE__, error_msg, detail_msg); JRT_END -JRT_ENTRY(void, GraalRuntime::graal_log_printf(JavaThread* thread, oop format, jlong v1, jlong v2, jlong v3)) +JRT_LEAF(void, GraalRuntime::graal_log_printf(JavaThread* thread, oop format, jlong v1, jlong v2, jlong v3)) ResourceMark rm; assert(format != NULL && java_lang_String::is_instance(format), "must be"); char *buf = java_lang_String::as_utf8_string(format); + //tty->print( " G1 PRE from field 0x%016lx to obj 0x%16lx, marking %d\n", v1, v2, v3); + tty->print(buf, v1, v2, v3); JRT_END
--- a/src/share/vm/graal/graalRuntime.hpp Wed Mar 06 19:35:04 2013 +0100 +++ b/src/share/vm/graal/graalRuntime.hpp Wed Mar 20 20:13:08 2013 +0100 @@ -105,7 +105,6 @@ stub(graal_thread_is_interrupted) \ stub(graal_wb_pre_call) \ stub(graal_wb_post_call) \ - stub(graal_ver_oop) \ last_entry(number_of_ids) #define DECLARE_STUB_ID(x) x ## _id , @@ -145,10 +144,8 @@ static void graal_verify_oop(JavaThread* thread, oopDesc* obj); static void graal_wb_pre_call(JavaThread* thread, oopDesc* obj); - static void graal_wb_post_call(JavaThread* thread, oopDesc* obj,void* obj); - static void graal_ver_oop(JavaThread* thread, oopDesc* obj); - static void graal_create_null_exception(JavaThread* thread); + static void graal_create_null_exception(JavaThread* thread); static void graal_create_out_of_bounds_exception(JavaThread* thread, jint index); static void graal_monitorenter(JavaThread* thread, oopDesc* obj, BasicLock* lock); static void graal_monitorexit (JavaThread* thread, oopDesc* obj, BasicLock* lock);
--- a/src/share/vm/memory/threadLocalAllocBuffer.cpp Wed Mar 06 19:35:04 2013 +0100 +++ b/src/share/vm/memory/threadLocalAllocBuffer.cpp Wed Mar 20 20:13:08 2013 +0100 @@ -144,12 +144,12 @@ size_t aligned_new_size = align_object_size(new_size); - if (PrintTLAB && Verbose) { + //if (PrintTLAB && Verbose) { gclog_or_tty->print("TLAB new size: thread: " INTPTR_FORMAT " [id: %2d]" " refills %d alloc: %8.6f desired_size: " SIZE_FORMAT " -> " SIZE_FORMAT "\n", myThread(), myThread()->osthread()->thread_id(), _target_refills, _allocation_fraction.average(), desired_size(), aligned_new_size); - } + //} set_desired_size(aligned_new_size); set_refill_waste_limit(initial_refill_waste_limit()); @@ -168,9 +168,9 @@ HeapWord* top, size_t new_size) { _number_of_refills++; - if (PrintTLAB && Verbose) { + //if (PrintTLAB && Verbose) { print_stats("fill"); - } + //} assert(top <= start + new_size - alignment_reserve(), "size too small"); initialize(start, top, start + new_size - alignment_reserve()); @@ -274,12 +274,12 @@ 100.0 * waste / alloc; size_t tlab_used = Universe::heap()->tlab_capacity(thrd) - Universe::heap()->unsafe_max_tlab_alloc(thrd); - gclog_or_tty->print("TLAB: %s thread: " INTPTR_FORMAT " [id: %2d]" + gclog_or_tty->print("TLAB: %s thread: " INTPTR_FORMAT " [id: %2d] start addr 0x%16lx" " desired_size: " SIZE_FORMAT "KB" " slow allocs: %d refill waste: " SIZE_FORMAT "B" " alloc:%8.5f %8.0fKB refills: %d waste %4.1f%% gc: %dB" " slow: %dB fast: %dB\n", - tag, thrd, thrd->osthread()->thread_id(), + tag, thrd, thrd->tlab().start(), thrd->osthread()->thread_id(), _desired_size / (K / HeapWordSize), _slow_allocations, _refill_waste_limit * HeapWordSize, _allocation_fraction.average(),