-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[SourceKit] Use a single PluginRegistry in multiple ASTContexts #64655
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
[SourceKit] Use a single PluginRegistry in multiple ASTContexts #64655
Conversation
Make a single 'PluginRegistry' and share it between SwiftASTManager, IDEInspectionInstance, and CompileInstance. And inject the plugin registry to ASTContext right after 'CompilerInstance.setup()' That way, all sema-capable ASTContext in SourceKit share a single PluginRegistry.
@swift-ci Please smoke test |
@swift-ci Please smoke test macOS |
@@ -139,6 +139,8 @@ class PluginRegistry { | |||
/// Flag to dump plugin messagings. | |||
bool dumpMessaging = false; | |||
|
|||
std::mutex mtx; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getLoadedLibraryPlugins()
needs to lock this, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to remove getLoadedLibraryPlugins()
method in follow-ups soon.
Currently only swift::emitLoadedModuleTraceIfNeeded()
is using it for dependency tracking. However since PluginRegistry might be shared between different compilations, getLoadedLibraryPlugins()
may contain unrelated entries. Instead, each ASTContext should track loaded libraries separately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a commit in this PR removing PluginRegistry::getLoadedLibraryPlugins()
.
PluginRegistry is now shared between multiple ASTContext. ASTContext should track its loaded plugin library paths separately.
2d5d934
to
59f744c
Compare
@swift-ci Please smoke test |
void *ASTContext::loadLibraryPlugin(StringRef path) { | ||
// Remember the path (even if it fails to load.) | ||
getImpl().LoadedPluginLibraryPaths.insert(path); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to track failed libraries? If not, I can just move this after getPluginRegistry()->loadLibraryPlugin(resolvedPath)
.
Also, do we want the VFS path or the "real" path here? I guess it doesn't matter because we only use this to get the module name from the filename. cc: @rxwei
Make a single
PluginRegistry
and share it betweenSwiftASTManager
,IDEInspectionInstance
, andCompileInstance
. And inject the plugin registry toASTContext
right afterCompilerInstance.setup()
That way, all sema-capable
ASTContext
in SourceKit share a singlePluginRegistry
.