changeset 5705:f96e7b39e9fe

Be more strict on isInt check in CAS lowering when index is constant Use array write barrier for UnsafeStore if we can't be sure we're not storing to an array
author Gilles Duboscq <duboscq@ssw.jku.at>
date Wed, 27 Jun 2012 15:40:03 +0200
parents 0a249ed5566a
children 6f2ccb483d96 8c478272fb34 f2fc4d13975a
files graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/ControlFlowOptimizer.java graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/amd64/AMD64LIRGenerator.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ValueNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeStoreNode.java
diffstat 5 files changed, 21 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/ControlFlowOptimizer.java	Wed Jun 27 14:15:32 2012 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/ControlFlowOptimizer.java	Wed Jun 27 15:40:03 2012 +0200
@@ -27,7 +27,6 @@
 import com.oracle.graal.compiler.util.*;
 import com.oracle.graal.debug.*;
 import com.oracle.graal.lir.*;
-import com.oracle.graal.lir.StandardOp.FallThroughOp;
 import com.oracle.graal.lir.cfg.*;
 
 /**
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/amd64/AMD64LIRGenerator.java	Wed Jun 27 14:15:32 2012 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/amd64/AMD64LIRGenerator.java	Wed Jun 27 15:40:03 2012 +0200
@@ -610,7 +610,7 @@
         Address address;
         int displacement = node.displacement();
         Value index = operand(node.offset());
-        if (isConstant(index) && NumUtil.isInt(asConstant(index).asLong())) {
+        if (isConstant(index) && NumUtil.isInt(asConstant(index).asLong() + displacement)) {
             displacement += (int) asConstant(index).asLong();
             address = new Address(kind, load(operand(node.object())), displacement);
         } else {
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java	Wed Jun 27 14:15:32 2012 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java	Wed Jun 27 15:40:03 2012 +0200
@@ -345,12 +345,21 @@
         } else if (n instanceof UnsafeStoreNode) {
             UnsafeStoreNode store = (UnsafeStoreNode) n;
             IndexedLocationNode location = IndexedLocationNode.create(LocationNode.ANY_LOCATION, store.storeKind(), store.displacement(), store.offset(), graph, false);
-            WriteNode write = graph.add(new WriteNode(store.object(), store.value(), location));
+            ValueNode object = store.object();
+            WriteNode write = graph.add(new WriteNode(object, store.value(), location));
             write.setStateAfter(store.stateAfter());
             graph.replaceFixedWithFixed(store, write);
             if (write.value().kind() == Kind.Object && !write.value().isNullConstant()) {
-                FieldWriteBarrier barrier = graph.add(new FieldWriteBarrier(write.object()));
-                graph.addBeforeFixed(write, barrier);
+                ResolvedJavaType type = object.objectStamp().type();
+                WriteBarrier writeBarrier;
+                if (type != null && !type.isArrayClass() && type.toJava() != Object.class) {
+                    // Use a field write barrier since it's not an array store
+                    writeBarrier = graph.add(new FieldWriteBarrier(object));
+                } else {
+                    // This may be an array store so use an array write barrier
+                    writeBarrier = graph.add(new ArrayWriteBarrier(object, location));
+                }
+                graph.addAfterFixed(write, writeBarrier);
             }
         } else if (n instanceof ReadHubNode) {
             ReadHubNode objectClassNode = (ReadHubNode) n;
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ValueNode.java	Wed Jun 27 14:15:32 2012 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ValueNode.java	Wed Jun 27 15:40:03 2012 +0200
@@ -150,6 +150,7 @@
     }
 
     public <T extends Stamp> boolean verifyStamp(Class<T> stampClass) {
+        assert stamp != null;
         assert stampClass.isInstance(stamp) : this + " (" + GraphUtil.approxSourceLocation(this) + ") has unexpected stamp type: expected " + stampClass.getName() +
             ", got " + stamp.getClass().getName();
         return true;
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeStoreNode.java	Wed Jun 27 14:15:32 2012 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeStoreNode.java	Wed Jun 27 15:40:03 2012 +0200
@@ -85,6 +85,13 @@
     }
 
     @Override
+    public boolean verify() {
+        assertTrue(storeKind != null, "UnsafeStoreNode must have a store kind");
+        assertTrue(object != null, "UnsafeStoreNode should have an object");
+        return super.verify();
+    }
+
+    @Override
     public void lower(CiLoweringTool tool) {
         tool.getRuntime().lower(this, tool);
     }