From 85db2b890ed830919b4f727bafca1d9e2fddcae4 Mon Sep 17 00:00:00 2001 From: Will Smith Date: Thu, 10 Dec 2020 18:01:05 -0800 Subject: [PATCH 1/2] Incremental build comment cleanup and minor fix for logical file timestamps --- src/fsharp/service/IncrementalBuild.fs | 42 ++++++++++---------------- 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/src/fsharp/service/IncrementalBuild.fs b/src/fsharp/service/IncrementalBuild.fs index 1bbb14ee397..da95f8bd911 100755 --- a/src/fsharp/service/IncrementalBuild.fs +++ b/src/fsharp/service/IncrementalBuild.fs @@ -575,16 +575,6 @@ type FrameworkImportsCache(size) = return tcGlobals, frameworkTcImports, nonFrameworkResolutions, unresolved } - -//------------------------------------------------------------------------------------ -// Rules for reactive building. -// -// This phrases the compile as a series of vector functions and vector manipulations. -// Rules written in this language are then transformed into a plan to execute the -// various steps of the process. -//----------------------------------------------------------------------------------- - - /// Represents the interim state of checking an assembly [] type PartialCheckResults private (semanticModel: SemanticModel, timeStamp: DateTime) = @@ -712,28 +702,19 @@ type IncrementalBuilder(tcGlobals, frameworkTcImports, nonFrameworkAssemblyInput //---------------------------------------------------- // START OF BUILD TASK FUNCTIONS - /// This is a build task function that gets placed into the build rules as the computation for a VectorStamp - /// /// Get the timestamp of the given file name. let StampFileNameTask (cache: TimeStampCache) _ctok (_m: range, filename: string, _isLastCompiland) = cache.GetFileTimeStamp filename - /// This is a build task function that gets placed into the build rules as the computation for a VectorMap - /// /// Parse the given file and return the given input. let ParseTask ctok (sourceRange: range, filename: string, isLastCompiland) = DoesNotRequireCompilerThreadTokenAndCouldPossiblyBeMadeConcurrent ctok SyntaxTree(tcConfig, fileParsed, lexResourceManager, sourceRange, filename, isLastCompiland) - /// This is a build task function that gets placed into the build rules as the computation for a Vector.Stamp - /// /// Timestamps of referenced assemblies are taken from the file's timestamp. let StampReferencedAssemblyTask (cache: TimeStampCache) ctok (_ref, timeStamper) = timeStamper cache ctok - - /// This is a build task function that gets placed into the build rules as the computation for a Vector.Demultiplex - /// // Link all the assemblies together and produce the input typecheck accumulator let CombineImportedAssembliesTask ctok : Cancellable = cancellable { @@ -819,8 +800,6 @@ type IncrementalBuilder(tcGlobals, frameworkTcImports, nonFrameworkAssemblyInput defaultPartialTypeChecking, beforeFileChecked, fileChecked, tcInfo, Eventually.Done (Some tcInfoOptional), None) } - /// This is a build task function that gets placed into the build rules as the computation for a Vector.ScanLeft - /// /// Type check all files. let TypeCheckTask ctok (prevSemanticModel: SemanticModel) syntaxTree: Eventually = eventually { @@ -832,8 +811,6 @@ type IncrementalBuilder(tcGlobals, frameworkTcImports, nonFrameworkAssemblyInput return semanticModel } - /// This is a build task function that gets placed into the build rules as the computation for a Vector.Demultiplex - /// /// Finish up the typechecking to produce outputs for the rest of the compilation process let FinalizeTypeCheckTask ctok (semanticModels: SemanticModel[]) = cancellable { @@ -932,7 +909,16 @@ type IncrementalBuilder(tcGlobals, frameworkTcImports, nonFrameworkAssemblyInput let fileNames = sourceFiles |> Array.ofList // TODO: This should be an immutable array. let referencedAssemblies = nonFrameworkAssemblyInputs |> Array.ofList // TODO: This should be an immutable array. + (* + The data below represents a dependency graph. + + ReferencedAssembliesStamps => FileStamps => SemanticModels => FinalizedSemanticModel + *) + + // stampedFileNames represent the real stamps of the files. + // logicalStampedFileNames represent the stamps of the files that are used to calculate the project's logical timestamp. let stampedFileNames = Array.init fileNames.Length (fun _ -> DateTime.MinValue) + let logicalStampedFileNames = Array.init fileNames.Length (fun _ -> DateTime.MinValue) let stampedReferencedAssemblies = Array.init referencedAssemblies.Length (fun _ -> DateTime.MinValue) let mutable initialSemanticModel = None let semanticModels = Array.zeroCreate fileNames.Length @@ -946,6 +932,7 @@ type IncrementalBuilder(tcGlobals, frameworkTcImports, nonFrameworkAssemblyInput match semanticModels.[slot] with // This prevents an implementation file that has a backing signature file from invalidating the rest of the build. | Some(semanticModel) when enablePartialTypeChecking && semanticModel.BackingSignature.IsSome -> + stampedFileNames.[slot] <- StampFileNameTask cache ctok fileInfo semanticModel.Invalidate() | _ -> // Something changed, the finalized view of the project must be invalidated. @@ -954,7 +941,9 @@ type IncrementalBuilder(tcGlobals, frameworkTcImports, nonFrameworkAssemblyInput // Invalidate the file and all files below it. stampedFileNames.[slot..] |> Array.iteri (fun j _ -> - stampedFileNames.[slot + j] <- StampFileNameTask cache ctok fileNames.[slot + j] + let stamp = StampFileNameTask cache ctok fileNames.[slot + j] + stampedFileNames.[slot + j] <- stamp + logicalStampedFileNames.[slot + j] <- stamp semanticModels.[slot + j] <- None ) @@ -985,13 +974,14 @@ type IncrementalBuilder(tcGlobals, frameworkTcImports, nonFrameworkAssemblyInput initialSemanticModel <- None finalizedSemanticModel <- None - for i = 0 to stampedFileNames.Length - 1 do + for i = 0 to logicalStampedFileNames.Length - 1 do stampedFileNames.[i] <- DateTime.MinValue + logicalStampedFileNames.[i] <- DateTime.MinValue semanticModels.[i] <- None let getStampedFileNames cache ctok = computeStampedFileNames cache ctok - stampedFileNames + logicalStampedFileNames let getStampedReferencedAssemblies cache ctok = computeStampedReferencedAssemblies cache ctok From 2776e793f1c443a0979ae38fc06d3dcb06e7316a Mon Sep 17 00:00:00 2001 From: Will Smith Date: Thu, 10 Dec 2020 18:04:07 -0800 Subject: [PATCH 2/2] Update IncrementalBuild.fs --- src/fsharp/service/IncrementalBuild.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fsharp/service/IncrementalBuild.fs b/src/fsharp/service/IncrementalBuild.fs index da95f8bd911..2ece0502cf5 100755 --- a/src/fsharp/service/IncrementalBuild.fs +++ b/src/fsharp/service/IncrementalBuild.fs @@ -974,7 +974,7 @@ type IncrementalBuilder(tcGlobals, frameworkTcImports, nonFrameworkAssemblyInput initialSemanticModel <- None finalizedSemanticModel <- None - for i = 0 to logicalStampedFileNames.Length - 1 do + for i = 0 to stampedFileNames.Length - 1 do stampedFileNames.[i] <- DateTime.MinValue logicalStampedFileNames.[i] <- DateTime.MinValue semanticModels.[i] <- None