Skip to content

Commit eb333d9

Browse files
committed
Removed unrelated code changes to the fix
1 parent 1fe8051 commit eb333d9

File tree

4 files changed

+60
-69
lines changed

4 files changed

+60
-69
lines changed

src/fsharp/CompileOptions.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ let SetOptimizeOn(tcConfigB: TcConfigBuilder) =
395395
tcConfigB.optSettings <- { tcConfigB.optSettings with jitOptUser = Some true }
396396
tcConfigB.optSettings <- { tcConfigB.optSettings with localOptUser = Some true }
397397
tcConfigB.optSettings <- { tcConfigB.optSettings with crossModuleOptUser = Some true }
398-
tcConfigB.optSettings <- { tcConfigB.optSettings with lambdaInlineThreshold = Optimizer.LambdaInlineThresholdDefault }
398+
tcConfigB.optSettings <- { tcConfigB.optSettings with lambdaInlineThreshold = 6 }
399399
tcConfigB.doDetuple <- true
400400
tcConfigB.doTLR <- true
401401
tcConfigB.doFinalSimplify <- true

src/fsharp/IlxGen.fs

Lines changed: 52 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -4383,62 +4383,9 @@ and GenGenericParams cenv eenv tps =
43834383
and GenGenericArgs m (tyenv: TypeReprEnv) tps =
43844384
tps |> DropErasedTypars |> List.map (fun c -> (mkILTyvarTy tyenv.[c, m]))
43854385

4386-
and GenMethodForLambda cenv mgbuf eenv (entryPointInfo, cloinfo, eenvinner, body, isLocalTypeFunc, m) =
4387-
let g = cenv.g
4388-
let ilCloBody = CodeGenMethodForExpr cenv mgbuf (SPAlways, entryPointInfo, cloinfo.cloName, eenvinner, 1, body, Return)
4389-
let ilCloTypeRef = cloinfo.cloSpec.TypeRef
4390-
let cloTypeDefs =
4391-
if isLocalTypeFunc then
4392-
4393-
// Work out the contract type and generate a class with an abstract method for this type
4394-
let (ilContractGenericParams, ilContractMethTyargs, ilContractTySpec: ILTypeSpec, ilContractFormalRetTy) = GenNamedLocalTypeFuncContractInfo cenv eenv m cloinfo
4395-
let ilContractTypeRef = ilContractTySpec.TypeRef
4396-
let ilContractTy = mkILFormalBoxedTy ilContractTypeRef ilContractGenericParams
4397-
let ilContractCtor = mkILNonGenericEmptyCtor None g.ilg.typ_Object
4398-
4399-
let ilContractMeths = [ilContractCtor; mkILGenericVirtualMethod("DirectInvoke", ILMemberAccess.Assembly, ilContractMethTyargs, [], mkILReturn ilContractFormalRetTy, MethodBody.Abstract) ]
4400-
let ilContractTypeDef =
4401-
ILTypeDef(name = ilContractTypeRef.Name,
4402-
layout = ILTypeDefLayout.Auto,
4403-
attributes = enum 0,
4404-
genericParams = ilContractGenericParams,
4405-
customAttrs = mkILCustomAttrs [mkCompilationMappingAttr g (int SourceConstructFlags.Closure) ],
4406-
fields = emptyILFields,
4407-
events= emptyILEvents,
4408-
properties = emptyILProperties,
4409-
methods= mkILMethods ilContractMeths,
4410-
methodImpls= emptyILMethodImpls,
4411-
nestedTypes=emptyILTypeDefs,
4412-
implements = [],
4413-
extends= Some g.ilg.typ_Object,
4414-
securityDecls= emptyILSecurityDecls)
4415-
4416-
// the contract type is an abstract type and not sealed
4417-
let ilContractTypeDef =
4418-
ilContractTypeDef
4419-
.WithAbstract(true)
4420-
.WithAccess(ComputeTypeAccess ilContractTypeRef true)
4421-
.WithSerializable(true)
4422-
.WithSpecialName(true)
4423-
.WithLayout(ILTypeDefLayout.Auto)
4424-
.WithInitSemantics(ILTypeInit.BeforeField)
4425-
.WithEncoding(ILDefaultPInvokeEncoding.Auto)
4426-
4427-
mgbuf.AddTypeDef(ilContractTypeRef, ilContractTypeDef, false, false, None)
4428-
4429-
let ilCtorBody = mkILMethodBody (true, [], 8, nonBranchingInstrsToCode (mkCallBaseConstructor(ilContractTy, [])), None )
4430-
let cloMethods = [ mkILGenericVirtualMethod("DirectInvoke", ILMemberAccess.Assembly, cloinfo.localTypeFuncDirectILGenericParams, [], mkILReturn (cloinfo.cloILFormalRetTy), MethodBody.IL ilCloBody) ]
4431-
let cloTypeDefs = GenClosureTypeDefs cenv (ilCloTypeRef, cloinfo.cloILGenericParams, [], cloinfo.cloILFreeVars, cloinfo.ilCloLambdas, ilCtorBody, cloMethods, [], ilContractTy, [])
4432-
cloTypeDefs
4433-
4434-
else
4435-
GenClosureTypeDefs cenv (ilCloTypeRef, cloinfo.cloILGenericParams, [], cloinfo.cloILFreeVars, cloinfo.ilCloLambdas, ilCloBody, [], [], g.ilg.typ_Object, [])
4436-
CountClosure()
4437-
for cloTypeDef in cloTypeDefs do
4438-
mgbuf.AddTypeDef(ilCloTypeRef, cloTypeDef, false, false, None)
4439-
44404386
/// Generate the closure class for a function
44414387
and GenLambdaClosure cenv (cgbuf: CodeGenBuffer) eenv isLocalTypeFunc selfv expr =
4388+
let g = cenv.g
44424389
match expr with
44434390
| Expr.Lambda (_, _, _, _, _, m, _)
44444391
| Expr.TyLambda (_, _, _, m, _) ->
@@ -4450,7 +4397,57 @@ and GenLambdaClosure cenv (cgbuf: CodeGenBuffer) eenv isLocalTypeFunc selfv expr
44504397
| Some v -> [(v, BranchCallClosure (cloinfo.cloArityInfo))]
44514398
| _ -> []
44524399

