Package com.oracle.truffle.api.object
Class Shape
java.lang.Object
com.oracle.truffle.api.object.Shape
- Direct Known Subclasses:
ShapeImpl
Shape objects create a mapping of Property objects to Locations. 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 ClassesModifier and TypeClassDescriptionstatic class
static interface
Represents a predicate (boolean-valued function) of one argument. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<R> R
accept
(ShapeVisitor<R> visitor) abstract Shape
addProperty
(Property property) Add a new property in the map, yielding a new or cached Shape object.abstract Shape.Allocator
Obtain anShape.Allocator
instance for the purpose of allocating locations.abstract Shape
Append the property, relocating it to the next allocated location.abstract Shape
changeType
(ObjectType newOps) Change the shape's type, yielding a new shape.abstract boolean
check
(DynamicObject subject) Check whether this shape is identical to the given shape.abstract Shape
copyOverPropertiesInternal
(Shape destination) For copying over properties after exchanging the prototype of an object.abstract DynamicObjectFactory
Create aDynamicObjectFactory
for creating instances of this shape.abstract Shape
createSeparateShape
(Object sharedData) Clone off a separate shape with new shared data.abstract Object
getData()
Get the shape's custom data.abstract int
getId()
Get a list of all property keys in insertion order.getKeyList
(Shape.Pred<Property> filter) Get a filtered list of property keys in insertion order.getKeys()
Get all property keys in insertion order.abstract Property
Get the last added property.abstract Layout
Get the shape's layout.abstract Assumption
Get an assumption that the shape is a leaf.abstract Object
getMutex()
Get mutex object shared by related shapes, i.e.abstract int
abstract int
abstract int
abstract ObjectType
Get the shape's operations.abstract Shape
abstract int
abstract int
abstract int
AnIterable
over the shape's properties in insertion order.abstract Property
getProperty
(Object key) Get a property entry by key.abstract int
Get 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 properties that this Shape stores.getPropertyListInternal
(boolean ascending) Returns all (also hidden) property objects in this shape.abstract Shape
getRoot()
Get the root shape.abstract Object
Get the shape's shared data.abstract Assumption
Get an assumption that the shape is valid.abstract boolean
abstract boolean
hasProperty
(Object key) Check whether the shape has a property with the given key.abstract boolean
Query whether the shape has a transition with the given key.abstract boolean
isLeaf()
Check whether this shape is a leaf in the transition graph, i.e.abstract boolean
Are these two shapes related, i.e.abstract boolean
isValid()
Check whether this shape is valid.abstract DynamicObject
Create a newDynamicObject
instance with this shape.abstract Shape
removeProperty
(Property property) Remove the given property from the shape.abstract Shape
replaceProperty
(Property oldProperty, Property newProperty) Replace a property in the shape.abstract Shape
Reserve the primitive extension array field.abstract Shape
-
Constructor Details
-
Shape
public Shape()
-
-
Method Details
-
getProperty
Get a property entry by key.- Parameters:
key
- the identifier to look up- Returns:
- a Property object, or null if not found
-
addProperty
Add a new property in the map, yielding a new or cached Shape object.- Parameters:
property
- the property to add- Returns:
- the new Shape
-
getProperties
AnIterable
over the shape's properties in insertion order. -
getPropertyList
Get a list of properties that this Shape stores.- Returns:
- list of properties
-
getPropertyList
Get a list of all properties that this Shape stores.- Returns:
- list of properties
-
getPropertyListInternal
Returns all (also hidden) property objects in this shape.- Parameters:
ascending
- desired order (true
for insertion order,false
for reverse insertion order)
-
getKeyList
Get a filtered list of property keys in insertion order. -
getKeyList
Get a list of all property keys in insertion order. -
getKeys
Get all property keys in insertion order. -
getValidAssumption
Get an assumption that the shape is valid. -
isValid
public abstract boolean isValid()Check whether this shape is valid. -
getLeafAssumption
Get an assumption that the shape is a leaf. -
isLeaf
public abstract boolean isLeaf()Check whether this shape is a leaf in the transition graph, i.e. transitionless. -
getParent
- Returns:
- the parent shape or
null
if none.
-
hasProperty
Check whether the shape has a property with the given key. -
removeProperty
Remove the given property from the shape. -
replaceProperty
Replace a property in the shape. -
getLastProperty
Get the last added property. -
getId
public abstract int getId() -
append
Append the property, relocating it to the next allocated location. -
allocator
Obtain anShape.Allocator
instance for the purpose of allocating locations. -
copyOverPropertiesInternal
For copying over properties after exchanging the prototype of an object. -
getPropertyCount
public abstract int getPropertyCount()Get number of properties in this shape. -
getObjectType
Get the shape's operations. -
getRoot
Get the root shape. -
check
Check whether this shape is identical to the given shape. -
getLayout
Get the shape's layout. -
getData
Get the shape's custom data. -
hasTransitionWithKey
Query whether the shape has a transition with the given key. -
createSeparateShape
Clone off a separate shape with new shared data. -
changeType
Change the shape's type, yielding a new shape. -
reservePrimitiveExtensionArray
Reserve the primitive extension array field. -
newInstance
Create a newDynamicObject
instance with this shape. -
createFactory
Create aDynamicObjectFactory
for creating instances of this shape. -
getMutex
Get mutex object shared by related shapes, i.e. shapes with a common root. -
getObjectArraySize
public abstract int getObjectArraySize() -
getObjectFieldSize
public abstract int getObjectFieldSize() -
getPrimitiveArraySize
public abstract int getPrimitiveArraySize() -
getPrimitiveFieldSize
public abstract int getPrimitiveFieldSize() -
getObjectArrayCapacity
public abstract int getObjectArrayCapacity() -
getPrimitiveArrayCapacity
public abstract int getPrimitiveArrayCapacity() -
hasPrimitiveArray
public abstract boolean hasPrimitiveArray() -
isRelated
Are these two shapes related, i.e. do they have the same root?- Parameters:
other
- Shape to compare to- Returns:
- true if one shape is an upcast of the other, or the Shapes are equal
-
tryMerge
-
accept
-