Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Minor change
  • Loading branch information
TIHan committed Jan 15, 2021
commit c96a3800018cd5e1eb219c13cef288b24e8ecd29
30 changes: 16 additions & 14 deletions src/fsharp/absil/il.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1614,13 +1614,15 @@ let NoMetadataIdx = -1

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

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

member private _.LazyBody = body

// The captured data - remember the object will be as large as the data captured by these members
member _.Name = name

Expand All @@ -1634,7 +1636,7 @@ type ILMethodDef (name: string, attributes: MethodAttributes, implAttributes: Me

member _.Return = ret

member _.Body = body
member _.Body = body.Value

member _.SecurityDeclsStored = securityDeclsStored

Expand All @@ -1648,7 +1650,7 @@ type ILMethodDef (name: string, attributes: MethodAttributes, implAttributes: Me

member x.With (?name: string, ?attributes: MethodAttributes, ?implAttributes: MethodImplAttributes,
?callingConv: ILCallingConv, ?parameters: ILParameters, ?ret: ILReturn,
?body: MethodBody, ?securityDecls: ILSecurityDecls, ?isEntryPoint: bool,
?body: Lazy<MethodBody>, ?securityDecls: ILSecurityDecls, ?isEntryPoint: bool,
?genericParams: ILGenericParameterDefs, ?customAttrs: ILAttributes) =

ILMethodDef (name = defaultArg name x.Name,
Expand All @@ -1657,7 +1659,7 @@ type ILMethodDef (name: string, attributes: MethodAttributes, implAttributes: Me
callingConv = defaultArg callingConv x.CallingConv,
parameters = defaultArg parameters x.Parameters,
ret = defaultArg ret x.Return,
body = defaultArg body x.Body,
body = defaultArg body x.LazyBody,
securityDecls = (match securityDecls with None -> x.SecurityDecls | Some attrs -> attrs),
isEntryPoint = defaultArg isEntryPoint x.IsEntryPoint,
genericParams = defaultArg genericParams x.GenericParams,
Expand Down Expand Up @@ -2938,11 +2940,11 @@ let mkMethodBody (zeroinit, locals, maxstack, code, tag) =

let mkILVoidReturn = mkILReturn ILType.Void

let methBodyNotAvailable = MethodBody.NotAvailable
let methBodyNotAvailable = notlazy MethodBody.NotAvailable

let methBodyAbstract = MethodBody.Abstract
let methBodyAbstract = notlazy MethodBody.Abstract

let methBodyNative = MethodBody.Native
let methBodyNative = notlazy MethodBody.Native

let mkILCtor (access, args, impl) =
ILMethodDef(name=".ctor",
Expand All @@ -2951,7 +2953,7 @@ let mkILCtor (access, args, impl) =
callingConv=ILCallingConv.Instance,
parameters = args,
ret= mkILVoidReturn,
body= impl,
body= notlazy impl,
securityDecls=emptyILSecurityDecls,
isEntryPoint=false,
genericParams=mkILEmptyGenericParams,
Expand Down Expand Up @@ -3000,7 +3002,7 @@ let mkILStaticMethod (genparams, nm, access, args, ret, impl) =
securityDecls=emptyILSecurityDecls,
isEntryPoint=false,
customAttrs = emptyILCustomAttrs,
body= impl)
body= notlazy impl)

let mkILNonGenericStaticMethod (nm, access, args, ret, impl) =
mkILStaticMethod (mkILEmptyGenericParams, nm, access, args, ret, impl)
Expand All @@ -3016,7 +3018,7 @@ let mkILClassCtor impl =
isEntryPoint=false,
securityDecls=emptyILSecurityDecls,
customAttrs=emptyILCustomAttrs,
body= impl)
body= notlazy impl)

// --------------------------------------------------------------------
// Make a virtual method, where the overriding is simply the default
Expand All @@ -3040,7 +3042,7 @@ let mkILGenericVirtualMethod (nm, access, genparams, actual_args, actual_ret, im
isEntryPoint=false,
securityDecls=emptyILSecurityDecls,
customAttrs = emptyILCustomAttrs,
body= impl)
body= notlazy impl)

