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

[ABI] Associated conformance defaults #19391

Merged

Conversation

DougGregor
Copy link
Member

Implement support for default associated conformance witnesses, as part of the default witness table, which includes:

  • Moving associated conformance witnesses into the resilient witness table
  • Identifying default associated conformance witnesses in the type checker. We warn when building a protocol resiliently where a the default for an associated type does not satisfy one of the conformance requirements placed on that associated type
  • Emitting default associated conformance witnesses into the default witness table
  • Adding a fun Evolution test trying to simulate the moral equivalent of adding Collection.SubSequence resiliently.

For a resilient conformance, emit the associated conformance accessor
functions into the resilient witness table (keyed on the associated
conformance descriptor) rather than in the fixed part of the witness
table. This is another part of resilience for associated conformances,
and a step toward defaults for associated conformances.
Default associated conformance accessors will be used in default
witness tables to fill in associated conformances for defaulted
associated types. Add (de|re|)mangling support for them and make them
linking entities in IRGen.
When forming the default witness table for a resilient protocol, look
for default associated conformances as well. These are identified by
associated conformance requirements whose root associated type has a
default type. For such requirements, we look for a conformance and
record it as a default associated conformance.

Emit a warning in cases where we don't find such a conformance,
because the associated type and conformance *may* have been added
with the intent of being resilient, and we can't know. This warning
might be a terrible idea, but it is only enabled under
-enable-resilience (which itself is hidden) and fires in one only
place in the standard library (which seems legitimate), so we'll try
it for now.
Referencing associated conformance witnesses via the index of the
requirement in the requirement signature is inconvenient. Reference
them by CanType/ProtocolDecl* instead.
For a resilient protocol that has defaulted associated types, emit
default associated conformance witnesses that compute associated
conformances based on that default witness.

This completes the implementation of resilience protocols that
add new, defaulted associated types, rdar://problem/44167982.
We *still* need a better way to model this, eventually, but this keeps
the SIL parser limping along for default witness tables.
@DougGregor
Copy link
Member Author

@swift-ci please test

@DougGregor
Copy link
Member Author

@swift-ci please benchmark

@DougGregor
Copy link
Member Author

@milseman this is the pull request that introduces a new warning into the build of the standard library:

swift/stdlib/public/core/StringProtocol.swift:17:17: warning: default type 'Slice<Self>' for associated type 'SubSequence' does not satisfy constraint 'Self.SubSequence': 'StringProtocol'
public protocol StringProtocol
                ^
swift/stdlib/public/core/Collection.swift:393:18: note: associated type 'SubSequence' has default type 'Slice<Self>' written here
  associatedtype SubSequence = Slice<Self> where SubSequence.Index == Index
                 ^             ~~~~~~~~~~~

We can add the conditional conformance of Slice to StringProtocol, if that's the right thing to do. We don't currently have a different way to suppress the warning (which only triggers when building code resiliently).

@swift-ci
Copy link
Collaborator

Build comment file:

Code size: -O

TEST OLD NEW DELTA RATIO
Regression
NibbleSort.o 14711 14999 +2.0% 0.98x

Code size: -Osize

TEST OLD NEW DELTA RATIO
Regression
NibbleSort.o 19831 20263 +2.2% 0.98x

Code size: Swift libraries

TEST OLD NEW DELTA RATIO
Regression
libswiftObjectiveC.dylib 16384 20480 +25.0% 0.80x
libswiftCoreGraphics.dylib 61440 65536 +6.7% 0.94x
libswiftCloudKit.dylib 102400 106496 +4.0% 0.96x
How to read the data The tables contain differences in performance which are larger than 8% and differences in code size which are larger than 1%.

If you see any unexpected regressions, you should consider fixing the regressions before you merge the PR.

Noise: Sometimes the performance results (not code size!) contain false alarms. Unexpected regressions which are marked with '(?)' are probably noise. If you see regressions which you cannot explain you can try to run the benchmarks again. If regressions still show up, please consult with the performance team (@eeckstein).

Hardware Overview
  Model Name: Mac Pro
  Model Identifier: MacPro6,1
  Processor Name: 12-Core Intel Xeon E5
  Processor Speed: 2.7 GHz
  Number of Processors: 1
  Total Number of Cores: 12
  L2 Cache (per Core): 256 KB
  L3 Cache: 30 MB
  Memory: 64 GB

@DougGregor DougGregor merged commit 32fd274 into apple:master Sep 19, 2018
@DougGregor DougGregor deleted the assoc-conformance-default-witnesses branch September 19, 2018 20:15
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