Type Restriction
This mechanism describes a restriction of a type without saying what it's to be applied to.
We capture an Avail A_Type, and an optional exactly known value, so that we can represent something that avoids the metacovariance weakness of metatypes.
We also capture negative type and negative instance information, to leverage more advantage from the failure paths of type tests like L2_JUMP_IF_KIND_OF_CONSTANT and L2_JUMP_IF_EQUALS_CONSTANT.
Author
Mark van Gulik
Todd L Smith
Types
An enumeration used to interpret the flags of a TypeRestriction. The sense of the flags is such that a bit-wise and can be used
A collection of all positive or all negative constraints. A TypeRestriction uses one for positive constraints, and one for negative constraints, and canonicalization keeps them from being contradictory or nonsensical.
Functions
Answer true if this TypeRestriction only contains values that are within the given testType.
Answer true if this TypeRestriction contains every possible element of the given type.
If this restriction has only a finite set of possible values, and the number of such values is no more than the given maximum, answer an A_Set of them, otherwise null.
Answer a restriction like the receiver, but for a boxed, mutable object. If the restriction is already for boxed objects, return the receiver, whether it's also marked with the immutable flag or not.
Answer a restriction like the receiver, but for unboxed floats. If the restriction is already for unboxed floats, return the receiver.
Answer a restriction like the receiver, but for unboxed ints. If the restriction is already for unboxed ints, return the receiver.
Answer whether the specified flag is set.
Create the intersection of the receiver and the other TypeRestriction. This is the restriction that a register would have if it were already known to have the first restriction, and has been tested positively against the second restriction.
Create the intersection of the receiver with the given object type variant ObjectLayoutVariant. This is the restriction that a register would have if it were already known to satisfy the receiver restriction, and has had its object type variant tested positively against the given variant.
Create the intersection of the receiver with the given object variant ObjectLayoutVariant. This is the restriction that a register would have if it were already known to satisfy the receiver restriction, and has had its variant tested positively against the given variant.
Create the intersection of the receiver with the given A_Type. This is the restriction that a register would have if it were already known to satisfy the receiver restriction, and has been tested positively against the given type.
Answer true if this TypeRestriction contains any values in common with the given type. It uses the A_Type.isVacuousType test to determine whether any instances exist in the intersection.
Answer whether this TypeRestriction is a specialization of the given one. That means every value that satisfies the receiver will also satisfy the argument.
Answer an EnumSet indicating which RegisterKinds are present in this restriction.
Ensure all referenced AvailObjects are Shared.
The receiver is a restriction for a register holding some value. Answer the restriction for a register holding that value's type.
Create the difference between the receiver and the given object type variant ObjectLayoutVariant. This is the restriction that a register would have if it were already known to satisfy the receiver restriction, and has had its variant tested negatively against the supplied variant.
Create the difference between the receiver and the given object variant ObjectLayoutVariant. This is the restriction that a register would have if it were already known to satisfy the receiver restriction, and has had its variant tested negatively against the supplied variant.
Create the asymmetric difference of the receiver and the given A_Type. This is the restriction that a register would have if it held a value that satisfied the receiver, but failed a test against the given type.
Create the asymmetric difference of the receiver and the given exact value. This is the restriction that a register would have if it held a value that satisfied the receiver, but failed a value comparison against the given value.
Create the asymmetric difference of the receiver and each of the given exact values. This is the restriction that a register would have if it held a value that satisfied the receiver, but failed a value comparison against each of the given values.
Answer a restriction like the receiver, but excluding RegisterKind-related flags that aren't set in the given kindFlagEncoding.
Answer a String, possibly empty, suitable for displaying after a register, after a read/write of a register, or after any other place that this restriction might be applied.
Create the union of the receiver and the other TypeRestriction. This is the restriction that a register would have if it were assigned from one of two sources, each having one of the restrictions.
Answer a restriction like the receiver, but with an additional flag set. If the flag is already set, answer the receiver.
Answer a restriction like the receiver, but with a flag cleared. If the flag is already clear, answer the receiver.
Properties
The set of types that are specifically excluded. A value that satisfies one of these types does not satisfy this type restriction. For the purpose of canonicalization, these types are all proper subtypes of the restriction's type.
The set of values that are specifically excluded. A value in this set does not satisfy this type restriction. For the purpose of canonicalization, these values must all be members of the restriction's type.
Answer whether the restricted value is known to be boxed in an L2BoxedRegister.
Answer whether the restricted value is known to be unboxed in an L2FloatRegister.
Answer whether the restricted value is known to be unboxed in an L2IntRegister.