Skip to content

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

Merged
merged 1 commit into from
Mar 19, 2018

Conversation

rjmccall
Copy link
Contributor

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.

@rjmccall
Copy link
Contributor Author

@swift-ci Please test and merge.

@slavapestov
Copy link
Contributor

slavapestov commented Mar 18, 2018

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.

@rjmccall
Copy link
Contributor Author

@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 foo(a,b,c) or foo(a,b,c,d,e,f,g,h). This doesn't support calls from runtime code that's agnostic about argument count, at least not without major complexity.

The hybrid approach is that we're capping the number of direct arguments and passing the rest indirectly, so that we do foo(a,b,c) but foo(a,b,c,&{d,e,f,g,h}). Except that, to make getting a complete buffer more efficient, it's actually foo(a,b,c,&{null,null,null,d,e,f,g,h}).

My change is that, when we cross the cap, we just pass everything indirectly. So it's either foo(a,b,c) or foo(&{a,b,c,d,e,f,g,h}).

@rjmccall
Copy link
Contributor Author

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.

@slavapestov
Copy link
Contributor

@rjmccall That makes sense, thanks.

@rjmccall rjmccall force-pushed the incomplete-metadata-accessors branch from 373cbc7 to e973368 Compare March 18, 2018 22:31
@rjmccall
Copy link
Contributor Author

@swift-ci Please smoke test and merge.

@rjmccall
Copy link
Contributor Author

@swift-ci Please test and merge.

@rjmccall
Copy link
Contributor Author

@swift-ci Please test.

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 373cbc710d02f9c4bd09658cf9b08a9b3822c9e4

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 373cbc710d02f9c4bd09658cf9b08a9b3822c9e4

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.
@rjmccall rjmccall force-pushed the incomplete-metadata-accessors branch from e973368 to 31f2eec Compare March 19, 2018 01:38
@rjmccall
Copy link
Contributor Author

@swift-ci Please test.

1 similar comment
@rjmccall
Copy link
Contributor Author

@swift-ci Please test.

@rjmccall rjmccall merged commit b04155b into swiftlang:master Mar 19, 2018
@rjmccall rjmccall deleted the incomplete-metadata-accessors branch March 19, 2018 03:48
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.

3 participants