use of com.oracle.truffle.api.object.DynamicObject in project graal by oracle.
the class LayoutStrategy method reshapeAfterDelete.
/**
* @since 0.17 or earlier
*/
protected void reshapeAfterDelete(DynamicObjectImpl object, ShapeImpl oldShape, ShapeImpl newShape, ShapeImpl deletedParentShape) {
DynamicObject original = object.cloneWithShape(oldShape);
object.setShapeAndResize(newShape);
object.copyProperties(original, deletedParentShape);
}
use of com.oracle.truffle.api.object.DynamicObject in project graal by oracle.
the class ShapeProfiler method dump.
public void dump(PrintWriter out) {
ShapeStats globalStats = new ShapeStats("Cumulative results for all shapes");
for (DynamicObject obj : queue) {
Shape shape = obj.getShape();
globalStats.profile(shape);
}
globalStats.dump(out);
}
use of com.oracle.truffle.api.object.DynamicObject in project graal by oracle.
the class ShapeProfiler method dump.
public void dump(PrintWriter out, int topResults) {
if (topResults > 0) {
IdentityHashMap<Shape, ShapeStats> shapeMap = new IdentityHashMap<>();
for (DynamicObject obj : queue) {
Shape shape = obj.getShape();
ShapeStats stats = shapeMap.get(shape);
if (stats == null) {
shapeMap.put(shape, stats = new ShapeStats(createLabel(shape)));
}
stats.profile(shape);
}
List<ShapeStats> allStats = new ArrayList<>(shapeMap.values());
Collections.sort(allStats, new Comparator<ShapeStats>() {
public int compare(ShapeStats a, ShapeStats b) {
return Long.compare(b.objects, a.objects);
}
});
int top = Math.min(topResults, allStats.size());
ShapeStats avgStats = new ShapeStats("Cumulative results for top " + top + " shapes");
for (int i = 0; i < top; i++) {
ShapeStats stats = allStats.get(i);
stats.setLabel("Shape " + (i + 1) + ": " + stats.getLabel());
stats.dump(out);
avgStats.add(stats);
}
avgStats.dump(out);
}
// Dump also cumulative results.
dump(out);
}
use of com.oracle.truffle.api.object.DynamicObject in project graal by oracle.
the class DynamicObjectBasic method reshape.
@Override
protected final void reshape(ShapeImpl newShape) {
reshapeCount.inc();
ShapeImpl oldShape = getShape();
ShapeImpl commonAncestor = ShapeImpl.findCommonAncestor(oldShape, newShape);
if (ObjectStorageOptions.TraceReshape) {
int limit = 200;
PrintStream out = System.out;
out.printf("RESHAPE\nOLD %s\nNEW %s\nLCA %s\nDIFF %s\n---\n", oldShape.toStringLimit(limit), newShape.toStringLimit(limit), commonAncestor.toStringLimit(limit), ShapeImpl.diff(oldShape, newShape));
}
DynamicObject original = this.cloneWithShape(oldShape);
setShapeAndGrow(oldShape, newShape);
assert !((newShape.hasPrimitiveArray() && newShape.getPrimitiveArrayCapacity() == 0)) || getPrimitiveStore(newShape) == null;
copyProperties(original, commonAncestor);
assert checkExtensionArrayInvariants(newShape);
}
use of com.oracle.truffle.api.object.DynamicObject in project graal by oracle.
the class Debug method dumpObject.
static String dumpObject(DynamicObject object, int level, int levelStop) {
List<Property> properties = object.getShape().getPropertyListInternal(true);
StringBuilder sb = new StringBuilder(properties.size() * 10);
sb.append("{\n");
for (Property property : properties) {
indent(sb, level + 1);
sb.append(property.getKey());
sb.append('[').append(property.getLocation()).append(']');
Object value = property.get(object, false);
if (value instanceof DynamicObject) {
if (level < levelStop) {
value = dumpObject((DynamicObject) value, level + 1, levelStop);
} else {
value = value.toString();
}
}
sb.append(": ");
sb.append(value);
if (property != properties.get(properties.size() - 1)) {
sb.append(",");
}
sb.append("\n");
}
indent(sb, level);
sb.append("}");
return sb.toString();
}
Aggregations