diff graal/com.oracle.truffle.object/src/com/oracle/truffle/object/ShapeImpl.java @ 21944:16725287d5af

Truffle: fix delete/removeProperty regression
author Andreas Woess <andreas.woess@oracle.com>
date Tue, 16 Jun 2015 19:27:51 +0200
parents 1adad389c232
children 9f70fc90169d
line wrap: on
line diff
--- a/graal/com.oracle.truffle.object/src/com/oracle/truffle/object/ShapeImpl.java	Tue Jun 16 19:26:49 2015 +0200
+++ b/graal/com.oracle.truffle.object/src/com/oracle/truffle/object/ShapeImpl.java	Tue Jun 16 19:27:51 2015 +0200
@@ -620,12 +620,15 @@
             return cachedShape;
         }
 
-        ShapeImpl shape = getShapeFromProperty(prop);
+        ShapeImpl shape = getShapeFromProperty(prop.getKey());
         if (shape != null) {
             List<Transition> transitionList = new ArrayList<>();
             ShapeImpl current = this;
             while (current != shape) {
-                transitionList.add(current.getTransitionFromParent());
+                if (!(current.getTransitionFromParent() instanceof Transition.DirectReplacePropertyTransition) ||
+                                !((Transition.DirectReplacePropertyTransition) current.getTransitionFromParent()).getPropertyBefore().getKey().equals(prop.getKey())) {
+                    transitionList.add(current.getTransitionFromParent());
+                }
                 current = current.parent;
             }
             ShapeImpl newShape = shape.parent;
@@ -655,7 +658,14 @@
         } else if (transition instanceof ReservePrimitiveArrayTransition) {
             return reservePrimitiveExtensionArray();
         } else if (transition instanceof DirectReplacePropertyTransition) {
-            return replaceProperty(((DirectReplacePropertyTransition) transition).getPropertyBefore(), ((DirectReplacePropertyTransition) transition).getPropertyAfter());
+            Property oldProperty = ((DirectReplacePropertyTransition) transition).getPropertyBefore();
+            Property newProperty = ((DirectReplacePropertyTransition) transition).getPropertyAfter();
+            if (append) {
+                assert oldProperty.getLocation() instanceof DualLocation && newProperty.getLocation() instanceof DualLocation;
+                oldProperty = getProperty(oldProperty.getKey());
+                newProperty = newProperty.relocate(((DualLocation) oldProperty.getLocation()).changeType(((DualLocation) newProperty.getLocation()).getType()));
+            }
+            return replaceProperty(oldProperty, newProperty);
         } else {
             throw new UnsupportedOperationException();
         }