@Override public final ShapeImpl reservePrimitiveExtensionArray() { if (layout.hasPrimitiveExtensionArray() && !hasPrimitiveArray()) { return addPrimitiveExtensionArray(); } return this; }
/** @since 0.17 or earlier */ @Override public final ShapeImpl reservePrimitiveExtensionArray() { if (layout.hasPrimitiveExtensionArray() && !hasPrimitiveArray()) { return layout.getStrategy().addPrimitiveExtensionArray(this); } return this; }
/** @since 0.17 or earlier */ @Override public final ShapeImpl reservePrimitiveExtensionArray() { if (layout.hasPrimitiveExtensionArray() && !hasPrimitiveArray()) { return layout.getStrategy().addPrimitiveExtensionArray(this); } return this; }
@Override protected final void resizePrimitiveStore(Shape oldShape, Shape newShape) { assert ((ShapeImpl) newShape).hasPrimitiveArray(); long[] newPrimitiveArray = null; int destinationCapacity = ((ShapeImpl) newShape).getPrimitiveArrayCapacity(); if (destinationCapacity != 0) { newPrimitiveArray = new long[destinationCapacity]; int sourceCapacity = ((ShapeImpl) oldShape).getPrimitiveArrayCapacity(); if (sourceCapacity != 0) { long[] oldPrimitiveArray = this.getPrimitiveStore(newShape); for (int i = 0; i < Math.min(sourceCapacity, destinationCapacity); ++i) { newPrimitiveArray[i] = oldPrimitiveArray[i]; } } } this.setPrimitiveStore(newPrimitiveArray, newShape); }
/** * Create a new shape that reserves the primitive extension array field. */ private static ShapeImpl makeShapeWithPrimitiveExtensionArray(ShapeImpl parent, Transition transition) { assert parent.getLayout().hasPrimitiveExtensionArray(); assert !parent.hasPrimitiveArray(); BaseAllocator allocator = parent.allocator().addLocation(parent.getLayout().getPrimitiveArrayLocation()); ShapeImpl newShape = parent.createShape(parent.layout, parent.sharedData, parent, parent.objectType, parent.propertyMap, transition, allocator, parent.id); assert newShape.hasPrimitiveArray(); assert newShape.depth == allocator.depth; return newShape; }
/** * Create a new shape that reserves the primitive extension array field. * * @since 0.17 or earlier */ protected static ShapeImpl makeShapeWithPrimitiveExtensionArray(ShapeImpl parent, Transition transition) { assert parent.getLayout().hasPrimitiveExtensionArray(); assert !parent.hasPrimitiveArray(); BaseAllocator allocator = parent.allocator().addLocation(parent.getLayout().getPrimitiveArrayLocation()); ShapeImpl newShape = parent.createShape(parent.layout, parent.sharedData, parent, parent.objectType, parent.propertyMap, transition, allocator, parent.id); assert newShape.hasPrimitiveArray(); assert newShape.depth == allocator.depth; return newShape; }
/** * Create a new shape that reserves the primitive extension array field. * * @since 0.17 or earlier */ protected static ShapeImpl makeShapeWithPrimitiveExtensionArray(ShapeImpl parent, Transition transition) { assert parent.getLayout().hasPrimitiveExtensionArray(); assert !parent.hasPrimitiveArray(); BaseAllocator allocator = parent.allocator().addLocation(parent.getLayout().getPrimitiveArrayLocation()); ShapeImpl newShape = parent.createShape(parent.layout, parent.sharedData, parent, parent.objectType, parent.propertyMap, transition, allocator, parent.id); assert newShape.hasPrimitiveArray(); assert newShape.depth == allocator.depth; return newShape; }
/** * Simpler version of {@link #resizePrimitiveStore} when the object is only increasing in size. */ @Override protected final void growPrimitiveStore(Shape oldShape, Shape newShape) { assert ((ShapeImpl) newShape).hasPrimitiveArray(); int oldPrimitiveCapacity = ((ShapeImpl) oldShape).getPrimitiveArrayCapacity(); int newPrimitiveCapacity = ((ShapeImpl) newShape).getPrimitiveArrayCapacity(); if (newPrimitiveCapacity == 0) { // due to obsolescence, we might have to reserve an empty primitive array slot this.setPrimitiveStore(null, newShape); } else if (oldPrimitiveCapacity != newPrimitiveCapacity) { growPrimitiveStoreIntl(oldPrimitiveCapacity, newPrimitiveCapacity, oldShape); } }
/** * Simpler version of {@link #resizePrimitiveStore} when the object is only increasing in size. */ @Override protected final void growPrimitiveStore(Shape oldShape, Shape newShape) { assert ((ShapeImpl) newShape).hasPrimitiveArray(); int oldPrimitiveCapacity = oldShape.getPrimitiveArrayCapacity(); int newPrimitiveCapacity = newShape.getPrimitiveArrayCapacity(); if (newPrimitiveCapacity == 0) { // due to obsolescence, we might have to reserve an empty primitive array slot this.setPrimitiveStore(null, newShape); } else if (oldPrimitiveCapacity != newPrimitiveCapacity) { growPrimitiveStoreIntl(oldPrimitiveCapacity, newPrimitiveCapacity, oldShape); } }
/** * Simpler version of {@link #resizePrimitiveStore} when the object is only increasing in size. */ @Override protected final void growPrimitiveStore(Shape oldShape, Shape newShape) { assert ((ShapeImpl) newShape).hasPrimitiveArray(); int oldPrimitiveCapacity = ((ShapeImpl) oldShape).getPrimitiveArrayCapacity(); int newPrimitiveCapacity = ((ShapeImpl) newShape).getPrimitiveArrayCapacity(); if (newPrimitiveCapacity == 0) { // due to obsolescence, we might have to reserve an empty primitive array slot this.setPrimitiveStore(null, newShape); } else if (oldPrimitiveCapacity != newPrimitiveCapacity) { growPrimitiveStoreIntl(oldPrimitiveCapacity, newPrimitiveCapacity, oldShape); } }
private ShapeImpl addPrimitiveExtensionArray() { assert layout.hasPrimitiveExtensionArray() && !hasPrimitiveArray(); Transition transition = new ReservePrimitiveArrayTransition(); ShapeImpl cachedShape = queryTransition(transition); if (cachedShape != null) { return cachedShape; } ShapeImpl oldShape = (ShapeImpl) layout.getStrategy().ensureSpace(this, layout.getPrimitiveArrayLocation()); ShapeImpl newShape = makeShapeWithPrimitiveExtensionArray(oldShape, transition); oldShape.addDirectTransition(transition, newShape); return newShape; }
@SuppressWarnings("deprecation") @Override protected final void reshape(ShapeImpl newShape) { ShapeImpl oldShape = (ShapeImpl) getShape(); ShapeImpl commonAncestor = ShapeImpl.findCommonAncestor(oldShape, newShape); if (com.oracle.truffle.object.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); }
@Override protected final DynamicObject cloneWithShape(Shape currentShape) { assert this.getShape() == currentShape; final DynamicObjectBasic clone = (DynamicObjectBasic) super.clone(); if (this.getObjectStore(currentShape) != null) { clone.setObjectStore(this.getObjectStore(currentShape).clone(), currentShape); } if (((ShapeImpl) currentShape).hasPrimitiveArray() && this.getPrimitiveStore(currentShape) != null) { clone.setPrimitiveStore(this.getPrimitiveStore(currentShape).clone(), currentShape); } return clone; }
@Override protected final DynamicObject cloneWithShape(Shape currentShape) { assert this.getShape() == currentShape; final DynamicObjectBasic clone = (DynamicObjectBasic) super.clone(); if (this.getObjectStore(currentShape) != null) { clone.setObjectStore(this.getObjectStore(currentShape).clone(), currentShape); } if (((ShapeImpl) currentShape).hasPrimitiveArray() && this.getPrimitiveStore(currentShape) != null) { clone.setPrimitiveStore(this.getPrimitiveStore(currentShape).clone(), currentShape); } return clone; }
protected final void reshape(ShapeImpl newShape) { reshapeCount.inc(); ShapeImpl oldShape = getShape(); ShapeImpl commonAncestor = ShapeImpl.findCommonAncestor(oldShape, newShape); if (ObjectStorageOptions.TraceReshape) { int limit = 150; System.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); }
/** @since 0.17 or earlier */ protected ShapeImpl addPrimitiveExtensionArray(ShapeImpl shape) { LayoutImpl layout = shape.getLayout(); assert layout.hasPrimitiveExtensionArray() && !shape.hasPrimitiveArray(); Transition transition = new ReservePrimitiveArrayTransition(); ShapeImpl cachedShape = shape.queryTransition(transition); if (cachedShape != null) { return layout.getStrategy().ensureValid(cachedShape); } ShapeImpl oldShape = ensureSpace(shape, layout.getPrimitiveArrayLocation()); ShapeImpl newShape = ShapeImpl.makeShapeWithPrimitiveExtensionArray(oldShape, transition); oldShape.addDirectTransition(transition, newShape); return newShape; }
/** * Check whether the extension arrays are in accordance with the description in the shape. */ @Override protected final boolean checkExtensionArrayInvariants(Shape newShape) { assert getShape() == newShape; assert (getObjectStore(newShape) == null && ((ShapeImpl) newShape).getObjectArrayCapacity() == 0) || (getObjectStore(newShape) != null && getObjectStore(newShape).length == ((ShapeImpl) newShape).getObjectArrayCapacity()); if (((ShapeImpl) newShape).hasPrimitiveArray()) { assert (getPrimitiveStore(newShape) == null && ((ShapeImpl) newShape).getPrimitiveArrayCapacity() == 0) || (getPrimitiveStore(newShape) != null && getPrimitiveStore(newShape).length == ((ShapeImpl) newShape).getPrimitiveArrayCapacity()); } return true; }
@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); }
/** @since 0.17 or earlier */ protected ShapeImpl addPrimitiveExtensionArray(ShapeImpl shape) { LayoutImpl layout = shape.getLayout(); assert layout.hasPrimitiveExtensionArray() && !shape.hasPrimitiveArray(); Transition transition = new ReservePrimitiveArrayTransition(); ShapeImpl cachedShape = shape.queryTransition(transition); if (cachedShape != null) { return layout.getStrategy().ensureValid(cachedShape); } ShapeImpl oldShape = ensureSpace(shape, layout.getPrimitiveArrayLocation()); ShapeImpl newShape = ShapeImpl.makeShapeWithPrimitiveExtensionArray(oldShape, transition); oldShape.addDirectTransition(transition, newShape); return newShape; }
/** * Check whether the extension arrays are in accordance with the description in the shape. */ @Override protected final boolean checkExtensionArrayInvariants(Shape newShape) { assert getShape() == newShape; assert (getObjectStore(newShape) == null && ((ShapeImpl) newShape).getObjectArrayCapacity() == 0) || (getObjectStore(newShape) != null && getObjectStore(newShape).length == ((ShapeImpl) newShape).getObjectArrayCapacity()); if (((ShapeImpl) newShape).hasPrimitiveArray()) { assert (getPrimitiveStore(newShape) == null && ((ShapeImpl) newShape).getPrimitiveArrayCapacity() == 0) || (getPrimitiveStore(newShape) != null && getPrimitiveStore(newShape).length == ((ShapeImpl) newShape).getPrimitiveArrayCapacity()); } return true; }