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 int
protected final boolean
protected final LayoutImpl
protected Assumption
protected final int
protected final int
protected final int
protected final ObjectType
protected final ShapeImpl
protected final int
protected final int
protected final int
protected Property[]
protected final int
protected static final DebugCounter
protected static final DebugCounter
protected final PropertyMap
protected final Assumption
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
ShapeImpl
(Layout layout, ObjectType operations, Object sharedData, int id) protected
ShapeImpl
(Layout layout, ShapeImpl parent, ObjectType operations, Object sharedData, PropertyMap propertyMap, Transition transition, Shape.Allocator allocator, int id) -
Method Summary
Modifier and TypeMethodDescriptionprotected final void
addDirectTransition
(Transition transition, ShapeImpl next) final void
addIndirectTransition
(Transition transition, ShapeImpl next) addProperty
(Property property) Add a new property in the map, yielding a new or cached Shape object.final ShapeImpl.BaseAllocator
Obtain anShape.Allocator
instance for the purpose of allocating locations.final ShapeImpl
Append the property, relocating it to the next allocated location.final ShapeImpl
applyTransition
(Transition transition, boolean append) final ShapeImpl
changeType
(ObjectType newOps) Change the shape's type, yielding a new shape.final boolean
check
(DynamicObject subject) Check whether this shape is identical to the given shape.protected final ShapeImpl
Create a separate clone of a shape.protected ShapeImpl
final ShapeImpl
copyOverPropertiesInternal
(Shape destination) For copying over properties after exchanging the prototype of an object.final DynamicObjectFactory
Create aDynamicObjectFactory
for creating instances of this shape.final ShapeImpl
createSeparateShape
(Object newSharedData) Clone off a separate shape with new shared data.protected abstract ShapeImpl
createShape
(Layout layout, Object sharedData, ShapeImpl parent, ObjectType operations, PropertyMap propertyMap, Transition transition, Shape.Allocator allocator, int id) Find difference between two shapes.static ShapeImpl
findCommonAncestor
(ShapeImpl left, ShapeImpl right) Find lowest common ancestor of two related shapes.final Object
getData()
Get the shape's custom data.final int
getDepth()
final int
getId()
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 Property
Get the last added property.final LayoutImpl
Get the shape's layout.final Assumption
Get an assumption that the shape is a leaf.getMutex()
Get mutex object shared by related shapes, i.e.final int
final int
final int
Get the shape's operations.final ShapeImpl
final int
final int
final int
AnIterable
over the shape's properties in insertion order.final Property
getProperty
(Object key) Get a property entry by string name.final 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 all properties that this Shape stores.getPropertyListInternal
(boolean ascending) Returns all (also hidden) Property objects in this shape.final PropertyMap
getRoot()
Get the root shape.final ShapeImpl
getShapeFromProperty
(Property prop) Get the (parent) shape that holds the given property.final ShapeImpl
getShapeFromProperty
(Object propertyName) Get the (parent) shape that holds the given property.final Object
Get the shape's shared data.final Transition
final Map<Transition,
ShapeImpl> final Assumption
Get an assumption that the shape is valid.final boolean
final boolean
hasProperty
(Object name) Check whether the shape has a property with the given key.final boolean
Query whether the shape has a transition with the given key.final void
final boolean
isLeaf()
Check whether this shape is a leaf in the transition graph, i.e.boolean
Are these two shapes related, i.e.final boolean
isValid()
Check whether this shape is valid.final DynamicObject
Create a newDynamicObject
instance with this shape.final ShapeImpl
removeProperty
(Property prop) Remove the given property from the shape.final ShapeImpl
replaceProperty
(Property oldProperty, Property newProperty) Duplicate shape exchanging existing property with new property.final ShapeImpl
Reserve 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:Shape
Get the last added property.- Specified by:
getLastProperty
in classShape
-
getId
public final int getId() -
getObjectArraySize
public final int getObjectArraySize()- Specified by:
getObjectArraySize
in classShape
-
getObjectFieldSize
public final int getObjectFieldSize()- Specified by:
getObjectFieldSize
in classShape
-
getPrimitiveFieldSize
public final int getPrimitiveFieldSize()- Specified by:
getPrimitiveFieldSize
in classShape
-
getObjectArrayCapacity
public final int getObjectArrayCapacity()- Specified by:
getObjectArrayCapacity
in classShape
-
getPrimitiveArrayCapacity
public final int getPrimitiveArrayCapacity()- Specified by:
getPrimitiveArrayCapacity
in classShape
-
getPrimitiveArraySize
public final int getPrimitiveArraySize()- Specified by:
getPrimitiveArraySize
in classShape
-
hasPrimitiveArray
public final boolean hasPrimitiveArray()- Specified by:
hasPrimitiveArray
in 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:
getProperty
in 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:
addProperty
in 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:
getPropertyList
in classShape
- Returns:
- list of properties
-
getPropertyList
Description copied from class:Shape
Get a list of all properties that this Shape stores.- Specified by:
getPropertyList
in classShape
- Returns:
- list of properties
-
getPropertyListInternal
Returns all (also hidden) Property objects in this shape.- Specified by:
getPropertyListInternal
in classShape
- Parameters:
ascending
- desired order
-
getKeyList
Get a list of all (visible) property names in insertion order.- Specified by:
getKeyList
in classShape
- Returns:
- list of property names
-
getKeyList
Description copied from class:Shape
Get a list of all property keys in insertion order.- Specified by:
getKeyList
in classShape
-
getKeys
Description copied from class:Shape
Get all property keys in insertion order. -
isValid
public final boolean isValid()Description copied from class:Shape
Check whether this shape is valid. -
getValidAssumption
Description copied from class:Shape
Get an assumption that the shape is valid.- Specified by:
getValidAssumption
in classShape
-
invalidateValidAssumption
public final void invalidateValidAssumption() -
isLeaf
public final boolean isLeaf()Description copied from class:Shape
Check whether this shape is a leaf in the transition graph, i.e. transitionless. -
getLeafAssumption
Description copied from class:Shape
Get an assumption that the shape is a leaf.- Specified by:
getLeafAssumption
in classShape
-
toString
-
toStringLimit
-
getParent
-
getDepth
public final int getDepth() -
hasProperty
Description copied from class:Shape
Check whether the shape has a property with the given key.- Specified by:
hasProperty
in classShape
-
removeProperty
Description copied from class:Shape
Remove the given property from the shape.- Specified by:
removeProperty
in classShape
-
append
Description copied from class:Shape
Append the property, relocating it to the next allocated location. -
applyTransition
-
allocator
Description copied from class:Shape
Obtain anShape.Allocator
instance for the purpose of allocating locations. -
replaceProperty
Duplicate shape exchanging existing property with new property.- Specified by:
replaceProperty
in classShape
-
findCommonAncestor
Find lowest common ancestor of two related shapes. -
copyOverPropertiesInternal
For copying over properties after exchanging the prototype of an object.- Specified by:
copyOverPropertiesInternal
in classShape
-
getPropertyCount
public final int getPropertyCount()Description copied from class:Shape
Get number of properties in this shape.- Specified by:
getPropertyCount
in classShape
-
diff
Find difference between two shapes.- See Also:
-
getObjectType
Description copied from class:Shape
Get the shape's operations.- Specified by:
getObjectType
in classShape
-
getRoot
Description copied from class:Shape
Get the root shape. -
check
Description copied from class:Shape
Check whether this shape is identical to the given shape. -
getLayout
Description copied from class:Shape
Get the shape's layout. -
getData
Description copied from class:Shape
Get the shape's custom data. -
hasTransitionWithKey
Description copied from class:Shape
Query whether the shape has a transition with the given key.- Specified by:
hasTransitionWithKey
in classShape
-
createSeparateShape
Clone off a separate shape with new shared data.- Specified by:
createSeparateShape
in classShape
-
changeType
Description copied from class:Shape
Change the shape's type, yielding a new shape.- Specified by:
changeType
in classShape
-
reservePrimitiveExtensionArray
Description copied from class:Shape
Reserve the primitive extension array field.- Specified by:
reservePrimitiveExtensionArray
in classShape
-
getProperties
Description copied from class:Shape
AnIterable
over the shape's properties in insertion order.- Specified by:
getProperties
in classShape
-
newInstance
Description copied from class:Shape
Create a newDynamicObject
instance with this shape.- Specified by:
newInstance
in classShape
-
createFactory
Description copied from class:Shape
Create aDynamicObjectFactory
for creating instances of this shape.- Specified by:
createFactory
in classShape
-
getMutex
Description copied from class:Shape
Get mutex object shared by related shapes, i.e. shapes with a common root. -
tryMerge
-