4453-
GenMethodForLambda cenv cgbuf.mgbuf eenv (entryPointInfo, cloinfo, eenvinner, body, isLocalTypeFunc, m)
4400+
let ilCloBody = CodeGenMethodForExpr cenv cgbuf.mgbuf (SPAlways, entryPointInfo, cloinfo.cloName, eenvinner, 1, body, Return)
4401+
let ilCloTypeRef = cloinfo.cloSpec.TypeRef
4402+
let cloTypeDefs =
4403+
if isLocalTypeFunc then
4404+
4405+
// Work out the contract type and generate a class with an abstract method for this type
4406+
let (ilContractGenericParams, ilContractMethTyargs, ilContractTySpec: ILTypeSpec, ilContractFormalRetTy) = GenNamedLocalTypeFuncContractInfo cenv eenv m cloinfo
4407+
let ilContractTypeRef = ilContractTySpec.TypeRef
4408+
let ilContractTy = mkILFormalBoxedTy ilContractTypeRef ilContractGenericParams
4409+
let ilContractCtor = mkILNonGenericEmptyCtor None g.ilg.typ_Object
4410+
4411+
let ilContractMeths = [ilContractCtor; mkILGenericVirtualMethod("DirectInvoke", ILMemberAccess.Assembly, ilContractMethTyargs, [], mkILReturn ilContractFormalRetTy, MethodBody.Abstract) ]
4412+
let ilContractTypeDef =
4413+
ILTypeDef(name = ilContractTypeRef.Name,
4414+
layout = ILTypeDefLayout.Auto,
4415+
attributes = enum 0,
4416+
genericParams = ilContractGenericParams,
4417+
customAttrs = mkILCustomAttrs [mkCompilationMappingAttr g (int SourceConstructFlags.Closure) ],
4418+
fields = emptyILFields,
4419+
events= emptyILEvents,
4420+
properties = emptyILProperties,
4421+
methods= mkILMethods ilContractMeths,
4422+
methodImpls= emptyILMethodImpls,
4423+
nestedTypes=emptyILTypeDefs,
4424+
implements = [],
4425+
extends= Some g.ilg.typ_Object,
4426+
securityDecls= emptyILSecurityDecls)
4427+
4428+
// the contract type is an abstract type and not sealed
4429+
let ilContractTypeDef =
4430+
ilContractTypeDef
4431+
.WithAbstract(true)
4432+
.WithAccess(ComputeTypeAccess ilContractTypeRef true)
4433+
.WithSerializable(true)
4434+
.WithSpecialName(true)
4435+
.WithLayout(ILTypeDefLayout.Auto)
4436+
.WithInitSemantics(ILTypeInit.BeforeField)
4437+
.WithEncoding(ILDefaultPInvokeEncoding.Auto)
4438+
4439+
cgbuf.mgbuf.AddTypeDef(ilContractTypeRef, ilContractTypeDef, false, false, None)
4440+
4441+
let ilCtorBody = mkILMethodBody (true, [], 8, nonBranchingInstrsToCode (mkCallBaseConstructor(ilContractTy, [])), None )
4442+
let cloMethods = [ mkILGenericVirtualMethod("DirectInvoke", ILMemberAccess.Assembly, cloinfo.localTypeFuncDirectILGenericParams, [], mkILReturn (cloinfo.cloILFormalRetTy), MethodBody.IL ilCloBody) ]
4443+
let cloTypeDefs = GenClosureTypeDefs cenv (ilCloTypeRef, cloinfo.cloILGenericParams, [], cloinfo.cloILFreeVars, cloinfo.ilCloLambdas, ilCtorBody, cloMethods, [], ilContractTy, [])
4444+
cloTypeDefs
4445+
4446+
else
4447+
GenClosureTypeDefs cenv (ilCloTypeRef, cloinfo.cloILGenericParams, [], cloinfo.cloILFreeVars, cloinfo.ilCloLambdas, ilCloBody, [], [], g.ilg.typ_Object, [])
4448+
CountClosure()
4449+
for cloTypeDef in cloTypeDefs do
4450+
cgbuf.mgbuf.AddTypeDef(ilCloTypeRef, cloTypeDef, false, false, None)
44544451
cloinfo, m
44554452

