changeset 11496:b36028c30a81

Allow escape analysis to ignore object identity correctness for types marked via the CompilerDirectives.ValueType annotation.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Sun, 01 Sep 2013 19:46:15 +0200
parents 3662471dcfaa
children f778836e07c6
files graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ObjectCloneNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/NewInstanceNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/virtual/VirtualArrayNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/virtual/VirtualBoxingNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/virtual/VirtualInstanceNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/virtual/VirtualObjectNode.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/frame/NewFrameNode.java
diffstat 8 files changed, 34 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ObjectCloneNode.java	Sun Sep 01 19:39:06 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ObjectCloneNode.java	Sun Sep 01 19:46:15 2013 +0200
@@ -121,7 +121,7 @@
             ResolvedJavaType type = getConcreteType(obj.stamp(), tool.getAssumptions());
             if (isCloneableType(type, tool.getMetaAccessProvider())) {
                 if (!type.isArray()) {
-                    VirtualInstanceNode newVirtual = new VirtualInstanceNode(type);
+                    VirtualInstanceNode newVirtual = new VirtualInstanceNode(type, true);
                     ResolvedJavaField[] fields = newVirtual.getFields();
 
                     ValueNode[] state = new ValueNode[fields.length];
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/NewInstanceNode.java	Sun Sep 01 19:39:06 2013 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/NewInstanceNode.java	Sun Sep 01 19:46:15 2013 +0200
@@ -85,7 +85,7 @@
     public void virtualize(VirtualizerTool tool) {
         if (instanceClass != null) {
             assert !instanceClass().isArray();
-            VirtualInstanceNode virtualObject = new VirtualInstanceNode(instanceClass());
+            VirtualInstanceNode virtualObject = new VirtualInstanceNode(instanceClass(), true);
             ResolvedJavaField[] fields = virtualObject.getFields();
             ValueNode[] state = new ValueNode[fields.length];
             for (int i = 0; i < state.length; i++) {
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/virtual/VirtualArrayNode.java	Sun Sep 01 19:39:06 2013 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/virtual/VirtualArrayNode.java	Sun Sep 01 19:46:15 2013 +0200
@@ -36,6 +36,7 @@
     private final int length;
 
     public VirtualArrayNode(ResolvedJavaType componentType, int length) {
+        super(true);
         this.componentType = componentType;
         this.length = length;
     }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/virtual/VirtualBoxingNode.java	Sun Sep 01 19:39:06 2013 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/virtual/VirtualBoxingNode.java	Sun Sep 01 19:46:15 2013 +0200
@@ -31,7 +31,7 @@
     private final Kind boxingKind;
 
     public VirtualBoxingNode(ResolvedJavaType type, Kind boxingKind) {
-        super(type);
+        super(type, false);
         this.boxingKind = boxingKind;
     }
 
@@ -41,11 +41,6 @@
     }
 
     @Override
-    public boolean hasIdentity() {
-        return false;
-    }
-
-    @Override
     public ValueNode getMaterializedRepresentation(FixedNode fixed, ValueNode[] entries, int[] locks) {
         assert entries.length == 1;
         assert locks.length == 0;
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/virtual/VirtualInstanceNode.java	Sun Sep 01 19:39:06 2013 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/virtual/VirtualInstanceNode.java	Sun Sep 01 19:46:15 2013 +0200
@@ -32,12 +32,12 @@
     private final ResolvedJavaType type;
     private final ResolvedJavaField[] fields;
 
-    public VirtualInstanceNode(ResolvedJavaType type) {
-        this.type = type;
-        this.fields = type.getInstanceFields(true);
+    public VirtualInstanceNode(ResolvedJavaType type, boolean hasIdentity) {
+        this(type, type.getInstanceFields(true), hasIdentity);
     }
 
-    public VirtualInstanceNode(ResolvedJavaType type, ResolvedJavaField[] fields) {
+    public VirtualInstanceNode(ResolvedJavaType type, ResolvedJavaField[] fields, boolean hasIdentity) {
+        super(hasIdentity);
         this.type = type;
         this.fields = fields;
     }
@@ -97,7 +97,7 @@
 
     @Override
     public VirtualInstanceNode duplicate() {
-        return new VirtualInstanceNode(type);
+        return new VirtualInstanceNode(type, fields, super.hasIdentity());
     }
 
     @Override
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/virtual/VirtualObjectNode.java	Sun Sep 01 19:39:06 2013 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/virtual/VirtualObjectNode.java	Sun Sep 01 19:46:15 2013 +0200
@@ -23,14 +23,18 @@
 package com.oracle.graal.nodes.virtual;
 
 import com.oracle.graal.api.meta.*;
+import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.nodes.type.*;
 
-public abstract class VirtualObjectNode extends ValueNode implements LIRLowerable {
+public abstract class VirtualObjectNode extends ValueNode implements LIRLowerable, Node.IterableNodeType {
 
-    public VirtualObjectNode() {
+    private boolean hasIdentity;
+
+    public VirtualObjectNode(boolean hasIdentity) {
         super(StampFactory.virtual());
+        this.hasIdentity = hasIdentity;
     }
 
     /**
@@ -72,7 +76,11 @@
      * comparison of two virtual objects is determined by comparing their contents.
      */
     public boolean hasIdentity() {
-        return true;
+        return hasIdentity;
+    }
+
+    public void setIdentity(boolean identity) {
+        this.hasIdentity = identity;
     }
 
     /**
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java	Sun Sep 01 19:39:06 2013 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java	Sun Sep 01 19:46:15 2013 +0200
@@ -42,6 +42,7 @@
 import com.oracle.graal.nodes.java.MethodCallTargetNode.InvokeKind;
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.nodes.util.*;
+import com.oracle.graal.nodes.virtual.*;
 import com.oracle.graal.phases.*;
 import com.oracle.graal.phases.PhasePlan.PhasePosition;
 import com.oracle.graal.phases.common.*;
@@ -184,8 +185,17 @@
                     materializeNode.replaceAtUsages(materializeNode.getFrame());
                     graph.removeFixed(materializeNode);
                 }
-                for (VirtualOnlyInstanceNode virtualOnlyNode : graph.getNodes(VirtualOnlyInstanceNode.class)) {
-                    virtualOnlyNode.setAllowMaterialization(true);
+                for (VirtualObjectNode virtualObjectNode : graph.getNodes(VirtualObjectNode.class)) {
+                    if (virtualObjectNode instanceof VirtualOnlyInstanceNode) {
+                        VirtualOnlyInstanceNode virtualOnlyInstanceNode = (VirtualOnlyInstanceNode) virtualObjectNode;
+                        virtualOnlyInstanceNode.setAllowMaterialization(true);
+                    } else if (virtualObjectNode instanceof VirtualInstanceNode) {
+                        VirtualInstanceNode virtualInstanceNode = (VirtualInstanceNode) virtualObjectNode;
+                        ResolvedJavaType type = virtualInstanceNode.type();
+                        if (type.getAnnotation(CompilerDirectives.ValueType.class) != null) {
+                            virtualInstanceNode.setIdentity(false);
+                        }
+                    }
                 }
 
                 // Convert deopt to guards.
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/frame/NewFrameNode.java	Sun Sep 01 19:39:06 2013 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/frame/NewFrameNode.java	Sun Sep 01 19:46:15 2013 +0200
@@ -92,12 +92,12 @@
         throw new RuntimeException("Frame field not found: " + fieldName);
     }
 
-    public static class VirtualOnlyInstanceNode extends VirtualInstanceNode implements Node.IterableNodeType {
+    public static class VirtualOnlyInstanceNode extends VirtualInstanceNode {
 
         private boolean allowMaterialization;
 
         public VirtualOnlyInstanceNode(ResolvedJavaType type, ResolvedJavaField[] fields) {
-            super(type, fields);
+            super(type, fields, false);
         }
 
         @Override