mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Serialization] Drop GenericEnvironmentID for GenericSignatureID (#26862)
A generic environment is always serialized as a GenericSignature with a lazily-recreated environment, though sometimes it has to include extra info specifically for generic environments used by SIL. The code that was doing this claimed a bit for disambiguating between the two, shrinking the permitted size of a compiled module from 2^31 bits to 2^30. (The code isn't just needlessly complicated; GenericEnvironments used to be serialized with more information.) Rather than have two representations for GenericEnvironmentID, this commit just drops it altogether in favor of referencing GenericSignatures directly. This causes a negligible file size shrinkage for swiftmodules in addition to eliminating the problematic disambiguation bit. For now, the Deserialization logic will continue to cache GenericEnvironments that are used directly by Deserialization, but really that should probably be done at the AST level. Then we can simplify further to ModuleFile tracking a plain list of GenericSignatures.
This commit is contained in:
@@ -928,11 +928,7 @@ bool ModuleFile::readIndexBlock(llvm::BitstreamCursor &cursor) {
|
||||
break;
|
||||
case index_block::GENERIC_SIGNATURE_OFFSETS:
|
||||
assert(blobData.empty());
|
||||
allocateBuffer(GenericSignatures, scratch);
|
||||
break;
|
||||
case index_block::GENERIC_ENVIRONMENT_OFFSETS:
|
||||
assert(blobData.empty());
|
||||
allocateBuffer(GenericEnvironments, scratch);
|
||||
allocateBuffer(GenericSignaturesAndEnvironments, scratch);
|
||||
break;
|
||||
case index_block::SUBSTITUTION_MAP_OFFSETS:
|
||||
assert(blobData.empty());
|
||||
@@ -2355,7 +2351,7 @@ bool SerializedASTFile::hasEntryPoint() const {
|
||||
bool SerializedASTFile::getAllGenericSignatures(
|
||||
SmallVectorImpl<GenericSignature*> &genericSignatures) {
|
||||
genericSignatures.clear();
|
||||
for (unsigned index : indices(File.GenericSignatures)) {
|
||||
for (unsigned index : indices(File.GenericSignaturesAndEnvironments)) {
|
||||
if (auto genericSig = File.getGenericSignature(index + 1))
|
||||
genericSignatures.push_back(genericSig);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user