mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Make deserialization of known protocol adopters lazy.
...by adding a new callback to ModuleLoader: loadDeclsConformingTo. This is used only when the type checker doesn't have enough contextual information to resolve an expression involving a literal, so it's possible many *LiteralConvertible types will never be loaded. Deserialization of types with conversion methods is still eager, since there's no easy hook to tell when they're needed, but the list has been renamed to refer to any decls that need to be eagerly deserialized, in case we need it for other purposes in the future. This probably won't help much in a real program, but it cuts the test run time by about 5-10% in my build. Swift SVN r7268
This commit is contained in:
@@ -177,14 +177,11 @@ private:
|
||||
std::unique_ptr<SerializedDeclTable> OperatorDecls;
|
||||
std::unique_ptr<SerializedDeclTable> ExtensionDecls;
|
||||
|
||||
using ProtocolAdopterVec = SmallVector<serialization::DeclID, 4>;
|
||||
using DeclIDVector = SmallVector<serialization::DeclID, 4>;
|
||||
|
||||
/// All adopters of compiler-known protocols in this module.
|
||||
///
|
||||
/// These are eagerly deserialized to aid in type-checking.
|
||||
/// The final entry (at NumKnownProtocols) contains decls that have
|
||||
/// conversion methods, which also need to be eagerly deserialized.
|
||||
ProtocolAdopterVec KnownProtocolAdopters[NumKnownProtocols+1];
|
||||
DeclIDVector KnownProtocolAdopters[NumKnownProtocols];
|
||||
DeclIDVector EagerDeserializationDecls;
|
||||
|
||||
/// Whether this module file can be used.
|
||||
ModuleStatus Status;
|
||||
@@ -342,8 +339,13 @@ public:
|
||||
|
||||
/// Loads extensions for the given decl.
|
||||
///
|
||||
/// Note that this may cause other extensions to load as well.
|
||||
/// Note that this may cause other decls to load as well.
|
||||
void loadExtensions(NominalTypeDecl *nominal);
|
||||
|
||||
/// Loads decls that conform to the given protocol.
|
||||
///
|
||||
/// Note that this may cause other decls to load as well.
|
||||
void loadDeclsConformingTo(KnownProtocolKind kind);
|
||||
};
|
||||
|
||||
class SerializedModule : public LoadedModule {
|
||||
|
||||
Reference in New Issue
Block a user