changeset 10546:a6d6e6afd897

Introduce ReadCompressed opcode in WordTypeRewriter
author Christos Kotselidis <christos.kotselidis@oracle.com>
date Thu, 27 Jun 2013 11:22:27 +0200
parents dc5b2b5089bd
children 01c902c59e38
files 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 3 files changed, 48 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.word/src/com/oracle/graal/word/Pointer.java	Thu Jun 27 11:16:18 2013 +0200
+++ b/graal/com.oracle.graal.word/src/com/oracle/graal/word/Pointer.java	Thu Jun 27 11:22:27 2013 +0200
@@ -586,6 +586,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.
+     * <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
+     * @return the result of the memory access
+     */
+    Object readObjectCompressed(WordBase offset);
+
+    /**
      * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in
      * bytes.
      * 
@@ -667,6 +680,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.
+     * 
+     * @param offset the signed offset for the memory access
+     * @return the result of the memory access
+     */
+    Object readObjectCompressed(int offset);
+
+    /**
      * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in
      * bytes.
      * <p>
--- a/graal/com.oracle.graal.word/src/com/oracle/graal/word/Word.java	Thu Jun 27 11:16:18 2013 +0200
+++ b/graal/com.oracle.graal.word/src/com/oracle/graal/word/Word.java	Thu Jun 27 11:22:27 2013 +0200
@@ -59,6 +59,7 @@
          COMPARISON,
          NOT,
          READ,
+         READ_COMPRESSED,
          WRITE,
          ZERO,
          FROM_UNSIGNED,
@@ -867,6 +868,10 @@
     public native Object readObject(WordBase offset);
 
     @Override
+    @Operation(opcode = Opcode.READ_COMPRESSED)
+    public native Object readObjectCompressed(WordBase offset);
+
+    @Override
     @Operation(opcode = Opcode.READ)
     public byte readByte(int offset) {
         return readByte(signed(offset));
@@ -921,6 +926,12 @@
     }
 
     @Override
+    @Operation(opcode = Opcode.READ_COMPRESSED)
+    public Object readObjectCompressed(int offset) {
+        return readObjectCompressed(signed(offset));
+    }
+
+    @Override
     @Operation(opcode = Opcode.WRITE)
     public void writeByte(WordBase offset, byte val) {
         unsafe.putByte(add((Word) offset).unbox(), val);
--- a/graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeRewriterPhase.java	Thu Jun 27 11:16:18 2013 +0200
+++ b/graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeRewriterPhase.java	Thu Jun 27 11:22:27 2013 +0200
@@ -169,7 +169,19 @@
                         } else {
                             location = makeLocation(graph, arguments.get(1), readKind, arguments.get(2));
                         }
-                        replace(invoke, readOp(graph, arguments.get(0), invoke, location));
+                        replace(invoke, readOp(graph, arguments.get(0), invoke, location, false));
+                        break;
+                    }
+                    case READ_COMPRESSED: {
+                        assert arguments.size() == 2 || arguments.size() == 3;
+                        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));
                         break;
                     }
                     case WRITE: {
@@ -309,8 +321,8 @@
         return IndexedLocationNode.create(locationIdentity, readKind, 0, offset, graph, 1);
     }
 
-    private static ValueNode readOp(StructuredGraph graph, ValueNode base, Invoke invoke, LocationNode location) {
-        ReadNode read = graph.add(new ReadNode(base, location, invoke.asNode().stamp(), WriteBarrierType.NONE, false));
+    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));
         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