Skip to content
This repository was archived by the owner on Dec 23, 2024. It is now read-only.

Commit fd12a2e

Browse files
TIHannosami
authored andcommitted
Stack-overflow fix (dotnet#10868)
* Backing out stackoverflow fix by delayed gen methods * Trying to lazily gen IL * Making ILMethodBody.IL be lazy * Consolidating lazy methodbodies by removing ILLazyMethodBody * Updating baseline and fixing build * Minor change
1 parent 242bd44 commit fd12a2e

File tree

10 files changed

+152
-140
lines changed

10 files changed

+152
-140
lines changed

src/fsharp/IlxGen.fs

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4371,7 +4371,7 @@ and GenObjectMethod cenv eenvinner (cgbuf: CodeGenBuffer) useMethodImpl tmethod
43714371
GenGenericParams cenv eenvUnderTypars methTyparsOfOverridingMethod,
43724372
ilParamsOfOverridingMethod,
43734373
ilReturnOfOverridingMethod,
4374-
MethodBody.IL ilMethodBody)
4374+
MethodBody.IL (lazy ilMethodBody))
43754375
// fixup attributes to generate a method impl
43764376
let mdef = if useMethodImpl then fixupMethodImplFlags mdef else mdef
43774377
let mdef = fixupVirtualSlotFlags mdef
@@ -4473,20 +4473,20 @@ and GenSequenceExpr
44734473
CG.EmitInstr cgbuf (pop ilCloAllFreeVars.Length) (Push [ilCloRetTyInner]) (I_newobj (formalClospec.Constructor, None))
44744474
GenSequel cenv eenv.cloc cgbuf Return),
44754475
m)
4476-
mkILNonGenericVirtualMethod("GetFreshEnumerator", ILMemberAccess.Public, [], mkILReturn ilCloEnumeratorTy, MethodBody.IL mbody)
4476+
mkILNonGenericVirtualMethod("GetFreshEnumerator", ILMemberAccess.Public, [], mkILReturn ilCloEnumeratorTy, MethodBody.IL (lazy mbody))
44774477
|> AddNonUserCompilerGeneratedAttribs g
44784478

44794479
let closeMethod =
44804480
// Note: We suppress the first sequence point in the body of this method since it is the initial state machine jump
44814481
let spReq = SPSuppress
44824482
let ilCode = CodeGenMethodForExpr cenv cgbuf.mgbuf (spReq, [], "Close", eenvinner, 1, closeExpr, discardAndReturnVoid)
4483-
mkILNonGenericVirtualMethod("Close", ILMemberAccess.Public, [], mkILReturn ILType.Void, MethodBody.IL ilCode)
4483+
mkILNonGenericVirtualMethod("Close", ILMemberAccess.Public, [], mkILReturn ILType.Void, MethodBody.IL (lazy ilCode))
44844484

44854485
let checkCloseMethod =
44864486
// Note: We suppress the first sequence point in the body of this method since it is the initial state machine jump
44874487
let spReq = SPSuppress
44884488
let ilCode = CodeGenMethodForExpr cenv cgbuf.mgbuf (spReq, [], "get_CheckClose", eenvinner, 1, checkCloseExpr, Return)
4489-
mkILNonGenericVirtualMethod("get_CheckClose", ILMemberAccess.Public, [], mkILReturn g.ilg.typ_Bool, MethodBody.IL ilCode)
4489+
mkILNonGenericVirtualMethod("get_CheckClose", ILMemberAccess.Public, [], mkILReturn g.ilg.typ_Bool, MethodBody.IL (lazy ilCode))
44904490

