Skip to content

[Remote Mirror] Pass spare bit data for multi-payload enums from compiler #34990

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 18 commits into from

Conversation

tbkka
Copy link
Contributor

@tbkka tbkka commented Dec 7, 2020

This updates the compiler to include "spare bits" data in the metadata record for fixed-layout multi-payload enums, and modifies RemoteMirror to use that data for correct introspection. The logic for actually using spare bit data is already there and has had some testing; this PR just plumbs through the data itself.

Resolves rdar://61158214

@tbkka tbkka force-pushed the tbkka-remoteMirror-projectEnum-pt4 branch from 557a353 to 1da80cc Compare December 9, 2020 20:02
@tbkka tbkka force-pushed the tbkka-remoteMirror-projectEnum-pt4 branch from a60d106 to 9cd8f1b Compare June 30, 2021 22:40
@tbkka tbkka force-pushed the tbkka-remoteMirror-projectEnum-pt4 branch from 9cd8f1b to 03c6314 Compare July 15, 2021 20:59
@tbkka tbkka force-pushed the tbkka-remoteMirror-projectEnum-pt4 branch from 03c6314 to 9c3e9b8 Compare November 15, 2021 18:51
tbkka added 18 commits December 7, 2021 14:46
This code rearchitects and simplifies the projectEnumValue support by
introducing a new `TypeInfo` subclass for each kind of enum, including trivial,
no-payload, single-payload, and three different classes for multi-payload enums:

* "UnsupportedEnum" that we don't understand.  This will allow us to
  return correct "don't know" answers in cases where the
  runtime lacks enough information to accurately handle
  a particular enum.

* MP Enums that only use a separate tag value.  This includes
  generic enums and other dynamic layouts, as well as
  enums whose payloads have no spare bits.

* MP Enums that use spare bits, possibly in addition to
  a separate tag.  This logic can only be used, of course,
  if we can in fact compute a spare bit mask that agrees
  with the compiler.

The final challenge is to choose one of the above three
handlings for every MPE.  The current code that computes
the spare bit mask for the third type above has some flaws
that need to be understood.

Next step: Figure out spare bit mask computation.  Any cases we can compute
correctly based on the information available at runtime can be handled by one of
the above three TI classes.  For the remaining cases, we'll probably have to
divert to "Unsupported" until we can arrange for the compiler to provide
us with augmented data.
…depended on it

The experimental spare bits calculation helped to validate
the structure of this code and the handling of various
multi-payload enum details, but it cannot be done here
in a way that will always agree with the compiler.

So I've backed that out:  The result can still handle
certain multi-payload enums (those with dynamic layouts that
can never utilize spare bits) but the remainder will require
some additional work for the compiler to expose the real
spare bit data for use in the runtime.
Fortunately, I don't actually want a "size" type here.  Otherwise, I would have
to figure out why any use of `size_t` or `typename Runtime::SizeType` causes
massive metadata failures at runtime, even when the trailing object isn't
actually present.
The previous logic had hardcoded determinations to compute the trailing objects
for a particular class of descriptors.  As more descriptors gain more diverse
trailing objects, this gets harder to maintain.

This instead repeatedly estimates the full size and incrementally fetches more
data until the trailing object logic says we have everything.  It rests on a new
trailing object method `totalSizeOfPartialObject` that takes the size of a
(possibly partial) TrailingObjects type and returns either a smaller size
(indicating that the original data is sufficient) or a larger size (indicating
that the original data is insufficient).

Note that in the latter case, the returned size is necessarily an estimate;
because trailing objects can vary depending on the contents of earlier trailing
objects, we can't be entirely certain of the exact size until we have
everything.
I finally worked out the template recursion needed to make
this actually compile.  I still need to test it and use
it to support the general decriptor copying I've been working
on.
@tbkka tbkka force-pushed the tbkka-remoteMirror-projectEnum-pt4 branch from 9c3e9b8 to b925063 Compare December 7, 2021 22:47
@tbkka tbkka closed this May 17, 2024
@tbkka
Copy link
Contributor Author

tbkka commented May 17, 2024

Closed: #73624 is expanding the runtime's ability to compute the mask directly, which should eliminate the need to have the compiler provide this information.

@tbkka tbkka deleted the tbkka-remoteMirror-projectEnum-pt4 branch August 1, 2024 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant