changeset 18848:49e5c062e77a

[SPARC] Do not virtualize objects, when the types do not match on big endian machines
author Stefan Anzinger <stefan.anzinger@oracle.com>
date Mon, 12 Jan 2015 21:12:24 +0100
parents 5e80dd2f1783
children 55a30b4beb5f
files graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeLoadNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeStoreNode.java
diffstat 2 files changed, 22 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeLoadNode.java	Mon Jan 12 19:34:31 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeLoadNode.java	Mon Jan 12 21:12:24 2015 +0100
@@ -24,6 +24,8 @@
 
 import static com.oracle.graal.compiler.common.UnsafeAccess.*;
 
+import java.nio.*;
+
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.compiler.common.type.*;
 import com.oracle.graal.nodeinfo.*;
@@ -73,9 +75,11 @@
             if (offsetValue.isConstant()) {
                 long off = offsetValue.asJavaConstant().asLong();
                 int entryIndex = state.getVirtualObject().entryIndexForOffset(off);
+
                 if (entryIndex != -1) {
                     ValueNode entry = state.getEntry(entryIndex);
-                    if (entry.getKind() == getKind() || state.getVirtualObject().entryKind(entryIndex) == accessKind()) {
+                    boolean isLoadSafe = ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN || accessKind() == entry.getKind();
+                    if (isLoadSafe && (entry.getKind() == getKind() || state.getVirtualObject().entryKind(entryIndex) == accessKind())) {
                         tool.replaceWith(entry);
                     }
                 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeStoreNode.java	Mon Jan 12 19:34:31 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeStoreNode.java	Mon Jan 12 21:12:24 2015 +0100
@@ -24,6 +24,8 @@
 
 import static com.oracle.graal.compiler.common.UnsafeAccess.*;
 
+import java.nio.*;
+
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.compiler.common.type.*;
 import com.oracle.graal.nodeinfo.*;
@@ -94,18 +96,21 @@
                 if (entryIndex != -1) {
                     Kind entryKind = state.getVirtualObject().entryKind(entryIndex);
                     ValueNode entry = state.getEntry(entryIndex);
-                    if (entry.getKind() == value.getKind() || entryKind == accessKind()) {
-                        tool.setVirtualEntry(state, entryIndex, value(), true);
-                        tool.delete();
-                    } else {
-                        if ((accessKind() == Kind.Long || accessKind() == Kind.Double) && entryKind == Kind.Int) {
-                            int nextIndex = state.getVirtualObject().entryIndexForOffset(off + 4);
-                            if (nextIndex != -1) {
-                                Kind nextKind = state.getVirtualObject().entryKind(nextIndex);
-                                if (nextKind == Kind.Int) {
-                                    tool.setVirtualEntry(state, entryIndex, value(), true);
-                                    tool.setVirtualEntry(state, nextIndex, ConstantNode.forConstant(JavaConstant.forIllegal(), tool.getMetaAccessProvider(), graph()), true);
-                                    tool.delete();
+                    boolean isLoadSafe = ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN || accessKind() == entry.getKind();
+                    if (isLoadSafe) {
+                        if (entry.getKind() == value.getKind() || entryKind == accessKind()) {
+                            tool.setVirtualEntry(state, entryIndex, value(), true);
+                            tool.delete();
+                        } else {
+                            if ((accessKind() == Kind.Long || accessKind() == Kind.Double) && entryKind == Kind.Int) {
+                                int nextIndex = state.getVirtualObject().entryIndexForOffset(off + 4);
+                                if (nextIndex != -1) {
+                                    Kind nextKind = state.getVirtualObject().entryKind(nextIndex);
+                                    if (nextKind == Kind.Int) {
+                                        tool.setVirtualEntry(state, entryIndex, value(), true);
+                                        tool.setVirtualEntry(state, nextIndex, ConstantNode.forConstant(JavaConstant.forIllegal(), tool.getMetaAccessProvider(), graph()), true);
+                                        tool.delete();
+                                    }
                                 }
                             }
                         }