changeset 8495:9131c075be7b

-More porting to G1 WBs
author Christos Kotselidis <christos.kotselidis@oracle.com>
date Wed, 27 Feb 2013 15:15:04 +0100
parents 7c9dbc80fd7d
children b089cde44076
files graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRuntime.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/WriteBarrierPostStubCall.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/WriteBarrierSnippets.java graal/com.oracle.graal.phases/src/com/oracle/graal/phases/GraalOptions.java src/share/vm/graal/graalRuntime.cpp src/share/vm/graal/graalRuntime.hpp
diffstat 7 files changed, 31 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRuntime.java	Tue Feb 26 19:49:00 2013 +0100
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRuntime.java	Wed Feb 27 15:15:04 2013 +0100
@@ -97,7 +97,7 @@
        addRuntimeCall(WBPOSTCALL, config.wbPostCallStub,
                 /*        temps */ null,
                 /*          ret */ ret(Kind.Void),
-                /* arg0: object */ javaCallingConvention(Kind.Object));
+                /* arg0: object */ javaCallingConvention(Kind.Object, word));
 
         addRuntimeCall(MONITOREXIT, config.monitorExitStub,
                 /*        temps */ null,
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java	Tue Feb 26 19:49:00 2013 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java	Wed Feb 27 15:15:04 2013 +0100
@@ -615,7 +615,7 @@
                     last = writeBarrier;
                 } else {
                     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()));
+                    WriteBarrierPost writeBarrierPost = graph.add(new WriteBarrierPost(memoryWrite.object(), memoryWrite.value(), memoryWrite.location()));
                     graph.addBeforeFixed(memoryWrite, writeBarrierPre);
                     graph.addAfterFixed(memoryWrite, writeBarrierPost);
                     last = writeBarrierPost;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/WriteBarrierPostStubCall.java	Tue Feb 26 19:49:00 2013 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/WriteBarrierPostStubCall.java	Wed Feb 27 15:15:04 2013 +0100
@@ -28,6 +28,7 @@
 import com.oracle.graal.compiler.target.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.type.*;
