public Location createLocation(Shape shape, Object value) { return ((ShapeImpl) shape).allocator().locationForValue(value, true, value != null); } };
protected ShapeImpl cloneRoot(ShapeImpl from, Object newSharedData) { return createShape(from.layout, newSharedData, null, from.objectType, from.propertyMap, null, from.allocator(), from.id); }
/** @since 0.17 or earlier */ protected ShapeImpl cloneRoot(ShapeImpl from, Object newSharedData) { return createShape(from.layout, newSharedData, null, from.objectType, from.propertyMap, null, from.allocator(), from.id); }
/** @since 0.17 or earlier */ protected ShapeImpl cloneRoot(ShapeImpl from, Object newSharedData) { return createShape(from.layout, newSharedData, null, from.objectType, from.propertyMap, null, from.allocator(), from.id); }
/** @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; } }
/** * Create a separate clone of a shape. * * @param newParent the cloned parent shape * @since 0.17 or earlier */ protected final ShapeImpl cloneOnto(ShapeImpl newParent) { ShapeImpl from = this; ShapeImpl newShape = createShape(newParent.layout, newParent.sharedData, newParent, from.objectType, from.propertyMap, from.transitionFromParent, from.allocator(), newParent.id); shapeCloneCount.inc(); newParent.addDirectTransition(from.transitionFromParent, newShape); return newShape; }
/** * Create a separate clone of a shape. * * @param newParent the cloned parent shape * @since 0.17 or earlier */ protected final ShapeImpl cloneOnto(ShapeImpl newParent) { ShapeImpl from = this; ShapeImpl newShape = createShape(newParent.layout, newParent.sharedData, newParent, from.objectType, from.propertyMap, from.transitionFromParent, from.allocator(), newParent.id); shapeCloneCount.inc(); newParent.addDirectTransition(from.transitionFromParent, newShape); return newShape; }
/** @since 0.17 or earlier */ protected ShapeImpl generalizeProperty(Property oldProperty, Object value, ShapeImpl currentShape, ShapeImpl nextShape) { Location oldLocation = oldProperty.getLocation(); Location newLocation = currentShape.allocator().locationForValueUpcast(value, oldLocation); Property newProperty = oldProperty.relocate(newLocation); ShapeImpl newShape = nextShape.replaceProperty(oldProperty, newProperty); return newShape; }
/** @since 0.17 or earlier */ protected ShapeImpl generalizeProperty(Property oldProperty, Object value, ShapeImpl currentShape, ShapeImpl nextShape) { Location oldLocation = oldProperty.getLocation(); Location newLocation = currentShape.allocator().locationForValueUpcast(value, oldLocation); Property newProperty = oldProperty.relocate(newLocation); ShapeImpl newShape = nextShape.replaceProperty(oldProperty, newProperty); return newShape; }
/** @since 0.17 or earlier */ @TruffleBoundary @Override public final ShapeImpl append(Property oldProperty) { return addProperty(oldProperty.relocate(allocator().moveLocation(oldProperty.getLocation()))); }
/** @since 0.17 or earlier */ @TruffleBoundary @Override public final ShapeImpl append(Property oldProperty) { return addProperty(oldProperty.relocate(allocator().moveLocation(oldProperty.getLocation()))); }
@TruffleBoundary @Override public final ShapeImpl append(Property oldProperty) { return addProperty(oldProperty.relocate(allocator().moveLocation(oldProperty.getLocation()))); }
@Override @TruffleBoundary public final ShapeImpl changeType(ObjectType newOps) { ObjectTypeTransition transition = new ObjectTypeTransition(newOps); ShapeImpl cachedShape = queryTransition(transition); if (cachedShape != null) { return cachedShape; } ShapeImpl newShape = createShape(layout, sharedData, this, newOps, propertyMap, transition, allocator(), id); addDirectTransition(transition, newShape); return newShape; }
/** @since 0.17 or earlier */ protected ShapeImpl definePropertyChangeFlags(ShapeImpl oldShape, Property oldProperty, Object value, int flags) { Location oldLocation = oldProperty.getLocation(); Location newLocation; if (oldLocation.canSet(value)) { newLocation = oldLocation; } else { newLocation = oldShape.allocator().locationForValueUpcast(value, oldLocation); } Property newProperty = Property.create(oldProperty.getKey(), newLocation, flags); ShapeImpl newShape = oldShape.replaceProperty(oldProperty, newProperty); return newShape; }
/** * Create a new shape that adds a property to the parent shape. */ private static ShapeImpl makeShapeWithAddedProperty(ShapeImpl parent, AddPropertyTransition addTransition) { Property addend = addTransition.getProperty(); BaseAllocator allocator = parent.allocator().addLocation(addend.getLocation()); PropertyMap newPropertyMap = parent.propertyMap.putCopy(addend); ShapeImpl newShape = parent.createShape(parent.layout, parent.sharedData, parent, parent.objectType, newPropertyMap, addTransition, allocator, parent.id); assert ((LocationImpl) addend.getLocation()).primitiveArrayCount() == 0 || newShape.hasPrimitiveArray; assert newShape.depth == allocator.depth; return newShape; }
/** @since 0.17 or earlier */ @Override @TruffleBoundary public final ShapeImpl changeType(ObjectType newOps) { ObjectTypeTransition transition = new ObjectTypeTransition(newOps); ShapeImpl cachedShape = queryTransition(transition); if (cachedShape != null) { return layout.getStrategy().ensureValid(cachedShape); } ShapeImpl newShape = createShape(layout, sharedData, this, newOps, propertyMap, transition, allocator(), id); addDirectTransition(transition, newShape); return newShape; }
/** * Create a new shape that adds a property to the parent shape. * * @since 0.17 or earlier */ protected static ShapeImpl makeShapeWithAddedProperty(ShapeImpl parent, AddPropertyTransition addTransition) { Property addend = addTransition.getProperty(); BaseAllocator allocator = parent.allocator().addLocation(addend.getLocation()); PropertyMap newPropertyMap = parent.propertyMap.putCopy(addend); ShapeImpl newShape = parent.createShape(parent.layout, parent.sharedData, parent, parent.objectType, newPropertyMap, addTransition, allocator, parent.id); assert ((LocationImpl) addend.getLocation()).primitiveArrayCount() == 0 || newShape.hasPrimitiveArray; assert newShape.depth == allocator.depth; return 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; }
/** @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; }