TYPE_VETTINGS_CACHE
A 0-, 2-, or 4-tuple containing results from previous instance tests against non-enumeration, Mutability.SHARED object types.
The presence of an object type in element 1 (or 3, if present) indicates that this object is an instance of that object type. The presence of an object type in element 2 (or 4, if present) indicates that this object is not an instance of that object type.
This is purely a cache for performance, and should be treated as such by any custom garbage collector. For now, we only capture object types that are Mutability.SHARED, since type tests for method dispatching are always against shared object types, and that's the case we're attempting to speed up.
Note that object types cache their hash value once computed. The two sets can be quickly searched because different object types very rarely have equal hashes, and equal ones merge via indirections after a successful comparison. Shared object types are placed in a canonical weak map to ensure these comparisons are fast.
For memory safety, we bound the set sizes to some reasonably large value (to deal with large dispatch trees). When this threshold is reached, we extend the tuple from two to four values, moving the first and second sets to the third and fourth, respectively, replacing the first and second with empty sets. This is a simple approximate mechanism to retain the most commonly accessed vettings. If there are already four elements in the tuple, the previous third and fourth sets are simply discarded. Note that all four sets must be examined to determine the result of a previous vetting.