comparison graal/com.oracle.truffle.object/src/com/oracle/truffle/object/ShapeImpl.java @ 21953:633eb3ec30ce

Truffle: fix delete/removeProperty regression
author Andreas Woess <andreas.woess@oracle.com>
date Fri, 12 Jun 2015 14:46:18 +0200
parents f929f601bdca
children
comparison
equal deleted inserted replaced
21952:f929f601bdca 21953:633eb3ec30ce
618 ShapeImpl cachedShape = queryTransition(transition); 618 ShapeImpl cachedShape = queryTransition(transition);
619 if (cachedShape != null) { 619 if (cachedShape != null) {
620 return cachedShape; 620 return cachedShape;
621 } 621 }
622 622
623 ShapeImpl shape = getShapeFromProperty(prop); 623 ShapeImpl shape = getShapeFromProperty(prop.getKey());
624 if (shape != null) { 624 if (shape != null) {
625 List<Transition> transitionList = new ArrayList<>(); 625 List<Transition> transitionList = new ArrayList<>();
626 ShapeImpl current = this; 626 ShapeImpl current = this;
627 while (current != shape) { 627 while (current != shape) {
628 transitionList.add(current.getTransitionFromParent()); 628 if (!(current.getTransitionFromParent() instanceof Transition.DirectReplacePropertyTransition) ||
629 !((Transition.DirectReplacePropertyTransition) current.getTransitionFromParent()).getPropertyBefore().getKey().equals(prop.getKey())) {
630 transitionList.add(current.getTransitionFromParent());
631 }
629 current = current.parent; 632 current = current.parent;
630 } 633 }
631 ShapeImpl newShape = shape.parent; 634 ShapeImpl newShape = shape.parent;
632 for (ListIterator<Transition> iterator = transitionList.listIterator(transitionList.size()); iterator.hasPrevious();) { 635 for (ListIterator<Transition> iterator = transitionList.listIterator(transitionList.size()); iterator.hasPrevious();) {
633 Transition previous = iterator.previous(); 636 Transition previous = iterator.previous();
653 } else if (transition instanceof ObjectTypeTransition) { 656 } else if (transition instanceof ObjectTypeTransition) {
654 return changeType(((ObjectTypeTransition) transition).getObjectType()); 657 return changeType(((ObjectTypeTransition) transition).getObjectType());
655 } else if (transition instanceof ReservePrimitiveArrayTransition) { 658 } else if (transition instanceof ReservePrimitiveArrayTransition) {
656 return reservePrimitiveExtensionArray(); 659 return reservePrimitiveExtensionArray();
657 } else if (transition instanceof DirectReplacePropertyTransition) { 660 } else if (transition instanceof DirectReplacePropertyTransition) {
658 return replaceProperty(((DirectReplacePropertyTransition) transition).getPropertyBefore(), ((DirectReplacePropertyTransition) transition).getPropertyAfter()); 661 Property oldProperty = ((DirectReplacePropertyTransition) transition).getPropertyBefore();
662 Property newProperty = ((DirectReplacePropertyTransition) transition).getPropertyAfter();
663 if (append) {
664 assert oldProperty.getLocation() instanceof DualLocation && newProperty.getLocation() instanceof DualLocation;
665 oldProperty = getProperty(oldProperty.getKey());
666 newProperty = newProperty.relocate(((DualLocation) oldProperty.getLocation()).changeType(((DualLocation) newProperty.getLocation()).getType()));
667 }
668 return replaceProperty(oldProperty, newProperty);
659 } else { 669 } else {
660 throw new UnsupportedOperationException(); 670 throw new UnsupportedOperationException();
661 } 671 }
662 } 672 }
663 673