Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dotNET Platform
fsharp
提交
eb333d99
F
fsharp
项目概览
dotNET Platform
/
fsharp
12 个月 前同步成功
通知
0
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
fsharp
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
eb333d99
编写于
10月 31, 2019
作者:
T
TIHan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Removed unrelated code changes to the fix
上级
1fe80512
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
60 addition
and
69 deletion
+60
-69
src/fsharp/CompileOptions.fs
src/fsharp/CompileOptions.fs
+1
-1
src/fsharp/IlxGen.fs
src/fsharp/IlxGen.fs
+52
-55
src/fsharp/Optimizer.fs
src/fsharp/Optimizer.fs
+6
-8
src/fsharp/Optimizer.fsi
src/fsharp/Optimizer.fsi
+1
-5
未找到文件。
src/fsharp/CompileOptions.fs
浏览文件 @
eb333d99
...
...
@@ -395,7 +395,7 @@ let SetOptimizeOn(tcConfigB: TcConfigBuilder) =
tcConfigB
.
optSettings
<-
{
tcConfigB
.
optSettings
with
jitOptUser
=
Some
true
}
tcConfigB
.
optSettings
<-
{
tcConfigB
.
optSettings
with
localOptUser
=
Some
true
}
tcConfigB
.
optSettings
<-
{
tcConfigB
.
optSettings
with
crossModuleOptUser
=
Some
true
}
tcConfigB
.
optSettings
<-
{
tcConfigB
.
optSettings
with
lambdaInlineThreshold
=
Optimizer
.
LambdaInlineThresholdDefault
}
tcConfigB
.
optSettings
<-
{
tcConfigB
.
optSettings
with
lambdaInlineThreshold
=
6
}
tcConfigB
.
doDetuple
<-
true
tcConfigB
.
doTLR
<-
true
tcConfigB
.
doFinalSimplify
<-
true
...
...
src/fsharp/IlxGen.fs
浏览文件 @
eb333d99
...
...
@@ -4383,62 +4383,9 @@ and GenGenericParams cenv eenv tps =
and
GenGenericArgs
m
(
tyenv
:
TypeReprEnv
)
tps
=
tps
|>
DropErasedTypars
|>
List
.
map
(
fun
c
->
(
mkILTyvarTy
tyenv
.[
c
,
m
]))
and
GenMethodForLambda
cenv
mgbuf
eenv
(
entryPointInfo
,
cloinfo
,
eenvinner
,
body
,
isLocalTypeFunc
,
m
)
=
let
g
=
cenv
.
g
let
ilCloBody
=
CodeGenMethodForExpr
cenv
mgbuf
(
SPAlways
,
entryPointInfo
,
cloinfo
.
cloName
,
eenvinner
,
1
,
body
,
Return
)
let
ilCloTypeRef
=
cloinfo
.
cloSpec
.
TypeRef
let
cloTypeDefs
=
if
isLocalTypeFunc
then
// Work out the contract type and generate a class with an abstract method for this type
let
(
ilContractGenericParams
,
ilContractMethTyargs
,
ilContractTySpec
:
ILTypeSpec
,
ilContractFormalRetTy
)
=
GenNamedLocalTypeFuncContractInfo
cenv
eenv
m
cloinfo
let
ilContractTypeRef
=
ilContractTySpec
.
TypeRef
let
ilContractTy
=
mkILFormalBoxedTy
ilContractTypeRef
ilContractGenericParams
let
ilContractCtor
=
mkILNonGenericEmptyCtor
None
g
.
ilg
.
typ_Object
let
ilContractMeths
=
[
ilContractCtor
;
mkILGenericVirtualMethod
(
"DirectInvoke"
,
ILMemberAccess
.
Assembly
,
ilContractMethTyargs
,
[]
,
mkILReturn
ilContractFormalRetTy
,
MethodBody
.
Abstract
)
]
let
ilContractTypeDef
=
ILTypeDef
(
name
=
ilContractTypeRef
.
Name
,
layout
=
ILTypeDefLayout
.
Auto
,
attributes
=
enum
0
,
genericParams
=
ilContractGenericParams
,
customAttrs
=
mkILCustomAttrs
[
mkCompilationMappingAttr
g
(
int
SourceConstructFlags
.
Closure
)
],
fields
=
emptyILFields
,
events
=
emptyILEvents
,
properties
=
emptyILProperties
,
methods
=
mkILMethods
ilContractMeths
,
methodImpls
=
emptyILMethodImpls
,
nestedTypes
=
emptyILTypeDefs
,
implements
=
[]
,
extends
=
Some
g
.
ilg
.
typ_Object
,
securityDecls
=
emptyILSecurityDecls
)
// the contract type is an abstract type and not sealed
let
ilContractTypeDef
=
ilContractTypeDef
.
WithAbstract
(
true
)
.
WithAccess
(
ComputeTypeAccess
ilContractTypeRef
true
)
.
WithSerializable
(
true
)
.
WithSpecialName
(
true
)
.
WithLayout
(
ILTypeDefLayout
.
Auto
)
.
WithInitSemantics
(
ILTypeInit
.
BeforeField
)
.
WithEncoding
(
ILDefaultPInvokeEncoding
.
Auto
)
mgbuf
.
AddTypeDef
(
ilContractTypeRef
,
ilContractTypeDef
,
false
,
false
,
None
)
let
ilCtorBody
=
mkILMethodBody
(
true
,
[]
,
8
,
nonBranchingInstrsToCode
(
mkCallBaseConstructor
(
ilContractTy
,
[]
)),
None
)
let
cloMethods
=
[
mkILGenericVirtualMethod
(
"DirectInvoke"
,
ILMemberAccess
.
Assembly
,
cloinfo
.
localTypeFuncDirectILGenericParams
,
[]
,
mkILReturn
(
cloinfo
.
cloILFormalRetTy
),
MethodBody
.
IL
ilCloBody
)
]
let
cloTypeDefs
=
GenClosureTypeDefs
cenv
(
ilCloTypeRef
,
cloinfo
.
cloILGenericParams
,
[]
,
cloinfo
.
cloILFreeVars
,
cloinfo
.
ilCloLambdas
,
ilCtorBody
,
cloMethods
,
[]
,
ilContractTy
,
[]
)
cloTypeDefs
else
GenClosureTypeDefs
cenv
(
ilCloTypeRef
,
cloinfo
.
cloILGenericParams
,
[]
,
cloinfo
.
cloILFreeVars
,
cloinfo
.
ilCloLambdas
,
ilCloBody
,
[]
,
[]
,
g
.
ilg
.
typ_Object
,
[]
)
CountClosure
()
for
cloTypeDef
in
cloTypeDefs
do
mgbuf
.
AddTypeDef
(
ilCloTypeRef
,
cloTypeDef
,
false
,
false
,
None
)
/// Generate the closure class for a function
and
GenLambdaClosure
cenv
(
cgbuf
:
CodeGenBuffer
)
eenv
isLocalTypeFunc
selfv
expr
=
let
g
=
cenv
.
g
match
expr
with
|
Expr
.
Lambda
(_,
_,
_,
_,
_,
m
,
_)
|
Expr
.
TyLambda
(_,
_,
_,
m
,
_)
->
...
...
@@ -4450,7 +4397,57 @@ and GenLambdaClosure cenv (cgbuf: CodeGenBuffer) eenv isLocalTypeFunc selfv expr
|
Some
v
->
[(
v
,
BranchCallClosure
(
cloinfo
.
cloArityInfo
))]
|
_
->
[]
GenMethodForLambda
cenv
cgbuf
.
mgbuf
eenv
(
entryPointInfo
,
cloinfo
,
eenvinner
,
body
,
isLocalTypeFunc
,
m
)
let
ilCloBody
=
CodeGenMethodForExpr
cenv
cgbuf
.
mgbuf
(
SPAlways
,
entryPointInfo
,
cloinfo
.
cloName
,
eenvinner
,
1
,
body
,
Return
)
let
ilCloTypeRef
=
cloinfo
.
cloSpec
.
TypeRef
let
cloTypeDefs
=
if
isLocalTypeFunc
then
// Work out the contract type and generate a class with an abstract method for this type
let
(
ilContractGenericParams
,
ilContractMethTyargs
,
ilContractTySpec
:
ILTypeSpec
,
ilContractFormalRetTy
)
=
GenNamedLocalTypeFuncContractInfo
cenv
eenv
m
cloinfo
let
ilContractTypeRef
=
ilContractTySpec
.
TypeRef
let
ilContractTy
=
mkILFormalBoxedTy
ilContractTypeRef
ilContractGenericParams
let
ilContractCtor
=
mkILNonGenericEmptyCtor
None
g
.
ilg
.
typ_Object
let
ilContractMeths
=
[
ilContractCtor
;
mkILGenericVirtualMethod
(
"DirectInvoke"
,
ILMemberAccess
.
Assembly
,
ilContractMethTyargs
,
[]
,
mkILReturn
ilContractFormalRetTy
,
MethodBody
.
Abstract
)
]
let
ilContractTypeDef
=
ILTypeDef
(
name
=
ilContractTypeRef
.
Name
,
layout
=
ILTypeDefLayout
.
Auto
,
attributes
=
enum
0
,
genericParams
=
ilContractGenericParams
,
customAttrs
=
mkILCustomAttrs
[
mkCompilationMappingAttr
g
(
int
SourceConstructFlags
.
Closure
)
],
fields
=
emptyILFields
,
events
=
emptyILEvents
,
properties
=
emptyILProperties
,
methods
=
mkILMethods
ilContractMeths
,
methodImpls
=
emptyILMethodImpls
,
nestedTypes
=
emptyILTypeDefs
,
implements
=
[]
,
extends
=
Some
g
.
ilg
.
typ_Object
,
securityDecls
=
emptyILSecurityDecls
)
// the contract type is an abstract type and not sealed
let
ilContractTypeDef
=
ilContractTypeDef
.
WithAbstract
(
true
)
.
WithAccess
(
ComputeTypeAccess
ilContractTypeRef
true
)
.
WithSerializable
(
true
)
.
WithSpecialName
(
true
)
.
WithLayout
(
ILTypeDefLayout
.
Auto
)
.
WithInitSemantics
(
ILTypeInit
.
BeforeField
)
.
WithEncoding
(
ILDefaultPInvokeEncoding
.
Auto
)
cgbuf
.
mgbuf
.
AddTypeDef
(
ilContractTypeRef
,
ilContractTypeDef
,
false
,
false
,
None
)
let
ilCtorBody
=
mkILMethodBody
(
true
,
[]
,
8
,
nonBranchingInstrsToCode
(
mkCallBaseConstructor
(
ilContractTy
,
[]
)),
None
)
let
cloMethods
=
[
mkILGenericVirtualMethod
(
"DirectInvoke"
,
ILMemberAccess
.
Assembly
,
cloinfo
.
localTypeFuncDirectILGenericParams
,
[]
,
mkILReturn
(
cloinfo
.
cloILFormalRetTy
),
MethodBody
.
IL
ilCloBody
)
]
let
cloTypeDefs
=
GenClosureTypeDefs
cenv
(
ilCloTypeRef
,
cloinfo
.
cloILGenericParams
,
[]
,
cloinfo
.
cloILFreeVars
,
cloinfo
.
ilCloLambdas
,
ilCtorBody
,
cloMethods
,
[]
,
ilContractTy
,
[]
)
cloTypeDefs
else
GenClosureTypeDefs
cenv
(
ilCloTypeRef
,
cloinfo
.
cloILGenericParams
,
[]
,
cloinfo
.
cloILFreeVars
,
cloinfo
.
ilCloLambdas
,
ilCloBody
,
[]
,
[]
,
g
.
ilg
.
typ_Object
,
[]
)
CountClosure
()
for
cloTypeDef
in
cloTypeDefs
do
cgbuf
.
mgbuf
.
AddTypeDef
(
ilCloTypeRef
,
cloTypeDef
,
false
,
false
,
None
)
cloinfo
,
m
|
_
->
failwith
"GenLambda: not a lambda"
...
...
src/fsharp/Optimizer.fs
浏览文件 @
eb333d99
...
...
@@ -278,8 +278,6 @@ let [<Literal>] localOptDefault = true
let
[<
Literal
>]
crossModuleOptDefault
=
true
let
[<
Literal
>]
LambdaInlineThresholdDefault
=
6
type
OptimizationSettings
=
{
abstractBigTargets
:
bool
...
...
@@ -317,7 +315,7 @@ type OptimizationSettings =
bigTargetSize
=
100
veryBigExprSize
=
3000
crossModuleOptUser
=
None
lambdaInlineThreshold
=
LambdaInlineThresholdDefault
lambdaInlineThreshold
=
6
reportingPhase
=
false
reportNoNeedToTailcall
=
false
reportFunctionSizes
=
false
...
...
@@ -1934,7 +1932,7 @@ let rec OptimizeExpr cenv (env: IncrementalOptimizationEnv) expr =
/// Optimize/analyze an object expression
and
OptimizeObjectExpr
cenv
env
(
ty
,
baseValOpt
,
basecall
,
overrides
,
iimpls
,
m
)
=
let
basecallR
,
basecallinfo
=
OptimizeExpr
cenv
env
basecall
let
overridesR
,
overrideinfos
=
Optimize
ObjectExpr
Methods
cenv
env
baseValOpt
overrides
let
overridesR
,
overrideinfos
=
OptimizeMethods
cenv
env
baseValOpt
overrides
let
iimplsR
,
iimplsinfos
=
OptimizeInterfaceImpls
cenv
env
baseValOpt
iimpls
let
exprR
=
mkObjExpr
(
ty
,
baseValOpt
,
basecallR
,
overridesR
,
iimplsR
,
m
)
exprR
,
{
TotalSize
=
closureTotalSize
+
basecallinfo
.
TotalSize
+
AddTotalSizes
overrideinfos
+
AddTotalSizes
iimplsinfos
...
...
@@ -1944,10 +1942,10 @@ and OptimizeObjectExpr cenv env (ty, baseValOpt, basecall, overrides, iimpls, m)
Info
=
UnknownValue
}
/// Optimize/analyze the methods that make up an object expression
and
Optimize
ObjectExpr
Methods
cenv
env
baseValOpt
methods
=
OptimizeList
(
Optimize
ObjectExpr
Method
cenv
env
baseValOpt
)
methods
and
OptimizeMethods
cenv
env
baseValOpt
methods
=
OptimizeList
(
OptimizeMethod
cenv
env
baseValOpt
)
methods
and
Optimize
ObjectExpr
Method
cenv
env
baseValOpt
(
TObjExprMethod
(
slotsig
,
attribs
,
tps
,
vs
,
e
,
m
)
as
tmethod
)
=
and
OptimizeMethod
cenv
env
baseValOpt
(
TObjExprMethod
(
slotsig
,
attribs
,
tps
,
vs
,
e
,
m
)
as
tmethod
)
=
let
env
=
{
env
with
latestBoundId
=
Some
tmethod
.
Id
;
functionVal
=
None
}
let
env
=
BindTypeVarsToUnknown
tps
env
let
env
=
BindInternalValsToUnknown
cenv
vs
env
...
...
@@ -1967,7 +1965,7 @@ and OptimizeInterfaceImpls cenv env baseValOpt iimpls =
/// Optimize/analyze the interface implementations that form part of an object expression
and
OptimizeInterfaceImpl
cenv
env
baseValOpt
(
ty
,
overrides
)
=
let
overridesR
,
overridesinfos
=
Optimize
ObjectExpr
Methods
cenv
env
baseValOpt
overrides
let
overridesR
,
overridesinfos
=
OptimizeMethods
cenv
env
baseValOpt
overrides
(
ty
,
overridesR
),
{
TotalSize
=
AddTotalSizes
overridesinfos
FunctionSize
=
1
...
...
src/fsharp/Optimizer.fsi
浏览文件 @
eb333d99
...
...
@@ -61,8 +61,4 @@ val UnionOptimizationInfos: seq<ImplFileOptimizationInfo> -> CcuOptimizationInfo
/// Check if an expression has an effect
val
ExprHasEffect
:
TcGlobals
->
Expr
->
bool
val
internal
u_CcuOptimizationInfo
:
TastPickle
.
ReaderState
->
CcuOptimizationInfo
// 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.
[<
Literal
>]
val
LambdaInlineThresholdDefault
:
int
=
6
\ No newline at end of file
val
internal
u_CcuOptimizationInfo
:
TastPickle
.
ReaderState
->
CcuOptimizationInfo
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录