Skip to content

Commit fc15661

Browse files
committed
Merge branch 'dev16.1' into merges/master-to-dev16.1
2 parents 7376e22 + 2422d4c commit fc15661

File tree

600 files changed

+4433
-3691
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

600 files changed

+4433
-3691
lines changed

FSharpBuild.Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<BaseOutputPath>$(ArtifactsBinDir)\$(MSBuildProjectName)</BaseOutputPath>
1919
<BaseIntermediateOutputPath>$(ArtifactsObjDir)\$(MSBuildProjectName)</BaseIntermediateOutputPath>
2020
<SymStoreDirectory>$(ArtifactsDir)\SymStore</SymStoreDirectory>
21-
<ProtoOutputPath Condition="'$(OS)' != 'Unix'">$(ArtifactsBinDir)\fsc\Proto\net46</ProtoOutputPath>
21+
<ProtoOutputPath Condition="'$(OS)' != 'Unix'">$(ArtifactsBinDir)\fsc\Proto\net472</ProtoOutputPath>
2222
<ProtoOutputPath Condition="'$(OS)' == 'Unix'">$(ArtifactsBinDir)/fsc/Proto/netcoreapp2.1</ProtoOutputPath>
2323
<ValueTupleImplicitPackageVersion>4.4.0</ValueTupleImplicitPackageVersion>
2424
</PropertyGroup>

FSharpTests.Directory.Build.props

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
<PropertyGroup Condition="'$(FSharpTestCompilerVersion)' == 'net40'">
44
<DisableAutoSetFscCompilerPath>true</DisableAutoSetFscCompilerPath>
55

6-
<FscToolPath>$(MSBuildThisFileDirectory)artifacts\bin\fsc\$(Configuration)\net46</FscToolPath>
6+
<FscToolPath>$(MSBuildThisFileDirectory)artifacts\bin\fsc\$(Configuration)\net472</FscToolPath>
77
<FscToolExe>fsc.exe</FscToolExe>
88
<DotnetFscCompilerPath></DotnetFscCompilerPath>
99

10-
<FsiToolPath>$(MSBuildThisFileDirectory)artifacts\bin\fsi\$(Configuration)\net46</FsiToolPath>
10+
<FsiToolPath>$(MSBuildThisFileDirectory)artifacts\bin\fsi\$(Configuration)\net472</FsiToolPath>
1111
<FsiToolExe>fsi.exe</FsiToolExe>
1212
<DotnetFsiCompilerPath></DotnetFsiCompilerPath>
1313
</PropertyGroup>
@@ -28,7 +28,7 @@
2828

2929
<!-- SDK targets override -->
3030
<PropertyGroup>
31-
<_FSharpBuildTargetFramework Condition="'$(FSharpTestCompilerVersion)' == 'net40'">net46</_FSharpBuildTargetFramework>
31+
<_FSharpBuildTargetFramework Condition="'$(FSharpTestCompilerVersion)' == 'net40'">net472</_FSharpBuildTargetFramework>
3232
<_FSharpBuildTargetFramework Condition="'$(FSharpTestCompilerVersion)' == 'coreclr'">netstandard2.0</_FSharpBuildTargetFramework>
3333
<_FSharpBuildBinPath>$(MSBuildThisFileDirectory)artifacts\bin\FSharp.Build\$(Configuration)\$(_FSharpBuildTargetFramework)</_FSharpBuildBinPath>
3434

RoslynPackageVersion.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.9.0-beta8-63208-01
1+
2.11.0-beta1-63431-08

