Skip to content

Commit 17f2d93

Browse files
committed
plug it in
1 parent 2e8000f commit 17f2d93

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

src/Compiler/Checking/TypeRelations.fs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ let TypesFeasiblyEquivStripMeasures g amap m ty1 ty2 =
102102
TypesFeasiblyEquivalent true 0 g amap m ty1 ty2
103103

104104
let inline TryGetCachedTypeSubsumption (g: TcGlobals) (amap: ImportMap) key =
105-
if g.compilationMode = CompilationMode.OneOff && g.langVersion.SupportsFeature LanguageFeature.UseTypeSubsumptionCache then
106-
match amap.TypeSubsumptionCache.TryGetValue(key) with
105+
if g.langVersion.SupportsFeature LanguageFeature.UseTypeSubsumptionCache then
106+
match amap.TypeSubsumptionCache.TryGet(key) with
107107
| true, subsumes ->
108108
ValueSome subsumes
109109
| false, _ ->
@@ -112,8 +112,8 @@ let inline TryGetCachedTypeSubsumption (g: TcGlobals) (amap: ImportMap) key =
112112
ValueNone
113113

114114
let inline UpdateCachedTypeSubsumption (g: TcGlobals) (amap: ImportMap) key subsumes : unit =
115-
if g.compilationMode = CompilationMode.OneOff && g.langVersion.SupportsFeature LanguageFeature.UseTypeSubsumptionCache then
116-
amap.TypeSubsumptionCache[key] <- subsumes
115+
if g.langVersion.SupportsFeature LanguageFeature.UseTypeSubsumptionCache then
116+
amap.TypeSubsumptionCache.TryAdd(key, subsumes) |> ignore
117117

118118
/// The feasible coercion relation. Part of the language spec.
119119
let rec TypeFeasiblySubsumesType ndeep (g: TcGlobals) (amap: ImportMap) m (ty1: TType) (canCoerce: CanCoerce) (ty2: TType) =

src/Compiler/Checking/import.fs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ type [<Struct; NoComparison; CustomEquality>] TTypeCacheKey =
106106
type ImportMap(g: TcGlobals, assemblyLoader: AssemblyLoader) =
107107
let typeRefToTyconRefCache = ConcurrentDictionary<ILTypeRef, TyconRef>()
108108

109-
let typeSubsumptionCache = ConcurrentDictionary<TTypeCacheKey, bool>(System.Environment.ProcessorCount, 1024)
109+
let typeSubsumptionCache =
110+
Cache<TTypeCacheKey, bool>.Create({ CacheOptions.Default with MaximumCapacity = 1024 })
110111

111112
member _.g = g
112113

src/Compiler/Checking/import.fsi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ type ImportMap =
7373
member g: TcGlobals
7474

7575
/// Type subsumption cache
76-
member TypeSubsumptionCache: ConcurrentDictionary<TTypeCacheKey, bool>
76+
member TypeSubsumptionCache: Cache<TTypeCacheKey, bool>
7777

7878
module Nullness =
7979

0 commit comments

Comments
 (0)