Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
4403766
revamp parallel checking
dsyme Aug 23, 2022
6e9a085
simplify names
dsyme Aug 23, 2022
2f77141
fix diagnostics
dsyme Aug 23, 2022
90a60f8
code formatting
dsyme Aug 23, 2022
5973c8e
update surface area
dsyme Aug 23, 2022
f73c7f3
simplify diagnostic logging and format diagnostics eagerly when proce…
dsyme Aug 23, 2022
a576266
format code
dsyme Aug 24, 2022
3f2574f
remove SplitRelatedDiagnostic
dsyme Aug 24, 2022
e33f028
fix build and cleanup
dsyme Aug 24, 2022
f177cf8
further cleanup
dsyme Aug 24, 2022
13ff391
further cleanup
dsyme Aug 24, 2022
7d30b89
format code
dsyme Aug 24, 2022
f71f230
fix flaterrors
dsyme Aug 24, 2022
ad1c58b
allow error recovery on collisions
dsyme Aug 24, 2022
2765915
fix name generation to be deterministic
dsyme Aug 24, 2022
e9a213e
fix build
dsyme Aug 24, 2022
b75d081
Update RecursiveSafetyAnalysis.fs
dsyme Aug 24, 2022
f4f0e7e
Add flag for parallel type checking of files backed by signatures.
nojaf Aug 30, 2022
61dc6c1
Update src/Compiler/Driver/ParseAndCheckInputs.fs
dsyme Sep 9, 2022
5ad1f0f
format code
dsyme Sep 9, 2022
ee784d9
Update TypeTests.fs
dsyme Sep 9, 2022
97fbf63
Prefix DiagnosticsLoggerProvider with I
nojaf Sep 12, 2022
9cbb6e0
Remove duplicate hadSig binding.
nojaf Sep 12, 2022
8ace572
Add basic test for ParallelCheckingWithSignatureFiles flag.
nojaf Sep 12, 2022
0880ba0
Add additional CI job.
nojaf Sep 12, 2022
0149259
Produce binlog for ParallelCheckingWithSignatureFiles
vzarytovskii Sep 12, 2022
73b166c
Update azure-pipelines.yml
vzarytovskii Sep 12, 2022
3e88736
Update azure-pipelines.yml
vzarytovskii Sep 12, 2022
60df51d
Update TypeTests.fs
nojaf Sep 15, 2022
703da1c
Update SyntaxTreeTests
nojaf Sep 15, 2022
e1cbfdc
Correct code after rebase
nojaf Sep 19, 2022
ae4fe96
Correct SynModuleSigDecl in SignatureTypeTests.fs
nojaf Sep 19, 2022
a19238e
Format ParseAndCheckInputs.fs
nojaf Sep 19, 2022
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 FSharpBuild.Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<WarningsAsErrors>1182;0025;$(WarningsAsErrors)</WarningsAsErrors>
<OtherFlags>$(OtherFlags) --nowarn:3384</OtherFlags>
<OtherFlags>$(OtherFlags) --times --nowarn:75</OtherFlags>
<OtherFlags Condition="$(ParallelCheckingWithSignatureFilesOn) == 'true'">$(OtherFlags) --test:ParallelCheckingWithSignatureFilesOn</OtherFlags>
</PropertyGroup>

<!-- nuget -->
Expand Down
30 changes: 30 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,36 @@ stages:
# filePath: eng\tests\UpToDate.ps1
# arguments: -configuration $(_BuildConfig) -ci -binaryLog

# Run Build with --test:ParallelCheckingWithSignatureFilesOn
- job: ParallelCheckingWithSignatureFiles
condition: eq(variables['Build.Reason'], 'PullRequest')
variables:
- name: _SignType
value: Test
pool:
name: NetCore-Public
demands: ImageOverride -equals $(WindowsMachineQueueName)
timeoutInMinutes: 90
steps:
- checkout: self
clean: true
- task: UseDotNet@2
displayName: install SDK
inputs:
packageType: sdk
useGlobalJson: true
includePreviewVersions: false
workingDirectory: $(Build.SourcesDirectory)
installationPath: $(Build.SourcesDirectory)/.dotnet
- script: .\build.cmd -c Release -binaryLog /p:ParallelCheckingWithSignatureFilesOn=true
displayName: ParallelCheckingWithSignatureFiles build with Debug configuration
- task: PublishPipelineArtifact@1
displayName: Publish ParallelCheckingWithSignatureFiles Logs
inputs:
targetPath: '$(Build.SourcesDirectory)/artifacts/log/Release'
artifactName: 'ParallelCheckingWithSignatureFiles Attempt $(System.JobAttempt) Logs'
continueOnError: true

