Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commited152d7

Browse files
AviAvniKevinRansom
authored andcommitted
Reduce memory footprint for Entity type (dotnet#4429)
* add entity_compiled_name, entity_other_range to EntityOptionalData* add entity_kind to EntityOptionalData* add entity_xmldoc, entity_xmldocsig to EntityOptionalData* add entity_tycon_abbrev to EntityOptionalData* add entity_tycon_repr_accessibility, entity_accessiblity to EntityOptionalData* add entity_exn_info to EntityOptionalData* remove XmlDocSif from TastPickle* fix unit check* add namespace check for unit
1 parent6d50665 commited152d7

File tree

5 files changed

+202
-159
lines changed

5 files changed

+202
-159
lines changed

‎src/fsharp/TastOps.fs‎

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5030,14 +5030,19 @@ and copyAndRemapAndBindTyconsAndVals g compgen tmenv tycons vs =
50305030

50315031
(tycons, tycons')||> List.iter2(fun tcd tcd'->
50325032
lettps',tmenvinner2= tmenvCopyRemapAndBindTypars(remapAttribs g tmenvinner) tmenvinner(tcd.entity_typars.Force(tcd.entity_range))
5033-
tcd'.entity_typars<- LazyWithContext.NotLazy tps';
5034-
tcd'.entity_attribs<- tcd.entity_attribs|> remapAttribs g tmenvinner2;
5035-
tcd'.entity_tycon_repr<- tcd.entity_tycon_repr|> remapTyconRepr g tmenvinner2;
5036-
tcd'.entity_tycon_abbrev<-tcd.entity_tycon_abbrev|> Option.map(remapType tmenvinner2);
5037-
tcd'.entity_tycon_tcaug<- tcd.entity_tycon_tcaug|> remapTyconAug tmenvinner2;
5033+
tcd'.entity_typars<- LazyWithContext.NotLazy tps'
5034+
tcd'.entity_attribs<- tcd.entity_attribs|> remapAttribs g tmenvinner2
5035+
tcd'.entity_tycon_repr<- tcd.entity_tycon_repr|> remapTyconRepr g tmenvinner2
5036+
lettypeAbbrevR=tcd.TypeAbbrev|> Option.map(remapType tmenvinner2)
5037+
tcd'.entity_tycon_tcaug<- tcd.entity_tycon_tcaug|> remapTyconAug tmenvinner2
50385038
tcd'.entity_modul_contents<- MaybeLazy.Strict(tcd.entity_modul_contents.Value
5039-
|> mapImmediateValsAndTycons lookupTycon lookupVal);
5040-
tcd'.entity_exn_info<- tcd.entity_exn_info|> remapTyconExnInfo g tmenvinner2);
5039+
|> mapImmediateValsAndTycons lookupTycon lookupVal)
5040+
letexnInfoR= tcd.ExceptionInfo|> remapTyconExnInfo g tmenvinner2
5041+
match tcd'.entity_opt_datawith
5042+
| Some optData-> tcd'.entity_opt_data<- Some{ optDatawith entity_tycon_abbrev= typeAbbrevR; entity_exn_info= exnInfoR}
5043+
|_->
5044+
tcd'.SetTypeAbbrev typeAbbrevR
5045+
tcd'.SetExceptionInfo exnInfoR)
50415046
tycons', vs', tmenvinner
50425047

50435048

@@ -7773,17 +7778,26 @@ let MakeExportRemapping viewedCcu (mspec:ModuleOrNamespace) =
77737778

77747779
let recremapEntityDataToNonLocal g tmenv(d:Entity)=
77757780
lettps',tmenvinner= tmenvCopyRemapAndBindTypars(remapAttribs g tmenv) tmenv(d.entity_typars.Force(d.entity_range))
7776-
7781+
lettyparsR= LazyWithContext.NotLazy tps'
7782+
letattribsR= d.entity_attribs|> remapAttribs g tmenvinner
7783+
lettyconReprR= d.entity_tycon_repr|> remapTyconRepr g tmenvinner
7784+
lettyconAbbrevR= d.TypeAbbrev|> Option.map(remapType tmenvinner)
7785+
lettyconTcaugR= d.entity_tycon_tcaug|> remapTyconAug tmenvinner
7786+
letmodulContentsR=
7787+
MaybeLazy.Strict(d.entity_modul_contents.Value
7788+
|> mapImmediateValsAndTycons(remapTyconToNonLocal g tmenv)(remapValToNonLocal g tmenv))
7789+
letexnInfoR= d.ExceptionInfo|> remapTyconExnInfo g tmenvinner
77777790
{ dwith
7778-
entity_typars= LazyWithContext.NotLazy tps';
7779-
entity_attribs= d.entity_attribs|> remapAttribs g tmenvinner;
7780-
entity_tycon_repr= d.entity_tycon_repr|> remapTyconRepr g tmenvinner;
7781-
entity_tycon_abbrev= d.entity_tycon_abbrev|> Option.map(remapType tmenvinner);
7782-
entity_tycon_tcaug= d.entity_tycon_tcaug|> remapTyconAug tmenvinner;
7783-
entity_modul_contents=
7784-
MaybeLazy.Strict(d.entity_modul_contents.Value
7785-
|> mapImmediateValsAndTycons(remapTyconToNonLocal g tmenv)(remapValToNonLocal g tmenv));
7786-
entity_exn_info= d.entity_exn_info|> remapTyconExnInfo g tmenvinner}
7791+
entity_typars= typarsR
7792+
entity_attribs= attribsR
7793+
entity_tycon_repr= tyconReprR
7794+
entity_tycon_tcaug= tyconTcaugR
7795+
entity_modul_contents= modulContentsR
7796+
entity_opt_data=
7797+
match d.entity_opt_datawith
7798+
| Some dd->
7799+
Some{ ddwith entity_tycon_abbrev= tyconAbbrevR; entity_exn_info= exnInfoR}
7800+
|_-> None}
77877801