+import com.oracle.graal.word.*;
 
 /**
  * Node implementing a call to HotSpot's {@code graal_monitorenter} stub.
@@ -35,19 +36,21 @@
 public class WriteBarrierPostStubCall extends FixedWithNextNode implements LIRGenLowerable {
 
     @Input private final ValueNode object;
-    public static final Descriptor WBPOSTCALL = new Descriptor("wbpostcall", true, void.class, Object.class);
+    @Input private final ValueNode card;
+    public static final Descriptor WBPOSTCALL = new Descriptor("wbpostcall", true, void.class, Object.class, Word.class);
 
-    public WriteBarrierPostStubCall(ValueNode object) {
+    public WriteBarrierPostStubCall(ValueNode object, ValueNode card) {
         super(StampFactory.forVoid());
         this.object = object;
+        this.card = card;
     }
 
     @Override
     public void generate(LIRGenerator gen) {
         RuntimeCallTarget stub = gen.getRuntime().lookupRuntimeCall(WriteBarrierPostStubCall.WBPOSTCALL);
-        gen.emitCall(stub, stub.getCallingConvention(), true, gen.operand(object));
+        gen.emitCall(stub, stub.getCallingConvention(), true, gen.operand(object), gen.operand(card));
     }
 
     @NodeIntrinsic
-    public static native void call(Object hub);
+    public static native void call(Object hub, Word card);
 }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/WriteBarrierSnippets.java	Tue Feb 26 19:49:00 2013 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/WriteBarrierSnippets.java	Wed Feb 27 15:15:04 2013 +0100
@@ -50,7 +50,8 @@
         Pointer field = Word.fromArray(object, location);
         Pointer previousOop = field.readWord(0);
 
-        Word markingAddress = thread.readWord(HotSpotSnippetUtils.g1SATBQueueMarkingOffset());
+        Word markingValue = thread.readWord(HotSpotSnippetUtils.g1SATBQueueMarkingOffset());
+
         Word bufferAddress = thread.readWord(HotSpotSnippetUtils.g1SATBQueueBufferOffset());
         Word indexAddress = thread.add(HotSpotSnippetUtils.g1SATBQueueIndexOffset());
         Word indexValue = thread.readWord(HotSpotSnippetUtils.g1SATBQueueIndexOffset());
@@ -62,27 +63,27 @@
         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 markingAddress: 0x%016lx\n", markingAddress);
+        trace(WriteBarrierSnippets.TRACE, "      G1 PRE markingValue: 0x%016lx\n", 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
-// bytes
 
-        if (markingAddress.notEqual(Word.zero())) {
+        if (markingValue.notEqual(Word.zero())) {
             if (doLoad) {
                 previousOop = field.readWord(0);
                 trace(WriteBarrierSnippets.TRACE, "      G1 PRE Do Load previous OOP: 0x%16lx\n", previousOop);
             }
             if (previousOop.notEqual(Word.zero())) {
-                if (indexValue.readInt(0) != 0) {
-                    Word nextIndex = indexAddress.subtract(Word.signed(HotSpotSnippetUtils.wordSize()));
+                if (indexValue.notEqual(Word.zero())) {
+                    Word nextIndex = indexValue.subtract(Word.signed(HotSpotSnippetUtils.wordSize()));
                     Word nextIndexX = nextIndex;
                     Word logAddress = bufferAddress.add(nextIndexX);
                     logAddress.writeWord(0, previousOop);
                     indexAddress.writeWord(0, nextIndex);
                     trace(WriteBarrierSnippets.TRACE, "      G1 PRE nextIndexindex: 0x%016lx\n", nextIndex);
                 } else {
-                    WriteBarrierPostStubCall.call(object);
+                    WriteBarrierPreStubCall.call(previousOop);
                 }
             }
         }
@@ -101,9 +102,12 @@
         Pointer writtenValue = Word.fromObject(value);
 
         Word bufferAddress = thread.readWord(HotSpotSnippetUtils.g1CardQueueBufferOffset());
-        Word indexAddress = thread.readWord(HotSpotSnippetUtils.g1CardQueueIndexOffset());
+        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);
+
         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);
@@ -127,12 +131,13 @@
         if (xorResult.notEqual(Word.zero())) {
             if (writtenValue.notEqual(Word.zero())) {
                 Word cardValue = base.readWord(displacement);
+                char cardByte = base.readChar(displacement);
                 trace(WriteBarrierSnippets.TRACE, "     G1 POST cardValue: 0x%016lx\n", cardValue);
 
-                if (cardValue.notEqual(Word.zero())) {
+                if (cardByte != (char) 0) {
                     base.writeWord(displacement, Word.zero()); // smash zero into card
-                    if (indexValue.readInt(0) != 0) {
-                        Word nextIndex = indexAddress.subtract(Word.signed(HotSpotSnippetUtils.wordSize()));
+                    if (indexValue.notEqual(Word.zero())) {
+                        Word nextIndex = indexValue.subtract(HotSpotSnippetUtils.wordSize());
                         trace(WriteBarrierSnippets.TRACE, "     G1 POST nextIndex: 0x%016lx\n", nextIndex);
 
                         Word nextIndexX = nextIndex;
@@ -142,7 +147,7 @@
                         logAddress.writeWord(0, base.add(displacement));
                         indexAddress.writeWord(0, nextIndex);
                     } else {
-                        WriteBarrierPostStubCall.call(object);
+                        WriteBarrierPostStubCall.call(object, base.add(displacement));
                     }
                 }
             }
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/GraalOptions.java	Tue Feb 26 19:49:00 2013 +0100
+++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/GraalOptions.java	Wed Feb 27 15:15:04 2013 +0100
@@ -198,7 +198,7 @@
 
     // Intrinsification settings
     public static boolean IntrinsifyObjectClone              = ____;
-    public static boolean IntrinsifyArrayCopy                = true;
+    public static boolean IntrinsifyArrayCopy                = false;
     public static boolean IntrinsifyObjectMethods            = true;
     public static boolean IntrinsifySystemMethods            = true;
     public static boolean IntrinsifyClassMethods             = true;
--- a/src/share/vm/graal/graalRuntime.cpp	Tue Feb 26 19:49:00 2013 +0100
+++ b/src/share/vm/graal/graalRuntime.cpp	Wed Feb 27 15:15:04 2013 +0100
@@ -485,13 +485,12 @@
 
 JRT_LEAF(void, GraalRuntime::graal_wb_pre_call(JavaThread* thread, oopDesc* obj))
     tty->print_cr("HELLO PRE WRITE BARRIER");
-if(!obj->is_oop()) {
-     tty->print_cr("ERROR in pre writebarrier address is not object " INTPTR_FORMAT, obj);
-}
+    SharedRuntime::g1_wb_pre(obj, thread);
 JRT_END
 
-JRT_LEAF(void, GraalRuntime::graal_wb_post_call(JavaThread* thread, oopDesc* obj))
+JRT_LEAF(void, GraalRuntime::graal_wb_post_call(JavaThread* thread, address* card_addr))
     tty->print_cr("HELLO POST WRITE BARRIER");
+    thread->dirty_card_queue().enqueue(card_addr);
 JRT_END
 
 JRT_LEAF(void, GraalRuntime::graal_monitorexit(JavaThread* thread, oopDesc* obj, BasicLock* lock))
--- a/src/share/vm/graal/graalRuntime.hpp	Tue Feb 26 19:49:00 2013 +0100
+++ b/src/share/vm/graal/graalRuntime.hpp	Wed Feb 27 15:15:04 2013 +0100
@@ -143,7 +143,7 @@
   static address exception_handler_for_pc(JavaThread* thread);
 
   static void graal_wb_pre_call(JavaThread* thread, oopDesc* obj);
-  static void graal_wb_post_call(JavaThread* thread, oopDesc* obj);
+  static void graal_wb_post_call(JavaThread* thread, address* obj);
   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);