44564453
| _ -> failwith "GenLambda: not a lambda"

src/fsharp/Optimizer.fs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,6 @@ let [<Literal>] localOptDefault = true
278278

279279
let [<Literal>] crossModuleOptDefault = true
280280

281-
let [<Literal>] LambdaInlineThresholdDefault = 6
282-
283281
type OptimizationSettings =
284282
{ abstractBigTargets : bool
285283

@@ -317,7 +315,7 @@ type OptimizationSettings =
317315
bigTargetSize = 100
318316
veryBigExprSize = 3000
319317
crossModuleOptUser = None
320-
lambdaInlineThreshold = LambdaInlineThresholdDefault
318+
lambdaInlineThreshold = 6
321319
reportingPhase = false
322320
reportNoNeedToTailcall = false
323321
reportFunctionSizes = false
@@ -1934,7 +1932,7 @@ let rec OptimizeExpr cenv (env: IncrementalOptimizationEnv) expr =
19341932
/// Optimize/analyze an object expression
19351933
and OptimizeObjectExpr cenv env (ty, baseValOpt, basecall, overrides, iimpls, m) =
19361934
let basecallR, basecallinfo = OptimizeExpr cenv env basecall
1937-
let overridesR, overrideinfos = OptimizeObjectExprMethods cenv env baseValOpt overrides
1935+
let overridesR, overrideinfos = OptimizeMethods cenv env baseValOpt overrides
19381936
let iimplsR, iimplsinfos = OptimizeInterfaceImpls cenv env baseValOpt iimpls
19391937
let exprR=mkObjExpr(ty, baseValOpt, basecallR, overridesR, iimplsR, m)
19401938
exprR, { TotalSize=closureTotalSize + basecallinfo.TotalSize + AddTotalSizes overrideinfos + AddTotalSizes iimplsinfos
@@ -1944,10 +1942,10 @@ and OptimizeObjectExpr cenv env (ty, baseValOpt, basecall, overrides, iimpls, m)
19441942
Info=UnknownValue}
19451943

19461944
/// Optimize/analyze the methods that make up an object expression
1947-
and OptimizeObjectExprMethods cenv env baseValOpt methods =
1948-
OptimizeList (OptimizeObjectExprMethod cenv env baseValOpt) methods
1945+
and OptimizeMethods cenv env baseValOpt methods =
1946+
OptimizeList (OptimizeMethod cenv env baseValOpt) methods
19491947

1950-
and OptimizeObjectExprMethod cenv env baseValOpt (TObjExprMethod(slotsig, attribs, tps, vs, e, m) as tmethod) =
1948+
and OptimizeMethod cenv env baseValOpt (TObjExprMethod(slotsig, attribs, tps, vs, e, m) as tmethod) =
19511949
let env = {env with latestBoundId=Some tmethod.Id; functionVal = None}
19521950
let env = BindTypeVarsToUnknown tps env
19531951
let env = BindInternalValsToUnknown cenv vs env
@@ -1967,7 +1965,7 @@ and OptimizeInterfaceImpls cenv env baseValOpt iimpls =
19671965

19681966
/// Optimize/analyze the interface implementations that form part of an object expression
19691967
and OptimizeInterfaceImpl cenv env baseValOpt (ty, overrides) =
1970-
let overridesR, overridesinfos = OptimizeObjectExprMethods cenv env baseValOpt overrides
1968+
let overridesR, overridesinfos = OptimizeMethods cenv env baseValOpt overrides
19711969
(ty, overridesR),
19721970
{ TotalSize = AddTotalSizes overridesinfos
19731971
FunctionSize = 1

src/fsharp/Optimizer.fsi

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,4 @@ val UnionOptimizationInfos: seq<ImplFileOptimizationInfo> -> CcuOptimizationInfo
6161
/// Check if an expression has an effect
6262
val ExprHasEffect: TcGlobals -> Expr -> bool
6363

64-
val internal u_CcuOptimizationInfo : TastPickle.ReaderState -> CcuOptimizationInfo
65-
66-
// REVIEW: We need to put the literal at the end of a file due to a bug that causes a compiler error when a literal is put in the middle other signature constructs.
67-
[<Literal>]
68-
val LambdaInlineThresholdDefault : int = 6
64+
val internal u_CcuOptimizationInfo : TastPickle.ReaderState -> CcuOptimizationInfo

0 commit comments

Comments
 (0)