changeset 10952:b43bc053ce8f

Fix bug in CardQueue/SATB buffer indexes' calculation in ArrayRangeBarrier snippets
author Christos Kotselidis <christos.kotselidis@oracle.com>
date Fri, 02 Aug 2013 18:29:49 +0200
parents e2ac8bf20433
children 97e282186b5b
files graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/WriteBarrierSnippets.java
diffstat 1 files changed, 15 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/WriteBarrierSnippets.java	Fri Aug 02 18:08:08 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/WriteBarrierSnippets.java	Fri Aug 02 18:29:49 2013 +0200
@@ -221,29 +221,29 @@
     public static void g1ArrayRangePreWriteBarrier(Object object, int startIndex, int length) {
         Word thread = thread();
         byte markingValue = thread.readByte(g1SATBQueueMarkingOffset());
-        // If the concurrent marker is not enabled return.
+        // If the concurrent marker is not enabled or the vector length is zero, return.
         if (markingValue == (byte) 0 || length == 0) {
             return;
         }
         Object dest = FixedValueAnchorNode.getObject(object);
         Word bufferAddress = thread.readWord(g1SATBQueueBufferOffset());
         Word indexAddress = thread.add(g1SATBQueueIndexOffset());
-        Word indexValue = indexAddress.readWord(0);
-
-        Word oop;
+        long dstAddr = GetObjectAddressNode.get(dest);
+        long indexValue = indexAddress.readWord(0).rawValue();
         final int scale = arrayIndexScale(Kind.Object);
         int header = arrayBaseOffset(Kind.Object);
 
         for (int i = startIndex; i < length; i++) {
-            Word address = (Word) Word.fromObject(dest).add(header).add(Word.unsigned(i * (long) scale));
-            oop = (Word) Word.fromObject(address.readObject(0, BarrierType.NONE, true));
+            long address = dstAddr + header + (i * scale);
+            Pointer oop = Word.fromObject(Word.unsigned(address).readObject(0, BarrierType.NONE, true));
+            verifyOop(oop.toObject());
             if (oop.notEqual(0)) {
-                if (indexValue.notEqual(0)) {
-                    Word nextIndex = indexValue.subtract(wordSize());
-                    Word logAddress = bufferAddress.add(nextIndex);
+                if (indexValue != 0) {
+                    indexValue = indexValue - wordSize();
+                    Word logAddress = bufferAddress.add(Word.unsigned(indexValue));
                     // Log the object to be marked as well as update the SATB's buffer next index.
                     logAddress.writeWord(0, oop);
-                    indexAddress.writeWord(0, nextIndex);
+                    indexAddress.writeWord(0, Word.unsigned(indexValue));
                 } else {
                     g1PreBarrierStub(G1WBPRECALL, oop.toObject());
                 }
@@ -260,7 +260,7 @@
         Word thread = thread();
         Word bufferAddress = thread.readWord(g1CardQueueBufferOffset());
         Word indexAddress = thread.add(g1CardQueueIndexOffset());
-        Word indexValue = thread.readWord(g1CardQueueIndexOffset());
+        long indexValue = thread.readWord(g1CardQueueIndexOffset()).rawValue();
 
         int cardShift = cardTableShift();
         long cardStart = cardTableStart();
@@ -279,13 +279,13 @@
                 cardAddress.writeByte(0, (byte) 0);
                 // If the thread local card queue is full, issue a native call which will
                 // initialize a new one and add the card entry.
-                if (indexValue.notEqual(0)) {
-                    Word nextIndex = indexValue.subtract(wordSize());
-                    Word logAddress = bufferAddress.add(nextIndex);
+                if (indexValue != 0) {
+                    indexValue = indexValue - wordSize();
+                    Word logAddress = bufferAddress.add(Word.unsigned(indexValue));
                     // Log the object to be scanned as well as update
                     // the card queue's next index.
                     logAddress.writeWord(0, cardAddress);
-                    indexAddress.writeWord(0, nextIndex);
+                    indexAddress.writeWord(0, Word.unsigned(indexValue));
                 } else {
                     g1PostBarrierStub(G1WBPOSTCALL, cardAddress);
                 }