Class DynamicObject.SetShapeFlagsNode
java.lang.Object
com.oracle.truffle.api.nodes.Node
com.oracle.truffle.api.object.DynamicObject.SetShapeFlagsNode
- All Implemented Interfaces:
NodeInterface, Cloneable
- Enclosing class:
DynamicObject
Sets or updates language-specific object shape flags.
- Since:
- 25.1
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class Node
Node.Child, Node.Children -
Method Summary
Modifier and TypeMethodDescriptioncreate()final booleanexecute(DynamicObject receiver, int newFlags) Sets language-specific object shape flags, changing the object's shape if need be.final booleanexecuteAdd(DynamicObject receiver, int addedFlags) Adds language-specific object shape flags, changing the object's shape if need be.final booleanexecuteRemove(DynamicObject receiver, int removedFlags) Removes language-specific object shape flags, changing the object's shape if need be.final booleanexecuteRemoveAndAdd(DynamicObject receiver, int removedFlags, int addedFlags) Removes, then adds language-specific object shape flags, changing the object's shape if need be.Methods inherited from class Node
accept, adoptChildren, atomic, atomic, copy, deepCopy, getChildren, getCost, getDebugProperties, getDescription, getEncapsulatingSourceSection, getLock, getParent, getRootNode, getSourceSection, insert, insert, isAdoptable, isSafelyReplaceableBy, notifyInserted, onReplace, replace, replace, reportPolymorphicSpecialize, reportReplace, toString
-
Method Details
-
execute
Sets language-specific object shape flags, changing the object's shape if need be. These flags may be used to tag objects that possess characteristics that need to be queried efficiently on fast and slow paths. For example, they can be used to mark objects as frozen. Only the lowest 16 bits (i.e. values in the range 0 to 65535) are allowed, the remaining bits are currently reserved.Usage example:
Implementing a freeze object operation:
Note thatabstract static class FreezeObjectNode extends Node { static final int FROZEN = 1; abstract void execute(DynamicObject receiver); @Specialization static void freeze(DynamicObject receiver, @Cached DynamicObject.GetShapeFlagsNode getShapeFlagsNode, @Cached DynamicObject.SetShapeFlagsNode setShapeFlagsNode) { int oldFlags = getShapeFlagsNode.execute(receiver); int newFlags = oldFlags | FROZEN; if (newFlags != oldFlags) { setShapeFlagsNode.execute(receiver, newFlags); } } }executeAdd(DynamicObject, int)is more efficient and convenient for that particular pattern.- Parameters:
newFlags- the flags to set; must be in the range from 0 to 65535 (inclusive).- Returns:
trueif the object's shape changed,falseif no change was made.- Throws:
IllegalArgumentException- if the flags are not in the allowed range.- Since:
- 25.1
- See Also:
-
executeAdd
Adds language-specific object shape flags, changing the object's shape if need be.Usage example:
Implementing a freeze object operation:
abstract static class FreezeNode extends Node { static final int FROZEN = 1; abstract void execute(DynamicObject receiver); @Specialization static void freeze(DynamicObject receiver, @Cached DynamicObject.SetShapeFlagsNode setShapeFlagsNode) { setShapeFlagsNode.executeAdd(receiver, FROZEN); } }- Since:
- 25.1
- See Also:
-
executeRemove
Removes language-specific object shape flags, changing the object's shape if need be.- Since:
- 25.1
- See Also:
-
executeRemoveAndAdd
Removes, then adds language-specific object shape flags, changing the object's shape if need be.- Since:
- 25.1
- See Also:
-
create
- Since:
- 25.1
-
getUncached
- Since:
- 25.1
-