/** * 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; }
/** * Create a separate clone of a shape. * * @param newParent the cloned parent shape */ 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(); // (aw) need to have this transition for obsolescence newParent.addDirectTransition(from.transitionFromParent, newShape); return newShape; }
/** @since 0.18 */ @Override public Shape makeSharedShape() { if (shared) { throw new UnsupportedOperationException("makeSharedShape() can only be called on non-shared shapes."); } Transition transition = new ShareShapeTransition(); ShapeImpl cachedShape = queryTransition(transition); if (cachedShape != null) { return layout.getStrategy().ensureValid(cachedShape); } ShapeImpl newShape = createShape(layout, sharedData, this, objectType, propertyMap, transition, allocator(), id); addDirectTransition(transition, newShape); return newShape; }
/** @since 0.18 */ @Override public Shape makeSharedShape() { if (shared) { throw new UnsupportedOperationException("makeSharedShape() can only be called on non-shared shapes."); } Transition transition = new ShareShapeTransition(); ShapeImpl cachedShape = queryTransition(transition); if (cachedShape != null) { return layout.getStrategy().ensureValid(cachedShape); } ShapeImpl newShape = createShape(layout, sharedData, this, objectType, propertyMap, transition, allocator(), id); addDirectTransition(transition, newShape); return newShape; }
@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 */ @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; }
/** @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; }
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; }
/** @since 0.17 or earlier */ protected ShapeImpl addProperty(ShapeImpl shape, Property property, boolean ensureValid) { assert !(shape.hasProperty(property.getKey())) : "duplicate property " + property.getKey(); AddPropertyTransition addTransition = new AddPropertyTransition(property); ShapeImpl cachedShape = shape.queryTransition(addTransition); if (cachedShape != null) { return ensureValid ? ensureValid(cachedShape) : cachedShape; } ShapeImpl oldShape = ensureSpace(shape, property.getLocation()); ShapeImpl newShape = ShapeImpl.makeShapeWithAddedProperty(oldShape, addTransition); oldShape.addDirectTransition(addTransition, newShape); return newShape; }
/** @since 0.17 or earlier */ protected ShapeImpl addProperty(ShapeImpl shape, Property property, boolean ensureValid) { assert !(shape.hasProperty(property.getKey())) : "duplicate property " + property.getKey(); AddPropertyTransition addTransition = new AddPropertyTransition(property); ShapeImpl cachedShape = shape.queryTransition(addTransition); if (cachedShape != null) { return ensureValid ? ensureValid(cachedShape) : cachedShape; } ShapeImpl oldShape = ensureSpace(shape, property.getLocation()); ShapeImpl newShape = ShapeImpl.makeShapeWithAddedProperty(oldShape, addTransition); oldShape.addDirectTransition(addTransition, newShape); return 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; }
/** @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; }
/** @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; }
/** * Add a new property in the map, yielding a new or cached Shape object. * * In contrast to {@link ShapeImpl#addProperty(Property)}, this method does not care about * obsolete shapes. * * @see #addProperty(Property) */ private ShapeImpl addPropertyInternal(Property prop) { CompilerAsserts.neverPartOfCompilation(); assert prop.isShadow() || !(this.hasProperty(prop.getKey())) : "duplicate property " + prop.getKey(); // assertion caused performance issues on e.g. testv8 regress-619.js // assert !getPropertyListInternal(false).contains(prop); AddPropertyTransition addTransition = new AddPropertyTransition(prop); ShapeImpl cachedShape = queryTransition(addTransition); if (cachedShape != null) { return cachedShape; } ShapeImpl oldShape = (ShapeImpl) layout.getStrategy().ensureSpace(this, prop.getLocation()); ShapeImpl newShape = makeShapeWithAddedProperty(oldShape, addTransition); oldShape.addDirectTransition(addTransition, newShape); return newShape; }