ObjectLayoutVariant

class ObjectLayoutVariant

The ObjectLayoutVariants capture field layouts for objects and object types. An object or object type's descriptor refers to a variant, and the variant contains a mapping from each present field atom to the slot number within the object or object type. All objects or object types with a particular set of field atoms have the same variant.

Author

Mark van Gulik

See also

Parameters

allFieldsSet

The set of fields for which to produce an ObjectLayoutVariant. Only one variant may exist for each set of fields, so this constructor is private.

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
fun isSubvariantOf(another: ObjectLayoutVariant): Boolean

Check whether an object type based on the receiver could be a subtype of a type based on another, based only on the fields present in each.

Link copied to clipboard
open override fun toString(): String

Properties

Link copied to clipboard
val allFields: A_Set

The set of all fields present in this variant. This includes not just the real fields that can hold multiple potential values, but also the fields that were created solely for the purpose of explicit subclassing.

Link copied to clipboard
val fieldToSlotIndex: Map<A_Atom, Int>

The mapping from field atoms to slots. The fields that are created just for making explicit subclasses all map to 0, which is not a valid slot.

Link copied to clipboard
val immutableObjectDescriptor: ObjectDescriptor

The immutable object descriptor for this variant.

Link copied to clipboard
val immutableObjectTypeDescriptor: ObjectTypeDescriptor

The immutable object type descriptor for this variant.

Link copied to clipboard
val mostGeneralObjectMeta: A_Type

The instanceMeta of the most general object type using this variant.

Link copied to clipboard
val mostGeneralObjectType: AvailObject

The most general object type using this variant.

Link copied to clipboard
val mutableObjectDescriptor: ObjectDescriptor

The mutable object descriptor for this variant.

Link copied to clipboard
val mutableObjectTypeDescriptor: ObjectTypeDescriptor

The mutable object type descriptor for this variant.

Link copied to clipboard
val realSlotCount: Int

The number of slots to allocate in an object or object type to accommodate the real fields. This excludes the keys that were created solely for the purpose of explicit subclassing. This value is always the largest value in fieldToSlotIndex.

Link copied to clipboard
val realSlots: List<A_Atom>

The List of A_Atoms for which to allocate slots in an object or object type. This only includes the real fields, and excludes the keys that were created solely for the purpose of explicit subclassing. These slots are in the same order that the slots should have in the object or object type.

Link copied to clipboard
val sharedObjectDescriptor: ObjectDescriptor

The shared object descriptor for this variant.

Link copied to clipboard
val sharedObjectTypeDescriptor: ObjectTypeDescriptor

The shared object type descriptor for this variant.

Link copied to clipboard
val variantId: Int

A unique int suitable for distinguishing variants. This may become more useful when Level Two code needs to track metrics and create variant specific versions of code without garbage collection complexity. It's allocated from the variantsCounter while holding the variantsLock.