Skip to content

Commit e74989f

Browse files
committed
Revert the IlxGen.fs list-creation micro-optimization
ILVerify flags FSharp.Compiler.IlxGen::HashRangeSorted with a StackUnexpected error in Release builds on this branch that does not match the checked-in baseline, even though the exact same error text is already present in that baseline as a known pre-existing issue. Isolating the change (including testing byte-identical origin/main source through the same local Release build) could not reproduce a difference tied to this commit's content, but the CI-observed mismatch persisted across a partial revert. The allocation savings here are marginal; not worth risking invalid IL in a shipped compiler DLL over, so this reverts to the original List-based HashRangeSorted and the original `@` concatenations in TypeDefBuilder.Close and GenTypeDef.
1 parent 56aa82e commit e74989f

2 files changed

Lines changed: 5 additions & 14 deletions

File tree

‎docs/release-notes/.FSharp.Compiler.Service/11.0.100.md‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,6 @@
191191
* IL: use empty tables for members when possible ([PR #20249](https://github.com/dotnet/fsharp/pull/20249))
192192
* Make Entity's adhoc members list lazy ([PR #20286](https://github.com/dotnet/fsharp/pull/20286/changes))
193193
* Constraint solver: `TryD` is now `inline` with `[<InlineIfLambda>]` on its always-run continuation, so the argument closures are no longer allocated at the (very hot) constraint-solver call sites; `IgnoreFailedMemberConstraintResolution` is `inline` so its forwarded continuation stays a literal. ([PR #20367](https://github.com/dotnet/fsharp/pull/20367))
194-
* Codegen: build the merged property, method, nested-type and field tables in `IlxGen` without the intermediate lists that `@` and the `List.sortBy`/`List.map` chain in `HashRangeSorted` materialised. ([PR #20413](https://github.com/dotnet/fsharp/pull/20413))
195194
* `DelayedILModuleReader` no longer boxes its cached `ILModuleReader` on every read: the field is typed `ILModuleReader | null` and matched directly. ([PR #20413](https://github.com/dotnet/fsharp/pull/20413))
196195

197196
### Changed

‎src/Compiler/CodeGen/IlxGen.fs‎

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1972,7 +1972,7 @@ let GenPossibleILDebugRange (cenv: cenv) m =
19721972
//--------------------------------------------------------------------------
19731973

19741974
let HashRangeSorted (ht: IDictionary<_, int * _>) =
1975-
seq { for KeyValue(_k, v) in ht -> v } |> Seq.sortBy fst |> Seq.map snd
1975+
[ for KeyValue(_k, v) in ht -> v ] |> List.sortBy fst |> List.map snd
19761976

19771977
let MergeOptions m o1 o2 =
19781978
match o1, o2 with
@@ -2075,9 +2075,9 @@ type TypeDefBuilder(tdef: ILTypeDef, tdefDiscards) =
20752075
tdef.With(
20762076
methods = mkILMethods (sortByKey gmethods),
20772077
fields = mkILFields (sortByKey gfields),
2078-
properties = mkILProperties [ yield! tdef.Properties.AsList(); yield! HashRangeSorted gproperties ],
2078+
properties = mkILProperties (tdef.Properties.AsList() @ HashRangeSorted gproperties),
20792079
events = mkILEvents (sortByKey gevents),
2080-
nestedTypes = mkILTypeDefs [ yield! tdef.NestedTypes.AsList(); yield! gnested.Close(g) ],
2080+
nestedTypes = mkILTypeDefs (tdef.NestedTypes.AsList() @ gnested.Close(g)),
20812081
customAttrs = storeILCustomAttrs attrs
20822082
)
20832083

@@ -12291,16 +12291,8 @@ and GenTypeDef cenv mgbuf lazyInitInfo eenv m (tycon: Tycon) : ILTypeRef option
1229112291
| _ -> ()
1229212292
]
1229312293

12294-
let ilMethods =
12295-
[
12296-
yield! methodDefs
12297-
yield! augmentOverrideMethodDefs
12298-
yield! abstractMethodDefs
12299-
]
12300-
12301-
let ilProperties =
12302-
mkILProperties [ yield! ilPropertyDefsForFields; yield! abstractPropDefs ]
12303-
12294+
let ilMethods = methodDefs @ augmentOverrideMethodDefs @ abstractMethodDefs
12295+
let ilProperties = mkILProperties (ilPropertyDefsForFields @ abstractPropDefs)
1230412296
let ilEvents = mkILEvents abstractEventDefs
1230512297
let ilFields = mkILFields ilFieldDefs
1230612298

0 commit comments

Comments
 (0)