44914491
let generateNextMethod =
44924492
// Note: We suppress the first sequence point in the body of this method since it is the initial state machine jump
@@ -4495,12 +4495,12 @@ and GenSequenceExpr
44954495
let eenvinner = eenvinner |> AddStorageForLocalVals g [ (nextEnumeratorValRef.Deref, Arg 1) ]
44964496
let ilParams = [mkILParamNamed("next", ILType.Byref ilCloEnumerableTy)]
44974497
let ilReturn = mkILReturn g.ilg.typ_Int32
4498-
let ilCode = MethodBody.IL (CodeGenMethodForExpr cenv cgbuf.mgbuf (spReq, [], "GenerateNext", eenvinner, 2, generateNextExpr, Return))
4498+
let ilCode = MethodBody.IL (lazy (CodeGenMethodForExpr cenv cgbuf.mgbuf (spReq, [], "GenerateNext", eenvinner, 2, generateNextExpr, Return)))
44994499
mkILNonGenericVirtualMethod("GenerateNext", ILMemberAccess.Public, ilParams, ilReturn, ilCode)
45004500

45014501
let lastGeneratedMethod =
45024502
let ilCode = CodeGenMethodForExpr cenv cgbuf.mgbuf (SPSuppress, [], "get_LastGenerated", eenvinner, 1, exprForValRef m currvref, Return)
4503-
mkILNonGenericVirtualMethod("get_LastGenerated", ILMemberAccess.Public, [], mkILReturn ilCloSeqElemTy, MethodBody.IL ilCode)
4503+
mkILNonGenericVirtualMethod("get_LastGenerated", ILMemberAccess.Public, [], mkILReturn ilCloSeqElemTy, MethodBody.IL (lazy ilCode))
45044504
|> AddNonUserCompilerGeneratedAttribs g
45054505