77887802
andremapTyconToNonLocal g tmenv x=
77897803
x|> NewModifiedTycon(remapEntityDataToNonLocal g tmenv)

‎src/fsharp/TastPickle.fs‎

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1706,23 +1706,23 @@ and p_rfield_table x st =
17061706
andp_entity_spec_data(x:Entity)st=
17071707
p_typar_specs(x.entity_typars.Force(x.entity_range)) st
17081708
p_string x.entity_logical_name st
1709-
p_option p_string x.entity_compiled_name st
1709+
p_option p_string x.EntityCompiledName st
17101710
p_range x.entity_range st
17111711
p_option p_pubpath x.entity_pubpath st
1712-
p_access x.entity_accessiblity st
1713-
p_access x.entity_tycon_repr_accessibility st
1712+
p_access x.Accessibility st
1713+
p_access x.TypeReprAccessibility st
17141714
p_attribs x.entity_attribs st
17151715
letflagBit= p_tycon_repr x.entity_tycon_repr st
1716-
p_option p_typ x.entity_tycon_abbrev st
1716+
p_option p_typ x.TypeAbbrev st
17171717
p_tcaug x.entity_tycon_tcaug st
1718-
p_stringx.entity_xmldocsig st
1719-
p_kind x.entity_kind st
1718+
p_stringSystem.String.Empty st
1719+
p_kind x.TypeOrMeasureKind st
17201720
p_int64(x.entity_flags.PickledBits|||(if flagBitthen EntityFlags.ReservedBitForPickleFormatTyconReprFlagelse0L)) st
17211721
p_option p_cpath x.entity_cpath st
17221722
p_maybe_lazy p_modul_typ x.entity_modul_contents st
1723-
p_exnc_repr x.entity_exn_info st
1723+
p_exnc_repr x.ExceptionInfo st
17241724
if st.oInMemthen
1725-
p_used_space1(p_xmldoc x.entity_xmldoc) st
1725+
p_used_space1(p_xmldoc x.XmlDoc) st
17261726
else
17271727
p_space1() st
17281728

@@ -1959,7 +1959,7 @@ and u_recdfield_spec st =
19591959
andu_rfield_table st= MakeRecdFieldsTable(u_list u_recdfield_spec st)
19601960

19611961
andu_entity_spec_data st:Entity=
1962-
letx1,x2a,x2b,x2c,x3,(x4a,x4b),x6,x7f,x8,x9,x10,x10b,x11,x12,x13,x14,x15=
1962+
letx1,x2a,x2b,x2c,x3,(x4a,x4b),x6,x7f,x8,x9,_x10,x10b,x11,x12,x13,x14,x15=
19631963
u_tup17
19641964
u_typar_specs
19651965
u_string
@@ -1986,25 +1986,20 @@ and u_entity_spec_data st : Entity =
19861986
{ entity_typars=LazyWithContext.NotLazy x1
19871987
entity_stamp=newStamp()
19881988
entity_logical_name=x2a
1989-
entity_compiled_name=x2b
19901989
entity_range=x2c
1991-
entity_other_range=None
19921990
entity_pubpath=x3
1993-
entity_accessiblity=x4a
1994-
entity_tycon_repr_accessibility=x4b
19951991
entity_attribs=x6
19961992
entity_tycon_repr=x7
1997-
entity_tycon_abbrev=x8
19981993
entity_tycon_tcaug=x9
1999-
entity_xmldoc= defaultArg x15 XmlDoc.Empty
2000-
entity_xmldocsig=x10
2001-
entity_kind=x10b
20021994
entity_flags=EntityFlags(x11)
20031995
entity_cpath=x12
20041996
entity_modul_contents=MaybeLazy.Lazy x13
2005-
entity_exn_info=x14
20061997
entity_il_repr_cache=newCache()
2007-
}
1998+
entity_opt_data=
1999+
match x2b, x10b, x15, x8, x4a, x4b, x14with
2000+
| None, TyparKind.Type, None, None, TAccess[], TAccess[], TExnNone-> None
2001+
|_-> Some{ Entity.EmptyEntityOptDatawith entity_compiled_name= x2b; entity_kind= x10b; entity_xmldoc= defaultArg x15 XmlDoc.Empty; entity_xmldocsig= System.String.Empty; entity_tycon_abbrev= x8; entity_accessiblity= x4a; entity_tycon_repr_accessibility= x4b; entity_exn_info= x14}
2002+
}
20082003

