Skip to content

Commit 03fa74b

Browse files
authored
Merge branch 'main' into copilot/fix-24b59ebb-af21-49f7-96cf-02e1313f6ac1
2 parents b880750 + aa69e48 commit 03fa74b

File tree

9 files changed

+91
-131
lines changed

9 files changed

+91
-131
lines changed

docs/release-notes/.FSharp.Compiler.Service/10.0.100.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
* Parser: fix range for computed binding expressions ([PR #18903](https://github.com/dotnet/fsharp/pull/18903))
3333
* Tests: set test source for range debug printing ([PR #18879](https://github.com/dotnet/fsharp/pull/18879))
3434
* Checker: fix declaring type for abbreviated types extensions ([PR #18909](https://github.com/dotnet/fsharp/pull/18909))
35+
* Caches: type subsumption cache key perf regression ([Issue #18925](https://github.com/dotnet/fsharp/issues/18925) [PR #18926](https://github.com/dotnet/fsharp/pull/18926))
3536

3637
### Changed
3738
* Use `errorR` instead of `error` in `CheckDeclarations.fs` when possible. ([PR #18645](https://github.com/dotnet/fsharp/pull/18645))

eng/Version.Details.props

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ This file should be imported by eng/Versions.props
66
<Project>
77
<PropertyGroup>
88
<!-- dotnet/msbuild dependencies -->
9-
<MicrosoftBuildPackageVersion>18.0.0-preview-25465-08</MicrosoftBuildPackageVersion>
10-
<MicrosoftBuildFrameworkPackageVersion>18.0.0-preview-25465-08</MicrosoftBuildFrameworkPackageVersion>
11-
<MicrosoftBuildTasksCorePackageVersion>18.0.0-preview-25465-08</MicrosoftBuildTasksCorePackageVersion>
12-
<MicrosoftBuildUtilitiesCorePackageVersion>18.0.0-preview-25465-08</MicrosoftBuildUtilitiesCorePackageVersion>
9+
<MicrosoftBuildPackageVersion>18.0.0-preview-25469-01</MicrosoftBuildPackageVersion>
10+
<MicrosoftBuildFrameworkPackageVersion>18.0.0-preview-25469-01</MicrosoftBuildFrameworkPackageVersion>
11+
<MicrosoftBuildTasksCorePackageVersion>18.0.0-preview-25469-01</MicrosoftBuildTasksCorePackageVersion>
12+
<MicrosoftBuildUtilitiesCorePackageVersion>18.0.0-preview-25469-01</MicrosoftBuildUtilitiesCorePackageVersion>
1313
<!-- dotnet/runtime dependencies -->
1414
<SystemCollectionsImmutablePackageVersion>9.0.0</SystemCollectionsImmutablePackageVersion>
1515
<SystemComponentModelCompositionPackageVersion>9.0.0</SystemComponentModelCompositionPackageVersion>

eng/Version.Details.xml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Dependencies>
3-
<Source Uri="https://github.com/dotnet/dotnet" Mapping="fsharp" Sha="e533cfad385ba4f0ec96e35ad3d485dc13581906" BarId="283666" />
3+
<Source Uri="https://github.com/dotnet/dotnet" Mapping="fsharp" Sha="2dea164f01d307c409cfe0d0ee5cb8a0691e3c94" BarId="283828" />
44
<ProductDependencies>
5-
<Dependency Name="Microsoft.Build" Version="18.0.0-preview-25465-08">
5+
<Dependency Name="Microsoft.Build" Version="18.0.0-preview-25469-01">
66
<Uri>https://github.com/dotnet/msbuild</Uri>
7-
<Sha>36b870ef0e3bc607c96e23f1f2d20125947be598</Sha>
7+
<Sha>c4727aaf51e93045250f638db9cdfbbb462a45c8</Sha>
88
</Dependency>
9-
<Dependency Name="Microsoft.Build.Framework" Version="18.0.0-preview-25465-08">
9+
<Dependency Name="Microsoft.Build.Framework" Version="18.0.0-preview-25469-01">
1010
<Uri>https://github.com/dotnet/msbuild</Uri>
11-
<Sha>36b870ef0e3bc607c96e23f1f2d20125947be598</Sha>
11+
<Sha>c4727aaf51e93045250f638db9cdfbbb462a45c8</Sha>
1212
</Dependency>
13-
<Dependency Name="Microsoft.Build.Tasks.Core" Version="18.0.0-preview-25465-08">
13+
<Dependency Name="Microsoft.Build.Tasks.Core" Version="18.0.0-preview-25469-01">
1414
<Uri>https://github.com/dotnet/msbuild</Uri>
15-
<Sha>36b870ef0e3bc607c96e23f1f2d20125947be598</Sha>
15+
<Sha>c4727aaf51e93045250f638db9cdfbbb462a45c8</Sha>
1616
</Dependency>
17-
<Dependency Name="Microsoft.Build.Utilities.Core" Version="18.0.0-preview-25465-08">
17+
<Dependency Name="Microsoft.Build.Utilities.Core" Version="18.0.0-preview-25469-01">
1818
<Uri>https://github.com/dotnet/msbuild</Uri>
19-
<Sha>36b870ef0e3bc607c96e23f1f2d20125947be598</Sha>
19+
<Sha>c4727aaf51e93045250f638db9cdfbbb462a45c8</Sha>
2020
</Dependency>
2121
<Dependency Name="System.Reflection.Metadata" Version="9.0.0">
2222
<Uri>https://github.com/dotnet/runtime</Uri>

src/Compiler/Utilities/TypeHashing.fs

Lines changed: 60 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module internal Internal.Utilities.TypeHashing
22

33
open Internal.Utilities.Rational
4+
open Internal.Utilities.Library
45
open FSharp.Compiler.AbstractIL.IL
56
open FSharp.Compiler.Syntax
67
open FSharp.Compiler.TcGlobals
@@ -397,72 +398,72 @@ module StructuralUtilities =
397398
| Nullness of nullness: NullnessInfo
398399
| TupInfo of b: bool
399400
| MeasureOne
400-
| MeasureRational of rational: Rational
401+
| MeasureRational of int * int
401402
| NeverEqual of never: NeverEqual
402403

403-
type TypeStructure = TypeToken[]
404-
405-
[<Literal>]
406-
let private initialTokenCapacity = 4
404+
type TypeStructure = TypeStructure of ImmutableArray<TypeToken>
407405

408406
let inline toNullnessToken (n: Nullness) =
409407
match n.TryEvaluate() with
410408
| ValueSome k -> TypeToken.Nullness k
411409
| _ -> TypeToken.NeverEqual NeverEqual.Singleton
412410

413-
let rec private accumulateMeasure (tokens: ResizeArray<TypeToken>) (m: Measure) =
414-
match m with
415-
| Measure.Var mv -> tokens.Add(TypeToken.Stamp mv.Stamp)
416-
| Measure.Const(tcref, _) -> tokens.Add(TypeToken.Stamp tcref.Stamp)
417-
| Measure.Prod(m1, m2, _) ->
418-
accumulateMeasure tokens m1
419-
accumulateMeasure tokens m2
420-
| Measure.Inv m1 -> accumulateMeasure tokens m1
421-
| Measure.One _ -> tokens.Add(TypeToken.MeasureOne)
422-
| Measure.RationalPower(m1, r) ->
423-
accumulateMeasure tokens m1
424-
tokens.Add(TypeToken.MeasureRational r)
425-
426-
let rec private accumulateTType (tokens: ResizeArray<TypeToken>) (ty: TType) =
427-
match ty with
428-
| TType_ucase(u, tinst) ->
429-
tokens.Add(TypeToken.Stamp u.TyconRef.Stamp)
430-
tokens.Add(TypeToken.UCase u.CaseName)
431-
432-
for arg in tinst do
433-
accumulateTType tokens arg
434-
| TType_app(tcref, tinst, n) ->
435-
tokens.Add(TypeToken.Stamp tcref.Stamp)
436-
tokens.Add(toNullnessToken n)
437-
438-
for arg in tinst do
439-
accumulateTType tokens arg
440-
| TType_anon(info, tys) ->
441-
tokens.Add(TypeToken.Stamp info.Stamp)
442-
443-
for arg in tys do
444-
accumulateTType tokens arg
445-
| TType_tuple(tupInfo, tys) ->
446-
tokens.Add(TypeToken.TupInfo(evalTupInfoIsStruct tupInfo))
447-
448-
for arg in tys do
449-
accumulateTType tokens arg
450-
| TType_forall(tps, tau) ->
451-
for tp in tps do
452-
tokens.Add(TypeToken.Stamp tp.Stamp)
453-
454-
accumulateTType tokens tau
455-
| TType_fun(d, r, n) ->
456-
accumulateTType tokens d
457-
accumulateTType tokens r
458-
tokens.Add(toNullnessToken n)
459-
| TType_var(r, n) ->
460-
tokens.Add(TypeToken.Stamp r.Stamp)
461-
tokens.Add(toNullnessToken n)
462-
| TType_measure m -> accumulateMeasure tokens m
411+
let rec private accumulateMeasure (m: Measure) =
412+
seq {
413+
match m with
414+
| Measure.Var mv -> TypeToken.Stamp mv.Stamp
415+
| Measure.Const(tcref, _) -> TypeToken.Stamp tcref.Stamp
416+
| Measure.Prod(m1, m2, _) ->
417+
yield! accumulateMeasure m1
418+
yield! accumulateMeasure m2
419+
| Measure.Inv m1 -> yield! accumulateMeasure m1
420+
| Measure.One _ -> TypeToken.MeasureOne
421+
| Measure.RationalPower(m1, r) ->
422+
yield! accumulateMeasure m1
423+
TypeToken.MeasureRational(GetNumerator r, GetDenominator r)
424+
}
425+
426+
let rec private accumulateTType (ty: TType) =
427+
seq {
428+
match ty with
429+
| TType_ucase(u, tinst) ->
430+
TypeToken.Stamp u.TyconRef.Stamp
431+
TypeToken.UCase u.CaseName
432+
433+
for arg in tinst do
434+
yield! accumulateTType arg
435+
436+
| TType_app(tcref, tinst, n) ->
437+
TypeToken.Stamp tcref.Stamp
438+
toNullnessToken n
439+
440+
for arg in tinst do
441+
yield! accumulateTType arg
442+
| TType_anon(info, tys) ->
443+
TypeToken.Stamp info.Stamp
444+
445+
for arg in tys do
446+
yield! accumulateTType arg
447+
| TType_tuple(tupInfo, tys) ->
448+
TypeToken.TupInfo(evalTupInfoIsStruct tupInfo)
449+
450+
for arg in tys do
451+
yield! accumulateTType arg
452+
| TType_forall(tps, tau) ->
453+
for tp in tps do
454+
TypeToken.Stamp tp.Stamp
455+
456+
yield! accumulateTType tau
457+
| TType_fun(d, r, n) ->
458+
yield! accumulateTType d
459+
yield! accumulateTType r
460+
toNullnessToken n
461+
| TType_var(r, n) ->
462+
TypeToken.Stamp r.Stamp
463+
toNullnessToken n
464+
| TType_measure m -> yield! accumulateMeasure m
465+
}
463466

464467
/// Get the full structure of a type as a sequence of tokens, suitable for equality
465-
let getTypeStructure ty =
466-
let tokens = ResizeArray<TypeToken>(initialTokenCapacity)
467-
accumulateTType tokens ty
468-
tokens.ToArray()
468+
let getTypeStructure =
469+
Extras.WeakMap.getOrCreate (fun ty -> accumulateTType ty |> ImmutableArray.ofSeq |> TypeStructure)

tests/FSharp.Test.Utilities/CompilerAssert.fs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -627,8 +627,6 @@ module CompilerAssertHelpers =
627627
File.WriteAllText(runtimeconfigPath, runtimeconfig)
628628
#endif
629629
let rc, output, errors = Commands.executeProcess fileName arguments (Path.GetDirectoryName(outputFilePath))
630-
let output = String.Join(Environment.NewLine, output)
631-
let errors = String.Join(Environment.NewLine, errors)
632630
ExitCode rc, output, errors
633631

634632
open CompilerAssertHelpers

tests/FSharp.Test.Utilities/ILChecker.fs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ module ILChecker =
1515

1616
let private exec exe args =
1717
let arguments = args |> String.concat " "
18-
let exitCode, _output, errors = Commands.executeProcess exe arguments ""
19-
let errors = errors |> String.concat Environment.NewLine
20-
errors, exitCode
18+
Commands.executeProcess exe arguments ""
2119

2220
/// Filters i.e ['The system type \'System.ReadOnlySpan`1\' was required but no referenced system DLL contained this type']
2321
let private filterSpecialComment (text: string) =
@@ -101,7 +99,7 @@ module ILChecker =
10199

102100
let ildasmFullArgs = [ dllFilePath; $"-out=%s{ilFilePath}"; yield! ildasmArgs ]
103101

104-
let stdErr, exitCode =
102+
let exitCode, _, stdErr =
105103
let ildasmCommandPath = Path.ChangeExtension(dllFilePath, ".ildasmCommandPath")
106104
File.WriteAllLines(ildasmCommandPath, [| $"{ildasmPath} {ildasmFullArgs}" |] )
107105
exec ildasmPath ildasmFullArgs
@@ -212,5 +210,5 @@ module ILChecker =
212210

213211
let reassembleIL ilFilePath dllFilePath =
214212
let ilasmPath = config.ILASM
215-
let errors, _ = exec ilasmPath [ $"%s{ilFilePath} /output=%s{dllFilePath} /dll" ]
213+
let _, _, errors = exec ilasmPath [ $"%s{ilFilePath} /output=%s{dllFilePath} /dll" ]
216214
errors

tests/FSharp.Test.Utilities/ILVerifierModule.fs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ module ILVerifierModule =
2323

2424
let private exec (dotnetExe: string) args workingDirectory =
2525
let arguments = args |> String.concat " "
26-
let exitCode, _output, errors = Commands.executeProcess dotnetExe arguments workingDirectory
27-
let errors = errors |> String.concat Environment.NewLine
28-
errors, exitCode
26+
Commands.executeProcess dotnetExe arguments workingDirectory
2927

3028
let private verifyPEFileCore peverifierArgs (dllFilePath: string) =
3129
let nuget_packages =
@@ -36,17 +34,13 @@ module ILVerifierModule =
3634
| path -> path
3735
let peverifyFullArgs = [ yield "exec"; yield $"""{nuget_packages}/dotnet-ilverify/9.0.0/tools/net9.0/any/ILVerify.dll"""; yield "--verbose"; yield dllFilePath; yield! peverifierArgs ]
3836
let workingDirectory = Path.GetDirectoryName dllFilePath
39-
let _, exitCode =
37+
let exitCode, outputText, errorText =
4038
let peverifierCommandPath = Path.ChangeExtension(dllFilePath, ".peverifierCommandPath.cmd")
4139
let args = peverifyFullArgs |> Seq.fold(fun a acc -> $"{a} " + acc) ""
4240
File.WriteAllLines(peverifierCommandPath, [| $"{args}" |] )
4341
File.Copy(typeof<RequireQualifiedAccessAttribute>.Assembly.Location, Path.GetDirectoryName(dllFilePath) ++ "FSharp.Core.dll", true)
4442
exec config.DotNetExe peverifyFullArgs workingDirectory
4543

46-
// Grab output
47-
let outputText = File.ReadAllText(Path.Combine(workingDirectory, "StandardOutput.txt"))
48-
let errorText = File.ReadAllText(Path.Combine(workingDirectory, "StandardError.txt"))
49-
5044
match exitCode with
5145
| 0 -> {Outcome = NoExitCode; StdOut = outputText; StdErr = errorText }
5246
| _ -> {Outcome = ExitCode exitCode; StdOut = outputText; StdErr = errorText }

tests/FSharp.Test.Utilities/TestFramework.fs

Lines changed: 8 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -65,21 +65,6 @@ module Commands =
6565
// returns exit code, stdio and stderr as string arrays
6666
let executeProcess pathToExe arguments workingDir =
6767
let commandLine = ResizeArray()
68-
let errorsList = ResizeArray()
69-
let outputList = ResizeArray()
70-
let errorslock = obj()
71-
let outputlock = obj()
72-
let outputDataReceived (message: string) =
73-
if not (isNull message) then
74-
lock outputlock (fun () ->
75-
printfn "%s" message
76-
outputList.Add(message))
77-
78-
let errorDataReceived (message: string) =
79-
if not (isNull message) then
80-
lock errorslock (fun () ->
81-
eprintfn "%s" message
82-
errorsList.Add(message))
8368

8469
commandLine.Add $"cd {workingDir}"
8570
commandLine.Add $"{pathToExe} {arguments} /bl"
@@ -103,29 +88,14 @@ module Commands =
10388
use p = new Process()
10489
p.StartInfo <- psi
10590

106-
p.OutputDataReceived.Add(fun a -> outputDataReceived a.Data)
107-
p.ErrorDataReceived.Add(fun a -> errorDataReceived a.Data)
108-
109-
if p.Start() then
110-
p.BeginOutputReadLine()
111-
p.BeginErrorReadLine()
112-
p.WaitForExit()
113-
114-
let workingDir' =
115-
if workingDir = ""
116-
then
117-
// Assign working dir to prevent default to C:\Windows\System32
118-
let executionLocation = Assembly.GetExecutingAssembly().Location
119-
Path.GetDirectoryName executionLocation
120-
else
121-
workingDir
122-
123-
lock gate (fun () ->
124-
File.WriteAllLines(Path.Combine(workingDir', "commandline.txt"), commandLine)
125-
File.WriteAllLines(Path.Combine(workingDir', "StandardOutput.txt"), outputList)
126-
File.WriteAllLines(Path.Combine(workingDir', "StandardError.txt"), errorsList)
127-
)
128-
p.ExitCode, outputList.ToArray(), errorsList.ToArray()
91+
if not (p.Start()) then failwith "new process did not start"
92+
93+
let readOutput = backgroundTask { return! p.StandardOutput.ReadToEndAsync() }
94+
let readErrors = backgroundTask { return! p.StandardError.ReadToEndAsync() }
95+
96+
p.WaitForExit()
97+
98+
p.ExitCode, readOutput.Result, readErrors.Result
12999

130100
let getfullpath workDir (path:string) =
131101
let rooted =

tests/FSharp.Test.Utilities/Utilities.fs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ open System
165165
let main argv = 0"""
166166

167167
let private getNetCoreAppReferences =
168-
let mutable output = [||]
169-
let mutable errors = [||]
168+
let mutable output = ""
169+
let mutable errors = ""
170170
let mutable cleanUp = true
171171
let pathToArtifacts = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "../../../.."))
172172
if Path.GetFileName(pathToArtifacts) <> "artifacts" then failwith "CompilerAssert did not find artifacts directory --- has the location changed????"
@@ -196,17 +196,15 @@ let main argv = 0"""
196196
errors <- dotneterrors
197197
output <- dotnetoutput
198198
printfn "Output:\n=======\n"
199-
output |> Seq.iter(fun line -> printfn "STDOUT:%s\n" line)
199+
printfn "%s" dotnetoutput
200200
printfn "Errors:\n=======\n"
201-
errors |> Seq.iter(fun line -> printfn "STDERR:%s\n" line)
201+
printfn "%s" dotneterrors
202202
Assert.True(false, "Errors produced generating References")
203203

204204
File.ReadLines(frameworkReferencesFileName) |> Seq.toArray
205205
with | e ->
206206
cleanUp <- false
207207
let message =
208-
let output = output |> String.concat "\nSTDOUT: "
209-
let errors = errors |> String.concat "\nSTDERR: "
210208
File.WriteAllText(Path.Combine(projectDirectory, "project.stdout"), output)
211209
File.WriteAllText(Path.Combine(projectDirectory, "project.stderror"), errors)
212210
$"""

0 commit comments

Comments
 (0)