Skip to content

[AST] Tail-allocate GenericEnvironment's archetypes-to-interface types mapping #6014

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
Dec 2, 2016

Conversation

DougGregor
Copy link
Member

Store the archetype-to-interface-type mapping (which is used to map
out of a generic environment) is a tail-allocated array of
(archetype, generic type parameter) pairs. This array is built up
lazily, as we compute the context types for generic parameters.

Searching in this array is linear while it is being constructed. Once
it is complete, it is sorted so that future searches are logarithmic.

Aside from the space savings of not having a DenseMap lying around,
this means we no longer need to register a destructor of a
GenericEnvironment with the ASTContext, which saves us tear-down
time.

@jrose-apple happy now?

…s mapping

Store the archetype-to-interface-type mapping (which is used to map
*out* of a generic environment) is a tail-allocated array of
(archetype, generic type parameter) pairs. This array is built up
lazily, as we compute the context types for generic parameters.

Searching in this array is linear while it is being constructed. Once
it is complete, it is sorted so that future searches are logarithmic.

Aside from the space savings of not having a DenseMap lying around,
this means we no longer need to register a destructor of a
GenericEnvironment with the ASTContext, which saves us tear-down
time.
@DougGregor
Copy link
Member Author

@swift-ci please smoke test and merge

@jrose-apple
Copy link
Contributor

Oh hey. :-)

Awful thought: is 65536 mappings enough?

@swift-ci swift-ci merged commit a0e7777 into swiftlang:master Dec 2, 2016
@DougGregor DougGregor deleted the generic-env-tail-alloc branch December 2, 2016 03:03
@DougGregor
Copy link
Member Author

That's a fine upper limit on the number of generic parameters in a contezt

@jckarter
Copy link
Contributor

jckarter commented Dec 2, 2016

"64K parameters ought to be enough for anyone"

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.

4 participants