Skip to content

Commit abc4ae1

Browse files
committed
get rid of maxDepth
1 parent f7c3efa commit abc4ae1

16 files changed

+25
-74
lines changed

src/Compiler/AbstractIL/ilwritepdb.fs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,11 +1023,7 @@ let rec pushShadowedLocals (stackGuard: StackGuard) (localsToPush: PdbLocalVar[]
10231023
// adding the text " (shadowed)" to the names of those with name conflicts.
10241024
let unshadowScopes rootScope =
10251025
// Avoid stack overflow when writing linearly nested scopes
1026-
let UnshadowScopesStackGuardDepth =
1027-
GetEnvInteger "FSHARP_ILPdb_UnshadowScopes_StackGuardDepth" 100
1028-
1029-
let stackGuard =
1030-
StackGuard(UnshadowScopesStackGuardDepth, "ILPdbWriter.unshadowScopes")
1026+
let stackGuard = StackGuard("ILPdbWriter.unshadowScopes")
10311027

10321028
let result, _ = pushShadowedLocals stackGuard [||] rootScope
10331029
result

src/Compiler/Checking/CheckBasics.fs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,6 @@ open FSharp.Compiler.TypedTreeOps
2828
open FSharp.Compiler.TypeProviders
2929
#endif
3030

31-
#if DEBUG
32-
let TcStackGuardDepth = GetEnvInteger "FSHARP_TcStackGuardDepth" 40
33-
#else
34-
let TcStackGuardDepth = GetEnvInteger "FSHARP_TcStackGuardDepth" 80
35-
#endif
36-
3731
/// The ValReprInfo for a value, except the number of typars is not yet inferred
3832
type PrelimValReprInfo =
3933
| PrelimValReprInfo of
@@ -353,7 +347,7 @@ type TcFileState =
353347
{ g = g
354348
amap = amap
355349
recUses = ValMultiMap<_>.Empty
356-
stackGuard = StackGuard(TcStackGuardDepth, "TcFileState")
350+
stackGuard = StackGuard("TcFileState")
357351
createsGeneratedProvidedTypes = false
358352
thisCcu = thisCcu
359353
isScript = isScript

src/Compiler/Checking/CheckIncrementalClasses.fs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ open FSharp.Compiler.TypeHierarchy
2828

2929
type cenv = TcFileState
3030

31-
let TcClassRewriteStackGuardDepth = StackGuard.GetDepthOption "TcClassRewrite"
32-
3331
exception ParameterlessStructCtor of range: range
3432

3533
/// Represents a single group of bindings in a class with an implicit constructor
@@ -579,7 +577,7 @@ type IncrClassReprInfo =
579577
PostTransform = (fun _ -> None)
580578
PreInterceptBinding = None
581579
RewriteQuotations = true
582-
StackGuard = StackGuard(TcClassRewriteStackGuardDepth, "FixupIncrClassExprPhase2C") } expr
580+
StackGuard = StackGuard("FixupIncrClassExprPhase2C") } expr
583581

584582
type IncrClassConstructionBindingsPhase2C =
585583
| Phase2CBindings of IncrClassBindingGroup list

src/Compiler/Checking/FindUnsolved.fs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ open FSharp.Compiler.TypeRelations
1717

1818
type env = | NoEnv
1919

20-
let FindUnsolvedStackGuardDepth = StackGuard.GetDepthOption "FindUnsolved"
21-
2220
/// The environment and collector
2321
type cenv =
2422
{ g: TcGlobals
@@ -318,7 +316,7 @@ let UnsolvedTyparsOfModuleDef g amap denv mdef extraAttribs =
318316
amap=amap
319317
denv=denv
320318
unsolved = []
321-
stackGuard = StackGuard(FindUnsolvedStackGuardDepth, "UnsolvedTyparsOfModuleDef") }
319+
stackGuard = StackGuard("UnsolvedTyparsOfModuleDef") }
322320
accModuleOrNamespaceDef cenv NoEnv mdef
323321
accAttribs cenv NoEnv extraAttribs
324322
List.rev cenv.unsolved

src/Compiler/Checking/PostInferenceChecks.fs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ open Import
5757
// b) a lambda expression - rejected.
5858
// c) none of the above - rejected as when checking outmost expressions.
5959

