Mercurial > hg > truffle
diff graal/com.oracle.truffle.object/src/com/oracle/truffle/object/ShapeImpl.java @ 21924:c0744b24b230
Truffle: minor refactoring
author | Andreas Woess <andreas.woess@oracle.com> |
---|---|
date | Thu, 11 Jun 2015 17:16:53 +0200 |
parents | 1b695a36c4d5 |
children | 1adad389c232 |
line wrap: on
line diff
--- a/graal/com.oracle.truffle.object/src/com/oracle/truffle/object/ShapeImpl.java Thu Jun 11 17:10:27 2015 +0200 +++ b/graal/com.oracle.truffle.object/src/com/oracle/truffle/object/ShapeImpl.java Thu Jun 11 17:16:53 2015 +0200 @@ -316,7 +316,7 @@ return addPropertyInternal(property); } - protected final void onPropertyTransition(Property property) { + private void onPropertyTransition(Property property) { if (sharedData instanceof ShapeListener) { ((ShapeListener) sharedData).onPropertyTransition(property.getKey()); } @@ -671,6 +671,10 @@ */ @Override public ShapeImpl replaceProperty(Property oldProperty, Property newProperty) { + return indirectReplaceProperty(oldProperty, newProperty); + } + + protected final ShapeImpl indirectReplaceProperty(Property oldProperty, Property newProperty) { assert oldProperty.getKey().equals(newProperty.getKey()); Transition replacePropertyTransition = new Transition.IndirectReplacePropertyTransition(oldProperty, newProperty); @@ -699,10 +703,27 @@ newShape = newShape.applyTransition(transition, false); } } + addIndirectTransition(replacePropertyTransition, newShape); return newShape; } + protected final ShapeImpl directReplaceProperty(Property oldProperty, Property newProperty) { + assert oldProperty.getKey().equals(newProperty.getKey()); + onPropertyTransition(oldProperty); + + Transition replacePropertyTransition = new Transition.DirectReplacePropertyTransition(oldProperty, newProperty); + ShapeImpl cachedShape = queryTransition(replacePropertyTransition); + if (cachedShape != null) { + return cachedShape; + } + PropertyMap newPropertyMap = this.getPropertyMap().replaceCopy(oldProperty, newProperty); + ShapeImpl newShape = createShape(getLayout(), getSharedData(), this, getObjectType(), newPropertyMap, replacePropertyTransition, allocator(), getId()); + + addDirectTransition(replacePropertyTransition, newShape); + return newShape; + } + /** * Find lowest common ancestor of two related shapes. */