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

Avoid building conformance lookup tables when we don't have to. #10715

Merged

Conversation

jrose-apple
Copy link
Contributor

@jrose-apple jrose-apple commented Jun 30, 2017

  • Deinitializers never get a custom Objective-C name.
  • Classes and protocols are never bridged themselves; that only matters for structs and enums.

This avoids another circularity issue like the one in #10707, where the Clang importer ends up importing a class and hands it to the type checker, which then asks about conformances. The conformance lookup table goes to add the extension from the Swift module, except that the Swift module is what asked for the import in the first place.

It's possible there's a more general solution here, but this particular change is good even in the non-crashy cases, and definitely safe for Swift 4.0. Even if the test case is even more idiosyncratic than the last one.

SR-5330 / rdar://problem/32677610

@jrose-apple
Copy link
Contributor Author

@DougGregor, any idea for a test case on this one? I'd take even a counter-based solution by this point. The code is very clearly correct, but I'm having trouble reproducing the original crash in a cut-down environment. (I'll try harder tomorrow, I suppose.)

@DougGregor
Copy link
Member

The only idea that comes to mind is something like the -debug-forbid-typecheck-prefix flag that Argyrios added, which basically checks that (in some given test case) we don't type-check something eagerly when we only need lazily-computed information.

That said, what we're really missing is a higher-level mechanism for determining when we get "less lazy", e.g., by tracking all of these statistics in aggregate. I'd be okay with deferring to that mechanism and merging without a test for this because it's so obviously correct.

@jrose-apple jrose-apple force-pushed the deinit-does-not-need-conformances branch from 4ab0680 to 724d93a Compare July 1, 2017 01:15
@jrose-apple
Copy link
Contributor Author

Managed to reduce the original case well enough. The Objective-C code being in a module rather than a bridging header was key, apparently.

@jrose-apple
Copy link
Contributor Author

@swift-ci Please test

@jrose-apple jrose-apple changed the title WIP: Avoid building conformance lookup tables when we don't have to. Avoid building conformance lookup tables when we don't have to. Jul 1, 2017
@swift-ci
Copy link
Collaborator

swift-ci commented Jul 1, 2017

Build failed
Jenkins build - Swift Test Linux Platform
Git Commit - 4ab06806407a03eca952eec6abf0be6c5a3667b9
Test requested by - @jrose-apple

@swift-ci
Copy link
Collaborator

swift-ci commented Jul 1, 2017

Build failed
Jenkins build - Swift Test OS X Platform
Git Commit - 4ab06806407a03eca952eec6abf0be6c5a3667b9
Test requested by - @jrose-apple

@jrose-apple jrose-apple force-pushed the deinit-does-not-need-conformances branch from 724d93a to be9d881 Compare July 1, 2017 03:01
@jrose-apple
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Collaborator

swift-ci commented Jul 1, 2017

Build failed
Jenkins build - Swift Test Linux Platform
Git Commit - 724d93aa995656d2c505590405e76bc4d09751e7
Test requested by - @jrose-apple

@swift-ci
Copy link
Collaborator

swift-ci commented Jul 1, 2017

Build failed
Jenkins build - Swift Test OS X Platform
Git Commit - 724d93aa995656d2c505590405e76bc4d09751e7
Test requested by - @jrose-apple

And consolidate two slightly different subclasses of PrettyStackTrace
that mostly did the same thing.
- Deinitializers never get a custom Objective-C name.
- Classes and protocols are never bridged themselves; that only matters
  for structs and enums.

This avoids another circularity issue like the one in a8bc132,
where the Clang importer ends up importing a class and hands it to the
type checker, which then asks about conformances. The conformance
lookup table goes to add the extension from the Swift module, except
that the Swift module is what asked for the import in the first place.

It's possible there's a more general solution here, but this
particular change is good even in the non-crashy cases, and definitely
safe for Swift 4.0. Even if the test case is even more idiosyncratic
than the last one.

The test case change for SourceKit is probably due to the first
category not triggering the import of the other two
categories. Changes in import order have been known to affect source
compatibility, though not frequently. However, categories are not
intended to be ordered in the first place. There's still more we can
do in this space, and implicitly depending on these calls /outside/ of
the importer to control category import order was quite brittle
anyway.

SR-5330 / rdar://problem/32677610
I didn't end up using this in the previous commit, but it seems
reasonable to have.
@jrose-apple jrose-apple force-pushed the deinit-does-not-need-conformances branch from be9d881 to 124f7d2 Compare July 5, 2017 18:28
@jrose-apple
Copy link
Contributor Author

@swift-ci Please test macOS

@jrose-apple
Copy link
Contributor Author

@swift-ci Please smoke test Linux

@swift-ci
Copy link
Collaborator

swift-ci commented Jul 5, 2017

Build failed
Jenkins build - Swift Test OS X Platform
Git Commit - be9d8817aae29866e7cbd570a21bca00ecfcd5b3
Test requested by - @jrose-apple

@jrose-apple jrose-apple merged commit 4671c40 into apple:master Jul 5, 2017
@jrose-apple jrose-apple deleted the deinit-does-not-need-conformances branch July 5, 2017 20:22
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