Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
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
1 change: 1 addition & 0 deletions docs/release-notes/.FSharp.Compiler.Service/9.0.100.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
### Changed
* Change compiler default setting realsig+ when building assemblies ([Issue #17384](https://github.com/dotnet/fsharp/issues/17384), [PR #17378](https://github.com/dotnet/fsharp/pull/17385))
* Change compiler default setting for compressedMetadata ([Issue #17379](https://github.com/dotnet/fsharp/issues/17379), [PR #17383](https://github.com/dotnet/fsharp/pull/17383))
* Optimize metadata reading for type members and custom attributes. ([PR #17364](https://github.com/dotnet/fsharp/pull/17364))

### Breaking Changes
74 changes: 47 additions & 27 deletions src/Compiler/AbstractIL/ilread.fs
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@ let tomdCompare (TaggedIndex(t1: TypeOrMethodDefTag, idx1)) (TaggedIndex(t2: Typ
elif idx1 > idx2 then 1
else compare t1.Tag t2.Tag

let simpleIndexCompare (idx1: int) (idx2: int) = compare idx1 idx2
let inline simpleIndexCompare (idx1: int) (idx2: int) = compare idx1 idx2

//---------------------------------------------------------------------
// The various keys for the various caches.
Expand Down Expand Up @@ -2305,18 +2305,23 @@ and seekReadTypeDefAsTypeUncached ctxtH (TypeDefAsTypIdx(boxity, ginst, idx)) =
mkILTy boxity (ILTypeSpec.Create(seekReadTypeDefAsTypeRef ctxt idx, ginst))

and seekReadTypeDefAsTypeRef (ctxt: ILMetadataReader) idx =
let mdv = ctxt.mdfile.GetView()

let enc =
if seekIsTopTypeDefOfIdx ctxt idx then
[]
else
let enclIdx =
seekReadIndexedRow (
ctxt.getNumRows TableNames.Nested,
seekReadNestedRow ctxt,
fst,
simpleIndexCompare idx,
id,
id,
(fun i ->
let mutable addr = ctxt.rowAddr TableNames.Nested i
let nestedIdx = seekReadUntaggedIdx TableNames.TypeDef ctxt mdv &addr
simpleIndexCompare idx nestedIdx),
isSorted ctxt TableNames.Nested,
snd
(fun i -> seekReadNestedRow ctxt i |> snd)
)

let tref = seekReadTypeDefAsTypeRef ctxt enclIdx
Expand Down Expand Up @@ -3077,15 +3082,18 @@ and seekReadMethodImpls (ctxt: ILMetadataReader) numTypars tidx =
let mimpls =
seekReadIndexedRows (
ctxt.getNumRows TableNames.MethodImpl,
seekReadMethodImplRow ctxt mdv,
(fun (a, _, _) -> a),
simpleIndexCompare tidx,
id,
id,
(fun i ->
let mutable addr = ctxt.rowAddr TableNames.MethodImpl i
let _tidx = seekReadUntaggedIdx TableNames.TypeDef ctxt mdv &addr
simpleIndexCompare tidx _tidx),
isSorted ctxt TableNames.MethodImpl,
(fun (_, b, c) -> b, c)
seekReadMethodImplRow ctxt mdv
)

mimpls
|> List.map (fun (b, c) ->
|> List.map (fun (_, b, c) ->
{
OverrideBy =
let (MethodData(enclTy, cc, nm, argTys, retTy, methInst)) =
Expand Down Expand Up @@ -3154,11 +3162,14 @@ and seekReadEvents (ctxt: ILMetadataReader) numTypars tidx =
match
seekReadOptionalIndexedRow (
ctxt.getNumRows TableNames.EventMap,
(fun i -> i, seekReadEventMapRow ctxt mdv i),
(fun (_, row) -> fst row),
compare tidx,
id,
id,
(fun i ->
let mutable addr = ctxt.rowAddr TableNames.EventMap i
let _tidx = seekReadUntaggedIdx TableNames.TypeDef ctxt mdv &addr
simpleIndexCompare tidx _tidx),
false,
(fun (i, row) -> (i, snd row))
(fun i -> i, seekReadEventMapRow ctxt mdv i |> snd)
)
with
| None -> []
Expand Down Expand Up @@ -3221,11 +3232,14 @@ and seekReadProperties (ctxt: ILMetadataReader) numTypars tidx =
match
seekReadOptionalIndexedRow (
ctxt.getNumRows TableNames.PropertyMap,
(fun i -> i, seekReadPropertyMapRow ctxt mdv i),
(fun (_, row) -> fst row),
compare tidx,
id,
id,
(fun i ->
let mutable addr = ctxt.rowAddr TableNames.PropertyMap i
let _tidx = seekReadUntaggedIdx TableNames.TypeDef ctxt mdv &addr
simpleIndexCompare tidx _tidx),
false,
(fun (i, row) -> (i, snd row))
(fun i -> i, seekReadPropertyMapRow ctxt mdv i |> snd)
)
with
| None -> []
Expand All @@ -3249,16 +3263,22 @@ and customAttrsReader ctxtH tag : ILAttributesStored =
let (ctxt: ILMetadataReader) = getHole ctxtH
let mdv = ctxt.mdfile.GetView()

let reader =
{ new ISeekReadIndexedRowReader<CustomAttributeRow, TaggedIndex<HasCustomAttributeTag>, ILAttribute> with
member _.GetRow(i, row) =
seekReadCustomAttributeRow ctxt mdv i &row

member _.GetKey(attrRow) = attrRow.parentIndex

member _.CompareKey(key) = hcaCompare (TaggedIndex(tag, idx)) key
let searchedKey = TaggedIndex(tag, idx)

member _.ConvertRow(attrRow) =
let reader =
{ new ISeekReadIndexedRowReader<int, int, ILAttribute> with
member _.GetRow(i, rowIndex) = rowIndex <- i
member _.GetKey(rowIndex) = rowIndex

member _.CompareKey(rowIndex) =
let mutable addr = ctxt.rowAddr TableNames.CustomAttribute rowIndex
// read parentIndex
let key = seekReadHasCustomAttributeIdx ctxt mdv &addr
hcaCompare searchedKey key

member _.ConvertRow(rowIndex) =
let mutable attrRow = Unchecked.defaultof<_>
seekReadCustomAttributeRow ctxt mdv rowIndex &attrRow
seekReadCustomAttr ctxt (attrRow.typeIndex, attrRow.valueIndex)
}

Expand Down