let mkILNonGenericVirtualMethod (nm, access, args, ret, impl) =
mkILGenericVirtualMethod (nm, access, mkILEmptyGenericParams, args, ret, impl)
Expand All @@ -3056,7 +3058,7 @@ let mkILGenericNonVirtualMethod (nm, access, genparams, actual_args, actual_ret,
isEntryPoint=false,
securityDecls=emptyILSecurityDecls,
customAttrs = emptyILCustomAttrs,
body= impl)
body= notlazy impl)

let mkILNonGenericInstanceMethod (nm, access, args, ret, impl) =
mkILGenericNonVirtualMethod (nm, access, mkILEmptyGenericParams, args, ret, impl)
Expand All @@ -3076,8 +3078,8 @@ let mdef_code2code f (md: ILMethodDef) =
| MethodBody.IL il-> il
| _ -> failwith "mdef_code2code - method not IL"
let ilCode = ilmbody_code2code f il.Value
let b = MethodBody.IL (lazy ilCode)
md.With(body = b)
let b = MethodBody.IL (notlazy ilCode)
md.With(body = notlazy b)

let prependInstrsToCode (instrs: ILInstr list) (c2: ILCode) =
let instrs = Array.ofList instrs
Expand Down
12 changes: 6 additions & 6 deletions src/fsharp/absil/il.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -977,12 +977,12 @@ type ILMethodDef =
/// Functional creation of a value, with delayed reading of some elements via a metadata index
internal new:
name: string * attributes: MethodAttributes * implAttributes: MethodImplAttributes * callingConv: ILCallingConv *
parameters: ILParameters * ret: ILReturn * body: MethodBody * isEntryPoint:bool * genericParams: ILGenericParameterDefs *
parameters: ILParameters * ret: ILReturn * body: Lazy<MethodBody> * isEntryPoint:bool * genericParams: ILGenericParameterDefs *
securityDeclsStored: ILSecurityDeclsStored * customAttrsStored: ILAttributesStored * metadataIndex: int32 -> ILMethodDef

/// Functional creation of a value, immediate
new: name: string * attributes: MethodAttributes * implAttributes: MethodImplAttributes * callingConv: ILCallingConv *
parameters: ILParameters * ret: ILReturn * body: MethodBody * isEntryPoint:bool * genericParams: ILGenericParameterDefs *
parameters: ILParameters * ret: ILReturn * body: Lazy<MethodBody> * isEntryPoint:bool * genericParams: ILGenericParameterDefs *
securityDecls: ILSecurityDecls * customAttrs: ILAttributes -> ILMethodDef

member Name: string
Expand Down Expand Up @@ -1048,7 +1048,7 @@ type ILMethodDef =
/// Functional update of the value
member internal
With: ?name: string * ?attributes: MethodAttributes * ?implAttributes: MethodImplAttributes * ?callingConv: ILCallingConv *
?parameters: ILParameters * ?ret: ILReturn * ?body: MethodBody * ?securityDecls: ILSecurityDecls * ?isEntryPoint:bool *
?parameters: ILParameters * ?ret: ILReturn * ?body: Lazy<MethodBody> * ?securityDecls: ILSecurityDecls * ?isEntryPoint:bool *
?genericParams: ILGenericParameterDefs * ?customAttrs: ILAttributes -> ILMethodDef
member internal WithSpecialName: ILMethodDef
member internal WithHideBySig: unit -> ILMethodDef
Expand Down Expand Up @@ -1813,9 +1813,9 @@ val internal mkILEmptyGenericParams: ILGenericParameterDefs
/// Make method definitions.
val internal mkILMethodBody: initlocals:bool * ILLocals * int * ILCode * ILSourceMarker option -> ILMethodBody
val internal mkMethodBody: bool * ILLocals * int * ILCode * ILSourceMarker option -> MethodBody
val internal methBodyNotAvailable: MethodBody
val internal methBodyAbstract: MethodBody
val internal methBodyNative: MethodBody
val internal methBodyNotAvailable: Lazy<MethodBody>
val internal methBodyAbstract: Lazy<MethodBody>
val internal methBodyNative: Lazy<MethodBody>

