Mercurial > hg > graal-jvmci-8
diff graal/com.oracle.truffle.object/src/com/oracle/truffle/object/ShapeImpl.java @ 21923:1b695a36c4d5
Truffle: remove cached property array
author | Andreas Woess <andreas.woess@oracle.com> |
---|---|
date | Thu, 11 Jun 2015 17:10:27 +0200 |
parents | e9b787f8134f |
children | c0744b24b230 |
line wrap: on
line diff
--- 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<Property> getProperties() { - if (getPropertyCount() != 0 && propertyArray == null) { - CompilerDirectives.transferToInterpreter(); - propertyArray = createPropertiesArray(); - } - return new Iterable<Property>() { - public Iterator<Property> iterator() { - return new Iterator<Property>() { - 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<Property> 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(); }