protected BaseAllocator(ShapeImpl shape) { this(shape.getLayout()); this.objectArraySize = shape.objectArraySize; this.objectFieldSize = shape.objectFieldSize; this.primitiveFieldSize = shape.primitiveFieldSize; this.primitiveArraySize = shape.primitiveArraySize; this.hasPrimitiveArray = shape.hasPrimitiveArray; this.depth = shape.depth; }
/** @since 0.17 or earlier */ protected BaseAllocator(ShapeImpl shape) { this(shape.getLayout()); this.objectArraySize = shape.objectArraySize; this.objectFieldSize = shape.objectFieldSize; this.primitiveFieldSize = shape.primitiveFieldSize; this.primitiveArraySize = shape.primitiveArraySize; this.hasPrimitiveArray = shape.hasPrimitiveArray; this.depth = shape.depth; this.shared = shape.shared; }
/** @since 0.17 or earlier */ protected BaseAllocator(ShapeImpl shape) { this(shape.getLayout()); this.objectArraySize = shape.objectArraySize; this.objectFieldSize = shape.objectFieldSize; this.primitiveFieldSize = shape.primitiveFieldSize; this.primitiveArraySize = shape.primitiveArraySize; this.hasPrimitiveArray = shape.hasPrimitiveArray; this.depth = shape.depth; this.shared = shape.shared; }
private void setWithShapeSlowCase(DynamicObject store, Object value, Shape currentShape, Shape nextShape) { ShapeImpl oldShape = (ShapeImpl) currentShape; oldShape.getLayout().getStrategy().propertySetWithShapeFallback(this, store, value, oldShape, (ShapeImpl) nextShape); }
/** @since 0.17 or earlier */ @Override public final boolean updateShape() { return getShapeImpl().getLayout().getStrategy().updateShape(this); }
/** @since 0.17 or earlier */ @Override public final boolean updateShape() { return getShape().getLayout().getStrategy().updateShape(this); }
/** @since 0.17 or earlier */ public Location existingLocationForValue(Object value, Location oldLocation, ShapeImpl oldShape) { assert oldShape.getLayout() == this.layout; Location newLocation; if (oldLocation.canSet(value)) { newLocation = oldLocation; } else { newLocation = oldShape.allocator().locationForValueUpcast(value, oldLocation); } return newLocation; } }
/** @since 0.17 or earlier */ public Location existingLocationForValue(Object value, Location oldLocation, ShapeImpl oldShape) { assert oldShape.getLayout() == this.layout; Location newLocation; if (oldLocation.canSet(value)) { newLocation = oldLocation; } else { newLocation = oldShape.allocator().locationForValueUpcast(value, oldLocation); } return newLocation; } }
@Override public final boolean updateShape() { return getShape().getLayout().getStrategy().updateShape(this); }
/** * 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; }
/** @since 0.17 or earlier */ @Override @TruffleBoundary public void define(Object key, Object value, int flags, LocationFactory locationFactory) { ShapeImpl oldShape = getShape(); oldShape.getLayout().getStrategy().objectDefineProperty(this, key, value, flags, locationFactory, oldShape); }
/** @since 0.17 or earlier */ @Override @TruffleBoundary public void define(Object key, Object value, int flags, LocationFactory locationFactory) { ShapeImpl oldShape = getShapeImpl(); oldShape.getLayout().getStrategy().objectDefineProperty(this, key, value, flags, locationFactory, oldShape); }
/** @since 0.17 or earlier */ @Override @TruffleBoundary public void define(Object key, Object value, int flags) { define(key, value, flags, getShape().getLayout().getStrategy().getDefaultLocationFactory()); }
/** @since 0.17 or earlier */ @Override @TruffleBoundary public void define(Object key, Object value, int flags) { define(key, value, flags, getShapeImpl().getLayout().getStrategy().getDefaultLocationFactory()); }
/** @since 0.17 or earlier */ @Override @TruffleBoundary public boolean delete(Object key) { ShapeImpl oldShape = getShapeImpl(); Property existing = oldShape.getProperty(key); if (existing != null) { oldShape.getLayout().getStrategy().objectRemoveProperty(this, existing, oldShape); return true; } else { return false; } }
private static boolean assertLocationInRange(ShapeImpl shape, Location location) { BasicLayout layout = (BasicLayout) shape.getLayout(); assert (shape.getPrimitiveFieldSize() + ((LocationImpl) location).primitiveFieldCount() <= layout.getPrimitiveFieldCount()); assert (shape.getObjectFieldSize() + ((LocationImpl) location).objectFieldCount() <= layout.getObjectFieldCount()); return true; }
private static boolean assertLocationInRange(ShapeImpl shape, Location location) { BasicLayout layout = (BasicLayout) shape.getLayout(); assert (shape.getPrimitiveFieldSize() + ((LocationImpl) location).primitiveFieldCount() <= layout.getPrimitiveFieldCount()); assert (shape.getObjectFieldSize() + ((LocationImpl) location).objectFieldCount() <= layout.getObjectFieldCount()); return true; }
private void defineExisting(Object id, Object value, int flags, Property existing, ShapeImpl oldShape) { if (existing.getFlags() == flags) { existing.setGeneric(this, value, null); } else { Property newProperty = Property.create(id, oldShape.getLayout().existingLocationForValue(value, existing.getLocation(), oldShape), flags); Shape newShape = oldShape.replaceProperty(existing, newProperty); this.setShapeAndResize(newShape); newProperty.setInternal(this, value); } }
/** @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; }
/** @since 0.17 or earlier */ protected ShapeImpl directReplaceProperty(ShapeImpl shape, Property oldProperty, Property newProperty) { Transition replacePropertyTransition = new Transition.DirectReplacePropertyTransition(oldProperty, newProperty); ShapeImpl cachedShape = shape.queryTransition(replacePropertyTransition); if (cachedShape != null) { return ensureValid(cachedShape); } PropertyMap newPropertyMap = shape.getPropertyMap().replaceCopy(oldProperty, newProperty); BaseAllocator allocator = shape.allocator().addLocation(newProperty.getLocation()); ShapeImpl newShape = shape.createShape(shape.getLayout(), shape.getSharedData(), shape, shape.getObjectType(), newPropertyMap, replacePropertyTransition, allocator, shape.getId()); shape.addDirectTransition(replacePropertyTransition, newShape); return newShape; }