diff graal/com.oracle.truffle.object/src/com/oracle/truffle/object/ShapeImpl.java @ 21900:cb051c368c80

Truffle: move property notification hook to shared data, and call it on remove as well
author Andreas Woess <andreas.woess@oracle.com>
date Wed, 10 Jun 2015 20:05:52 +0200
parents c76742cc2c6f
children 19340125f182
line wrap: on
line diff
--- a/graal/com.oracle.truffle.object/src/com/oracle/truffle/object/ShapeImpl.java	Wed Jun 10 16:18:22 2015 +0200
+++ b/graal/com.oracle.truffle.object/src/com/oracle/truffle/object/ShapeImpl.java	Wed Jun 10 20:05:52 2015 +0200
@@ -332,9 +332,14 @@
     @Override
     public ShapeImpl addProperty(Property property) {
         assert isValid();
-        ShapeImpl nextShape = addPropertyInternal(property);
-        objectType.onPropertyAdded(property, this, nextShape);
-        return nextShape;
+        onPropertyTransition(property);
+        return addPropertyInternal(property);
+    }
+
+    protected final void onPropertyTransition(Property property) {
+        if (sharedData instanceof ShapeListener) {
+            ((ShapeListener) sharedData).onPropertyTransition(property.getKey());
+        }
     }
 
     /**
@@ -627,6 +632,8 @@
     @TruffleBoundary
     @Override
     public final ShapeImpl removeProperty(Property prop) {
+        onPropertyTransition(prop);
+
         RemovePropertyTransition transition = new RemovePropertyTransition(prop);
         ShapeImpl cachedShape = queryTransition(transition);
         if (cachedShape != null) {