-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[WIP][IRGen] Emit type field descriptors for imported structs #14185
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
Conversation
Opaque metadata goes to reflection Builtins section, so I need to register that with |
/cc @jckarter |
Shouldn't the nominal type descriptor for an opaque-metadata type still end up in the RuntimeResolvableTypes array? |
I realized that yes, it should but currently it doesn't, that's the only way to establish name -> metadata relationship... |
@jckarter I'm kind of stuck here because I'm not sure if it's valid to look into properties of the nominal types which are being added for lazy metadata emission, it doesn't seem like the best approach. It looks like if we were to do that we'd actually pollute binary with unnecessary lazy callbacks. Another way maybe it to augment lazy metadata access function to emit lazy type metadata accessors for its fields when evaluated? I'm leaning towards closing this and actually leaving lazy field types accessor for imported types, so runtime hook can use reflection for regular swift types and |
Thinking about that some more, we can't actually lazily emit metadata accessors for the fields because they require reserved global var space to hook initialization too, which means we have to actually look inside of the imported structs etc. :( |
It seems to me that we would end up emitting the exact same set of type metadata as we do today, since we currently force all of the field type metadata indirectly by generating the |
35720d6
to
704f465
Compare
@jckarter Finally finished this up I think, for every field it's going to invoke |
@swift-ci please test |
Looks good! Maybe add some tests for Swift structs containing fields with imported types in structural positions, e.g.:
should force |
@jckarter |
I see. The fact that the types now show up in the dumper output (and you test for that) should be sufficient then. |
It shouldn't harm anything to land this first. |
Alright :) |
@swift-ci please smoke test |
Aha! Good that I re-ran the tests, since this is impacted by changes made by @rudkx where "!" is going to generate "Optional", going to change the test and merge. |
Update IRGen to trigger generation of type metadata for foreign struct types found in fields. And fix TypeRefBuilder to handle the case where struct has fields but at the same time has opaque metadata.
704f465
to
9e08ea4
Compare
@swift-ci please smoke test |
@swift-ci please test Linux platform |
@swift-ci please smoke test Linux platform |
Build failed |
Having field descriptors for imported structs helps to implement new reflection
call to retrieve field names/types.