Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/release-notes/.FSharp.Compiler.Service/9.0.200.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### Fixed

* Ensure `frameworkTcImportsCache` mutations are threadsafe. ([PR #17795](https://github.com/dotnet/fsharp/pull/17795))

### Added

Expand Down
8 changes: 5 additions & 3 deletions src/Compiler/Service/IncrementalBuild.fs
Original file line number Diff line number Diff line change
Expand Up @@ -507,10 +507,12 @@ type FrameworkImportsCache(size) =
let frameworkTcImportsCache = AgedLookup<AnyCallerThreadToken, FrameworkImportsCacheKey, GraphNode<TcGlobals * TcImports>>(size, areSimilar=(fun (x, y) -> x = y))

/// Reduce the size of the cache in low-memory scenarios
member _.Downsize() = frameworkTcImportsCache.Resize(AnyCallerThread, newKeepStrongly=0)
member _.Downsize() = lock gate <| fun () ->
frameworkTcImportsCache.Resize(AnyCallerThread, newKeepStrongly=0)

/// Clear the cache
member _.Clear() = frameworkTcImportsCache.Clear AnyCallerThread
member _.Clear() = lock gate <| fun () ->
frameworkTcImportsCache.Clear AnyCallerThread

/// This function strips the "System" assemblies from the tcConfig and returns a age-cached TcImports for them.
member _.GetNode(tcConfig: TcConfig, frameworkDLLs: AssemblyResolution list, nonFrameworkResolutions: AssemblyResolution list) =
Expand Down Expand Up @@ -541,7 +543,7 @@ type FrameworkImportsCache(size) =
let tcConfigP = TcConfigProvider.Constant tcConfig
return! TcImports.BuildFrameworkTcImports (tcConfigP, frameworkDLLs, nonFrameworkResolutions)
})
frameworkTcImportsCache.Put(AnyCallerThread, key, lazyWork)
lock gate <| fun () -> frameworkTcImportsCache.Put(AnyCallerThread, key, lazyWork)
lazyWork
)
node
Expand Down