Package com.oracle.truffle.object
Class ShapeImpl
java.lang.Object
com.oracle.truffle.api.object.Shape
com.oracle.truffle.object.ShapeImpl
- Direct Known Subclasses:
ShapeBasic
Shape objects create a mapping of Property objects to indexes. The mapping of those indexes to an
actual store is not part of Shape's role, but JSObject's. Shapes are immutable; adding or
deleting a property yields a new Shape which links to the old one. This allows inline caching to
simply check the identity of an object's Shape to determine if the cache is valid. There is one
exception to this immutability, the transition map, but that is used simply to assure that an
identical series of property additions and deletions will yield the same Shape object.
- See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class com.oracle.truffle.api.object.Shape
Shape.Allocator, Shape.Pred<T> -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Shape.Pred<Property>Match all filter.protected final intprotected final booleanprotected final LayoutImplprotected Assumptionprotected final intprotected final intprotected final intprotected final ObjectTypeprotected final ShapeImplprotected final intprotected final intprotected final intprotected Property[]protected final intprotected static final DebugCounterprotected static final DebugCounterprotected final PropertyMapprotected final Assumption -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedShapeImpl(Layout layout, ObjectType operations, Object sharedData, int id) protectedShapeImpl(Layout layout, ShapeImpl parent, ObjectType operations, Object sharedData, PropertyMap propertyMap, Transition transition, Shape.Allocator allocator, int id) -
Method Summary
Modifier and TypeMethodDescriptionprotected final voidaddDirectTransition(Transition transition, ShapeImpl next) final voidaddIndirectTransition(Transition transition, ShapeImpl next) addProperty(Property property) Add a new property in the map, yielding a new or cached Shape object.final ShapeImpl.BaseAllocatorObtain anShape.Allocatorinstance for the purpose of allocating locations.final ShapeImplAppend the property, relocating it to the next allocated location.final ShapeImplapplyTransition(Transition transition, boolean append) final ShapeImplchangeType(ObjectType newOps) Change the shape's type, yielding a new shape.final booleancheck(DynamicObject subject) Check whether this shape is identical to the given shape.protected final ShapeImplCreate a separate clone of a shape.protected ShapeImplfinal ShapeImplcopyOverPropertiesInternal(Shape destination) For copying over properties after exchanging the prototype of an object.final DynamicObjectFactoryCreate aDynamicObjectFactoryfor creating instances of this shape.final ShapeImplcreateSeparateShape(Object newSharedData) Clone off a separate shape with new shared data.protected abstract ShapeImplcreateShape(Layout layout, Object sharedData, ShapeImpl parent, ObjectType operations, PropertyMap propertyMap, Transition transition, Shape.Allocator allocator, int id) Find difference between two shapes.static ShapeImplfindCommonAncestor(ShapeImpl left, ShapeImpl right) Find lowest common ancestor of two related shapes.final ObjectgetData()Get the shape's custom data.final intgetDepth()final intgetId()Get a list of all property keys in insertion order.getKeyList(Shape.Pred<Property> filter) Get a list of all (visible) property names in insertion order.getKeys()Get all property keys in insertion order.final PropertyGet the last added property.final LayoutImplGet the shape's layout.final AssumptionGet an assumption that the shape is a leaf.getMutex()Get mutex object shared by related shapes, i.e.final intfinal intfinal intGet the shape's operations.final ShapeImplfinal intfinal intfinal intAnIterableover the shape's properties in insertion order.final PropertygetProperty(Object key) Get a property entry by string name.final intGet number of properties in this shape.Get a list of all properties that this Shape stores.getPropertyList(Shape.Pred<Property> filter) Get a list of all properties that this Shape stores.getPropertyListInternal(boolean ascending) Returns all (also hidden) Property objects in this shape.final PropertyMapgetRoot()Get the root shape.final ShapeImplgetShapeFromProperty(Property prop) Get the (parent) shape that holds the given property.final ShapeImplgetShapeFromProperty(Object propertyName) Get the (parent) shape that holds the given property.final ObjectGet the shape's shared data.final Transitionfinal Map<Transition,ShapeImpl> final AssumptionGet an assumption that the shape is valid.final booleanfinal booleanhasProperty(Object name) Check whether the shape has a property with the given key.final booleanQuery whether the shape has a transition with the given key.final voidfinal booleanisLeaf()Check whether this shape is a leaf in the transition graph, i.e.booleanAre these two shapes related, i.e.final booleanisValid()Check whether this shape is valid.final DynamicObjectCreate a newDynamicObjectinstance with this shape.final ShapeImplremoveProperty(Property prop) Remove the given property from the shape.final ShapeImplreplaceProperty(Property oldProperty, Property newProperty) Duplicate shape exchanging existing property with new property.final ShapeImplReserve the primitive extension array field.toString()toStringLimit(int limit)
-
Field Details
-
layout
-
objectType
-
parent
-
propertyMap
-
objectArraySize
protected final int objectArraySize -
objectArrayCapacity
protected final int objectArrayCapacity -
objectFieldSize
protected final int objectFieldSize -
primitiveFieldSize
protected final int primitiveFieldSize -
primitiveArraySize
protected final int primitiveArraySize -
primitiveArrayCapacity
protected final int primitiveArrayCapacity -
hasPrimitiveArray
protected final boolean hasPrimitiveArray -
depth
protected final int depth -
propertyCount
protected final int propertyCount -
propertyArray
-
validAssumption
-
leafAssumption
-
ALL
Match all filter. -
propertyListAllocCount
-
-
Constructor Details
-
ShapeImpl
protected ShapeImpl(Layout layout, ShapeImpl parent, ObjectType operations, Object sharedData, PropertyMap propertyMap, Transition transition, Shape.Allocator allocator, int id) -
ShapeImpl
-
-
Method Details
-
createShape
protected abstract ShapeImpl createShape(Layout layout, Object sharedData, ShapeImpl parent, ObjectType operations, PropertyMap propertyMap, Transition transition, Shape.Allocator allocator, int id) -
getLastProperty
Description copied from class:ShapeGet the last added property.- Specified by:
getLastPropertyin classShape
-
getId
public final int getId() -
getObjectArraySize
public final int getObjectArraySize()- Specified by:
getObjectArraySizein classShape
-
getObjectFieldSize
public final int getObjectFieldSize()- Specified by:
getObjectFieldSizein classShape
-
getPrimitiveFieldSize
public final int getPrimitiveFieldSize()- Specified by:
getPrimitiveFieldSizein classShape
-
getObjectArrayCapacity
public final int getObjectArrayCapacity()- Specified by:
getObjectArrayCapacityin classShape
-
getPrimitiveArrayCapacity
public final int getPrimitiveArrayCapacity()- Specified by:
getPrimitiveArrayCapacityin classShape
-
getPrimitiveArraySize
public final int getPrimitiveArraySize()- Specified by:
getPrimitiveArraySizein classShape
-
hasPrimitiveArray
public final boolean hasPrimitiveArray()- Specified by:
hasPrimitiveArrayin classShape
-
getShapeFromProperty
Get the (parent) shape that holds the given property. -
getShapeFromProperty
Get the (parent) shape that holds the given property. -
getProperty
Get a property entry by string name.- Specified by:
getPropertyin classShape- Parameters:
key- the name to look up- Returns:
- a Property object, or null if not found
-
addDirectTransition
-
addIndirectTransition
-
getTransitionMapForRead
-
getPropertyMap
-
addProperty
Add a new property in the map, yielding a new or cached Shape object.- Specified by:
addPropertyin classShape- Parameters:
property- the property to add- Returns:
- the new Shape
-
cloneRoot
-
cloneOnto
Create a separate clone of a shape.- Parameters:
newParent- the cloned parent shape
-
getTransitionFromParent
-
isRelated
Are these two shapes related, i.e. do they have the same root? -
getPropertyList
Get a list of all properties that this Shape stores.- Specified by:
getPropertyListin classShape- Returns:
- list of properties
-
getPropertyList
Description copied from class:ShapeGet a list of all properties that this Shape stores.- Specified by:
getPropertyListin classShape- Returns:
- list of properties
-
getPropertyListInternal
Returns all (also hidden) Property objects in this shape.- Specified by:
getPropertyListInternalin classShape- Parameters:
ascending- desired order
-
getKeyList
Get a list of all (visible) property names in insertion order.- Specified by:
getKeyListin classShape- Returns:
- list of property names
-
getKeyList
Description copied from class:ShapeGet a list of all property keys in insertion order.- Specified by:
getKeyListin classShape
-
getKeys
Description copied from class:ShapeGet all property keys in insertion order. -
isValid
public final boolean isValid()Description copied from class:ShapeCheck whether this shape is valid. -
getValidAssumption
Description copied from class:ShapeGet an assumption that the shape is valid.- Specified by:
getValidAssumptionin classShape
-
invalidateValidAssumption
public final void invalidateValidAssumption() -
isLeaf
public final boolean isLeaf()Description copied from class:ShapeCheck whether this shape is a leaf in the transition graph, i.e. transitionless. -
getLeafAssumption
Description copied from class:ShapeGet an assumption that the shape is a leaf.- Specified by:
getLeafAssumptionin classShape
-
toString
-
toStringLimit
-
getParent
-
getDepth
public final int getDepth() -
hasProperty
Description copied from class:ShapeCheck whether the shape has a property with the given key.- Specified by:
hasPropertyin classShape
-
removeProperty
Description copied from class:ShapeRemove the given property from the shape.- Specified by:
removePropertyin classShape
-
append
Description copied from class:ShapeAppend the property, relocating it to the next allocated location. -
applyTransition
-
allocator
Description copied from class:ShapeObtain anShape.Allocatorinstance for the purpose of allocating locations. -
replaceProperty
Duplicate shape exchanging existing property with new property.- Specified by:
replacePropertyin classShape
-
findCommonAncestor
Find lowest common ancestor of two related shapes. -
copyOverPropertiesInternal
For copying over properties after exchanging the prototype of an object.- Specified by:
copyOverPropertiesInternalin classShape
-
getPropertyCount
public final int getPropertyCount()Description copied from class:ShapeGet number of properties in this shape.- Specified by:
getPropertyCountin classShape
-
diff
Find difference between two shapes.- See Also:
-
getObjectType
Description copied from class:ShapeGet the shape's operations.- Specified by:
getObjectTypein classShape
-
getRoot
Description copied from class:ShapeGet the root shape. -
check
Description copied from class:ShapeCheck whether this shape is identical to the given shape. -
getLayout
Description copied from class:ShapeGet the shape's layout. -
getData
Description copied from class:ShapeGet the shape's custom data. -
hasTransitionWithKey
Description copied from class:ShapeQuery whether the shape has a transition with the given key.- Specified by:
hasTransitionWithKeyin classShape
-
createSeparateShape
Clone off a separate shape with new shared data.- Specified by:
createSeparateShapein classShape
-
changeType
Description copied from class:ShapeChange the shape's type, yielding a new shape.- Specified by:
changeTypein classShape
-
reservePrimitiveExtensionArray
Description copied from class:ShapeReserve the primitive extension array field.- Specified by:
reservePrimitiveExtensionArrayin classShape
-
getProperties
Description copied from class:ShapeAnIterableover the shape's properties in insertion order.- Specified by:
getPropertiesin classShape
-
newInstance
Description copied from class:ShapeCreate a newDynamicObjectinstance with this shape.- Specified by:
newInstancein classShape
-
createFactory
Description copied from class:ShapeCreate aDynamicObjectFactoryfor creating instances of this shape.- Specified by:
createFactoryin classShape
-
getMutex
Description copied from class:ShapeGet mutex object shared by related shapes, i.e. shapes with a common root. -
tryMerge
-