-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Change type metadata accessors to support incomplete metadata #15330
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
Change type metadata accessors to support incomplete metadata #15330
Conversation
@swift-ci Please test and merge. |
The hybrid approach you describe allows us to dynamically construct type metadata. If you don’t know the number of generic arguments that are required, you only have to handle a fixed number of cases before passing them indirectly. |
@slavapestov I think I wasn't very clear about what I've done there. It used to be that all the metadata access functions took all their arguments directly, like The hybrid approach is that we're capping the number of direct arguments and passing the rest indirectly, so that we do My change is that, when we cross the cap, we just pass everything indirectly. So it's either |
So it's still a hybrid approach in many senses, and it still supports reflective calls from the runtime. It's just that, in any particular case, the data is not passed in a hybrid way: it's either all direct (if it fits under the cap) or all indirect. |
@rjmccall That makes sense, thanks. |
373cbc7
to
e973368
Compare
@swift-ci Please smoke test and merge. |
@swift-ci Please test and merge. |
@swift-ci Please test. |
Build failed |
Build failed |
This includes global generic and non-generic global access functions, protocol associated type access functions, swift_getGenericMetadata, and generic type completion functions. The main part of this change is that the functions now need to take a MetadataRequest and return a MetadataResponse, which is capable of expressing that the request can fail. The state of the returned metadata is reported as an second, independent return value; this allows the caller to easily check the possibility of failure without having to mask it out from the returned metadata pointer, as well as allowing it to be easily ignored. Also, change metadata access functions to use swiftcc to ensure that this return value is indeed returned in two separate registers. Also, change protocol associated conformance access functions to use swiftcc. This isn't really related, but for some reason it snuck in. Since it's clearly the right thing to do, and since I really didn't want to retroactively tease that back out from all the rest of the test changes, I've left it in. Also, change generic metadata access functions to either pass all the generic arguments directly or pass them all indirectly. I don't know how we ended up with the hybrid approach. I needed to change all the code-generation and calls here anyway in order to pass the request parameter, and I figured I might as well change the ABI to something sensible.
e973368
to
31f2eec
Compare
@swift-ci Please test. |
1 similar comment
@swift-ci Please test. |
This includes global generic and non-generic global access functions, protocol associated type access functions, swift_getGenericMetadata, and generic type completion functions.
The main part of this change is that the functions now need to take a MetadataRequest and return a MetadataResponse, which is capable of expressing that the request can fail. The state of the returned
metadata is reported as an second, independent return value; this allows the caller to easily check the possibility of failure without having to mask it out from the returned metadata pointer, as well as allowing it to be easily ignored.
Also, change metadata access functions to use swiftcc to ensure that this return value is indeed returned in two separate registers.
Also, change protocol associated conformance access functions to use swiftcc. This isn't really related, but for some reason it snuck in. Since it's clearly the right thing to do, and since I really didn't want to retroactively tease that back out from all the rest of the test changes, I've left it in.
Also, change generic metadata access functions to either pass all the generic arguments directly or pass them all indirectly. I don't know how we ended up with the hybrid approach. I needed to change all the code-generation and calls here anyway in order to pass the request parameter, and I figured I might as well change the ABI to something sensible.