From 7c0d74a5fb7d17dbf0c415d2cd210d7000c6b27f Mon Sep 17 00:00:00 2001 From: Don Syme Date: Wed, 12 Oct 2016 11:30:14 +0100 Subject: [PATCH 1/2] fix ilread cache --- src/fsharp/CompileOps.fs | 4 ---- src/fsharp/CompileOps.fsi | 1 - src/fsharp/TcGlobals.fs | 14 ++++++++++++-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/fsharp/CompileOps.fs b/src/fsharp/CompileOps.fs index 84ba70bb3f7..b96457ba5a3 100644 --- a/src/fsharp/CompileOps.fs +++ b/src/fsharp/CompileOps.fs @@ -3713,10 +3713,6 @@ type TcImports(tcConfigP:TcConfigProvider, initialResolutions:TcAssemblyResoluti | None -> false | None -> false - member tcImports.SetBase(baseTcImports) = - CheckDisposed() - importsBase <- Some(baseTcImports) - member private tcImports.Base = CheckDisposed() importsBase diff --git a/src/fsharp/CompileOps.fsi b/src/fsharp/CompileOps.fsi index cc3f9d415c2..b8e7c83aba9 100755 --- a/src/fsharp/CompileOps.fsi +++ b/src/fsharp/CompileOps.fsi @@ -582,7 +582,6 @@ type TcAssemblyResolutions = type TcImports = interface System.IDisposable //new : TcImports option -> TcImports - member SetBase : TcImports -> unit member DllTable : NameMap with get member GetImportedAssemblies : unit -> ImportedAssembly list member GetCcusInDeclOrder : unit -> CcuThunk list diff --git a/src/fsharp/TcGlobals.fs b/src/fsharp/TcGlobals.fs index 2243b552c9f..d60d1fbbcd9 100755 --- a/src/fsharp/TcGlobals.fs +++ b/src/fsharp/TcGlobals.fs @@ -1336,25 +1336,35 @@ let mkTcGlobals (compilingFslib,sysCcu,ilg,fslibCcu,directoryToResolveRelativePa // the TyconRef's we have in our hands, hence we can't dereference them to find their stamps. // So this dictionary is indexed by names. + // + // Make it lazy to avoid dereferencing while setting up the base imports. let dict = + lazy entries |> List.map (fun (nm,tcref,builder) -> nm, (fun tcref2 tinst -> if tyconRefEq tcref tcref2 then Some(builder tinst) else None)) |> Dictionary.ofList (fun tcref tinst -> - if dict.ContainsKey tcref.LogicalName then dict.[tcref.LogicalName] tcref tinst + let dict = dict.Value + let key = tcref.LogicalName + if dict.ContainsKey key nm then dict.[key] tcref tinst else None ) else // This map is for use in normal times (not building FSharp.Core.dll). It is indexed by tcref stamp which is // faster than the indexing technique used in the case above. // // So this dictionary is indexed by integers. + // + // Make it lazy to avoid dereferencing while setting up the base imports. let dict = + lazy entries |> List.filter (fun (_,tcref,_) -> tcref.CanDeref) |> List.map (fun (_,tcref,builder) -> tcref.Stamp, builder) |> Dictionary.ofList (fun tcref2 tinst -> - if dict.ContainsKey tcref2.Stamp then Some(dict.[tcref2.Stamp] tinst) + let dict = dict.Value + let key = tcref2.Stamp + if dict.ContainsKey key then Some(dict.[key] tinst) else None) end From 300a5f3f73bb76e760c2d1b348ba4794a0463bc1 Mon Sep 17 00:00:00 2001 From: Don Syme Date: Wed, 12 Oct 2016 12:25:57 +0100 Subject: [PATCH 2/2] fix build --- src/fsharp/TcGlobals.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fsharp/TcGlobals.fs b/src/fsharp/TcGlobals.fs index d60d1fbbcd9..1a5b753a280 100755 --- a/src/fsharp/TcGlobals.fs +++ b/src/fsharp/TcGlobals.fs @@ -1346,7 +1346,7 @@ let mkTcGlobals (compilingFslib,sysCcu,ilg,fslibCcu,directoryToResolveRelativePa (fun tcref tinst -> let dict = dict.Value let key = tcref.LogicalName - if dict.ContainsKey key nm then dict.[key] tcref tinst + if dict.ContainsKey key then dict.[key] tcref tinst else None ) else // This map is for use in normal times (not building FSharp.Core.dll). It is indexed by tcref stamp which is