Skip to content

Add a request to lazily parse function bodies. #26981

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

Conversation

DougGregor
Copy link
Member

Rework the lazy function body parsing mechanism to use the
request-evaluator, so that asking for the body of a function will
initiate parsing. Clean up a number of callers to
AbstractFunctionDecl::getBody() that don't actually need the body, so
we don't perform unnecessary parsing.

This change does not delay parsing of function bodies in the general
case; rather, it sets up the infrastructure to always delay parsing of
function bodies.

Rework the lazy function body parsing mechanism to use the
request-evaluator, so that asking for the body of a function will
initiate parsing. Clean up a number of callers to
AbstractFunctionDecl::getBody() that don't actually need the body, so
we don't perform unnecessary parsing.

This change does not delay parsing of function bodies in the general
case; rather, it sets up the infrastructure to always delay parsing of
function bodies.
Use the delayed parsing of function bodies for source imports, and
switch source imports over to lazy type checking. There's no point in
doing a full type check for them.
@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor DougGregor merged commit 097b1b4 into swiftlang:master Sep 1, 2019
@DougGregor DougGregor deleted the request-function-body-parse-again branch September 1, 2019 02:21
compnerd added a commit to compnerd/apple-swift that referenced this pull request Sep 1, 2019
The build on Windows has been failing due to the ambiguous constructor
overload:

```
lib\Parse\ParseRequests.cpp(83): error C2666: 'swift::Parser::Parser': 2 overloads have similar conversions
include\swift\Parse\Parser.h(412): note: could be 'swift::Parser::Parser(std::unique_ptr<swift::Lexer,std::default_delete<_Ty>>,swift::SourceFile &,swift::SILParserTUStateBase *,swift::PersistentParserState *,std::shared_ptr<swift::SyntaxParseActions>,bool)'
        with
        [
            _Ty=swift::Lexer
        ]
include\swift\Parse\Parser.h(408): note: or       'swift::Parser::Parser(unsigned int,swift::SourceFile &,swift::SILParserTUStateBase *,swift::PersistentParserState *,std::shared_ptr<swift::SyntaxParseActions>,bool)'
include\swift\Parse\Parser.h(403): note: or       'swift::Parser::Parser(unsigned int,swift::SourceFile &,swift::DiagnosticEngine *,swift::SILParserTUStateBase *,swift::PersistentParserState *,std::shared_ptr<swift::SyntaxParseActions>,bool)'
lib\Parse\ParseRequests.cpp(84): note: while trying to match the argument list '(unsigned int, swift::SourceFile, nullptr, nullptr, nullptr, bool)'
```
compnerd added a commit that referenced this pull request Sep 1, 2019
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