Skip to content

[GSB] Centralize, clean up, and cache nested type name lookup #12097

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 9 commits into from
Sep 25, 2017

Conversation

DougGregor
Copy link
Member

Handle all name lookup for nested types of generic types through the equivalence class, rather than relying on depending on which potential archetypes have been constructed and returning the first one. Introduce caching of that lookup to improve compile-time performance (5% of type-checking time for the standard library).

We had two similar loops that performed name lookup for nested types on a
potential archetype, so consolidate those into a single implementation on
the equivalence class itself.
The full state of the GSB isn’t all that useful for testing, creates a ton of noise and gets in the way of some cleanups we’d like to make in the interface.
Stop dumping it as part of `-debug-generic-signatures`.
Funnel all places where we create a generic signature builder to compute
the generic signature through a single entry point in the GSB
(`computeGenericSignature()`), and make `finalize` and `getGenericSignature`
private so no new uses crop up.

Tighten up the signature of `computeGenericSignature()` so it only works on
GSB rvalues, and ensure that all clients consider the GSB dead after that
point by clearing out the internal representation of the GSB.
These only occur with canonicalized builders in invalid code; it’s not worth
having them slip out.
The GSB performs repeated lookups of the same nested type (by name) within
a given equivalence class. Cache the results of this lookup.
…type().

The type checker shouldn’t know about potential archetypes. Use
GenericSignatureBuilder::resolveEquivalenceClass() and perform the lookup
into that instead.

The test case change highlights an existing problem with generic signature
minimization.
@DougGregor
Copy link
Member Author

@swift-ci please smoke test and merge

@DougGregor
Copy link
Member Author

@swift-ci please smoke test and merge

1 similar comment
@DougGregor
Copy link
Member Author

@swift-ci please smoke test and merge

@DougGregor
Copy link
Member Author

Foundation/NSData.swift:19:8: error: module file was created by an older version of the compiler; rebuild 'Dispatch' and try again:

@DougGregor
Copy link
Member Author

@swift-ci please clean smoke test Linux

1 similar comment
@DougGregor
Copy link
Member Author

@swift-ci please clean smoke test Linux

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.

1 participant