Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
0ce3752
Helper function for FastGenericEqualityComparerTable
manofstick Jun 5, 2018
9921f45
Use the default equality comparer where applicable
manofstick Jun 5, 2018
2040158
Avoid calls to GenericEqualityObj for known types
manofstick Jun 5, 2018
de7b484
Avoid boxing in the "standard" use of GenericEqualityWithComparerIntr…
manofstick Jun 6, 2018
0f1f3e8
Added method to avoid tail calls
manofstick Jun 6, 2018
24325dd
Implemented hashing
manofstick Jun 6, 2018
178497e
Additional use of EqualityComparer.Default
manofstick Jun 6, 2018
7630841
Consistent naming
manofstick Jun 6, 2018
eceabba
Fixed up by mix up my ERs with my PERs!
manofstick Jun 7, 2018
e809216
Apply De Morgan's law to make it a bit cleaner
manofstick Jun 7, 2018
29c2d51
Argh, got the PER and ER mixed up even when I tried to fix. Now good …
manofstick Jun 8, 2018
d9d5a41
Removed custom delegates by using System.Func
manofstick Jun 8, 2018
aeb3b23
Disallow optimization on Nullable types
manofstick Jun 8, 2018
f3360c7
More inclusive check for canUseDefaultEqualityComparer
manofstick Jun 9, 2018
4be30d1
Updated il output files
manofstick Jun 9, 2018
44d7bcd
Removed IERorPER by splitting calling class into 2, and added helper …
manofstick Jun 11, 2018
cd7dff4
Changed it all to used EqualityComparer derived classes and restored …
manofstick Jun 13, 2018
cb29dbb
Removed comparers that matched EqualityComparer<>.Default and code re…
manofstick Jun 14, 2018
23cc296
Added additional types where EqualityComparer.Default can be used
manofstick Jun 16, 2018
e89986e
Save unnecessary type checks when more information is known
manofstick Jun 16, 2018
4d65fcd
Removed now unused objects, and other minor cleanup
manofstick Jun 18, 2018
69e954b
Modified Optimizer to manually inline GenericEqualityIntrinsic and fr…
manofstick Jun 23, 2018
1198f42
Fixed SurfaceArea
manofstick Jun 23, 2018
41ddb08
Ensure FSharp.Core has the optimization functions (and added comments)
manofstick Jun 23, 2018
d845e48
Remove IL bloat from this PR as per https://github.com/Microsoft/visu…
manofstick Jun 25, 2018
251dbdb
Remove null checks for IStructuralEquality Value Types
manofstick Jun 26, 2018
4a68ba5
Consolidated Type Specific Array Equality functions
manofstick Jun 27, 2018
6bce4b8
Fix compiler call via FSharpFunc.Invoke rather than direct
manofstick Jun 27, 2018
b5e2633
Replaced duplicated GetHashCode code with inline function
manofstick Jun 28, 2018
7551f93
Common array EqualityComparers (for types that previously had special…
manofstick Jun 28, 2018
02f05d1
Fix regression in regards to hash code on fast-path covariant arrays …
manofstick Jul 11, 2018
3c58e14
Similar treatment within prim-types for Comparer as #5112 was for Equ…
manofstick Jul 1, 2018
9dc65cc
Moved throwing exceptions closer
manofstick Jul 2, 2018
c179042
Added comparison usage, so could remove exception catching logic when…
manofstick Jul 2, 2018
553efd9
Consolidated functions
manofstick Jul 3, 2018
76d191f
Consolidated ArrayComparisons and addressed issue #5263
manofstick Jul 3, 2018
0f42ffa
Fixed bug introduced in #5278 where an unstable sort could be used wh…
manofstick Jul 18, 2018
c62d5b2
Removed now unnecessary optimization from stableSortWithKeysAndComparer
manofstick Jul 19, 2018
0420e6d
Moved isRecordType down to prim-types.fs (internal only)
manofstick Jul 8, 2018
e6ef7fb
Moved enough of reflect.fs to get Record fields
manofstick Jul 8, 2018
5472606
Moved reflection functions for Union types into prim-types.fs
manofstick Jul 9, 2018
5c0785d
Removed methods from prim-types.fsi that are now just used internally
manofstick Jul 9, 2018
951a3be
Used the reflection functions to handle records and unions
manofstick Jul 9, 2018
12372c5
Added check for fsharp value types
manofstick Jul 9, 2018
3887b72
Fixed struct check where a [<DefaultValue>] field is used.
manofstick Jul 10, 2018
225e3ef
Minor shift in logic order for less comparisons
manofstick Jul 11, 2018
b0b64f6
Removed MapOne case for performance.
manofstick Jul 19, 2018
cc3435f
Converted Map.Count from O(n) to O(1)
manofstick Jul 20, 2018
c25e038
inlined mk/mkLeaf
manofstick Jul 21, 2018
a27cc24
optimize ofSeq, ofList, ofArray via a temporary sorted ResizeArray an…
manofstick Jul 21, 2018
16ba0ac
Split rebalance so as to inline decision logic
manofstick Jul 24, 2018
9bd6af7
Removed MapEmpty
manofstick Jul 26, 2018
33529d7
manual selective inlining of rebalance in add
manofstick Jul 26, 2018
768a8d7
Only access members when necessary - measurable performance diff for …
manofstick Jul 28, 2018
c7e6a01
Consolidated find functionality
manofstick Jul 28, 2018
a35212c
Labelled MapNode fields
manofstick Jul 28, 2018
2a7e1d0
Revamped enumeration to create less garbage. Faster on 64-bit, slower…
manofstick Jul 29, 2018
c0685c5
Added Checked logic to ensure size constraint isn't violated
manofstick Jul 29, 2018
97ff635
findImpl use helper functions to clean up
manofstick Jul 29, 2018
9896c65
Made the non-(to|of)(Seq|List|Array) Map changes to the TaggedCollect…
manofstick Jul 29, 2018
9611fb1
Removed SetOne
manofstick Jul 30, 2018
752fa52
Converted Set's height to size
manofstick Jul 30, 2018
1f4c59b
Cut SetTree down to just SetNode
manofstick Jul 31, 2018
45509bd
rebalance split and add from Map
manofstick Aug 1, 2018
ba7392e
Easy case Zmap to Map
manofstick Aug 4, 2018
fcef137
Removed IntMap
manofstick Aug 5, 2018
e4575bc
Added SortKey as Adapter for Map to use IComparable
manofstick Aug 5, 2018
85a3e6a
Converted Zmaps on Val types
manofstick Aug 6, 2018
7e7a499
...working way through all Zmaps...
manofstick Aug 9, 2018
17d2fed
Fixed call missed in #debug section
manofstick Aug 9, 2018
a174712
Removed remaining usages of Zmap
manofstick Aug 9, 2018
b48f024
Removed now unused TaggedCollections.Map & Zmap
manofstick Aug 9, 2018
efb31dc
Converted Map.force to MapCustom.force
manofstick Aug 10, 2018
28c95f2
Renamed MapCusom to Zmap
manofstick Aug 10, 2018
14b1214
Type alias : zmap<...> = Map<SortKey<...>...>
manofstick Aug 10, 2018
210bc9f
Created SetCustom to remove Zset
manofstick Aug 10, 2018
36a1346
mhiVals to SetCustom
manofstick Aug 11, 2018
bdbbe7d
converted all zset<Val>s
manofstick Aug 11, 2018
f3523f2
Transferred Zset<Typar> to SetCustom
manofstick Aug 11, 2018
c6579fb
Tycon set conversion
manofstick Aug 11, 2018
204f2b3
Final two Zset orderers converted
manofstick Aug 11, 2018
eb0d576
Added NoComparison/NoEquality to ordering objects
manofstick Aug 11, 2018
b2060ed
Changed dontInline to normal set
manofstick Aug 11, 2018
e69e4d0
Replacing Zset usage where plain Set could be used
manofstick Aug 11, 2018
406d7ea
Removed few remaining usages of Zset
manofstick Aug 11, 2018
e525f29
Deleted zset and TaggedCollections
manofstick Aug 11, 2018
c0dd6dd
Renamed comparers to be based off original names
manofstick Aug 11, 2018
a21cb4d
Renamed SetCustom to Zset
manofstick Aug 11, 2018
8f14562
Brought Zmap naming inline with Map
manofstick Aug 12, 2018
e81f27e
Revert "Deleted zset and TaggedCollections"
manofstick Aug 13, 2018
d5cd1be
Removing zset & taggedcollections
manofstick Aug 13, 2018
73faf34
Removed unused commented code
manofstick Aug 13, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 2 additions & 17 deletions fcs/FSharp.Compiler.Service/FSharp.Compiler.Service.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,8 @@
<Compile Include="$(FSharpSourcesRoot)/utils/EditDistance.fs">
<Link>Utilities/EditDistance.fs</Link>
</Compile>
<Compile Include="$(FSharpSourcesRoot)/utils/TaggedCollections.fsi">
<Link>Utilities/TaggedCollections.fsi</Link>
</Compile>
<Compile Include="$(FSharpSourcesRoot)/utils/TaggedCollections.fs">
<Link>Utilities/TaggedCollections.fs</Link>
<Compile Include="$(FSharpSourcesRoot)/utils/SortKey.fs">
<Link>Utilities/SortKey.fs</Link>
</Compile>
<Compile Include="$(FSharpSourcesRoot)/fsharp/QueueList.fs">
<Link>Utilities/QueueList.fs</Link>
Expand All @@ -135,18 +132,6 @@
<Compile Include="$(FSharpSourcesRoot)/utils/filename.fs">
<Link>Utilities/filename.fs</Link>
</Compile>
<Compile Include="$(FSharpSourcesRoot)/absil/zmap.fsi">
<Link>Utilities/zmap.fsi</Link>
</Compile>
<Compile Include="$(FSharpSourcesRoot)/absil/zmap.fs">
<Link>Utilities/zmap.fs</Link>
</Compile>
<Compile Include="$(FSharpSourcesRoot)/absil/zset.fsi">
<Link>Utilities/zset.fsi</Link>
</Compile>
<Compile Include="$(FSharpSourcesRoot)/absil/zset.fs">
<Link>Utilities/zset.fs</Link>
</Compile>
<Compile Include="$(FSharpSourcesRoot)/absil/bytes.fsi">
<Link>Utilities/bytes.fsi</Link>
</Compile>
Expand Down
75 changes: 34 additions & 41 deletions src/absil/ilreflect.fs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ open Microsoft.FSharp.Core.Printf
open Microsoft.FSharp.Core.ReflectionAdapters
#endif

let codeLabelOrder = ComparisonIdentity.Structural<ILCodeLabel>

// Convert the output of convCustomAttr
open Microsoft.FSharp.Compiler.AbstractIL.ILAsciiWriter
let wrapCustomAttr setCustomAttr (cinfo, bytes) =
Expand Down Expand Up @@ -284,8 +282,8 @@ type System.Reflection.Emit.ILGenerator with

let inline flagsIf b x = if b then x else enum 0

module Zmap =
let force x m str = match Zmap.tryFind x m with Some y -> y | None -> failwithf "Zmap.force: %s: x = %+A" str x
module Map =
let force x m str = match Map.tryFind x m with Some y -> y | None -> failwithf "Map.force: %s: x = %+A" str x

let equalTypes (s:Type) (t:Type) = s.Equals(t)
let equalTypeLists ss tt = List.lengthsEqAndForall2 equalTypes ss tt
Expand Down Expand Up @@ -363,44 +361,39 @@ let convTypeRefAux (cenv:cenv) (tref:ILTypeRef) =
/// and could be placed as hash tables in the global environment.
[<AutoSerializable(false)>]
type emEnv =
{ emTypMap : Zmap<ILTypeRef, Type * TypeBuilder * ILTypeDef * Type option (*the created type*) > ;
emConsMap : Zmap<ILMethodRef, ConstructorBuilder>;
emMethMap : Zmap<ILMethodRef, MethodBuilder>;
emFieldMap : Zmap<ILFieldRef, FieldBuilder>;
emPropMap : Zmap<ILPropertyRef, PropertyBuilder>;
{ emTypMap : Map<ILTypeRef, Type * TypeBuilder * ILTypeDef * Type option (*the created type*) >
emConsMap : Map<ILMethodRef, ConstructorBuilder>;
emMethMap : Map<ILMethodRef, MethodBuilder>
emFieldMap : Map<ILFieldRef, FieldBuilder>
emPropMap : Map<ILPropertyRef, PropertyBuilder>
emLocals : LocalBuilder[];
emLabels : Zmap<IL.ILCodeLabel, Label>;
emLabels : Map<IL.ILCodeLabel, Label>
emTyvars : Type[] list; // stack
emEntryPts : (TypeBuilder * string) list
delayedFieldInits : (unit -> unit) list}

let orderILTypeRef = ComparisonIdentity.Structural<ILTypeRef>
let orderILMethodRef = ComparisonIdentity.Structural<ILMethodRef>
let orderILFieldRef = ComparisonIdentity.Structural<ILFieldRef>
let orderILPropertyRef = ComparisonIdentity.Structural<ILPropertyRef>

let emEnv0 =
{ emTypMap = Zmap.empty orderILTypeRef;
emConsMap = Zmap.empty orderILMethodRef;
emMethMap = Zmap.empty orderILMethodRef;
emFieldMap = Zmap.empty orderILFieldRef;
emPropMap = Zmap.empty orderILPropertyRef;
{ emTypMap = Map.empty
emConsMap = Map.empty
emMethMap = Map.empty
emFieldMap = Map.empty
emPropMap = Map.empty
emLocals = [| |];
emLabels = Zmap.empty codeLabelOrder;
emLabels = Map.empty
emTyvars = [];
emEntryPts = []
delayedFieldInits = [] }

let envBindTypeRef emEnv (tref:ILTypeRef) (typT, typB, typeDef)=
match typT with
| null -> failwithf "binding null type in envBindTypeRef: %s\n" tref.Name;
| _ -> {emEnv with emTypMap = Zmap.add tref (typT, typB, typeDef, None) emEnv.emTypMap}
| _ -> {emEnv with emTypMap = Map.add tref (typT, typB, typeDef, None) emEnv.emTypMap}

let envUpdateCreatedTypeRef emEnv (tref:ILTypeRef) =
// The tref's TypeBuilder has been created, so we have a Type proper.
// Update the tables to include this created type (the typT held prior to this is (i think) actually (TypeBuilder :> Type).
// The (TypeBuilder :> Type) does not implement all the methods that a Type proper does.
let typT, typB, typeDef, _createdTypOpt = Zmap.force tref emEnv.emTypMap "envGetTypeDef: failed"
let typT, typB, typeDef, _createdTypOpt = Map.force tref emEnv.emTypMap "envGetTypeDef: failed"
if typB.IsCreated() then
let ty = typB.CreateTypeAndLog()
#if ENABLE_MONO_SUPPORT
Expand All @@ -415,7 +408,7 @@ let envUpdateCreatedTypeRef emEnv (tref:ILTypeRef) =
System.Runtime.Serialization.FormatterServices.GetUninitializedObject(ty) |> ignore
with e -> ()
#endif
{emEnv with emTypMap = Zmap.add tref (typT, typB, typeDef, Some ty) emEnv.emTypMap}
{emEnv with emTypMap = Map.add tref (typT, typB, typeDef, Some ty) emEnv.emTypMap}
else
#if DEBUG
printf "envUpdateCreatedTypeRef: expected type to be created\n";
Expand All @@ -424,7 +417,7 @@ let envUpdateCreatedTypeRef emEnv (tref:ILTypeRef) =

let convTypeRef cenv emEnv preferCreated (tref:ILTypeRef) =
let res =
match Zmap.tryFind tref emEnv.emTypMap with
match Map.tryFind tref emEnv.emTypMap with
| Some (_typT, _typB, _typeDef, Some createdTy) when preferCreated -> createdTy
| Some (typT, _typB, _typeDef, _) -> typT
| None -> convTypeRefAux cenv tref
Expand All @@ -433,47 +426,47 @@ let convTypeRef cenv emEnv preferCreated (tref:ILTypeRef) =
| _ -> res

let envBindConsRef emEnv (mref:ILMethodRef) consB =
{emEnv with emConsMap = Zmap.add mref consB emEnv.emConsMap}
{emEnv with emConsMap = Map.add mref consB emEnv.emConsMap}

let envGetConsB emEnv (mref:ILMethodRef) =
Zmap.force mref emEnv.emConsMap "envGetConsB: failed"
Map.force mref emEnv.emConsMap "envGetConsB: failed"

let envBindMethodRef emEnv (mref:ILMethodRef) methB =
{emEnv with emMethMap = Zmap.add mref methB emEnv.emMethMap}
{emEnv with emMethMap = Map.add mref methB emEnv.emMethMap}

let envGetMethB emEnv (mref:ILMethodRef) =
Zmap.force mref emEnv.emMethMap "envGetMethB: failed"
Map.force mref emEnv.emMethMap "envGetMethB: failed"

let envBindFieldRef emEnv fref fieldB =
{emEnv with emFieldMap = Zmap.add fref fieldB emEnv.emFieldMap}
{emEnv with emFieldMap = Map.add fref fieldB emEnv.emFieldMap}

let envGetFieldB emEnv fref =
Zmap.force fref emEnv.emFieldMap "- envGetMethB: failed"
Map.force fref emEnv.emFieldMap "- envGetMethB: failed"

let envBindPropRef emEnv (pref:ILPropertyRef) propB =
{emEnv with emPropMap = Zmap.add pref propB emEnv.emPropMap}
{emEnv with emPropMap = Map.add pref propB emEnv.emPropMap}

let envGetPropB emEnv pref =
Zmap.force pref emEnv.emPropMap "- envGetPropB: failed"
Map.force pref emEnv.emPropMap "- envGetPropB: failed"

let envGetTypB emEnv (tref:ILTypeRef) =
Zmap.force tref emEnv.emTypMap "envGetTypB: failed"
Map.force tref emEnv.emTypMap "envGetTypB: failed"
|> (fun (_typT, typB, _typeDef, _createdTypOpt) -> typB)

let envGetTypeDef emEnv (tref:ILTypeRef) =
Zmap.force tref emEnv.emTypMap "envGetTypeDef: failed"
Map.force tref emEnv.emTypMap "envGetTypeDef: failed"
|> (fun (_typT, _typB, typeDef, _createdTypOpt) -> typeDef)

let envSetLocals emEnv locs = assert (emEnv.emLocals.Length = 0); // check "locals" is not yet set (scopes once only)
{emEnv with emLocals = locs}
let envGetLocal emEnv i = emEnv.emLocals.[i] // implicit bounds checking

let envSetLabel emEnv name lab =
assert (not (Zmap.mem name emEnv.emLabels));
{emEnv with emLabels = Zmap.add name lab emEnv.emLabels}
assert (not (Map.containsKey name emEnv.emLabels));
{emEnv with emLabels = Map.add name lab emEnv.emLabels}

let envGetLabel emEnv name =
Zmap.find name emEnv.emLabels
Map.find name emEnv.emLabels

let envPushTyvars emEnv tys = {emEnv with emTyvars = tys :: emEnv.emTyvars}
let envPopTyvars emEnv = {emEnv with emTyvars = List.tail emEnv.emTyvars}
Expand All @@ -487,7 +480,7 @@ let envGetTyvar emEnv u16 =
else
tvs.[i]

let isEmittedTypeRef emEnv tref = Zmap.mem tref emEnv.emTypMap
let isEmittedTypeRef emEnv tref = Map.containsKey tref emEnv.emTypMap

let envAddEntryPt emEnv mref = {emEnv with emEntryPts = mref::emEnv.emEntryPts}
let envPopEntryPts emEnv = {emEnv with emEntryPts = []}, emEnv.emEntryPts
Expand Down Expand Up @@ -2147,6 +2140,6 @@ let LookupTypeRef cenv emEnv tref = convCreatedTypeRef cenv emEnv tref
let LookupType cenv emEnv ty = convCreatedType cenv emEnv ty

// Lookups of ILFieldRef and MethodRef may require a similar non-Builder-fixup post Type-creation.
let LookupFieldRef emEnv fref = Zmap.tryFind fref emEnv.emFieldMap |> Option.map (fun fieldBuilder -> fieldBuilder :> FieldInfo)
let LookupMethodRef emEnv mref = Zmap.tryFind mref emEnv.emMethMap |> Option.map (fun methodBuilder -> methodBuilder :> MethodInfo)
let LookupFieldRef emEnv fref = Map.tryFind fref emEnv.emFieldMap |> Option.map (fun fieldBuilder -> fieldBuilder :> FieldInfo)
let LookupMethodRef emEnv mref = Map.tryFind mref emEnv.emMethMap |> Option.map (fun methodBuilder -> methodBuilder :> MethodInfo)

47 changes: 0 additions & 47 deletions src/absil/zmap.fs

This file was deleted.

45 changes: 0 additions & 45 deletions src/absil/zmap.fsi

This file was deleted.

43 changes: 0 additions & 43 deletions src/absil/zset.fs

This file was deleted.

42 changes: 0 additions & 42 deletions src/absil/zset.fsi

This file was deleted.

Loading