changeset 6959:9c71ad0a0652

extra assertion checking when initializing the values of a VirtualObject
author Doug Simon <doug.simon@oracle.com>
date Sun, 18 Nov 2012 21:10:55 +0100
parents abbe4faaf0c1
children 72056acf27ab
files graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/VirtualObject.java graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/DebugInfoBuilder.java
diffstat 2 files changed, 28 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/VirtualObject.java	Fri Nov 16 12:39:26 2012 +0100
+++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/VirtualObject.java	Sun Nov 18 21:10:55 2012 +0100
@@ -92,7 +92,7 @@
     /**
      * Returns the type of the object whose allocation was removed during compilation. This can be either an instance of an array type.
      */
-    public JavaType getType() {
+    public ResolvedJavaType getType() {
         return type;
     }
 
@@ -110,12 +110,34 @@
         return id;
     }
 
+    private static boolean checkValues(ResolvedJavaType type, Value[] values) {
+        if (values != null) {
+            if (!type.isArrayClass()) {
+                ResolvedJavaField[] fields = type.getInstanceFields(true);
+                assert fields.length == values.length : type + ": fields=" + Arrays.toString(fields) + ", field values=" + Arrays.toString(values);
+                for (int i = 0; i < values.length; i++) {
+                    ResolvedJavaField field = fields[i];
+                    Kind valKind = values[i].getKind().getStackKind();
+                    assert valKind == field.getKind().getStackKind() : field + ": " + valKind + " != " + field.getKind().getStackKind();
+                }
+            } else {
+                Kind componentKind = type.getComponentType().getKind().getStackKind();
+                for (int i = 0; i < values.length; i++) {
+                    assert values[i].getKind().getStackKind() == componentKind : values[i].getKind() + " != " + componentKind;
+                }
+            }
+
+        }
+        return true;
+    }
+
     /**
      * Overwrites the current set of values with a new one.
      *
      * @param values an array containing all the values to be stored into the object when it is recreated.
      */
     public void setValues(Value[] values) {
+        assert checkValues(type, values);
         this.values = values;
     }
 
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/DebugInfoBuilder.java	Fri Nov 16 12:39:26 2012 +0100
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/DebugInfoBuilder.java	Sun Nov 18 21:10:55 2012 +0100
@@ -149,13 +149,13 @@
                 return toValue(((MaterializedObjectState) state).materializedValue());
             } else {
                 assert obj.entryCount() == 0 || state instanceof VirtualObjectState || obj instanceof BoxedVirtualObjectNode;
-                VirtualObject ciObj = virtualObjects.get(value);
-                if (ciObj == null) {
-                    ciObj = VirtualObject.get(obj.type(), null, virtualObjects.size());
-                    virtualObjects.put(obj, ciObj);
+                VirtualObject vobject = virtualObjects.get(value);
+                if (vobject == null) {
+                    vobject = VirtualObject.get(obj.type(), null, virtualObjects.size());
+                    virtualObjects.put(obj, vobject);
                 }
                 Debug.metric("StateVirtualObjects").increment();
-                return ciObj;
+                return vobject;
             }
         } else if (value instanceof ConstantNode) {
             Debug.metric("StateConstants").increment();