From 615475b87bacc6728cb6a80acfd185983bf3ce8b Mon Sep 17 00:00:00 2001 From: dawe Date: Thu, 25 Jan 2024 13:43:08 +0100 Subject: [PATCH] Take the Unshadow stackguard from environment (#16583) * try to take the stackguard depth for pushShadowedLocals from the environment * add release notes entry * add PR number --- docs/release-notes/.FSharp.Compiler.Service/8.0.300.md | 1 + src/Compiler/AbstractIL/ilwritepdb.fs | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/release-notes/.FSharp.Compiler.Service/8.0.300.md b/docs/release-notes/.FSharp.Compiler.Service/8.0.300.md index 8fa3c363b20..35128d40ad0 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/8.0.300.md +++ b/docs/release-notes/.FSharp.Compiler.Service/8.0.300.md @@ -6,6 +6,7 @@ ### Added +* The stackguard depth for ILPdbWriter.unshadowScopes can be modified via the environment variable `FSHARP_ILPdb_UnshadowScopes_StackGuardDepth`([PR #16583](https://github.com/dotnet/fsharp/pull/16583)) * Parser recovers on complex primary constructor patterns, better tree representation for primary constructor patterns. ([PR #16425](https://github.com/dotnet/fsharp/pull/16425)) * Name resolution: keep type vars in subsequent checks ([PR #16456](https://github.com/dotnet/fsharp/pull/16456)) * Higher-order-function-based API for working with the untyped abstract syntax tree. ([PR #16462](https://github.com/dotnet/fsharp/pull/16462)) diff --git a/src/Compiler/AbstractIL/ilwritepdb.fs b/src/Compiler/AbstractIL/ilwritepdb.fs index 24082eea2b3..fd5ffad27ac 100644 --- a/src/Compiler/AbstractIL/ilwritepdb.fs +++ b/src/Compiler/AbstractIL/ilwritepdb.fs @@ -16,6 +16,7 @@ open Internal.Utilities open FSharp.Compiler.AbstractIL.IL open FSharp.Compiler.AbstractIL.Support open Internal.Utilities.Library +open Internal.Utilities.Library.Extras open FSharp.Compiler.DiagnosticsLogger open FSharp.Compiler.IO open FSharp.Compiler.Text.Range @@ -1028,6 +1029,11 @@ let rec pushShadowedLocals (stackGuard: StackGuard) (localsToPush: PdbLocalVar[] // adding the text " (shadowed)" to the names of those with name conflicts. let unshadowScopes rootScope = // Avoid stack overflow when writing linearly nested scopes - let stackGuard = StackGuard(100, "ILPdbWriter.unshadowScopes") + let UnshadowScopesStackGuardDepth = + GetEnvInteger "FSHARP_ILPdb_UnshadowScopes_StackGuardDepth" 100 + + let stackGuard = + StackGuard(UnshadowScopesStackGuardDepth, "ILPdbWriter.unshadowScopes") + let result, _ = pushShadowedLocals stackGuard [||] rootScope result