Skip to content
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

[Parse] Eliminate backtracking in collection expression parsing #21487

Merged
merged 1 commit into from Jan 7, 2019

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented Dec 21, 2018

Parsing collection literal expression used to take exponential time depending on the nesting level of the first element.

Stop using parseList() because using it complicates libSyntax parsing.

SR-9220 / rdar://problem/45221238
SR-7283 / rdar://problem/38913395

@rintaro
Copy link
Member Author

rintaro commented Dec 21, 2018

@swift-ci Please smoke test

@@ -1,7 +1,7 @@
// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -profile-generate -profile-coverage-mapping -emit-sil -module-name coverage_closures %s | %FileCheck %s

func bar(arr: [(Int32) -> Int32]) {
// CHECK-LABEL: sil_coverage_map {{.*}}// closure #2 (Swift.Int32) -> Swift.Int32 in coverage_closures.bar
// CHECK-LABEL: sil_coverage_map {{.*}}// closure #1 (Swift.Int32) -> Swift.Int32 in coverage_closures.bar
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously, local discriminator #1 used to be consumed during backtracking.

@slavapestov
Copy link
Member

Cool, I wonder if your PR fixes this bug too: https://github.com/apple/swift/pull/15619/files#diff-1a9565d4ad49da3f2dcb708fa95d21a3

Copy link
Member

@nkcsgexi nkcsgexi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, Thanks for fixing this!

Parsing collection literal expression used to take exponential time
depending on the nesting level of the first element.

Stop using 'parseList()' because using it complicates libSyntax parsing.

rdar://problem/45221238 / https://bugs.swift.org/browse/SR-9220
rdar://problem/38913395 / https://bugs.swift.org/browse/SR-7283
@rintaro rintaro force-pushed the parse-collection-rdar45221238 branch from 9cdad2c to 22652f9 Compare December 25, 2018 02:06
@rintaro
Copy link
Member Author

rintaro commented Dec 25, 2018

@slavapestov Yes this PR fixes that. Thank you for the link. I added a test case from #15619 .

@rintaro
Copy link
Member Author

rintaro commented Dec 25, 2018

@swift-ci Please smoke test

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.

None yet

3 participants