changeset 10800:69e305a5cf09

Introduce new read opcode that allows compressed oops and read barriers
author Christos Kotselidis <christos.kotselidis@oracle.com>
date Wed, 17 Jul 2013 19:52:20 +0200
parents a84634196540
children 4bfbd4be6e7a
files graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/WriteBarrierSnippets.java graal/com.oracle.graal.word/src/com/oracle/graal/word/Pointer.java graal/com.oracle.graal.word/src/com/oracle/graal/word/Word.java graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeRewriterPhase.java
diffstat 4 files changed, 25 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/WriteBarrierSnippets.java	Wed Jul 17 19:31:46 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/WriteBarrierSnippets.java	Wed Jul 17 19:52:20 2013 +0200
@@ -118,7 +118,7 @@
             // If the previous value has to be loaded (before the write), the load is issued.
             // The load is always issued except the cases of CAS and referent field.
             if (probability(LIKELY_PROBABILITY, doLoad)) {
-                previousOop = (Word) Word.fromObject(field.readObjectCompressed(0));
+                previousOop = (Word) Word.fromObject(field.readObject(0, 0, true));
                 if (trace) {
                     log(trace, "[%d] G1-Pre Thread %p Previous Object %p\n ", gcCycle, thread.rawValue(), previousOop.rawValue());
                     verifyOop(previousOop.toObject());
@@ -225,7 +225,7 @@
 
         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.readObjectCompressed(0));
+            oop = (Word) Word.fromObject(address.readObject(0, 0, true));
             if (oop.notEqual(0)) {
                 if (indexValue.notEqual(0)) {
                     Word nextIndex = indexValue.subtract(wordSize());
--- a/graal/com.oracle.graal.word/src/com/oracle/graal/word/Pointer.java	Wed Jul 17 19:31:46 2013 +0200
+++ b/graal/com.oracle.graal.word/src/com/oracle/graal/word/Pointer.java	Wed Jul 17 19:52:20 2013 +0200
@@ -610,17 +610,19 @@
     Object readObject(WordBase offset);
 
     /**
-     * Reads the memory at address {@code (this + offset)} and uncompresses it. Both the base
-     * address and offset are in bytes.
+     * Reads the memory at address {@code (this + offset)}. This particular access can allow
+     * decompression and read barriers (G1 referent field).
      * <p>
      * The offset is always treated as a {@link Signed} value. However, the static type is
      * {@link WordBase} to avoid the frequent casts to of {@link Unsigned} values (where the caller
      * knows that the highest-order bit of the unsigned value is never used).
      * 
      * @param offset the signed offset for the memory access
+     * @param barrierType the type of the read barrier to be added
+     * @param compress whether or not the object is a decompression candidate
      * @return the result of the memory access
      */
-    Object readObjectCompressed(WordBase offset);
+    Object readObject(WordBase offset, int barrierType, boolean compress);
 
     /**
      * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in
@@ -704,13 +706,15 @@
     Object readObject(int offset);
 
     /**
-     * Reads the memory at address {@code (this + offset)} and decompressed it. Both the base
-     * address and offset are in bytes.
+     * Reads the memory at address {@code (this + offset)}. This particular access can be
+     * parameterized to allow decompression and read barriers (G1 referent field).
      * 
      * @param offset the signed offset for the memory access
+     * @param barrierType the type of the read barrier to be added
+     * @param compress whether or not the object is a decompression candidate
      * @return the result of the memory access
      */
-    Object readObjectCompressed(int offset);
+    Object readObject(int offset, int barrierType, boolean compress);
 
     /**
      * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in
--- a/graal/com.oracle.graal.word/src/com/oracle/graal/word/Word.java	Wed Jul 17 19:31:46 2013 +0200
+++ b/graal/com.oracle.graal.word/src/com/oracle/graal/word/Word.java	Wed Jul 17 19:52:20 2013 +0200
@@ -59,7 +59,7 @@
          COMPARISON,
          NOT,
          READ,
-         READ_COMPRESSED,
+         READ_HEAP,
          WRITE,
          INITIALIZE,
          ZERO,
@@ -880,9 +880,8 @@
     @Operation(opcode = Opcode.READ)
     public native Object readObject(WordBase offset);
 
-    @Override
-    @Operation(opcode = Opcode.READ_COMPRESSED)
-    public native Object readObjectCompressed(WordBase offset);
+    @Operation(opcode = Opcode.READ_HEAP)
+    public native Object readObject(WordBase offset, int barrierType, boolean compress);
 
     @Override
     @Operation(opcode = Opcode.READ)
@@ -938,10 +937,9 @@
         return readObject(signed(offset));
     }
 
-    @Override
-    @Operation(opcode = Opcode.READ_COMPRESSED)
-    public Object readObjectCompressed(int offset) {
-        return readObjectCompressed(signed(offset));
+    @Operation(opcode = Opcode.READ_HEAP)
+    public Object readObject(int offset, int barrierType, boolean compress) {
+        return readObject(signed(offset), barrierType, compress);
     }
 
     @Override
--- a/graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeRewriterPhase.java	Wed Jul 17 19:31:46 2013 +0200
+++ b/graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeRewriterPhase.java	Wed Jul 17 19:52:20 2013 +0200
@@ -175,19 +175,14 @@
                         } else {
                             location = makeLocation(graph, arguments.get(1), readKind, arguments.get(2));
                         }
-                        replace(invoke, readOp(graph, arguments.get(0), invoke, location, false));
+                        replace(invoke, readOp(graph, arguments.get(0), invoke, location, 0, false));
                         break;
                     }
-                    case READ_COMPRESSED: {
-                        assert arguments.size() == 2 || arguments.size() == 3;
+                    case READ_HEAP: {
+                        assert arguments.size() == 4;
                         Kind readKind = asKind(callTargetNode.returnType());
-                        LocationNode location;
-                        if (arguments.size() == 2) {
-                            location = makeLocation(graph, arguments.get(1), readKind, ANY_LOCATION);
-                        } else {
-                            location = makeLocation(graph, arguments.get(1), readKind, arguments.get(2));
-                        }
-                        replace(invoke, readOp(graph, arguments.get(0), invoke, location, true));
+                        LocationNode location = makeLocation(graph, arguments.get(1), readKind, ANY_LOCATION);
+                        replace(invoke, readOp(graph, arguments.get(0), invoke, location, arguments.get(2).asConstant().asInt(), arguments.get(3).asConstant().asInt() == 0 ? false : true));
                         break;
                     }
                     case WRITE:
@@ -328,8 +323,8 @@
         return IndexedLocationNode.create(locationIdentity, readKind, 0, offset, graph, 1);
     }
 
-    private static ValueNode readOp(StructuredGraph graph, ValueNode base, Invoke invoke, LocationNode location, boolean compress) {
-        ReadNode read = graph.add(new ReadNode(base, location, invoke.asNode().stamp(), WriteBarrierType.NONE, compress));
+    private static ValueNode readOp(StructuredGraph graph, ValueNode base, Invoke invoke, LocationNode location, int barrierType, boolean compress) {
+        ReadNode read = graph.add(new ReadNode(base, location, invoke.asNode().stamp(), WriteBarrierType.values()[barrierType], compress));
         graph.addBeforeFixed(invoke.asNode(), read);
         // The read must not float outside its block otherwise it may float above an explicit zero
         // check on its base address