[swift-dev] [SE-0143] Dynamic casting for conditional conformances
rjmccall at apple.com
Thu Dec 7 00:10:20 CST 2017
> On Dec 7, 2017, at 1:03 AM, Slava Pestov <spestov at apple.com> wrote:
>> On Dec 6, 2017, at 10:00 PM, John McCall <rjmccall at apple.com> wrote:
>> Yes, I can see how there's some nice synergy there, and it would certainly be good to avoid having to eagerly generate code for this operation. And it should be possible to optimize the cast operation in the runtime if we find ourselves executing it many times for different types.
>> Okay, the basic idea seems reasonable to me. I guess my biggest concern is the use of just mangled names, since it seems like that will pose a lot of problems with private or local types.
> As long as we mangle the unique private or local discriminator prefix, it shouldn’t be a problem. We’re not looking up global symbols by name, but scanning some kind of metadata section in the binary, which would presumably still have metadata for private and local types.
Among other things, I have to note that this will make it much more difficult to dead-strip type metadata because we'll have to assume that somebody might have a string reference to it.
>> When Ashley was working on the remote-mirrors metadata, we had the idea of using descriptor "strings" that could embed a reference to a nominal type descriptor (or something like that) instead of just relying on a name. (A name would still be reasonable for a type that's not known to be defined within the linkage unit, of course.)
> Yes, this would be a useful optimization, but I don’t think it’s a pre-requisite for getting an initial implementation going before the ABI is finalized.
I feel like if you try to use a purely name-based solution, you are going to end up solving the same problems but worse. Also, of course, it will be much more difficult to revise the expected representation after ABI is finalized.
>> In AST terms:
>> func matchEnvironment(GenericSignature, Type, TypeMetadata) -> GenericEnvironment?
>> func substitute(GenericEnvironment, Type) -> TypeMetadata?
> By GenericEnvironment do you really mean a substitution map?
Yes, sorry, confused my terms.
More information about the swift-dev