Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] [Prototype] Compilation Model #6947

Closed
wants to merge 173 commits into from
Closed
Show file tree
Hide file tree
Changes from 107 commits
Commits
Show all changes
173 commits
Select commit Hold shift + click to select a range
c1fd46f
Building compilation model
TIHan Apr 27, 2019
81a9c1a
More work
TIHan Apr 27, 2019
e2a5f50
Compiling
TIHan Apr 27, 2019
2061cd5
more work
TIHan Apr 28, 2019
0924776
Trying to get type checking implemented
TIHan Apr 28, 2019
fa60f57
Moved things around
TIHan Apr 28, 2019
15d14ac
Refactoring
TIHan Apr 28, 2019
0884798
Moving parsing out
TIHan Apr 28, 2019
376dc9c
Forgot to add files
TIHan Apr 28, 2019
62fe0a9
Quick rename
TIHan Apr 28, 2019
83d96a6
Renamed Stamp to TimeStamp files
TIHan Apr 28, 2019
fc64d85
IncrementalChecker intial work
TIHan Apr 29, 2019
237373b
Trying to figure it all out
TIHan Apr 29, 2019
ec28602
Nothing compiles
TIHan Apr 29, 2019
ad8b592
Now compiles
TIHan Apr 29, 2019
ce0d080
Trying to get it all working with mmf
TIHan Apr 30, 2019
1735bb9
Some work
TIHan Apr 30, 2019
189d136
Moving things around
TIHan Apr 30, 2019
b914749
Fixing build
TIHan Apr 30, 2019
822cb91
Able to build test project
TIHan Apr 30, 2019
746e5c5
Fixed a few things
TIHan May 1, 2019
e1b35b8
Fixed a few things
TIHan May 1, 2019
3ba03e5
Testing the work
TIHan May 2, 2019
b741573
Don't need any of that
TIHan May 2, 2019
e6a2811
Going to figure out cancellation for in progress checking
TIHan May 2, 2019
44abaf7
Better eventually
TIHan May 2, 2019
3e92acf
Getting stuff to work
TIHan May 2, 2019
8a788f5
Lots of refactoring
TIHan May 2, 2019
b6f71bb
Added CompilationService
TIHan May 2, 2019
cd17ac5
Added different MruCache
TIHan May 3, 2019
0af56c0
Added CompilationId
TIHan May 3, 2019
a33cb07
Added CompilationCaches
TIHan May 3, 2019
5359060
A little refactor
TIHan May 3, 2019
b23ab3a
Fixing mrucache
TIHan May 3, 2019
1c84701
Fixing MruCache again
TIHan May 3, 2019
ccc10b4
Doesn't compile
TIHan May 4, 2019
3eefc05
Compiles
TIHan May 4, 2019
89b8e81
Moved compilation
TIHan May 4, 2019
4680819
First test
TIHan May 4, 2019
a2bf0de
Added TypeCheckInfo to fsi
TIHan May 4, 2019
a2a57ee
Actually, won't do this
TIHan May 4, 2019
b8d7b41
Added cache tests
TIHan May 5, 2019
d3ca155
Remove some cruft
TIHan May 5, 2019
2782cdb
Added CheckerSink and SemanticModel
TIHan May 6, 2019
e89b3a5
Starting to impl semantic model
TIHan May 6, 2019
1b974dc
Remove printfn
TIHan May 6, 2019
3d10c0f
Trying to use TcSymbolUseData
TIHan May 6, 2019
360305f
Able to find a symbol
TIHan May 6, 2019
cdca0f4
Building get all symbols
TIHan May 6, 2019
e196383
Looking at symbols
TIHan May 9, 2019
bcf5fa2
simplified a few things, we are not going to build our own symbols
TIHan May 27, 2019
2fe75b2
Added FindSymbolUsesAsync
TIHan May 27, 2019
54e837a
Compilation is now netstandard2.0
TIHan May 27, 2019
63ff627
Tests pass
TIHan May 28, 2019
554509b
Added GetSyntaxTree
TIHan May 28, 2019
7ce5473
Trying to figure out token stuff, but it's not working
TIHan May 28, 2019
1fe313a
Added GetToolTipTextAsync
TIHan May 28, 2019
95a83db
Don't need that assembly
TIHan May 29, 2019
43c9451
Working again. Improved perf.
TIHan May 29, 2019
e04ad9c
Added PreEmitAsync
TIHan May 29, 2019
c56fd92
PreEmitAsync is now just preEmit
TIHan May 29, 2019
b829ea1
Adding Roslyn's MetadataReference
TIHan May 29, 2019
5714d8e
oops
TIHan May 29, 2019
17d2d7c
Using tryGetMetadataSnapshot
TIHan May 29, 2019
69aa252
Using IProjectReference
TIHan May 29, 2019
66327ef
Trying to fix assembly resolution
TIHan May 30, 2019
ef2941c
Bring back simpleresolution
TIHan May 30, 2019
8a660e8
merging with master
TIHan May 31, 2019
1fc907e
Fixed build
TIHan May 31, 2019
0af0882
Minor cleanup
TIHan May 31, 2019
56af78d
Trying to get tests to show in test explorer
TIHan May 31, 2019
45a964e
Tests show up
TIHan May 31, 2019
158eecb
Test passes
TIHan Jun 1, 2019
0dc1db3
Trying to get something to work on completions
TIHan Jun 2, 2019
6b8d83a
Some completion
TIHan Jun 2, 2019
35776b8
Some more work on completions
TIHan Jun 3, 2019
691fa83
Added slim syntax node
TIHan Jun 3, 2019
bc4274c
Does not compile
TIHan Jun 3, 2019
327d28c
Added SyntaxTreeNode work
TIHan Jun 4, 2019
a91bb3e
Trying to figure out ranges
TIHan Jun 4, 2019
520e819
Removing work on nodes. Going to look into tokens
TIHan Jun 4, 2019
a82bdeb
Able to grab a token
TIHan Jun 5, 2019
b910770
Merge remote-tracking branch 'upstream/master' into fsharp-compilation
TIHan Jun 5, 2019
261bc6a
fixed sln
TIHan Jun 5, 2019
f8b4537
Fixing build
TIHan Jun 5, 2019
738e781
Big refactor, mainly for names. Removed CompilationService/GlobalOpti…
TIHan Jun 6, 2019
a4e6d61
Added AstVisitor
TIHan Jun 7, 2019
cdf3829
Finished astvisitor
TIHan Jun 8, 2019
db0fd47
does not compile yet
TIHan Jun 9, 2019
9a37314
Alot of work, finally completing visitor
TIHan Jun 9, 2019
5959823
Quick refactor
TIHan Jun 9, 2019
c1cd8f8
Separated out parsing/lexing from syntax tree
TIHan Jun 9, 2019
cf4e74d
Need to find a way to make FSharpSyntaxTree not async
TIHan Jun 9, 2019
3d5f5fb
Minor work in syntax tree
TIHan Jun 9, 2019
b770e26
Something is mildly working
TIHan Jun 9, 2019
13c2299
more work
TIHan Jun 9, 2019
f493f61
Remove commented code
TIHan Jun 9, 2019
355d15b
Trying to re-use lex
TIHan Jun 9, 2019
a9c8bcd
Trying get a lexer to work without a real lexbuffer
TIHan Jun 9, 2019
b7ff046
Minor cleanup
TIHan Jun 9, 2019
6d31fe1
Refactoring, put querying on syntax node
TIHan Jun 10, 2019
2ff68d3
Finding tokens
TIHan Jun 10, 2019
6d76abf
Want to figure out function app context
TIHan Jun 10, 2019
bdefdce
Fixing range
TIHan Jun 10, 2019
4527c27
Implemented TryGetNextToken
TIHan Jun 10, 2019
e88df55
Fixing ranges
TIHan Jun 11, 2019
0b4bf64
Fixing a few things, binder not finished
TIHan Jun 11, 2019
ec7035c
Getting rid of apis we don't need
TIHan Jun 11, 2019
600c422
quick format fix
TIHan Jun 11, 2019
4d8c893
another quick format fix
TIHan Jun 11, 2019
f89ea36
Better and consistent api to find a symbol by position
TIHan Jun 11, 2019
10d7863
fixed logic
TIHan Jun 11, 2019
1273570
do not need those attributes
TIHan Jun 11, 2019
f5d4a63
Fixed bug
TIHan Jun 12, 2019
ff3975b
Added very experiemental speculative binding
TIHan Jun 12, 2019
6654f2a
Removed commented code
TIHan Jun 12, 2019
dd843b6
Added FSharpSyntaxTokenQueryFlags
TIHan Jun 12, 2019
7baff46
Added GetDiagnostics to FSharpSyntaxTree
TIHan Jun 12, 2019
fbcb1d0
Merge remote-tracking branch 'upstream/master' into fsharp-compilation
TIHan Jun 12, 2019
4856788
Added FSharpTools.sln
TIHan Jun 12, 2019
77eac42
Added FSharp.Tools.Visualizer.WPF. Will be used to test compilation
TIHan Jun 13, 2019
4d2f6e6
quick updates
TIHan Jun 13, 2019
d9eeddb
About to add a treeview to show syntax
TIHan Jun 13, 2019
b389fd9
Compilation is working in visualizer
TIHan Jun 13, 2019
928d863
Adding diagnostics everywhere
TIHan Jun 13, 2019
94348bd
Fixed getting descendants
TIHan Jun 14, 2019
5e19937
Fixed tree
TIHan Jun 14, 2019
5a83810
Using avalonedit
TIHan Jun 14, 2019
53870a9
quickly fixing up visualizer
TIHan Jun 14, 2019
81b449b
Trying to get visualizer set up for testin compilation
TIHan Jun 15, 2019
96d306b
Trying to fix clicks
TIHan Jun 15, 2019
28b094b
Fixed a few bugs
TIHan Jun 15, 2019
0246281
About to test completions
TIHan Jun 15, 2019
9875ee2
Going to add LookupSymbols
TIHan Jun 16, 2019
e516130
Fixed a few issues
TIHan Jun 16, 2019
1efadc5
Getting simple keyword highlighting
TIHan Jun 16, 2019
ea6ea88
Better behavior, able to get some highlighting
TIHan Jun 16, 2019
962a83b
Getting rid of Range
TIHan Jun 16, 2019
6152c3e
Testing incremental lexing
TIHan Jun 16, 2019
48d53f3
Better API and more optimized
TIHan Jun 17, 2019
56cf7ca
Making syntax token a struct
TIHan Jun 17, 2019
d57667f
More optimized
TIHan Jun 17, 2019
5172983
We do need to sleep for about 50 seconds
TIHan Jun 17, 2019
1d064eb
Added IncrementalLexer
TIHan Jun 17, 2019
3a4d101
Changed up API a bit. FSharpSyntaxToken now has None/IsNone properties.
TIHan Jun 17, 2019
7c5a936
small update
TIHan Jun 17, 2019
28ee798
Simple incremental lexing working
TIHan Jun 18, 2019
3539701
Small update
TIHan Jun 18, 2019
acd4f9f
A couple of fixes
TIHan Jun 18, 2019
4d838b9
Added string
TIHan Jun 18, 2019
d5216d3
Adding LexerConfig
TIHan Jun 18, 2019
cbb806c
Minor cleanup
TIHan Jun 19, 2019
04d188f
Didn't mean to includ tests project
TIHan Jun 19, 2019
ab1847b
Tests passing
TIHan Jun 19, 2019
01ea2b9
Fixed asr keyword
TIHan Jun 19, 2019
62c9340
Testing semantics
TIHan Jun 19, 2019
d580324
Added previous token query
TIHan Jun 19, 2019
b43a3ee
TryinFindTokenItem by position
TIHan Jun 19, 2019
2f91fa7
Fixed build
TIHan Jun 19, 2019
bd9285b
cache work
TIHan Jun 19, 2019
22d6a84
Lex filter not quite working
TIHan Jun 19, 2019
7c3ba97
Changing visitor a bit
TIHan Jun 20, 2019
7b463d5
Removed sort as it doubles the performance
TIHan Jun 20, 2019
f8e67d6
Fixed a bug
TIHan Jun 20, 2019
9cd3f5a
More perf improvements
TIHan Jun 22, 2019
d36469e
More opt
TIHan Jun 22, 2019
dcd020f
more opt
TIHan Jun 22, 2019
d1c383b
More opts
TIHan Jun 23, 2019
7004d9b
More opts
TIHan Jun 23, 2019
5fbf2cd
Going to perfect lexing
TIHan Jun 23, 2019
f84a72c
More work on incr lexer
TIHan Jun 24, 2019
5d52c5a
More work on lexer
TIHan Jun 24, 2019
d775016
Merge remote-tracking branch 'upstream/master' into fsharp-compilation
TIHan Aug 21, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 30 additions & 0 deletions VisualFSharp.sln
Expand Up @@ -154,6 +154,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TutorialProject", "vsintegr
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FSharp.Core.nuget", "src\fsharp\FSharp.Core.nuget\FSharp.Core.nuget.csproj", "{8EC30B2E-F1F9-4A98-BBB5-DD0CF6C84DDC}"
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharp.Compiler.Compilation", "src\fsharp\FSharp.Compiler.Compilation\FSharp.Compiler.Compilation.fsproj", "{6C05C603-43BB-4A6F-8485-3ED1F685F4A0}"
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharp.Compiler.Compilation.Tests", "tests\FSharp.Compiler.Compilation.Tests\FSharp.Compiler.Compilation.Tests.fsproj", "{0661AF4D-5655-4038-A254-0AC57DEFBD2A}"
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharp.Compiler.LanguageServer", "src\fsharp\FSharp.Compiler.LanguageServer\FSharp.Compiler.LanguageServer.fsproj", "{60BAFFA5-6631-4328-B044-2E012AB76DCA}"
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharp.Compiler.LanguageServer.UnitTests", "tests\FSharp.Compiler.LanguageServer.UnitTests\FSharp.Compiler.LanguageServer.UnitTests.fsproj", "{AAF2D233-1C38-4090-8FFA-F7C545625E06}"
Expand Down Expand Up @@ -888,6 +892,30 @@ Global
{8EC30B2E-F1F9-4A98-BBB5-DD0CF6C84DDC}.Release|Any CPU.Build.0 = Release|Any CPU
{8EC30B2E-F1F9-4A98-BBB5-DD0CF6C84DDC}.Release|x86.ActiveCfg = Release|Any CPU
{8EC30B2E-F1F9-4A98-BBB5-DD0CF6C84DDC}.Release|x86.Build.0 = Release|Any CPU
{6C05C603-43BB-4A6F-8485-3ED1F685F4A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6C05C603-43BB-4A6F-8485-3ED1F685F4A0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6C05C603-43BB-4A6F-8485-3ED1F685F4A0}.Debug|x86.ActiveCfg = Debug|Any CPU
{6C05C603-43BB-4A6F-8485-3ED1F685F4A0}.Debug|x86.Build.0 = Debug|Any CPU
{6C05C603-43BB-4A6F-8485-3ED1F685F4A0}.Proto|Any CPU.ActiveCfg = Debug|Any CPU
{6C05C603-43BB-4A6F-8485-3ED1F685F4A0}.Proto|Any CPU.Build.0 = Debug|Any CPU
{6C05C603-43BB-4A6F-8485-3ED1F685F4A0}.Proto|x86.ActiveCfg = Debug|Any CPU
{6C05C603-43BB-4A6F-8485-3ED1F685F4A0}.Proto|x86.Build.0 = Debug|Any CPU
{6C05C603-43BB-4A6F-8485-3ED1F685F4A0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6C05C603-43BB-4A6F-8485-3ED1F685F4A0}.Release|Any CPU.Build.0 = Release|Any CPU
{6C05C603-43BB-4A6F-8485-3ED1F685F4A0}.Release|x86.ActiveCfg = Release|Any CPU
{6C05C603-43BB-4A6F-8485-3ED1F685F4A0}.Release|x86.Build.0 = Release|Any CPU
{0661AF4D-5655-4038-A254-0AC57DEFBD2A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0661AF4D-5655-4038-A254-0AC57DEFBD2A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0661AF4D-5655-4038-A254-0AC57DEFBD2A}.Debug|x86.ActiveCfg = Debug|Any CPU
{0661AF4D-5655-4038-A254-0AC57DEFBD2A}.Debug|x86.Build.0 = Debug|Any CPU
{0661AF4D-5655-4038-A254-0AC57DEFBD2A}.Proto|Any CPU.ActiveCfg = Debug|Any CPU
{0661AF4D-5655-4038-A254-0AC57DEFBD2A}.Proto|Any CPU.Build.0 = Debug|Any CPU
{0661AF4D-5655-4038-A254-0AC57DEFBD2A}.Proto|x86.ActiveCfg = Debug|Any CPU
{0661AF4D-5655-4038-A254-0AC57DEFBD2A}.Proto|x86.Build.0 = Debug|Any CPU
{0661AF4D-5655-4038-A254-0AC57DEFBD2A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0661AF4D-5655-4038-A254-0AC57DEFBD2A}.Release|Any CPU.Build.0 = Release|Any CPU
{0661AF4D-5655-4038-A254-0AC57DEFBD2A}.Release|x86.ActiveCfg = Release|Any CPU
{0661AF4D-5655-4038-A254-0AC57DEFBD2A}.Release|x86.Build.0 = Release|Any CPU
{60BAFFA5-6631-4328-B044-2E012AB76DCA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{60BAFFA5-6631-4328-B044-2E012AB76DCA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{60BAFFA5-6631-4328-B044-2E012AB76DCA}.Debug|x86.ActiveCfg = Debug|Any CPU
Expand Down Expand Up @@ -984,6 +1012,8 @@ Global
{C32806E0-71C2-40E4-AEC4-517F73F6A18A} = {BED74F9E-A0D2-48E2-9EE7-449832100487}
{7B345E51-F2C0-4D4B-B0E0-05432EC9D5E1} = {BED74F9E-A0D2-48E2-9EE7-449832100487}
{8EC30B2E-F1F9-4A98-BBB5-DD0CF6C84DDC} = {647810D0-5307-448F-99A2-E83917010DAE}
{6C05C603-43BB-4A6F-8485-3ED1F685F4A0} = {3881429D-A97A-49EB-B7AE-A82BA5FE9C77}
{0661AF4D-5655-4038-A254-0AC57DEFBD2A} = {CFE3259A-2D30-4EB0-80D5-E8B5F3D01449}
{60BAFFA5-6631-4328-B044-2E012AB76DCA} = {B8DDA694-7939-42E3-95E5-265C2217C142}
{AAF2D233-1C38-4090-8FFA-F7C545625E06} = {CFE3259A-2D30-4EB0-80D5-E8B5F3D01449}
EndGlobalSection
Expand Down
8 changes: 8 additions & 0 deletions benchmarks/Benchmarks.sln
Expand Up @@ -9,6 +9,8 @@ Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharp.Core", "..\src\fshar
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharp.Compiler.Private", "..\src\fsharp\FSharp.Compiler.Private\FSharp.Compiler.Private.fsproj", "{2E4D67B4-522D-4CF7-97E4-BA940F0B18F3}"
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharp.Compiler.Compilation", "..\src\fsharp\FSharp.Compiler.Compilation\FSharp.Compiler.Compilation.fsproj", "{B13184B7-7B95-4D66-AEAF-487F09B35A9C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -34,6 +36,12 @@ Global
{2E4D67B4-522D-4CF7-97E4-BA940F0B18F3}.Proto|Any CPU.Build.0 = Debug|Any CPU
{2E4D67B4-522D-4CF7-97E4-BA940F0B18F3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2E4D67B4-522D-4CF7-97E4-BA940F0B18F3}.Release|Any CPU.Build.0 = Release|Any CPU
{B13184B7-7B95-4D66-AEAF-487F09B35A9C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B13184B7-7B95-4D66-AEAF-487F09B35A9C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B13184B7-7B95-4D66-AEAF-487F09B35A9C}.Proto|Any CPU.ActiveCfg = Debug|Any CPU
{B13184B7-7B95-4D66-AEAF-487F09B35A9C}.Proto|Any CPU.Build.0 = Debug|Any CPU
{B13184B7-7B95-4D66-AEAF-487F09B35A9C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B13184B7-7B95-4D66-AEAF-487F09B35A9C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Expand Up @@ -22,12 +22,15 @@

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.11.3" />
<PackageReference Include="Microsoft.CodeAnalysis.EditorFeatures.Text" Version="2.9.0" />
<PackageReference Include="Microsoft.CodeAnalysis.EditorFeatures" Version="$(MicrosoftCodeAnalysisEditorFeaturesPackageVersion)" />
<PackageReference Include="Microsoft.CodeAnalysis.EditorFeatures.Text" Version="$(MicrosoftCodeAnalysisEditorFeaturesTextPackageVersion)" />
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.Common" Version="$(MicrosoftCodeAnalysisWorkspacesCommonPackageVersion)" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="$(FSharpSourcesRoot)\fsharp\FSharp.Compiler.Private\FSharp.Compiler.Private.fsproj" />
<ProjectReference Include="$(FSharpSourcesRoot)\fsharp\FSharp.Core\FSharp.Core.fsproj" />
<ProjectReference Include="..\..\src\fsharp\FSharp.Compiler.Compilation\FSharp.Compiler.Compilation.fsproj" />
</ItemGroup>

</Project>
1 change: 1 addition & 0 deletions eng/Versions.props
Expand Up @@ -100,6 +100,7 @@
<MicrosoftCodeAnalysisExternalAccessFSharpVersion>$(RoslynVersion)</MicrosoftCodeAnalysisExternalAccessFSharpVersion>
<MicrosoftCodeAnalysisWorkspacesCommonVersion>$(RoslynVersion)</MicrosoftCodeAnalysisWorkspacesCommonVersion>
<MicrosoftVisualStudioLanguageServicesVersion>$(RoslynVersion)</MicrosoftVisualStudioLanguageServicesVersion>
<MicrosoftCodeAnalysisWorkspacesMSBuildVersion>$(RoslynVersion)</MicrosoftCodeAnalysisWorkspacesMSBuildVersion>
<!-- Microsoft Build packages -->
<MicrosoftBuildOverallPackagesVersion>16.0.461</MicrosoftBuildOverallPackagesVersion>
<MicrosoftBuildVersion>$(MicrosoftBuildOverallPackagesVersion)</MicrosoftBuildVersion>
Expand Down
59 changes: 33 additions & 26 deletions src/absil/ilread.fs
Expand Up @@ -894,45 +894,52 @@ let mkCacheInt32 lowMem _inbase _nm _sz =
if lowMem then (fun f x -> f x) else
let cache = ref null
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be a mutable?

let count = ref 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be a mutable?

let gate = obj ()
#if STATISTICS
addReport (fun oc -> if !count <> 0 then oc.WriteLine ((_inbase + string !count + " "+ _nm + " cache hits"): string))
#endif
fun f (idx: int32) ->
let cache =
match !cache with
| null -> cache := new Dictionary<int32, _>(11)
| _ -> ()
!cache
match cache.TryGetValue idx with
| true, res ->
incr count
res
| _ ->
let res = f idx
cache.[idx] <- res
res
lock gate (fun () ->
let cache =
match !cache with
| null -> cache := new Dictionary<int32, _>(11)
| _ -> ()
!cache
let mutable res = Unchecked.defaultof<_>
let ok = cache.TryGetValue(idx, &res)
if ok then
incr count
res
else
let res = f idx
cache.[idx] <- res
res
)

let mkCacheGeneric lowMem _inbase _nm _sz =
if lowMem then (fun f x -> f x) else
let cache = ref null
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be good to mutable this up

let count = ref 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be good to mutable this up

let gate = obj ()
#if STATISTICS
addReport (fun oc -> if !count <> 0 then oc.WriteLine ((_inbase + string !count + " " + _nm + " cache hits"): string))
#endif
fun f (idx :'T) ->
let cache =
match !cache with
| null -> cache := new Dictionary<_, _>(11 (* sz: int *) )
| _ -> ()
!cache
match cache.TryGetValue idx with
| true, v ->
incr count
v
| _ ->
let res = f idx
cache.[idx] <- res
res
lock gate (fun () ->
let cache =
match !cache with
| null -> cache := new Dictionary<_, _>(11 (* sz: int *) )
| _ -> ()
!cache
match cache.TryGetValue idx with
| true, v ->
incr count
v
| _ ->
let res = f idx
cache.[idx] <- res
res
)

//-----------------------------------------------------------------------
// Polymorphic general helpers for searching for particular rows.
Expand Down
22 changes: 20 additions & 2 deletions src/fsharp/CompileOps.fs
Expand Up @@ -3481,8 +3481,23 @@ let ParseOneInputFile (tcConfig: TcConfig, lexResourceManager, conditionalCompil
let lexbuf = UnicodeLexing.UnicodeFileAsLexbuf(filename, tcConfig.inputCodePage, retryLocked)
ParseOneInputLexbuf(tcConfig, lexResourceManager, conditionalCompilationDefines, lexbuf, filename, isLastCompiland, errorLogger)
else error(Error(FSComp.SR.buildInvalidSourceFileExtension(SanitizeFileName filename tcConfig.implicitIncludeDir), rangeStartup))
with e -> (* errorR(Failure("parse failed")); *) errorRecovery e rangeStartup; None

with e -> (* errorR(Failure("parse failed")); *) errorRecovery e rangeStartup; None

let ParseOneInputSourceText (tcConfig: TcConfig, lexResourceManager, conditionalCompilationDefines, filename, sourceText, isLastCompiland, errorLogger) =
try
let lexbuf = UnicodeLexing.SourceTextAsLexbuf sourceText
ParseOneInputLexbuf(tcConfig, lexResourceManager, conditionalCompilationDefines, lexbuf, filename, isLastCompiland, errorLogger)
with e -> (* errorR(Failure("parse failed")); *) errorRecovery e rangeStartup; None

let ParseOneInputStream (tcConfig: TcConfig, lexResourceManager, conditionalCompilationDefines, filename, stream: Stream, isLastCompiland, errorLogger) =
try
let streamReader = new StreamReader(stream) // don't dispose of stream reader
let lexbuf =
UnicodeLexing.FunctionAsLexbuf (fun (chars, start, length) ->
streamReader.ReadBlock (chars, start, length)
)
ParseOneInputLexbuf(tcConfig, lexResourceManager, conditionalCompilationDefines, lexbuf, filename, isLastCompiland, errorLogger)
with e -> (* errorR(Failure("parse failed")); *) errorRecovery e rangeStartup; None

[<Sealed>]
type TcAssemblyResolutions(tcConfig: TcConfig, results: AssemblyResolution list, unresolved: UnresolvedAssemblyReference list) =
Expand Down Expand Up @@ -4767,6 +4782,9 @@ and [<Sealed>] TcImports(tcConfigP: TcConfigProvider, initialResolutions: TcAsse
let! tcImports = TcImports.BuildNonFrameworkTcImports(ctok, tcConfigP, tcGlobals, frameworkTcImports, nonFrameworkReferences, knownUnresolved)
return tcGlobals, tcImports
}

static member BuildResolvedTcImports(ctok, tcConfigP: TcConfigProvider, assemblyResolutions) =
TcImports.BuildFrameworkTcImports (ctok, tcConfigP, assemblyResolutions, [])

interface System.IDisposable with
member tcImports.Dispose() =
Expand Down
8 changes: 8 additions & 0 deletions src/fsharp/CompileOps.fsi
Expand Up @@ -4,6 +4,7 @@
module internal FSharp.Compiler.CompileOps

open System
open System.IO
open System.Text
open System.Collections.Generic
open Internal.Utilities
Expand Down Expand Up @@ -644,6 +645,7 @@ type TcImports =
static member BuildFrameworkTcImports : CompilationThreadToken * TcConfigProvider * AssemblyResolution list * AssemblyResolution list -> Cancellable<TcGlobals * TcImports>
static member BuildNonFrameworkTcImports : CompilationThreadToken * TcConfigProvider * TcGlobals * TcImports * AssemblyResolution list * UnresolvedAssemblyReference list -> Cancellable<TcImports>
static member BuildTcImports : CompilationThreadToken * TcConfigProvider -> Cancellable<TcGlobals * TcImports>
static member BuildResolvedTcImports : CompilationThreadToken * TcConfigProvider * AssemblyResolution list -> Cancellable<TcGlobals * TcImports>

//----------------------------------------------------------------------------
// Special resources in DLLs
Expand Down Expand Up @@ -709,6 +711,12 @@ val DefaultReferencesForScriptsAndOutOfProjectSources: bool -> string list
/// Parse one input file
val ParseOneInputFile: TcConfig * Lexhelp.LexResourceManager * string list * string * isLastCompiland: (bool * bool) * ErrorLogger * (*retryLocked*) bool -> ParsedInput option

/// Parse one input source text
val ParseOneInputSourceText: TcConfig * Lexhelp.LexResourceManager * string list * string * ISourceText * isLastCompiland: (bool * bool) * ErrorLogger -> ParsedInput option

/// Parse one input stream
val ParseOneInputStream: TcConfig * Lexhelp.LexResourceManager * string list * string * Stream * isLastCompiland: (bool * bool) * ErrorLogger -> ParsedInput option

//----------------------------------------------------------------------------
// Type checking and querying the type checking state
//--------------------------------------------------------------------------
Expand Down
16 changes: 16 additions & 0 deletions src/fsharp/FSharp.Compiler.Compilation/Abbreviations.fs
@@ -0,0 +1,16 @@
namespace FSharp.Compiler.Compilation

open FSharp.Compiler.Ast
open FSharp.Compiler.ErrorLogger

type internal FSharpErrorSeverity = FSharp.Compiler.SourceCodeServices.FSharpErrorSeverity
type internal CompilationErrorLogger = FSharp.Compiler.SourceCodeServices.CompilationErrorLogger
type internal CompilationGlobalsScope = FSharp.Compiler.SourceCodeServices.CompilationGlobalsScope
type internal ParseResult = ParsedInput option * (PhasedDiagnostic * FSharpErrorSeverity) []
type internal SymbolEnv = FSharp.Compiler.SourceCodeServices.SymbolEnv
type FSharpSymbol = FSharp.Compiler.SourceCodeServices.FSharpSymbol
type FSharpSymbolUse = FSharp.Compiler.SourceCodeServices.FSharpSymbolUse
type internal FSharpSourceTokenizer = FSharp.Compiler.SourceCodeServices.FSharpSourceTokenizer
type internal FSharpTokenizerLexState = FSharp.Compiler.SourceCodeServices.FSharpTokenizerLexState
type FSharpTokenInfo = FSharp.Compiler.SourceCodeServices.FSharpTokenInfo