20092004
andu_tcaug st=
20102005
leta1,a2,a3,b2,c,d,e,g,_space=

‎src/fsharp/TypeChecker.fs‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14358,7 +14358,7 @@ module TcExceptionDeclarations =
1435814358
| None ->
1435914359
TExnFresh (MakeRecdFieldsTable args')
1436014360

14361-
exnc.entity_exn_info <- repr
14361+
exnc.SetExceptionInfo repr
1436214362

1436314363
let item = Item.ExnCase(mkLocalTyconRef exnc)
1436414364
CallNameResolutionSink cenv.tcSink (id.idRange, env.NameEnv, item, item, emptyTyparInst, ItemOccurence.Binding, env.DisplayEnv, env.eAccessRights)
@@ -14665,10 +14665,10 @@ module EstablishTypeDefinitionCores =
1466514665
tycon.SetIsStructRecordOrUnion isStructRecordOrUnionType
1466614666

1466714667
// Set the compiled name, if any
14668-
tycon.entity_compiled_name <-TryFindFSharpStringAttribute cenv.g cenv.g.attrib_CompiledNameAttribute attrs
14668+
tycon.SetCompiledName (TryFindFSharpStringAttribute cenv.g cenv.g.attrib_CompiledNameAttribute attrs)
1466914669

1467014670
if hasMeasureAttr then
14671-
tycon.entity_kind <- TyparKind.Measure
14671+
tycon.SetTypeOrMeasureKind TyparKind.Measure
1467214672
if not (isNil typars) then error(Error(FSComp.SR.tcMeasureDefinitionsCannotHaveTypeParameters(), m))
1467314673

1467414674
let repr =
@@ -14990,7 +14990,7 @@ module EstablishTypeDefinitionCores =
1499014990
errorR(Deprecated(FSComp.SR.tcTypeAbbreviationHasTypeParametersMissingOnType(), tycon.Range))
1499114991

1499214992
if firstPass then
14993-
tycon.entity_tycon_abbrev <-Some ty
14993+
tycon.SetTypeAbbrev (Some ty)
1499414994

1499514995
| _ -> ()
1499614996

@@ -15507,7 +15507,7 @@ module EstablishTypeDefinitionCores =
1550715507
graph.IterateCycles (fun path ->
1550815508
let tycon = path.Head
1550915509
// The thing is cyclic. Set the abbreviation and representation to be "None" to stop later VS crashes
15510-
tycon.entity_tycon_abbrev <- None
15510+
tycon.SetTypeAbbrev None
1551115511
tycon.entity_tycon_repr <- TNoRepr
1551215512
errorR(Error(FSComp.SR.tcTypeDefinitionIsCyclic(), tycon.Range)))
1551315513

@@ -15642,7 +15642,7 @@ module EstablishTypeDefinitionCores =
1564215642
graph.IterateCycles (fun path ->
1564315643
let tycon = path.Head
1564415644
// The thing is cyclic. Set the abbreviation and representation to be "None" to stop later VS crashes
15645-
tycon.entity_tycon_abbrev <- None
15645+
tycon.SetTypeAbbrev None
1564615646
tycon.entity_tycon_repr <- TNoRepr
1564715647
errorR(Error(FSComp.SR.tcTypeDefinitionIsCyclicThroughInheritance(), tycon.Range)))
1564815648

‎src/fsharp/service/ServiceInterfaceStubGenerator.fs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ module internal InterfaceStubGenerator =
213213
letnm=
214214
match arg.Namewith
215215
| None->
216-
if arg.Type.HasTypeDefinition&& arg.Type.TypeDefinition.XmlDocSig="T:Microsoft.FSharp.Core.unit"then"()"
216+
if arg.Type.HasTypeDefinition&& arg.Type.TypeDefinition.CompiledName="unit"&& arg.Type.TypeDefinition.Namespace= Some"Microsoft.FSharp.Core"then"()"
217217
else sprintf"arg%d"(namesWithIndices|> Map.toSeq|> Seq.map snd|> Seq.sumBy Set.count|> max1)
218218
| Some x-> x
219219

@@ -302,7 +302,8 @@ module internal InterfaceStubGenerator =
302302
letargs,namesWithIndices=
303303
match argInfoswith
304304
|[[x]]when v.IsPropertyGetterMethod&& x.Name.IsNone
305-
&& x.Type.TypeDefinition.XmlDocSig="T:Microsoft.FSharp.Core.unit"->
305+
&& x.Type.TypeDefinition.CompiledName="unit"
306+
&& x.Type.TypeDefinition.Namespace= Some"Microsoft.FSharp.Core"->
306307
"", Map.ofList[ctx.ObjectIdent, Set.empty]
307308
|_-> formatArgsUsage ctx verboseMode v argInfos
308309

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp