Skip to content

[IRGen] Cond. conformance witness table count isn't needed dynamically. #14973

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 2 commits into from
Mar 6, 2018

Conversation

huonw
Copy link
Contributor

@huonw huonw commented Mar 5, 2018

The count of the number of witness tables was designed to be an
assertion/check that we've hooked up all the infrastructure
correctly. Everything is now implemented, and the assertion has never
triggered, so it can be removed, saving some work.

@huonw
Copy link
Contributor Author

huonw commented Mar 5, 2018

@swift-ci please smoke test

@huonw
Copy link
Contributor Author

huonw commented Mar 5, 2018

This changes the code from passing a swift.witness_table_slice* to passing a witness_table** (i.e. a pointer to an array of witness table pointers, which ends up being a void***) to the void ** instantiationArgs argument of swift_getGenericWitnessTable. This seems like a moderately unusual argument type (that is, plain void * is more conventional for context parameters IME) which makes me think there was reasoning for that particular choice, but it seems like it wasn't used until conditional conformances, nor changed since it was introduced. I'm inclined to change the argument to void *** instead, and make the compiler code and IR slightly simpler, but would like confirmation that this fits with the design.

@rjmccall it looks like you introduced this scheme originally, so maybe you're best positioned to comment on the above?

@rjmccall
Copy link
Contributor

rjmccall commented Mar 5, 2018

You're not talking about changing anything about the actual bits we're passing, right? I don't really care about the exact pointer type we use in the function's IR declaration; if i8*** is convenient, and I agree that it probably is, then let's go with that.

@huonw
Copy link
Contributor Author

huonw commented Mar 5, 2018

This is changing the bits, slightly: when I first implemented conditional conformances, it did something like

struct WitnessTableSlice {
    WitnessTable **requirements;
    size_t count;
};
size_t count = ...;
WitnessTable *conditionalRequirements[count] = { ... };
WitnessTableSlice slice = { conditionalRequirements, count };
swift_getGenericWitnessTable(..., (void**)&slice);

But now it does

WitnessTable *conditionalRequirements[count] = { ... };
swift_getGenericWitnessTable(..., (void**)conditionalRequirements);

But, those (currently, at least) just get passed straight through to the instantiation function, which is also controlled by the code that decides the format for that argument, so the exact format of the data doesn't seem like it matters for ABI.

@rjmccall
Copy link
Contributor

rjmccall commented Mar 5, 2018

Well, the runtime should in theory be able to inspect all the witness tables being passed in; consider that we might want to do dynamic partial specialization of the conformance or something. But it also seems to me that, much like getGenericMetadata, the length of that array should be fixed for any given generic witness table, so it doesn't need to be passed in separately.

@rjmccall
Copy link
Contributor

rjmccall commented Mar 5, 2018

Which is to say that I agree that this change is a good one.

@huonw huonw force-pushed the no-dynamic-count branch from ab3669e to fc65c29 Compare March 5, 2018 08:48
@huonw
Copy link
Contributor Author

huonw commented Mar 5, 2018

@swift-ci please test

@swift-ci
Copy link
Contributor

swift-ci commented Mar 5, 2018

Build failed
Swift Test Linux Platform
Git Sha - ab3669ed9b62a0adfd04a55e3eef8010d862b48f

@swift-ci
Copy link
Contributor

swift-ci commented Mar 5, 2018

Build failed
Swift Test OS X Platform
Git Sha - ab3669ed9b62a0adfd04a55e3eef8010d862b48f

@huonw
Copy link
Contributor Author

huonw commented Mar 5, 2018

@swift-ci please test

huonw added 2 commits March 6, 2018 00:22
The count of the number of witness tables was designed to be an
assertion/check that we've hooked up all the infrastructure
correctly. Everything is now implemented, and the assertion has never
triggered, so it can be removed, saving some work.

Fixes rdar://problem/38038928.
This is simpler, because the native form of that last argument is: a
pointer to a buffer (*) of pointers (*) to witness tables, which is
modelled as a buffer of void *s. Thus, void ***.
@huonw huonw force-pushed the no-dynamic-count branch from fc65c29 to 43196c2 Compare March 5, 2018 13:22
@huonw
Copy link
Contributor Author

huonw commented Mar 5, 2018

@swift-ci please smoke test

@huonw
Copy link
Contributor Author

huonw commented Mar 5, 2018

@swift-ci please smoke test.

@huonw huonw merged commit 216e69e into swiftlang:master Mar 6, 2018
@huonw huonw deleted the no-dynamic-count branch March 6, 2018 00:07
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