Skip to content

[AST] Lazily compute the set of nested types of an ArchetypeType #6011

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 4 commits into from
Dec 2, 2016

Conversation

DougGregor
Copy link
Member

Lazily expand out the list of nested types of an ArchetypeType. The archetype builder need not be involved.

While I'm here, optimize the storage of ArchetypeType with more trailing objects.

Superclass constraints are uncommon, so put them into trailing-object
storage. Similarly, there's no reason to pay for the pointer + size of
the array of protocols to which the archetype conforms when we can use
trailing objects and existing padding bits.

Note that the nested types are *not* tail-allocated because they will
(eventually) be lazily allocated.
An ArchetypeType has all of the information it needs to lazily compute
its set of nested types (hint: they're the associated types of all of
the protocols to which it conforms). Do so only when asked about the
nested types.

Not that there are two levels of laziness happening here: first, we
only create the (sorted) array of nested types when asked about the
nested types the first time. Second, even when we do create it, we
only record the names of these types---the actual archetypes (or
concrete types) behind these names are lazily created when requested.

Of course, all of this laziness is short-lived, because
ArchetypeBuilder::getGenericEnvironment() forces all of the archetypes
to be constructed.
@DougGregor
Copy link
Member Author

@swift-ci please smoke test and merge

@DougGregor
Copy link
Member Author

Fixed some crashers? Oh darn

@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

@swift-ci please smoke test Linux

1 similar comment
@DougGregor
Copy link
Member Author

@swift-ci please smoke test Linux

@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

@swift-ci swift-ci merged commit 8be4df4 into swiftlang:master Dec 2, 2016
@DougGregor DougGregor deleted the lazy-nested-types branch December 2, 2016 05:18
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.

2 participants