benchmarks/Benchmarks.sln

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,39 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 15
4-
VisualStudioVersion = 15.0.28307.136
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.28407.52
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "CompilerServiceBenchmarks", "CompilerServiceBenchmarks\CompilerServiceBenchmarks.fsproj", "{9A3C565C-B514-4AE0-8B01-CA80E8453EB0}"
6+
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "CompilerServiceBenchmarks", "CompilerServiceBenchmarks\CompilerServiceBenchmarks.fsproj", "{9A3C565C-B514-4AE0-8B01-CA80E8453EB0}"
77
EndProject
8-
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharp.Core", "..\src\fsharp\FSharp.Core\FSharp.Core.fsproj", "{BB9EAE76-194A-49D8-9618-586CBE7031D9}"
8+
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharp.Core", "..\src\fsharp\FSharp.Core\FSharp.Core.fsproj", "{DED3BBD7-53F4-428A-8C9F-27968E768605}"
99
EndProject
10-
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharp.Compiler.Private", "..\src\fsharp\FSharp.Compiler.Private\FSharp.Compiler.Private.fsproj", "{F57B02B1-CF26-4D93-9211-8CEB4F1572F0}"
10+
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharp.Compiler.Private", "..\src\fsharp\FSharp.Compiler.Private\FSharp.Compiler.Private.fsproj", "{2E4D67B4-522D-4CF7-97E4-BA940F0B18F3}"
1111
EndProject
1212
Global
1313
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1414
Debug|Any CPU = Debug|Any CPU
15+
Proto|Any CPU = Proto|Any CPU
1516
Release|Any CPU = Release|Any CPU
1617
EndGlobalSection
1718
GlobalSection(ProjectConfigurationPlatforms) = postSolution
1819
{9A3C565C-B514-4AE0-8B01-CA80E8453EB0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
1920
{9A3C565C-B514-4AE0-8B01-CA80E8453EB0}.Debug|Any CPU.Build.0 = Debug|Any CPU
21+
{9A3C565C-B514-4AE0-8B01-CA80E8453EB0}.Proto|Any CPU.ActiveCfg = Release|Any CPU
22+
{9A3C565C-B514-4AE0-8B01-CA80E8453EB0}.Proto|Any CPU.Build.0 = Release|Any CPU
2023
{9A3C565C-B514-4AE0-8B01-CA80E8453EB0}.Release|Any CPU.ActiveCfg = Release|Any CPU
2124
{9A3C565C-B514-4AE0-8B01-CA80E8453EB0}.Release|Any CPU.Build.0 = Release|Any CPU
22-
{BB9EAE76-194A-49D8-9618-586CBE7031D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23-
{BB9EAE76-194A-49D8-9618-586CBE7031D9}.Debug|Any CPU.Build.0 = Debug|Any CPU
24-
{BB9EAE76-194A-49D8-9618-586CBE7031D9}.Release|Any CPU.ActiveCfg = Release|Any CPU
25-
{BB9EAE76-194A-49D8-9618-586CBE7031D9}.Release|Any CPU.Build.0 = Release|Any CPU
26-
{F57B02B1-CF26-4D93-9211-8CEB4F1572F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27-
{F57B02B1-CF26-4D93-9211-8CEB4F1572F0}.Debug|Any CPU.Build.0 = Debug|Any CPU
28-
{F57B02B1-CF26-4D93-9211-8CEB4F1572F0}.Release|Any CPU.ActiveCfg = Release|Any CPU
29-
{F57B02B1-CF26-4D93-9211-8CEB4F1572F0}.Release|Any CPU.Build.0 = Release|Any CPU
25+
{DED3BBD7-53F4-428A-8C9F-27968E768605}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
26+
{DED3BBD7-53F4-428A-8C9F-27968E768605}.Debug|Any CPU.Build.0 = Debug|Any CPU
27+
{DED3BBD7-53F4-428A-8C9F-27968E768605}.Proto|Any CPU.ActiveCfg = Debug|Any CPU
28+
{DED3BBD7-53F4-428A-8C9F-27968E768605}.Proto|Any CPU.Build.0 = Debug|Any CPU
29+
{DED3BBD7-53F4-428A-8C9F-27968E768605}.Release|Any CPU.ActiveCfg = Release|Any CPU
30+
{DED3BBD7-53F4-428A-8C9F-27968E768605}.Release|Any CPU.Build.0 = Release|Any CPU
31+
{2E4D67B4-522D-4CF7-97E4-BA940F0B18F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
32+
{2E4D67B4-522D-4CF7-97E4-BA940F0B18F3}.Debug|Any CPU.Build.0 = Debug|Any CPU
33+
{2E4D67B4-522D-4CF7-97E4-BA940F0B18F3}.Proto|Any CPU.ActiveCfg = Debug|Any CPU
34+
{2E4D67B4-522D-4CF7-97E4-BA940F0B18F3}.Proto|Any CPU.Build.0 = Debug|Any CPU
35+
{2E4D67B4-522D-4CF7-97E4-BA940F0B18F3}.Release|Any CPU.ActiveCfg = Release|Any CPU
36+
{2E4D67B4-522D-4CF7-97E4-BA940F0B18F3}.Release|Any CPU.Build.0 = Release|Any CPU
3037
EndGlobalSection
3138
GlobalSection(SolutionProperties) = preSolution
3239
HideSolutionNode = FALSE
Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3+
<PropertyGroup>
4+
<FSharpSourcesRoot>$(MSBuildProjectDirectory)\..\..\src</FSharpSourcesRoot>
5+
</PropertyGroup>
6+
37
<PropertyGroup>
48
<OutputType>Exe</OutputType>
59
<TargetFramework>net472</TargetFramework>
10+
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
11+
<DisableImplicitSystemValueTupleReference>true</DisableImplicitSystemValueTupleReference>
12+
<DefaultValueTuplePackageVersion>$(SystemValueTuplePackageVersion)</DefaultValueTuplePackageVersion>
13+
</PropertyGroup>
14+
15+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
16+
<PlatformTarget>AnyCPU</PlatformTarget>
617
</PropertyGroup>
718

819
<ItemGroup>
@@ -11,11 +22,12 @@
1122

1223
<ItemGroup>
1324
<PackageReference Include="BenchmarkDotNet" Version="0.11.3" />
25+
<PackageReference Include="Microsoft.CodeAnalysis.EditorFeatures.Text" Version="2.9.0" />
1426
</ItemGroup>
1527

1628
<ItemGroup>
17-
<ProjectReference Include="..\..\src\fsharp\FSharp.Compiler.Private\FSharp.Compiler.Private.fsproj" />
18-
<ProjectReference Include="..\..\src\fsharp\FSharp.Core\FSharp.Core.fsproj" />
29+
<ProjectReference Include="$(FSharpSourcesRoot)\fsharp\FSharp.Compiler.Private\FSharp.Compiler.Private.fsproj" />
30+
<ProjectReference Include="$(FSharpSourcesRoot)\fsharp\FSharp.Core\FSharp.Core.fsproj" />
1931
</ItemGroup>
2032

2133
</Project>
Lines changed: 155 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,87 @@
11
open System
22
open System.IO
3-
open BenchmarkDotNet.Attributes
4-
open BenchmarkDotNet.Running
3+
open System.Text
54
open Microsoft.FSharp.Compiler.ErrorLogger
65
open Microsoft.FSharp.Compiler.SourceCodeServices
7-
open System.Text
6+
open Microsoft.FSharp.Compiler.Text
7+
open Microsoft.FSharp.Compiler.AbstractIL
8+
open Microsoft.FSharp.Compiler.AbstractIL.IL
9+
open Microsoft.FSharp.Compiler.AbstractIL.ILBinaryReader
10+
open Microsoft.CodeAnalysis.Text
11+
open BenchmarkDotNet.Attributes
12+
open BenchmarkDotNet.Running
13+
14+
module private SourceText =
15+
16+
open System.Runtime.CompilerServices
17+
18+
let weakTable = ConditionalWeakTable<SourceText, ISourceText>()
19+
20+
let create (sourceText: SourceText) =
21+
22+
let sourceText =
23+
{ new ISourceText with
24+
25+
member __.Item with get index = sourceText.[index]
26+
27+
member __.GetLineString(lineIndex) =
28+
sourceText.Lines.[lineIndex].ToString()
29+
30+
member __.GetLineCount() =
31+
sourceText.Lines.Count
32+
33+
member __.GetLastCharacterPosition() =
34+
if sourceText.Lines.Count > 0 then
35+
(sourceText.Lines.Count, sourceText.Lines.[sourceText.Lines.Count - 1].Span.Length)
36+
else
37+
(0, 0)
38+
39+
member __.GetSubTextString(start, length) =
40+
sourceText.GetSubText(TextSpan(start, length)).ToString()
41+
42+
member __.SubTextEquals(target, startIndex) =
43+
if startIndex < 0 || startIndex >= sourceText.Length then
44+
raise (ArgumentOutOfRangeException("startIndex"))
45+
46+
if String.IsNullOrEmpty(target) then
47+
raise (ArgumentException("Target is null or empty.", "target"))
48+
49+
let lastIndex = startIndex + target.Length
50+
if lastIndex <= startIndex || lastIndex >= sourceText.Length then
51+
raise (ArgumentException("Target is too big.", "target"))
52+
53+
let mutable finished = false
54+
let mutable didEqual = true
55+
let mutable i = 0
56+
while not finished && i < target.Length do
57+
if target.[i] <> sourceText.[startIndex + i] then
58+
didEqual <- false
59+
finished <- true // bail out early
60+
else
61+
i <- i + 1
62+
63+
didEqual
64+
65+
member __.ContentEquals(sourceText) =
66+
match sourceText with
67+
| :? SourceText as sourceText -> sourceText.ContentEquals(sourceText)
68+
| _ -> false
869

9-
[<ClrJob(baseline = true)>]
10-
type CompilerServiceParsing() =
70+
member __.Length = sourceText.Length
71+
72+
member __.CopyTo(sourceIndex, destination, destinationIndex, count) =
73+
sourceText.CopyTo(sourceIndex, destination, destinationIndex, count)
74+
}
75+
76+
sourceText
77+
78+
type SourceText with
79+
80+
member this.ToFSharpSourceText() =
81+
SourceText.weakTable.GetValue(this, Runtime.CompilerServices.ConditionalWeakTable<_,_>.CreateValueCallback(SourceText.create))
82+
83+
[<MemoryDiagnoser>]
84+
type CompilerService() =
1185

1286
let mutable checkerOpt = None
1387

@@ -24,6 +98,17 @@ type CompilerServiceParsing() =
2498
IsExe = false
2599
}
26100

101+
let mutable assembliesOpt = None
102+
103+
let readerOptions =
104+
{
105+
pdbDirPath = None
106+
ilGlobals = mkILGlobals ILScopeRef.Local
107+
reduceMemoryUsage = ReduceMemoryFlag.No
108+
metadataOnly = MetadataOnlyFlag.Yes
109+
tryGetMetadataSnapshot = fun _ -> None
110+
}
111+
27112
[<GlobalSetup>]
28113
member __.Setup() =
29114
match checkerOpt with
@@ -32,29 +117,88 @@ type CompilerServiceParsing() =
32117

33118
match sourceOpt with
34119
| None ->
35-
let source = File.ReadAllText("""..\..\..\..\..\src\fsharp\TypeChecker.fs""")
36-
sourceOpt <- Some(source)
120+
sourceOpt <- Some <| SourceText.From(File.OpenRead("""..\..\..\..\..\src\fsharp\TypeChecker.fs"""), Encoding.Default, SourceHashAlgorithm.Sha1, true)
121+
| _ -> ()
122+
123+
match assembliesOpt with
124+
| None ->
125+
assembliesOpt <-
126+
System.AppDomain.CurrentDomain.GetAssemblies()
127+
|> Array.map (fun x -> (x.Location))
128+
|> Some
37129
| _ -> ()
38130

39-
[<IterationSetup>]
131+
[<IterationSetup(Target = "Parsing")>]
40132
member __.ParsingSetup() =
41133
match checkerOpt with
42134
| None -> failwith "no checker"
43135
| Some(checker) ->
44136
checker.InvalidateAll()
45137
checker.ClearLanguageServiceRootCachesAndCollectAndFinalizeAllTransients()
46-
checker.ParseFile("dummy.fs", "dummy", parsingOptions) |> Async.RunSynchronously |> ignore
138+
checker.ParseFile("dummy.fs", SourceText.ofString "dummy", parsingOptions) |> Async.RunSynchronously |> ignore
47139

48140
[<Benchmark>]
49141
member __.Parsing() =
50142
match checkerOpt, sourceOpt with
51143
| None, _ -> failwith "no checker"
52144
| _, None -> failwith "no source"
53145
| Some(checker), Some(source) ->
54-
let results = checker.ParseFile("TypeChecker.fs", source, parsingOptions) |> Async.RunSynchronously
146+
let results = checker.ParseFile("TypeChecker.fs", source.ToFSharpSourceText(), parsingOptions) |> Async.RunSynchronously
55147
if results.ParseHadErrors then failwithf "parse had errors: %A" results.Errors
56148

149+
[<IterationSetup(Target = "ILReading")>]
150+
member __.ILReadingSetup() =
151+
// With caching, performance increases an order of magnitude when re-reading an ILModuleReader.
152+
// Clear it for benchmarking.
153+
ClearAllILModuleReaderCache()
154+
155+
[<Benchmark>]
156+
member __.ILReading() =
157+
match assembliesOpt with
158+
| None -> failwith "no assemblies"
159+
| Some(assemblies) ->
160+
// We try to read most of everything in the assembly that matter, mainly types with their properties, methods, and fields.
161+
// CustomAttrs and SecurityDecls are lazy until you call them, so we call them here for benchmarking.
162+
assemblies
163+
|> Array.iter (fun (fileName) ->
164+
let reader = OpenILModuleReader fileName readerOptions
165+
166+
let ilModuleDef = reader.ILModuleDef
167+
168+
let ilAssemblyManifest = ilModuleDef.Manifest.Value
169+
170+
ilAssemblyManifest.CustomAttrs |> ignore
171+
ilAssemblyManifest.SecurityDecls |> ignore
172+
ilAssemblyManifest.ExportedTypes.AsList
173+
|> List.iter (fun x ->
174+
x.CustomAttrs |> ignore
175+
)
176+
177+
ilModuleDef.CustomAttrs |> ignore
178+
ilModuleDef.TypeDefs.AsArray
179+
|> Array.iter (fun ilTypeDef ->
180+
ilTypeDef.CustomAttrs |> ignore
181+
ilTypeDef.SecurityDecls |> ignore
182+
183+
ilTypeDef.Methods.AsArray
184+
|> Array.iter (fun ilMethodDef ->
185+
ilMethodDef.CustomAttrs |> ignore
186+
ilMethodDef.SecurityDecls |> ignore
187+
)
188+
189+
ilTypeDef.Fields.AsList
190+
|> List.iter (fun ilFieldDef ->
191+
ilFieldDef.CustomAttrs |> ignore
192+
)
193+
194+
ilTypeDef.Properties.AsList
195+
|> List.iter (fun ilPropertyDef ->
196+
ilPropertyDef.CustomAttrs |> ignore
197+
)
198+
)
199+
)
200+
57201
[<EntryPoint>]
58202
let main argv =
59-
let _ = BenchmarkRunner.Run<CompilerServiceParsing>()
203+
let _ = BenchmarkRunner.Run<CompilerService>()
60204
0

benchmarks/Directory.Build.props

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<Project>
2+
<Import Project="$([MSBuild]::GetPathOfFileAbove('FSharp.Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
3+
</Project>

benchmarks/Directory.Build.targets

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<Project>
2+
<Import Project="$([MSBuild]::GetPathOfFileAbove('FSharp.Directory.Build.targets', '$(MSBuildThisFileDirectory)../'))" />
3+
</Project>

0 commit comments

Comments
 (0)