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

[Sema] Stop visiting existential exprs an extra time checking for uses #27150

Conversation

jrose-apple
Copy link
Contributor

@jrose-apple jrose-apple commented Sep 12, 2019

This was causing an exponential amount of time traversing the AST with deeply chained protocol extension methods, such as in the TestCodableRouter.swift test in Kitura. Introduced in #23867.

If the OpaqueValueExpr is referenced more than once within the OpenExistentialExpr it'll still get visited more than once, but that doesn't seem to happen in practice. If it turns out to be a problem, we can weaken the assertion I'm adding here.

SR-11012 / rdar://problem/52194425

This was causing an exponential amount of time traversing the AST with
deeply chained protocol extension methods, such as in the
TestCodableRouter.swift test in Kitura.

If the OpaqueValueExpr is referenced more than once within the
OpenExistentialExpr it'll still get visited more than once, but that
doesn't seem to happen in practice. If it turns out to be a problem,
we can weaken the assertion I'm adding here.

https://bugs.swift.org/browse/SR-11012
@jrose-apple
Copy link
Contributor Author

If the OpaqueValueExpr is referenced more than once within the OpenExistentialExpr it'll still get visited more than once, but that doesn't seem to happen in practice.

Is this actually a valid assumption, reviewerfolk?

@jrose-apple
Copy link
Contributor Author

@swift-ci Please test

@jrose-apple
Copy link
Contributor Author

@swift-ci Please test source compatibility

@slavapestov
Copy link
Member

Nice catch. Currently an OVE can only be referenced once regardless of its parent expr. This is enforced with assertions in SILGen.

@jrose-apple jrose-apple merged commit dc59cd2 into apple:master Sep 13, 2019
@jrose-apple jrose-apple deleted the apparently-some-exprs-are-more-equal-than-others branch September 13, 2019 03:21
jrose-apple added a commit to jrose-apple/swift that referenced this pull request Sep 13, 2019
apple#27150)

This was causing an exponential amount of time traversing the AST with
deeply chained protocol extension methods, such as in the
TestCodableRouter.swift test in Kitura.

If the OpaqueValueExpr is referenced more than once within the
OpenExistentialExpr it'll still get visited more than once, but that
doesn't seem to happen in practice. If it turns out to be a problem,
we can weaken the assertion I'm adding here.

https://bugs.swift.org/browse/SR-11012
(cherry picked from commit dc59cd2)
jrose-apple added a commit to jrose-apple/swift that referenced this pull request Sep 13, 2019
apple#27150)

This was causing an exponential amount of time traversing the AST with
deeply chained protocol extension methods, such as in the
TestCodableRouter.swift test in Kitura.

If the OpaqueValueExpr is referenced more than once within the
OpenExistentialExpr it'll still get visited more than once, but that
doesn't seem to happen in practice. If it turns out to be a problem,
we can weaken the assertion I'm adding here.

https://bugs.swift.org/browse/SR-11012
(cherry picked from commit dc59cd2)
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

2 participants