# HG changeset patch # User Andreas Woess # Date 1434035427 -7200 # Node ID 1b695a36c4d53f1e30bf59a1cbbcbff3e3b9e352 # Parent 2ee70257c9c4dad458107a4327565968a296d349 Truffle: remove cached property array diff -r 2ee70257c9c4 -r 1b695a36c4d5 graal/com.oracle.truffle.object/src/com/oracle/truffle/object/ShapeImpl.java --- a/graal/com.oracle.truffle.object/src/com/oracle/truffle/object/ShapeImpl.java Thu Jun 11 16:45:42 2015 +0200 +++ b/graal/com.oracle.truffle.object/src/com/oracle/truffle/object/ShapeImpl.java Thu Jun 11 17:10:27 2015 +0200 @@ -80,7 +80,6 @@ protected final int depth; protected final int propertyCount; - protected Property[] propertyArray; protected final Assumption validAssumption; @CompilationFinal protected volatile Assumption leafAssumption; @@ -121,11 +120,9 @@ if (parent != null) { this.propertyCount = makePropertyCount(parent, propertyMap); - this.propertyArray = makePropertiesList(parent, propertyMap); this.depth = parent.depth + 1; } else { this.propertyCount = 0; - this.propertyArray = null; this.depth = 0; } @@ -156,30 +153,6 @@ return parent.propertyCount + ((propertyMap.size() > parent.propertyMap.size() && !propertyMap.getLastProperty().isHidden() && !propertyMap.getLastProperty().isShadow()) ? 1 : 0); } - private static Property[] makePropertiesList(ShapeImpl parent, PropertyMap propertyMap) { - Property[] properties = parent.propertyArray; - if (properties != null && propertyMap.size() != parent.propertyMap.size()) { - Property lastProperty = propertyMap.getLastProperty(); - if (lastProperty != null && !lastProperty.isHidden()) { - propertyListAllocCount.inc(); - if (!lastProperty.isShadow()) { - properties = Arrays.copyOf(properties, properties.length + 1); - properties[properties.length - 1] = lastProperty; - } else { - properties = Arrays.copyOf(properties, properties.length); - for (int i = 0; i < properties.length; i++) { - if (properties[i].isSame(lastProperty)) { - properties[i] = lastProperty; - } - } - } - } else { - propertyListShareCount.inc(); - } - } - return properties; - } - @Override public final Property getLastProperty() { return propertyMap.getLastProperty(); @@ -880,43 +853,7 @@ @Override public final Iterable getProperties() { - if (getPropertyCount() != 0 && propertyArray == null) { - CompilerDirectives.transferToInterpreter(); - propertyArray = createPropertiesArray(); - } - return new Iterable() { - public Iterator iterator() { - return new Iterator() { - private int cursor; - - public boolean hasNext() { - return cursor < getPropertyCount(); - } - - public Property next() { - if (hasNext()) { - return propertyArray[cursor++]; - } - throw new NoSuchElementException(); - } - - public void remove() { - throw new UnsupportedOperationException(); - } - }; - } - }; - } - - private Property[] createPropertiesArray() { - propertyListAllocCount.inc(); - Property[] propertiesArray = new Property[getPropertyCount()]; - List ownProperties = getPropertyList(); - assert ownProperties.size() == getPropertyCount(); - for (int i = 0; i < getPropertyCount(); i++) { - propertiesArray[i] = ownProperties.get(i); - } - return propertiesArray; + return getPropertyList(); } @Override @@ -1122,9 +1059,6 @@ private static final DebugCounter shapeCacheHitCount = DebugCounter.create("Shape cache hits"); private static final DebugCounter shapeCacheMissCount = DebugCounter.create("Shape cache misses"); - protected static final DebugCounter propertyListAllocCount = DebugCounter.create("Property lists allocated"); - protected static final DebugCounter propertyListShareCount = DebugCounter.create("Property lists shared"); - public ForeignAccess getForeignAccessFactory() { return getObjectType().getForeignAccessFactory(); }