Reference-or-nuint runtime type #131072
Unanswered
bencyoung-Fignum
asked this question in
Ideas
Replies: 1 comment 3 replies
|
This will introduce significant overhead for very little benefit, if not zero.
This is really an impossible thing. Since every GC reference requires strict pointer alignment, the tag will likely take up a whole pointer. Then you would have a pointer of RefOrNuint and a pointer of tag, saving zero space but introduces much more complexity. Trying to compact multiple tags into one pointer will only make things unmanagable. |
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Thinking about the new union feature and how it could be optimized in the future. I think all (not saying it's easy) that is probably needed is a built in struct type RefOrNuint or similar that has a pointer and some sort of byte sized tag. It would have to be known to the GC during compilation so that the GC knows if the tag is e.g 0 in which case the data payload is treated as a reference, else it is treated as raw data. You'd need methods to TryGetReference(out object? value) and TryGetData(out nunit? data) and equivalent to set
As a stretch you could expose the tag you'd need too to be able to make the nunit data is exposing other types but it wouldn't be built in. E.g. TryGetData(out byte? tag, out nunit? data). The tag would always be 0 for references and trying to set it to 0 for a non reference would throw
The internal code would have a special write barrier that depends on the tag value, and the GC would also check the tag before enumerating the value as a root
Once you had this primitive then all kinds of compressed types, unions, short vectors etc become possible, but from a runtime perspective all the attention could be focused on this?
All reactions