# Plain build Windows
- job: Plain_Build_Windows
pool:
Expand Down
3 changes: 2 additions & 1 deletion src/Compiler/Checking/CheckBasics.fs
Original file line number Diff line number Diff line change
Expand Up @@ -328,13 +328,14 @@ type TcFileState =

/// Create a new compilation environment
static member Create
(g, isScript, niceNameGen, amap, thisCcu, isSig, haveSig, conditionalDefines, tcSink, tcVal, isInternalTestSpanStackReferring,
(g, isScript, amap, thisCcu, isSig, haveSig, conditionalDefines, tcSink, tcVal, isInternalTestSpanStackReferring,
tcPat,
tcSimplePats,
tcSequenceExpressionEntry,
tcArrayOrListSequenceExpression,
tcComputationExpression) =

let niceNameGen = NiceNameGenerator()
let infoReader = InfoReader(g, amap)
let instantiationGenerator m tpsorig = FreshenTypars g m tpsorig
let nameResolver = NameResolver(g, amap, infoReader, instantiationGenerator)
Expand Down
1 change: 0 additions & 1 deletion src/Compiler/Checking/CheckBasics.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,6 @@ type TcFileState =
static member Create:
g: TcGlobals *
isScript: bool *
niceNameGen: NiceNameGenerator *
amap: ImportMap *
thisCcu: CcuThunk *
isSig: bool *
Expand Down
31 changes: 15 additions & 16 deletions src/Compiler/Checking/CheckDeclarations.fs
Original file line number Diff line number Diff line change
Expand Up @@ -688,13 +688,12 @@ let TcOpenDecl (cenv: cenv) mOpenDecl scopem env target =
| SynOpenDeclTarget.Type (synType, m) ->
TcOpenTypeDecl cenv mOpenDecl scopem env (synType, m)

let MakeSafeInitField (g: TcGlobals) env m isStatic =
let MakeSafeInitField (cenv: cenv) env m isStatic =
let id =
// Ensure that we have an g.CompilerGlobalState
assert(g.CompilerGlobalState |> Option.isSome)
ident(g.CompilerGlobalState.Value.NiceNameGenerator.FreshCompilerGeneratedName("init", m), m)
ident(cenv.niceNameGen.FreshCompilerGeneratedName("init", m), m)
let taccess = TAccess [env.eAccessPath]
Construct.NewRecdField isStatic None id false g.int_ty true true [] [] XmlDoc.Empty taccess true
Construct.NewRecdField isStatic None id false cenv.g.int_ty true true [] [] XmlDoc.Empty taccess true

// Checking of mutually recursive types, members and 'let' bindings in classes
//
Expand Down Expand Up @@ -1268,7 +1267,7 @@ module MutRecBindingChecking =
| _ -> false)

if needsSafeStaticInit && hasStaticBindings then
let rfield = MakeSafeInitField g envForDecls tcref.Range true
let rfield = MakeSafeInitField cenv envForDecls tcref.Range true
SafeInitField(mkRecdFieldRef tcref rfield.LogicalName, rfield)
else
NoSafeInitInfo
Expand Down Expand Up @@ -2426,7 +2425,7 @@ module EstablishTypeDefinitionCores =
let ComputeInstanceSafeInitInfo (cenv: cenv) env m thisTy =
let g = cenv.g
if InstanceMembersNeedSafeInitCheck cenv m thisTy then
let rfield = MakeSafeInitField g env m false
let rfield = MakeSafeInitField cenv env m false
let tcref = tcrefOfAppTy g thisTy
SafeInitField (mkRecdFieldRef tcref rfield.LogicalName, rfield)
else
Expand Down Expand Up @@ -4479,7 +4478,7 @@ let rec TcSignatureElementNonMutRec (cenv: cenv) parent typeNames endm (env: TcE

// Publish the combined module type
env.eModuleOrNamespaceTypeAccumulator.Value <-
CombineCcuContentFragments m [env.eModuleOrNamespaceTypeAccumulator.Value; modTyRoot]
CombineCcuContentFragments [env.eModuleOrNamespaceTypeAccumulator.Value; modTyRoot]
env

return env
Expand Down Expand Up @@ -4801,7 +4800,7 @@ let rec TcModuleOrNamespaceElementNonMutRec (cenv: cenv) parent typeNames scopem

// Publish the combined module type
env.eModuleOrNamespaceTypeAccumulator.Value <-
CombineCcuContentFragments m [env.eModuleOrNamespaceTypeAccumulator.Value; modTyRoot]
CombineCcuContentFragments [env.eModuleOrNamespaceTypeAccumulator.Value; modTyRoot]
env, openDecls

let moduleContentsRoot = BuildRootModuleContents kind.IsModule enclosingNamespacePath envNS.eCompPath moduleContents
Expand Down Expand Up @@ -5157,7 +5156,7 @@ let MakeInitialEnv env =
/// Typecheck, then close the inference scope and then check the file meets its signature (if any)
let CheckOneImplFile
// checkForErrors: A function to help us stop reporting cascading errors
(g, niceNameGen, amap,
(g, amap,
thisCcu,
openDecls0,
checkForErrors,
Expand All @@ -5173,7 +5172,7 @@ let CheckOneImplFile

cancellable {
let cenv =
cenv.Create (g, isScript, niceNameGen, amap, thisCcu, false, Option.isSome rootSigOpt,
cenv.Create (g, isScript, amap, thisCcu, false, Option.isSome rootSigOpt,
conditionalDefines, tcSink, (LightweightTcValForUsingInBuildMethodCall g), isInternalTestSpanStackReferring,
tcPat=TcPat,
tcSimplePats=TcSimplePats,
Expand Down Expand Up @@ -5291,17 +5290,17 @@ let CheckOneImplFile

let implFile = CheckedImplFile (qualNameOfFile, scopedPragmas, implFileTy, implFileContents, hasExplicitEntryPoint, isScript, anonRecdTypes, namedDebugPointsForInlinedCode)

return (topAttrs, implFile, implFileTypePriorToSig, envAtEnd, cenv.createsGeneratedProvidedTypes)
return (topAttrs, implFile, envAtEnd, cenv.createsGeneratedProvidedTypes)
}



/// Check an entire signature file
let CheckOneSigFile (g, niceNameGen, amap, thisCcu, checkForErrors, conditionalDefines, tcSink, isInternalTestSpanStackReferring) tcEnv (ParsedSigFileInput (qualifiedNameOfFile = qualNameOfFile; modules = sigFileFrags)) =
let CheckOneSigFile (g, amap, thisCcu, checkForErrors, conditionalDefines, tcSink, isInternalTestSpanStackReferring) tcEnv (sigFile: ParsedSigFileInput) =
cancellable {
let cenv =
cenv.Create
(g, false, niceNameGen, amap, thisCcu, true, false, conditionalDefines, tcSink,
(g, false, amap, thisCcu, true, false, conditionalDefines, tcSink,
(LightweightTcValForUsingInBuildMethodCall g), isInternalTestSpanStackReferring,
tcPat=TcPat,
tcSimplePats=TcSimplePats,
Expand All @@ -5311,16 +5310,16 @@ let CheckOneSigFile (g, niceNameGen, amap, thisCcu, checkForErrors, conditionalD

let envinner, moduleTyAcc = MakeInitialEnv tcEnv

let specs = [ for x in sigFileFrags -> SynModuleSigDecl.NamespaceFragment x ]
let! tcEnv = TcSignatureElements cenv ParentNone qualNameOfFile.Range envinner PreXmlDoc.Empty None specs
let specs = [ for x in sigFile.Contents -> SynModuleSigDecl.NamespaceFragment x ]
let! tcEnv = TcSignatureElements cenv ParentNone sigFile.QualifiedName.Range envinner PreXmlDoc.Empty None specs

let sigFileType = moduleTyAcc.Value

if not (checkForErrors()) then
try
sigFileType |> IterTyconsOfModuleOrNamespaceType (fun tycon ->
FinalTypeDefinitionChecksAtEndOfInferenceScope(cenv.infoReader, tcEnv.NameEnv, cenv.tcSink, false, tcEnv.DisplayEnv, tycon))
with exn -> errorRecovery exn qualNameOfFile.Range
with exn -> errorRecovery exn sigFile.QualifiedName.Range

return (tcEnv, sigFileType, cenv.createsGeneratedProvidedTypes)
}
12 changes: 2 additions & 10 deletions src/Compiler/Checking/CheckDeclarations.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ val AddLocalSubModule:

val CheckOneImplFile:
TcGlobals *
NiceNameGenerator *
ImportMap *
CcuThunk *
OpenDeclaration list *
Expand All @@ -60,17 +59,10 @@ val CheckOneImplFile:
TcEnv *
ModuleOrNamespaceType option *
ParsedImplFileInput ->
Cancellable<TopAttribs * CheckedImplFile * ModuleOrNamespaceType * TcEnv * bool>
Cancellable<TopAttribs * CheckedImplFile * TcEnv * bool>

val CheckOneSigFile:
TcGlobals *
NiceNameGenerator *
ImportMap *
CcuThunk *
(unit -> bool) *
ConditionalDefines option *
TcResultsSink *
bool ->
TcGlobals * ImportMap * CcuThunk * (unit -> bool) * ConditionalDefines option * TcResultsSink * bool ->
TcEnv ->
ParsedSigFileInput ->
Cancellable<TcEnv * ModuleOrNamespaceType * bool>
Expand Down
10 changes: 5 additions & 5 deletions src/Compiler/Checking/ConstraintSolver.fs
Original file line number Diff line number Diff line change
Expand Up @@ -244,15 +244,15 @@ exception ConstraintSolverMissingConstraint of displayEnv: DisplayEnv * Typar *

exception ConstraintSolverError of string * range * range

exception ErrorFromApplyingDefault of tcGlobals: TcGlobals * displayEnv: DisplayEnv * Typar * TType * exn * range
exception ErrorFromApplyingDefault of tcGlobals: TcGlobals * displayEnv: DisplayEnv * Typar * TType * error: exn * range: range

exception ErrorFromAddingTypeEquation of tcGlobals: TcGlobals * displayEnv: DisplayEnv * actualTy: TType * expectedTy: TType * exn * range
exception ErrorFromAddingTypeEquation of tcGlobals: TcGlobals * displayEnv: DisplayEnv * actualTy: TType * expectedTy: TType * error: exn * range: range

exception ErrorsFromAddingSubsumptionConstraint of tcGlobals: TcGlobals * displayEnv: DisplayEnv * actualTy: TType * expectedTy: TType * exn * ContextInfo * parameterRange: range
exception ErrorsFromAddingSubsumptionConstraint of tcGlobals: TcGlobals * displayEnv: DisplayEnv * actualTy: TType * expectedTy: TType * error: exn * ctxtInfo: ContextInfo * parameterRange: range

exception ErrorFromAddingConstraint of displayEnv: DisplayEnv * exn * range
exception ErrorFromAddingConstraint of displayEnv: DisplayEnv * error: exn * range: range

exception UnresolvedOverloading of displayEnv: DisplayEnv * callerArgs: CallerArgs<Expr> * failure: OverloadResolutionFailure * range
exception UnresolvedOverloading of displayEnv: DisplayEnv * callerArgs: CallerArgs<Expr> * failure: OverloadResolutionFailure * range: range

exception UnresolvedConversionOperator of displayEnv: DisplayEnv * TType * TType * range

Expand Down
20 changes: 13 additions & 7 deletions src/Compiler/Checking/ConstraintSolver.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -170,33 +170,39 @@ exception ConstraintSolverMissingConstraint of displayEnv: DisplayEnv * Typar *

exception ConstraintSolverError of string * range * range

exception ErrorFromApplyingDefault of tcGlobals: TcGlobals * displayEnv: DisplayEnv * Typar * TType * exn * range
exception ErrorFromApplyingDefault of
tcGlobals: TcGlobals *
displayEnv: DisplayEnv *
Typar *
TType *
error: exn *
range: range

exception ErrorFromAddingTypeEquation of
tcGlobals: TcGlobals *
displayEnv: DisplayEnv *
actualTy: TType *
expectedTy: TType *
exn *
range
error: exn *
range: range

exception ErrorsFromAddingSubsumptionConstraint of
tcGlobals: TcGlobals *
displayEnv: DisplayEnv *
actualTy: TType *
expectedTy: TType *
exn *
ContextInfo *
error: exn *
ctxtInfo: ContextInfo *
parameterRange: range

exception ErrorFromAddingConstraint of displayEnv: DisplayEnv * exn * range
exception ErrorFromAddingConstraint of displayEnv: DisplayEnv * error: exn * range: range
exception UnresolvedConversionOperator of displayEnv: DisplayEnv * TType * TType * range

exception UnresolvedOverloading of
displayEnv: DisplayEnv *
callerArgs: CallerArgs<Expr> *
failure: OverloadResolutionFailure *
range
range: range

exception NonRigidTypar of displayEnv: DisplayEnv * string option * range * TType * TType * range

Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/Checking/import.fs
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ let ImportILAssemblyTypeDefs (amap, m, auxModLoader, aref, mainmod: ILModuleDef)
let scoref = ILScopeRef.Assembly aref
let mtypsForExportedTypes = ImportILAssemblyExportedTypes amap m auxModLoader scoref mainmod.ManifestOfAssembly.ExportedTypes
let mainmod = ImportILAssemblyMainTypeDefs amap m scoref mainmod
CombineCcuContentFragments m (mainmod :: mtypsForExportedTypes)
CombineCcuContentFragments (mainmod :: mtypsForExportedTypes)

/// Import the type forwarder table for an IL assembly
let ImportILAssemblyTypeForwarders (amap, m, exportedTypes: ILExportedTypesAndForwarders): CcuTypeForwarderTable =
Expand Down
7 changes: 6 additions & 1 deletion src/Compiler/CodeGen/IlxGen.fs
Original file line number Diff line number Diff line change
Expand Up @@ -11552,6 +11552,11 @@ let CodegenAssembly cenv eenv mgbuf implFiles =
match List.tryFrontAndBack implFiles with
| None -> ()
| Some (firstImplFiles, lastImplFile) ->

// Generate the assembly sequentially, implementation file by implementation file.
//
// NOTE: In theory this could be done in parallel, except for the presence of linear
// state in the AssemblyBuilder
let eenv = List.fold (GenImplFile cenv mgbuf None) eenv firstImplFiles
let eenv = GenImplFile cenv mgbuf cenv.options.mainMethodInfo eenv lastImplFile

Expand Down Expand Up @@ -11626,7 +11631,7 @@ type IlxGenResults =

let GenerateCode (cenv, anonTypeTable, eenv, CheckedAssemblyAfterOptimization implFiles, assemAttribs, moduleAttribs) =

use unwindBuildPhase = PushThreadBuildPhaseUntilUnwind BuildPhase.IlxGen
use _ = UseBuildPhase BuildPhase.IlxGen
let g = cenv.g

// Generate the implementations into the mgbuf
Expand Down
17 changes: 10 additions & 7 deletions src/Compiler/Driver/CompilerConfig.fs
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ type TcConfigBuilder =
mutable emitTailcalls: bool
mutable deterministic: bool
mutable concurrentBuild: bool
mutable parallelCheckingWithSignatureFiles: bool
mutable emitMetadataAssembly: MetadataAssemblyGeneration
mutable preferredUiLang: string option
mutable lcid: int option
Expand Down Expand Up @@ -725,6 +726,7 @@ type TcConfigBuilder =
emitTailcalls = true
deterministic = false
concurrentBuild = true
parallelCheckingWithSignatureFiles = false
emitMetadataAssembly = MetadataAssemblyGeneration.None
preferredUiLang = None
lcid = None
Expand Down Expand Up @@ -797,7 +799,7 @@ type TcConfigBuilder =
tcConfigB.fxResolver <- None // this needs to be recreated when the primary assembly changes

member tcConfigB.ResolveSourceFile(m, nm, pathLoadedFrom) =
use unwindBuildPhase = PushThreadBuildPhaseUntilUnwind BuildPhase.Parameter
use _ = UseBuildPhase BuildPhase.Parameter

let paths =
seq {
Expand All @@ -809,7 +811,7 @@ type TcConfigBuilder =

/// Decide names of output file, pdb and assembly
member tcConfigB.DecideNames sourceFiles =
use unwindBuildPhase = PushThreadBuildPhaseUntilUnwind BuildPhase.Parameter
use _ = UseBuildPhase BuildPhase.Parameter

if sourceFiles = [] then
errorR (Error(FSComp.SR.buildNoInputsSpecified (), rangeCmdArgs))
Expand Down Expand Up @@ -860,7 +862,7 @@ type TcConfigBuilder =
outfile, pdbfile, assemblyName

member tcConfigB.TurnWarningOff(m, s: string) =
use unwindBuildPhase = PushThreadBuildPhaseUntilUnwind BuildPhase.Parameter
use _ = UseBuildPhase BuildPhase.Parameter

match GetWarningNumber(m, s) with
| None -> ()
Expand All @@ -875,7 +877,7 @@ type TcConfigBuilder =
}

member tcConfigB.TurnWarningOn(m, s: string) =
use unwindBuildPhase = PushThreadBuildPhaseUntilUnwind BuildPhase.Parameter
use _ = UseBuildPhase BuildPhase.Parameter

match GetWarningNumber(m, s) with
| None -> ()
Expand Down Expand Up @@ -1276,6 +1278,7 @@ type TcConfig private (data: TcConfigBuilder, validate: bool) =
member _.emitTailcalls = data.emitTailcalls
member _.deterministic = data.deterministic
member _.concurrentBuild = data.concurrentBuild
member _.parallelCheckingWithSignatureFiles = data.parallelCheckingWithSignatureFiles
member _.emitMetadataAssembly = data.emitMetadataAssembly
member _.pathMap = data.pathMap
member _.langVersion = data.langVersion
Expand Down Expand Up @@ -1309,7 +1312,7 @@ type TcConfig private (data: TcConfigBuilder, validate: bool) =
member _.exiter = data.exiter

static member Create(builder, validate) =
use unwindBuildPhase = PushThreadBuildPhaseUntilUnwind BuildPhase.Parameter
use _ = UseBuildPhase BuildPhase.Parameter
TcConfig(builder, validate)

member _.legacyReferenceResolver = data.legacyReferenceResolver
Expand All @@ -1326,7 +1329,7 @@ type TcConfig private (data: TcConfigBuilder, validate: bool) =
member _.GetTargetFrameworkDirectories() = targetFrameworkDirectories

member tcConfig.ComputeIndentationAwareSyntaxInitialStatus fileName =
use _unwindBuildPhase = PushThreadBuildPhaseUntilUnwind BuildPhase.Parameter
use _unwindBuildPhase = UseBuildPhase BuildPhase.Parameter

let indentationAwareSyntaxOnByDefault =
List.exists (FileSystemUtils.checkSuffix fileName) FSharpIndentationAwareSyntaxFileSuffixes
Expand All @@ -1337,7 +1340,7 @@ type TcConfig private (data: TcConfigBuilder, validate: bool) =
(tcConfig.indentationAwareSyntax = Some true)

member tcConfig.GetAvailableLoadedSources() =
use _unwindBuildPhase = PushThreadBuildPhaseUntilUnwind BuildPhase.Parameter
use _unwindBuildPhase = UseBuildPhase BuildPhase.Parameter

let resolveLoadedSource (m, originalPath, path) =
try
Expand Down
Loading