-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[IRGen] Use generic value witnesses for prespecialized types. #36765
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
[IRGen] Use generic value witnesses for prespecialized types. #36765
Conversation
de792fc
to
d14b550
Compare
d14b550
to
e56fe17
Compare
e56fe17
to
1509fc1
Compare
3604439
to
e9ea4f3
Compare
Performance (x86_64): -O
Code size: -OPerformance (x86_64): -Osize
Code size: -OsizePerformance (x86_64): -Onone
Code size: -swiftlibsHow to read the dataThe 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 Noise: Sometimes the performance results (not code size!) contain false Hardware Overview
|
When witness tables for enums are instantiated at runtime via swift::swift_initEnumMetadataMultiPayload the witnesses getEnumTagSinglePayload storeEnumTagSinglePayload are filled with swift_getMultiPayloadEnumTagSinglePayload (previously getMultiPayloadEnumTagSinglePayload) and swift_storeMultiPayloadEnumTagSinglePayload (previously storeMultiPayloadEnumTagSinglePayload). Concretely, that occurs when instantiating the value witness table for a generic enum which has more than one case with a payload, like Result<T>. To enable the compiler to do the same work, those functions need to be visible to it. Here, those functions are made visible to the compiler. Doing so requires changing the way they are declared and adding them to RuntimeFunctions.def which in turn requires the definition of some functions to describe the availability of those functions.
isOSDarwin is true on tvOS so there is no need to also check for isTvOS.
e9ea4f3
to
6295ee1
Compare
eae1476
to
c17facc
Compare
c17facc
to
7624c0f
Compare
Previously, specialized value witness functions were emitted and used in the prespecialized value witness table corresponding to and pointed to by the prespecialized metadata for a generic type whose metadata was prespecialized. That incurs a codesize cost: specialized value witness functions had to be emitted. Here, the generic value witness functions are used instead. The change is not entirely trivial, though. We can't simply emit all the witnesses for the unbound generic type (indeed if that were possible there would be no need to emit a separate VWT). There are two reasons: (1) the non-function fields (size, stride, flags, extra inhabitant count) need to be those for the specialized generic type, (2) in the case of multi-payload enums, the getEnumTagSinglePayload and storeEnumTagSinglePayload witnesses cannot be those emitted for the unspecialized generic type--instead they need to be swift_getMultiPayloadEnumTagSinglePayload and swift_storeMultiPayloadEnumTagSinglePayload respectively.
7624c0f
to
02a63e5
Compare
@swift-ci please clean test windows platform |
@swift-ci please clean test linux platform |
@swift-ci please clean test windows platform |
1 similar comment
@swift-ci please clean test windows platform |
Previously, specialized value witnesses were emitted and used in the prespecialized value witness table corresponding to and pointed to by the prespecialized metadata for a generic type whose metadata was prespecialized. That incurs a codesize cost. Here, the generic value witnesses are used instead.