val internal mkILCtor: ILMemberAccess * ILParameter list * MethodBody -> ILMethodDef
val internal mkILClassCtor: MethodBody -> ILMethodDef
Expand Down
2 changes: 1 addition & 1 deletion src/fsharp/absil/ilmorph.fs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ let mdef_ty2ty_ilmbody2ilmbody ilg fs (md: ILMethodDef) =
let ftye' = ftye (Some md)
let body' = morphILMethodBody (filmbody (Some md)) md.Body
md.With(genericParams=gparams_ty2ty ftye' md.GenericParams,
body= body',
body= notlazy body',
parameters = List.map (param_ty2ty ilg ftye') md.Parameters,
ret = return_ty2ty ilg ftye' md.Return,
customAttrs=cattrs_ty2ty ilg ftye' md.CustomAttrs)
Expand Down
2 changes: 2 additions & 0 deletions src/fsharp/absil/ilread.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2494,6 +2494,7 @@ and seekReadConstant (ctxt: ILMetadataReader) idx =
| _ -> ILFieldInit.Null

and seekReadImplMap (ctxt: ILMetadataReader) nm midx =
lazy
MethodBody.PInvoke
(lazy
let mdv = ctxt.mdfile.GetView()
Expand Down Expand Up @@ -2797,6 +2798,7 @@ and seekReadMethodRVA (pectxt: PEReader) (ctxt: ILMetadataReader) (_idx, nm, _in
#else
and seekReadMethodRVA (pectxt: PEReader) (ctxt: ILMetadataReader) (idx, nm, _internalcall, noinline, aggressiveinline, numtypars) rva =
#endif
lazy
let pev = pectxt.pefile.GetView()
let baseRVA = pectxt.anyV2P("method rva", rva)
// ": reading body of method "+nm+" at rva "+string rva+", phys "+string baseRVA
Expand Down
2 changes: 1 addition & 1 deletion src/fsharp/ilx/EraseClosures.fs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ let convMethodBody thisClo = function

let convMethodDef thisClo (md: ILMethodDef) =
let b' = convMethodBody thisClo (md.Body)
md.With(body=b')
md.With(body=notlazy b')

// --------------------------------------------------------------------
// Make fields for free variables of a type abstraction.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ FSharp.Compiler.AbstractIL.IL+ILMethodDef: System.Reflection.MethodImplAttribute
FSharp.Compiler.AbstractIL.IL+ILMethodDef: System.Reflection.MethodImplAttributes get_ImplAttributes()
FSharp.Compiler.AbstractIL.IL+ILMethodDef: System.String Name
FSharp.Compiler.AbstractIL.IL+ILMethodDef: System.String get_Name()
FSharp.Compiler.AbstractIL.IL+ILMethodDef: Void .ctor(System.String, System.Reflection.MethodAttributes, System.Reflection.MethodImplAttributes, ILCallingConv, Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.AbstractIL.IL+ILParameter], ILReturn, MethodBody, Boolean, Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.AbstractIL.IL+ILGenericParameterDef], ILSecurityDecls, ILAttributes)
FSharp.Compiler.AbstractIL.IL+ILMethodDef: Void .ctor(System.String, System.Reflection.MethodAttributes, System.Reflection.MethodImplAttributes, ILCallingConv, Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.AbstractIL.IL+ILParameter], ILReturn, System.Lazy`1[FSharp.Compiler.AbstractIL.IL+MethodBody], Boolean, Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.AbstractIL.IL+ILGenericParameterDef], ILSecurityDecls, ILAttributes)
FSharp.Compiler.AbstractIL.IL+ILMethodDefs: ILMethodDef[] AsArray
FSharp.Compiler.AbstractIL.IL+ILMethodDefs: ILMethodDef[] get_AsArray()
FSharp.Compiler.AbstractIL.IL+ILMethodDefs: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.AbstractIL.IL+ILMethodDef] AsList
Expand Down