[Serialization] Add control over adding a loaded module to the in-memory cache

This commit is contained in:
Alexis Laferrière
2022-10-26 16:05:09 -07:00
parent 3b63f4986a
commit 730497e9a3
8 changed files with 30 additions and 12 deletions

View File

@@ -1208,7 +1208,8 @@ bool MemoryBufferSerializedModuleLoader::canImportModule(
ModuleDecl *
SerializedModuleLoaderBase::loadModule(SourceLoc importLoc,
ImportPath::Module path) {
ImportPath::Module path,
bool AllowMemoryCache) {
// FIXME: Swift submodules?
if (path.size() > 1)
return nullptr;
@@ -1233,7 +1234,8 @@ SerializedModuleLoaderBase::loadModule(SourceLoc importLoc,
auto M = ModuleDecl::create(moduleID.Item, Ctx);
M->setIsSystemModule(isSystemModule);
Ctx.addLoadedModule(M);
if (AllowMemoryCache)
Ctx.addLoadedModule(M);
SWIFT_DEFER { M->setHasResolvedImports(); };
llvm::sys::path::native(moduleInterfacePath);
@@ -1264,7 +1266,8 @@ SerializedModuleLoaderBase::loadModule(SourceLoc importLoc,
ModuleDecl *
MemoryBufferSerializedModuleLoader::loadModule(SourceLoc importLoc,
ImportPath::Module path) {
ImportPath::Module path,
bool AllowMemoryCache) {
// FIXME: Swift submodules?
if (path.size() > 1)
return nullptr;
@@ -1300,7 +1303,8 @@ MemoryBufferSerializedModuleLoader::loadModule(SourceLoc importLoc,
if (BypassResilience)
M->setBypassResilience();
M->addFile(*file);
Ctx.addLoadedModule(M);
if (AllowMemoryCache)
Ctx.addLoadedModule(M);
return M;
}