45064506
let ilCtorBody =
@@ -4543,7 +4543,7 @@ and GenClosureTypeDefs cenv (tref: ILTypeRef, ilGenParams, attrs, ilCloAllFreeVa
45434543
let fspec = mkILFieldSpec (cloSpec.GetStaticFieldSpec().FieldRef, cloTy)
45444544
let ctorSpec = mkILMethSpecForMethRefInTy (cloSpec.Constructor.MethodRef, cloTy, [])
45454545
let ilCode = mkILMethodBody (true, [], 8, nonBranchingInstrsToCode ([ I_newobj (ctorSpec, None); mkNormalStsfld fspec ]), None)
4546-
let cctor = mkILClassCtor (MethodBody.IL ilCode)
4546+
let cctor = mkILClassCtor (MethodBody.IL (lazy ilCode))
45474547
let ilFieldDef = mkILStaticField(fspec.Name, fspec.FormalType, None, None, ILMemberAccess.Assembly).WithInitOnly(true)
45484548
(cctor :: mdefs), [ ilFieldDef ]
45494549
else
@@ -4642,7 +4642,7 @@ and GenLambdaClosure cenv (cgbuf: CodeGenBuffer) eenv isLocalTypeFunc thisVars e
46424642
cgbuf.mgbuf.AddTypeDef(ilContractTypeRef, ilContractTypeDef, false, false, None)
46434643

46444644
let ilCtorBody = mkILMethodBody (true, [], 8, nonBranchingInstrsToCode (mkCallBaseConstructor(ilContractTy, [])), None )
4645-
let cloMethods = [ mkILGenericVirtualMethod("DirectInvoke", ILMemberAccess.Assembly, cloinfo.localTypeFuncDirectILGenericParams, [], mkILReturn (cloinfo.ilCloFormalReturnTy), MethodBody.IL ilCloBody) ]
4645+
let cloMethods = [ mkILGenericVirtualMethod("DirectInvoke", ILMemberAccess.Assembly, cloinfo.localTypeFuncDirectILGenericParams, [], mkILReturn (cloinfo.ilCloFormalReturnTy), MethodBody.IL(lazy ilCloBody)) ]
46464646
let cloTypeDefs = GenClosureTypeDefs cenv (ilCloTypeRef, cloinfo.cloILGenericParams, [], cloinfo.ilCloAllFreeVars, cloinfo.ilCloLambdas, ilCtorBody, cloMethods, [], ilContractTy, [], Some cloinfo.cloSpec)
46474647
cloTypeDefs
46484648

@@ -5039,7 +5039,7 @@ and GenDelegateExpr cenv cgbuf eenvouter expr (TObjExprMethod((TSlotSig(_, deleg
50395039
ILMemberAccess.Assembly,
50405040
ilDelegeeParams,
50415041
ilDelegeeRet,
5042-
MethodBody.IL ilMethodBody)
5042+
MethodBody.IL(lazy ilMethodBody))
50435043
let delegeeCtorMeth = mkILSimpleStorageCtor(None, Some g.ilg.typ_Object.TypeSpec, ilDelegeeTyInner, [], [], ILMemberAccess.Assembly)
50445044
let ilCtorBody = delegeeCtorMeth.MethodBody
50455045

@@ -5616,8 +5616,7 @@ and GenBindingAfterDebugPoint cenv cgbuf eenv sp (TBind(vspec, rhsExpr, _)) star
56165616

56175617
CommitStartScope cgbuf startScopeMarkOpt
56185618

5619-
// if we have any expression recursion depth, we should delay the generation of a method to prevent stack overflows
5620-
let generator = if cenv.exprRecursionDepth > 0 then DelayGenMethodForBinding else GenMethodForBinding
5619+
let generator = GenMethodForBinding
56215620
let hasWitnessEntry = cenv.g.generateWitnesses && not witnessInfos.IsEmpty
56225621

56235622
generator cenv cgbuf.mgbuf eenv (vspec, mspec, hasWitnessEntry, false, access, ctps, mtps, [], curriedArgInfos, paramInfos, argTys, retInfo, topValInfo, methLambdaCtorThisValOpt, methLambdaBaseValOpt, methLambdaTypars, methLambdaVars, methLambdaBody, methLambdaBodyTy)
@@ -5645,7 +5644,8 @@ and GenBindingAfterDebugPoint cenv cgbuf eenv sp (TBind(vspec, rhsExpr, _)) star
56455644
cgbuf.mgbuf.AddOrMergePropertyDef(ilGetterMethSpec.MethodRef.DeclaringTypeRef, ilPropDef, m)
56465645

56475646
let ilMethodDef =
5648-
let ilMethodBody = MethodBody.IL(CodeGenMethodForExpr cenv cgbuf.mgbuf (SPSuppress, [], ilGetterMethSpec.Name, eenv, 0, rhsExpr, Return))
5647+
let ilCode = CodeGenMethodForExpr cenv cgbuf.mgbuf (SPSuppress, [], ilGetterMethSpec.Name, eenv, 0, rhsExpr, Return)
5648+
let ilMethodBody = MethodBody.IL(lazy ilCode)
56495649
(mkILStaticMethod ([], ilGetterMethSpec.Name, access, [], mkILReturn ilTy, ilMethodBody)).WithSpecialName
56505650
|> AddNonUserCompilerGeneratedAttribs g
56515651

@@ -6188,10 +6188,20 @@ and GenMethodForBinding
61886188
else
61896189
body
61906190

6191-
let ilCode = CodeGenMethodForExpr cenv mgbuf (SPAlways, tailCallInfo, mspec.Name, eenvForMeth, 0, bodyExpr, sequel)
6191+
let ilCodeLazy = lazy CodeGenMethodForExpr cenv mgbuf (SPAlways, tailCallInfo, mspec.Name, eenvForMeth, 0, bodyExpr, sequel)
61926192

61936193
// This is the main code generation for most methods
6194-
false, MethodBody.IL ilCode, false
6194+
false, MethodBody.IL(ilCodeLazy), false
6195+
6196+
match ilMethodBody with
6197+
| MethodBody.IL(ilCodeLazy) ->
6198+
if cenv.exprRecursionDepth > 0 then
6199+
cenv.delayedGenMethods.Enqueue(fun _ -> ilCodeLazy.Force() |> ignore)
6200+
else
6201+
// Eagerly codegen if we are not in an expression depth.
6202+
ilCodeLazy.Force() |> ignore
6203+
| _ ->
6204+
()
61956205

61966206
// Do not generate DllImport attributes into the code - they are implicit from the P/Invoke
61976207
let attrs =
@@ -6396,7 +6406,7 @@ and GenPInvokeMethod (nm, dll, namedArgs) =
63966406

63976407
let hasPreserveSigNamedArg = decoder.FindBool "PreserveSig" true
63986408
hasPreserveSigNamedArg,
6399-
MethodBody.PInvoke
6409+
let pinvoke =
64006410
{ Where=mkSimpleModRef dll
64016411
Name=decoder.FindString "EntryPoint" nm
64026412
CallingConv=
@@ -6417,7 +6427,8 @@ and GenPInvokeMethod (nm, dll, namedArgs) =
64176427
NoMangle= decoder.FindBool "ExactSpelling" false
64186428
LastError= decoder.FindBool "SetLastError" false
64196429
ThrowOnUnmappableChar= if (decoder.FindBool "ThrowOnUnmappableChar" false) then PInvokeThrowOnUnmappableChar.Enabled else PInvokeThrowOnUnmappableChar.UseAssembly
6420-
CharBestFit=if (decoder.FindBool "BestFitMapping" false) then PInvokeCharBestFit.Enabled else PInvokeCharBestFit.UseAssembly }
6430+
CharBestFit=if (decoder.FindBool "BestFitMapping" false) then PInvokeCharBestFit.Enabled else PInvokeCharBestFit.UseAssembly } : PInvokeMethod
6431+
MethodBody.PInvoke(lazy pinvoke)
64216432

64226433
and GenBindings cenv cgbuf eenv binds = List.iter (GenBinding cenv cgbuf eenv) binds
64236434

@@ -7033,7 +7044,7 @@ and GenImplFile cenv (mgbuf: AssemblyBuilder) mainInfoOpt eenv (implFile: TypedI
70337044
// This adds the explicit init of the .cctor to the explicit entry point main method
70347045
mgbuf.AddExplicitInitToSpecificMethodDef((fun md -> md.IsEntryPoint), tref, fspec, GenPossibleILSourceMarker cenv m, feefee, seqpt))
70357046

7036-
let cctorMethDef = mkILClassCtor (MethodBody.IL topCode)
7047+
let cctorMethDef = mkILClassCtor (MethodBody.IL (lazy topCode))
70377048
mgbuf.AddMethodDef(initClassTy.TypeRef, cctorMethDef)
70387049

70397050
// Final file, implicit entry point. We generate no .cctor.
@@ -7048,7 +7059,7 @@ and GenImplFile cenv (mgbuf: AssemblyBuilder) mainInfoOpt eenv (implFile: TypedI
70487059

70497060
// generate main@
70507061
let ilMainMethodDef =
7051-
let mdef = mkILNonGenericStaticMethod(mainMethName, ILMemberAccess.Public, [], mkILReturn ILType.Void, MethodBody.IL topCode)
7062+
let mdef = mkILNonGenericStaticMethod(mainMethName, ILMemberAccess.Public, [], mkILReturn ILType.Void, MethodBody.IL (lazy topCode))
70527063
mdef.With(isEntryPoint= true, customAttrs = ilAttrs)
70537064

70547065
mgbuf.AddMethodDef(initClassTy.TypeRef, ilMainMethodDef)
@@ -7058,7 +7069,7 @@ and GenImplFile cenv (mgbuf: AssemblyBuilder) mainInfoOpt eenv (implFile: TypedI
70587069
| None ->
70597070
if doesSomething then
70607071
// Add the cctor
7061-
let cctorMethDef = mkILClassCtor (MethodBody.IL topCode)
7072+
let cctorMethDef = mkILClassCtor (MethodBody.IL (lazy topCode))
70627073
mgbuf.AddMethodDef(initClassTy.TypeRef, cctorMethDef)
70637074

70647075
// Commit the directed initializations

src/fsharp/absil/il.fs

Lines changed: 31 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1498,28 +1498,18 @@ type ILMethodVirtualInfo =
14981498

14991499
[<RequireQualifiedAccess>]
15001500
type MethodBody =
1501-
| IL of ILMethodBody
1502-
| PInvoke of PInvokeMethod (* platform invoke to native *)
1501+
| IL of Lazy<ILMethodBody>
1502+
| PInvoke of Lazy<PInvokeMethod> (* platform invoke to native *)
15031503
| Abstract
15041504
| Native
15051505
| NotAvailable
15061506

1507-
type ILLazyMethodBody =
1508-
| ILLazyMethodBody of Lazy<MethodBody >
1509-
1510-
member x.Contents = let (ILLazyMethodBody mb) = x in mb.Force()
1511-
static member NotAvailable = ILLazyMethodBody (notlazy MethodBody.NotAvailable)
1512-
15131507
[<RequireQualifiedAccess>]
15141508
type MethodCodeKind =
15151509
| IL
15161510
| Native
15171511
| Runtime
15181512

1519-
let mkMethBodyAux mb = ILLazyMethodBody (notlazy mb)
1520-
1521-
let mkMethBodyLazyAux mb = ILLazyMethodBody mb
1522-
15231513
let typesOfILParams (ps: ILParameters) : ILTypes = ps |> List.map (fun p -> p.Type)
15241514

15251515
[<StructuralEquality; StructuralComparison>]
@@ -1575,13 +1565,15 @@ let NoMetadataIdx = -1
15751565

15761566
[<NoComparison; NoEquality>]
15771567
type ILMethodDef (name: string, attributes: MethodAttributes, implAttributes: MethodImplAttributes, callingConv: ILCallingConv,
1578-
parameters: ILParameters, ret: ILReturn, body: ILLazyMethodBody, isEntryPoint: bool, genericParams: ILGenericParameterDefs,
1568+
parameters: ILParameters, ret: ILReturn, body: Lazy<MethodBody>, isEntryPoint: bool, genericParams: ILGenericParameterDefs,
15791569
securityDeclsStored: ILSecurityDeclsStored, customAttrsStored: ILAttributesStored, metadataIndex: int32) =
15801570

15811571
new (name, attributes, implAttributes, callingConv, parameters, ret, body, isEntryPoint, genericParams, securityDecls, customAttrs) =
15821572
ILMethodDef (name, attributes, implAttributes, callingConv, parameters, ret, body, isEntryPoint, genericParams,
15831573
storeILSecurityDecls securityDecls, storeILCustomAttrs customAttrs, NoMetadataIdx)
15841574

1575+
member private _.LazyBody = body
1576+
15851577
// The captured data - remember the object will be as large as the data captured by these members
15861578
member _.Name = name
15871579

@@ -1595,7 +1587,7 @@ type ILMethodDef (name: string, attributes: MethodAttributes, implAttributes: Me
15951587

15961588
member _.Return = ret
15971589

1598-
member _.Body = body
1590+
member _.Body = body.Value
15991591

16001592
member _.SecurityDeclsStored = securityDeclsStored
16011593

@@ -1609,7 +1601,7 @@ type ILMethodDef (name: string, attributes: MethodAttributes, implAttributes: Me
16091601

16101602
member x.With (?name: string, ?attributes: MethodAttributes, ?implAttributes: MethodImplAttributes,
16111603
?callingConv: ILCallingConv, ?parameters: ILParameters, ?ret: ILReturn,
1612-
?body: ILLazyMethodBody, ?securityDecls: ILSecurityDecls, ?isEntryPoint: bool,
1604+
?body: Lazy<MethodBody>, ?securityDecls: ILSecurityDecls, ?isEntryPoint: bool,
16131605
?genericParams: ILGenericParameterDefs, ?customAttrs: ILAttributes) =
16141606

16151607
ILMethodDef (name = defaultArg name x.Name,
@@ -1618,7 +1610,7 @@ type ILMethodDef (name: string, attributes: MethodAttributes, implAttributes: Me
16181610
callingConv = defaultArg callingConv x.CallingConv,
16191611
parameters = defaultArg parameters x.Parameters,
16201612
ret = defaultArg ret x.Return,
1621-
body = defaultArg body x.Body,
1613+
body = defaultArg body x.LazyBody,
16221614
securityDecls = (match securityDecls with None -> x.SecurityDecls | Some attrs -> attrs),
16231615
isEntryPoint = defaultArg isEntryPoint x.IsEntryPoint,
16241616
genericParams = defaultArg genericParams x.GenericParams,
@@ -1631,15 +1623,15 @@ type ILMethodDef (name: string, attributes: MethodAttributes, implAttributes: Me
16311623
member x.ParameterTypes = typesOfILParams x.Parameters
16321624

16331625
member md.Code =
1634-
match md.Body.Contents with
1635-
| MethodBody.IL il-> Some il.Code
1626+
match md.Body with
1627+
| MethodBody.IL il-> Some il.Value.Code
16361628
| _ -> None
16371629

1638-
member x.IsIL = match x.Body.Contents with | MethodBody.IL _ -> true | _ -> false
1630+
member x.IsIL = match x.Body with | MethodBody.IL _ -> true | _ -> false
16391631

1640-
member x.Locals = match x.Body.Contents with | MethodBody.IL il -> il.Locals | _ -> []
1632+
member x.Locals = match x.Body with | MethodBody.IL il -> il.Value.Locals | _ -> []
16411633

1642-
member x.MethodBody = match x.Body.Contents with MethodBody.IL il -> il | _ -> failwith "not IL"
1634+
member x.MethodBody = match x.Body with MethodBody.IL il -> il.Value | _ -> failwith "not IL"
16431635

16441636
member x.SourceMarker = x.MethodBody.SourceMarker
16451637

@@ -2890,19 +2882,21 @@ let mkILMethodBody (zeroinit, locals, maxstack, code, tag) : ILMethodBody =
28902882
Code= code
28912883
SourceMarker=tag }
28922884

2893-
let mkMethodBody (zeroinit, locals, maxstack, code, tag) = MethodBody.IL (mkILMethodBody (zeroinit, locals, maxstack, code, tag))
2885+
let mkMethodBody (zeroinit, locals, maxstack, code, tag) =
2886+
let ilCode = mkILMethodBody (zeroinit, locals, maxstack, code, tag)
2887+
MethodBody.IL (lazy ilCode)
28942888

28952889
// --------------------------------------------------------------------
28962890
// Make a constructor
28972891
// --------------------------------------------------------------------
28982892

28992893
let mkILVoidReturn = mkILReturn ILType.Void
29002894

2901-
let methBodyNotAvailable = mkMethBodyAux MethodBody.NotAvailable
2895+
let methBodyNotAvailable = notlazy MethodBody.NotAvailable
29022896

2903-
let methBodyAbstract = mkMethBodyAux MethodBody.Abstract
2897+
let methBodyAbstract = notlazy MethodBody.Abstract
29042898

2905-
let methBodyNative = mkMethBodyAux MethodBody.Native
2899+
let methBodyNative = notlazy MethodBody.Native
29062900

29072901
let mkILCtor (access, args, impl) =
29082902
ILMethodDef(name=".ctor",
@@ -2911,7 +2905,7 @@ let mkILCtor (access, args, impl) =
29112905
callingConv=ILCallingConv.Instance,
29122906
parameters = args,
29132907
ret= mkILVoidReturn,
2914-
body= mkMethBodyAux impl,
2908+
body= notlazy impl,
29152909
securityDecls=emptyILSecurityDecls,
29162910
isEntryPoint=false,
29172911
genericParams=mkILEmptyGenericParams,
@@ -2960,7 +2954,7 @@ let mkILStaticMethod (genparams, nm, access, args, ret, impl) =
29602954
securityDecls=emptyILSecurityDecls,
29612955
isEntryPoint=false,
29622956
customAttrs = emptyILCustomAttrs,
2963-
body= mkMethBodyAux impl)
2957+
body= notlazy impl)
29642958

29652959
let mkILNonGenericStaticMethod (nm, access, args, ret, impl) =
29662960
mkILStaticMethod (mkILEmptyGenericParams, nm, access, args, ret, impl)
@@ -2976,7 +2970,7 @@ let mkILClassCtor impl =
29762970
isEntryPoint=false,
29772971
securityDecls=emptyILSecurityDecls,
29782972
customAttrs=emptyILCustomAttrs,
2979-
body= mkMethBodyAux impl)
2973+
body= notlazy impl)
29802974

29812975
// --------------------------------------------------------------------
29822976
// Make a virtual method, where the overriding is simply the default
@@ -3000,7 +2994,7 @@ let mkILGenericVirtualMethod (nm, access, genparams, actual_args, actual_ret, im
30002994
isEntryPoint=false,
30012995
securityDecls=emptyILSecurityDecls,
30022996
customAttrs = emptyILCustomAttrs,
3003-
body= mkMethBodyAux impl)
2997+
body= notlazy impl)
30042998

30052999
let mkILNonGenericVirtualMethod (nm, access, args, ret, impl) =
30063000
mkILGenericVirtualMethod (nm, access, mkILEmptyGenericParams, args, ret, impl)
@@ -3016,7 +3010,7 @@ let mkILGenericNonVirtualMethod (nm, access, genparams, actual_args, actual_ret,
30163010
isEntryPoint=false,
30173011
securityDecls=emptyILSecurityDecls,
30183012
customAttrs = emptyILCustomAttrs,
3019-
body= mkMethBodyAux impl)
3013+
body= notlazy impl)
30203014

30213015
let mkILNonGenericInstanceMethod (nm, access, args, ret, impl) =
30223016
mkILGenericNonVirtualMethod (nm, access, mkILEmptyGenericParams, args, ret, impl)
@@ -3032,11 +3026,12 @@ let ilmbody_code2code f (il: ILMethodBody) =
30323026

30333027
let mdef_code2code f (md: ILMethodDef) =
30343028
let il =
3035-
match md.Body.Contents with
3029+
match md.Body with
30363030
| MethodBody.IL il-> il
30373031
| _ -> failwith "mdef_code2code - method not IL"
3038-
let b = MethodBody.IL (ilmbody_code2code f il)
3039-
md.With(body = mkMethBodyAux b)
3032+
let ilCode = ilmbody_code2code f il.Value
3033+
let b = MethodBody.IL (notlazy ilCode)
3034+
md.With(body = notlazy b)
30403035

30413036
let prependInstrsToCode (instrs: ILInstr list) (c2: ILCode) =
30423037
let instrs = Array.ofList instrs
@@ -4122,14 +4117,14 @@ and refs_of_local s loc = refs_of_typ s loc.Type
41224117

41234118
and refs_of_mbody s x =
41244119
match x with
4125-
| MethodBody.IL il -> refs_of_ilmbody s il
4126-
| MethodBody.PInvoke (attr) -> refs_of_modref s attr.Where
4120+
| MethodBody.IL il -> refs_of_ilmbody s il.Value
4121+
| MethodBody.PInvoke (attr) -> refs_of_modref s attr.Value.Where
41274122
| _ -> ()
41284123

41294124
and refs_of_mdef s (md: ILMethodDef) =
41304125
List.iter (refs_of_param s) md.Parameters
41314126
refs_of_return s md.Return
4132-
refs_of_mbody s md.Body.Contents
4127+
refs_of_mbody s md.Body
41334128
refs_of_custom_attrs s md.CustomAttrs
41344129
refs_of_genparams s md.GenericParams
41354130

0 commit comments

Comments
 (0)