60-
let PostInferenceChecksStackGuardDepth = GetEnvInteger "FSHARP_PostInferenceChecks" 50
61-
6260
//--------------------------------------------------------------------------
6361
// check environment
6462
//--------------------------------------------------------------------------
@@ -2691,7 +2689,7 @@ let CheckImplFile (g, amap, reportErrors, infoReader, internalsVisibleToPaths, v
26912689
reportErrors = reportErrors
26922690
boundVals = Dictionary<_, _>(100, HashIdentity.Structural)
26932691
limitVals = Dictionary<_, _>(100, HashIdentity.Structural)
2694-
stackGuard = StackGuard(PostInferenceChecksStackGuardDepth, "CheckImplFile")
2692+
stackGuard = StackGuard("CheckImplFile")
26952693
potentialUnboundUsesOfVals = Map.empty
26962694
anonRecdTypes = StampMap.Empty
26972695
usesQuotations = false

src/Compiler/Checking/TailCallChecks.fs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ open FSharp.Compiler.TypedTreeBasics
1616
open FSharp.Compiler.TypedTreeOps
1717
open FSharp.Compiler.TypeRelations
1818

19-
let PostInferenceChecksStackGuardDepth = GetEnvInteger "FSHARP_TailCallChecks" 50
20-
2119
[<return: Struct>]
2220
let (|ValUseAtApp|_|) e =
2321
match e with
@@ -887,7 +885,7 @@ let CheckImplFile (g: TcGlobals, amap, reportErrors, implFileContents) =
887885
let cenv =
888886
{
889887
g = g
890-
stackGuard = StackGuard(PostInferenceChecksStackGuardDepth, "CheckImplFile")
888+
stackGuard = StackGuard("CheckImplFile")
891889
amap = amap
892890
mustTailCall = Zset.empty valOrder
893891
hasPinnedLocals = false

src/Compiler/CodeGen/IlxGen.fs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,8 @@ open FSharp.Compiler.TypedTreeOps.DebugPrint
4545
open FSharp.Compiler.TypeHierarchy
4646
open FSharp.Compiler.TypeRelations
4747

48-
let IlxGenStackGuardDepth = StackGuard.GetDepthOption "IlxGen"
49-
5048
let getEmptyStackGuard () =
51-
StackGuard(IlxGenStackGuardDepth, "IlxAssemblyGenerator")
49+
StackGuard("IlxAssemblyGenerator")
5250

5351
let IsNonErasedTypar (tp: Typar) = not tp.IsErased
5452

src/Compiler/Facilities/DiagnosticsLogger.fs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -937,9 +937,7 @@ module StackGuardMetrics =
937937
}
938938

939939
/// Guard against depth of expression nesting, by moving to new stack when a maximum depth is reached
940-
type StackGuard(maxDepth: int, name: string) =
941-
942-
do ignore maxDepth
940+
type StackGuard(name: string) =
943941

944942
let depth = new ThreadLocal<int>()
945943

@@ -979,15 +977,6 @@ type StackGuard(maxDepth: int, name: string) =
979977
member x.GuardCancellable(original: Cancellable<'T>) =
980978
Cancellable(fun ct -> x.Guard(fun () -> Cancellable.run ct original))
981979

982-
static member val DefaultDepth =
983-
#if DEBUG
984-
GetEnvInteger "FSHARP_DefaultStackGuardDepth" 50
985-
#else
986-
GetEnvInteger "FSHARP_DefaultStackGuardDepth" 100
987-
#endif
988-
989-
static member GetDepthOption(name: string) =
990-
GetEnvInteger ("FSHARP_" + name + "StackGuardDepth") StackGuard.DefaultDepth
991980

992981
// UseMultipleDiagnosticLoggers in ParseAndCheckProject.fs provides similar functionality.
993982
// We should probably adapt and reuse that code.

src/Compiler/Facilities/DiagnosticsLogger.fsi

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ module internal StackGuardMetrics =
465465
val CaptureStatsAndWriteToConsole: unit -> IDisposable
466466

467467
type StackGuard =
468-
new: maxDepth: int * name: string -> StackGuard
468+
new: name: string -> StackGuard
469469

470470
/// Execute the new function, on a new thread if necessary
471471
member Guard:
@@ -477,8 +477,6 @@ type StackGuard =
477477

478478
member GuardCancellable: Internal.Utilities.Library.Cancellable<'T> -> Internal.Utilities.Library.Cancellable<'T>
479479

480-
static member GetDepthOption: string -> int
481-
482480
/// This represents the global state established as each task function runs as part of the build.
483481
///
484482
/// Use to reset error and warning handlers.

src/Compiler/Optimize/DetupleArgs.fs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ open FSharp.Compiler.TypedTreeBasics
1414
open FSharp.Compiler.TypedTreeOps
1515
open FSharp.Compiler.Xml
1616

17-
let DetupleRewriteStackGuardDepth = StackGuard.GetDepthOption "DetupleRewrite"
18-
1917
// This pass has one aim.
2018
// - to eliminate tuples allocated at call sites (due to uncurried style)
2119
//
@@ -943,7 +941,7 @@ let passImplFile penv assembly =
943941
PreInterceptBinding = None
944942
PostTransform = postTransformExpr penv
945943
RewriteQuotations = false
946-
StackGuard = StackGuard(DetupleRewriteStackGuardDepth, "RewriteImplFile") }
944+
StackGuard = StackGuard("RewriteImplFile") }
947945

948946
assembly |> RewriteImplFile rwenv
949947

0 commit comments

Comments
 (0)