-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[syntax-parse] Migrate parsing of literals and magic identifiers #35120
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
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…xt is enabled This commit re-applies changes that have been applied, reversed, re-applied and re-reversed. Credit for the original implementation goes to Jan Svoboda <[email protected]> for writing the original implementation and Rintaro Ishizaki <[email protected]> who review it and applied some fixes. Co-authored-by: Jan Svoboda <[email protected]> Co-authored-by: Rintaro Ishizaki <[email protected]> (+2 squashed commits) Squashed commits: [b7b884d513a] [syntax-parse] Use the HiddenLibSyntaxAction to always generate a libSyntax tree when the SyntaxParsingContext is enabled This commit re-applies changes that have been applied, reversed, re-applied and re-reversed. Credit for the original implementation goes to Jan Svoboda <[email protected]> for writing the original implementation and Rintaro Ishizaki <[email protected]> who review it and applied some fixes. Co-authored-by: Jan Svoboda <[email protected]> Co-authored-by: Rintaro Ishizaki <[email protected]> [077fb9b3690] [syntax-parse] Add a HiddenLibSyntaxAction that delegates to two SyntaxActions The class is not yet used, it just compiles. This commit re-applies changes that have been applied, reversed, re-applied and re-reversed. Credit for the original implementation goes to Jan Svoboda <[email protected]> for writing the original implementation and Rintaro Ishizaki <[email protected]> who review it and applied some fixes. Co-authored-by: Jan Svoboda <[email protected]> Co-authored-by: Rintaro Ishizaki <[email protected]>
…sEnabled() This commit re-applies changes that have been applied, reversed, re-applied and re-reversed. Credit for the original implementation goes to Jan Svoboda <[email protected]> for writing the original implementation and Rintaro Ishizaki <[email protected]> who review it and applied some fixes. Co-authored-by: Jan Svoboda <[email protected]> Co-authored-by: Rintaro Ishizaki <[email protected]>
@swift-ci Please test |
@swift-ci Please smoke test compiler performance |
1 similar comment
@swift-ci Please smoke test compiler performance |
…ontext when needed
This commit re-applies changes that have been applied, reversed, re-applied and re-reversed. Credit for the original implementation goes to Jan Svoboda <[email protected]> for writing the original implementation and Rintaro Ishizaki <[email protected]> who reviewed it and applied some fixes. Co-authored-by: Jan Svoboda <[email protected]> Co-authored-by: Rintaro Ishizaki <[email protected]>
…yntaxNodes This class is not used yet, just added and made sure it compiles This commit re-applies changes that have been applied, reversed, re-applied and re-reversed. Credit for the original implementation goes to Jan Svoboda <[email protected]> for writing the original implementation and Rintaro Ishizaki <[email protected]> who review it and applied some fixes. Co-authored-by: Jan Svoboda <[email protected]> Co-authored-by: Rintaro Ishizaki <[email protected]>
This commit re-applies changes that have been applied, reversed, re-applied and re-reversed. Credit for the original implementation goes to Jan Svoboda <[email protected]> for writing the original implementation and Rintaro Ishizaki <[email protected]> who review it and applied some fixes. Co-authored-by: Jan Svoboda <[email protected]> Co-authored-by: Rintaro Ishizaki <[email protected]>
This commit re-applies changes that have been applied, reversed, re-applied and re-reversed. Credit for the original implementation goes to Jan Svoboda <[email protected]> for writing the original implementation and Rintaro Ishizaki <[email protected]> who review it and applied some fixes. Co-authored-by: Jan Svoboda <[email protected]> Co-authored-by: Rintaro Ishizaki <[email protected]>
Compilation-performance test failed |
47f4524
to
4639f99
Compare
@swift-ci Please smoke test compiler performance |
@swift-ci Please smoke test |
This is no longer up-to-date. Closing. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is an effort migrate the parser to generate a libSyntax tree and have a separate
ASTGen
class generate an AST from the libSyntax tree.The gist of these changes has previously been made in #25193, been reverted, re-applied in #26403 and then been reverted again due to performance issues.
AFAIU the major performance issue that caused the final revert of the changes previously was because the libSyntax tree was always created, even for syntax elements that hadn't been migrated to the new parsing approach yet. In particular, this meant that we were no longer able to skip function bodies since the parser wanted to generate the libSyntax tree for the body.
I believe, we can mitigate the performance impact that we saw earlier by only selectively enabling the syntax parsing context in places where we need it. This will work as follows:
– During normal compilation the syntax context will be disable just like it is today
– Whenever we encounter a syntax element that has been migrated, we enable the syntax parsing context, and set its accumulation mode to discard
– Once parsing of that syntax element is finished, we disable the syntax parsing context again.
That way, we’d only pay the cost of unnecessarily creating the libSyntax tree for non-migrated elements nested inside migrated elements. As long as we don’t migrate declaration parsing, this cost should be negligible (Rintaro’s case of nesting declarations inside string literal interpolations should be pretty niche and the nested declarations small).
Once we start migrating declarations, we need to find a way to skip function bodies etc. to maintain performant parsing. I’m confident that this is a problem we’re able to solve once we get to it – in essence we need to teach libSyntax to also skip function bodies.
CC: @jansvoboda11