diff graal/com.oracle.truffle.object/src/com/oracle/truffle/object/DynamicObjectImpl.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 c76742cc2c6f
children
line wrap: on
line diff
--- a/graal/com.oracle.truffle.object/src/com/oracle/truffle/object/DynamicObjectImpl.java	Tue Jun 16 19:26:49 2015 +0200
+++ b/graal/com.oracle.truffle.object/src/com/oracle/truffle/object/DynamicObjectImpl.java	Tue Jun 16 19:27:51 2015 +0200
@@ -165,23 +165,21 @@
         assert toShape.isRelated(ancestor);
         assert toShape.isValid();
         assert ancestor.isValid();
-        for (; toShape != ancestor; toShape = toShape.getParent()) {
-            Transition transitionFromParent = toShape.getTransitionFromParent();
-            if (transitionFromParent instanceof Transition.AddPropertyTransition) {
-                Property toProperty = ((Transition.AddPropertyTransition) transitionFromParent).getProperty();
-                Property fromProperty = fromShape.getProperty(toProperty.getKey());
+        PropertyMap ancestorMap = ((ShapeImpl) ancestor).getPropertyMap();
+        PropertyMap fromMap = fromShape.getPropertyMap();
+        for (PropertyMap toMap = toShape.getPropertyMap(); !toMap.isEmpty() && toMap != ancestorMap; toMap = toMap.getParentMap()) {
+            Property toProperty = toMap.getLastProperty();
+            Property fromProperty = fromMap.get(toProperty.getKey());
 
-                // copy only if property has a location and it's not the same as the source location
-                if (toProperty.getLocation() != null && !(toProperty.getLocation() instanceof ValueLocation) && !toProperty.getLocation().equals(fromProperty.getLocation())) {
-                    toProperty.setInternal(this, fromProperty.get(fromObject, false));
-                    assert toShape.isValid();
-                }
+            // copy only if property has a location and it's not the same as the source location
+            if (toProperty.getLocation() != null && !(toProperty.getLocation() instanceof ValueLocation) && !toProperty.getLocation().equals(fromProperty.getLocation())) {
+                toProperty.setInternal(this, fromProperty.get(fromObject, false));
+                assert toShape.isValid();
+            }
 
-                if (fromShape.getTransitionFromParent() instanceof Transition.AddPropertyTransition &&
-                                ((Transition.AddPropertyTransition) fromShape.getTransitionFromParent()).getProperty() == fromProperty) {
-                    // no property is looked up twice, so we can skip over to parent
-                    fromShape = fromShape.getParent();
-                }
+            if (fromProperty == fromMap.getLastProperty()) {
+                // no property is looked up twice, so we can skip over to parent
+                fromMap = fromMap.getParentMap();
             }
         }
     }