Skip to content

[metadata prespecialization] Add canonical prespecialization to end of type descriptors. #33442

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

Conversation

nate-chandler
Copy link
Contributor

Enumerating the canonical prespecializations at the end of the type descriptors enables both (1) lifting one of the limitations on cross-module prespecializations and also (2) lifting the logic for iterating through the canonical prespecializations from individual metadata accessors into getGenericMetadata.

Previously, it was possible to alias an old LinkEntity which was marked
used (i.e. in LLVMUsed) or compiler used (i.e. in LLVMCompilerUsed).
The result of defining such an alias was a failure downstream when
writing out the lists of globals.

Here, the old value is removed from the list before it is invalidated.
@nate-chandler
Copy link
Contributor Author

@swift-ci please test

1 similar comment
@nate-chandler
Copy link
Contributor Author

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - e0da2f8c6860514bec33d72ce01e288f317570de

@shahmishal
Copy link
Member

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - e0da2f8c6860514bec33d72ce01e288f317570de

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - e0da2f8c6860514bec33d72ce01e288f317570de

@nate-chandler nate-chandler force-pushed the generic-metadata-prespecialization-components/record-canonical-prespecializations branch from e0da2f8 to 7069f4b Compare August 13, 2020 17:26
@nate-chandler
Copy link
Contributor Author

@swift-ci please test

Previously, a call to emitMethodLookupFunction or emitDispatchThunk
would always simply emit a function, even if it had previously been
emitted.  That was a problem since these emissions are triggered by
emitting class type context descriptors which can now be lazily
reemitted upon encountering prespecialized metadata.

Here, that behavior is changed to delete the old body, if any, before
emitting the body again.
Previously, emitting the descriptor for a nonoverride method always
simply emitted, even if it had previously been emitted.  That was not a
problem before, but is now that class type context descriptors can be
reemitted upon encountering metadata prespecializations.

Here, the behavior is changed to delete the old definition before
emitting the new definition.
The attachment of the canonical prespecializations to the generic type
will enable runtime functions to look through the canonical
prespecializations in order to return them (getGenericMetadata) and
register them with the runtime (getSpecializedGenericMetadata).
The metadata accessor and type context descriptor for a nominal type
both depend on canonical metadata--the former because it returns those
metadata, the latter because it has them as trailing objects.

Here, the work is done to reemit those values when new canonical
prespecialized metadata are encountered.
Previously, noncanonical records were only allowed if one of the
arguments was from the module where the record was to be emitted.

Here, that restriction is lifted.  Now getSpecializedGenericMetadata
will, on first run, register all canonical metadata with the global
cache before attempting to bless the passed-in noncanonical record,
allowing noncanonical records to be for the same arguments as a
canonical record (since in the case that a canonical record does exist,
it will be returned).
@nate-chandler nate-chandler force-pushed the generic-metadata-prespecialization-components/record-canonical-prespecializations branch from 7069f4b to 5114f22 Compare August 14, 2020 00:45
@nate-chandler
Copy link
Contributor Author

@swift-ci please test

1 similar comment
@nate-chandler
Copy link
Contributor Author

@swift-ci please test

@nate-chandler
Copy link
Contributor Author

@swift-ci please test windows

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 5114f22

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 5114f22

@nate-chandler
Copy link
Contributor Author

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 5114f22

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 5114f22

@nate-chandler
Copy link
Contributor Author

@swift-ci please test macos

@nate-chandler
Copy link
Contributor Author

@swift-ci please test windows

@nate-chandler nate-chandler merged commit 6dddf96 into swiftlang:master Aug 14, 2020
@nate-chandler nate-chandler deleted the generic-metadata-prespecialization-components/record-canonical-prespecializations branch August 14, 2020 16:59
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.

3 participants