Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dotNET Platform
fsharp
提交
448da58c
F
fsharp
项目概览
dotNET Platform
/
fsharp
10 个月 前同步成功
通知
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,发现更多精彩内容 >>
未验证
提交
448da58c
编写于
3月 27, 2023
作者:
K
kerams
提交者:
GitHub
3月 27, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Do not skip locals init in state machines (#14984)
上级
3d4eb5c0
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
65 addition
and
1 deletion
+65
-1
src/Compiler/CodeGen/IlxGen.fs
src/Compiler/CodeGen/IlxGen.fs
+9
-0
tests/FSharp.Compiler.ComponentTests/EmittedIL/SkipLocalsInit.fs
...Sharp.Compiler.ComponentTests/EmittedIL/SkipLocalsInit.fs
+34
-1
tests/FSharp.Compiler.ComponentTests/Language/StateMachineTests.fs
...arp.Compiler.ComponentTests/Language/StateMachineTests.fs
+22
-0
未找到文件。
src/Compiler/CodeGen/IlxGen.fs
浏览文件 @
448da58c
...
@@ -1317,6 +1317,12 @@ let AddStorageForLocalWitness eenv (w, s) =
...
@@ -1317,6 +1317,12 @@ let AddStorageForLocalWitness eenv (w, s) =
let
AddStorageForLocalWitnesses
witnesses
eenv
=
let
AddStorageForLocalWitnesses
witnesses
eenv
=
(
eenv
,
witnesses
)
||>
List
.
fold
AddStorageForLocalWitness
(
eenv
,
witnesses
)
||>
List
.
fold
AddStorageForLocalWitness
let
ForceInitLocals
eenv
=
if
eenv
.
initLocals
then
eenv
else
{
eenv
with
initLocals
=
true
}
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
// Lookup eenv
// Lookup eenv
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
...
@@ -5934,6 +5940,9 @@ and GenStructStateMachine cenv cgbuf eenvouter (res: LoweredStateMachine) sequel
...
@@ -5934,6 +5940,9 @@ and GenStructStateMachine cenv cgbuf eenvouter (res: LoweredStateMachine) sequel
let
eenvinner
=
let
eenvinner
=
AddTemplateReplacement
eenvinner
(
templateTyconRef
,
ilCloTypeRef
,
cloinfo
.
cloFreeTyvars
,
templateTypeInst
)
AddTemplateReplacement
eenvinner
(
templateTyconRef
,
ilCloTypeRef
,
cloinfo
.
cloFreeTyvars
,
templateTypeInst
)
// In MoveNext we're relying on default initialization of locals, so force it in spite of the presence of any SkipLocalsInit
let
eenvinner
=
ForceInitLocals
eenvinner
let
infoReader
=
InfoReader
.
InfoReader
(
g
,
cenv
.
amap
)
let
infoReader
=
InfoReader
.
InfoReader
(
g
,
cenv
.
amap
)
// We codegen the IResumableStateMachine implementation for each generated struct type
// We codegen the IResumableStateMachine implementation for each generated struct type
...
...
tests/FSharp.Compiler.ComponentTests/EmittedIL/SkipLocalsInit.fs
浏览文件 @
448da58c
...
@@ -180,3 +180,36 @@ IL_001a: ldloc.0
...
@@ -180,3 +180,36 @@ IL_001a: ldloc.0
IL_001b: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<valuetype [runtime]System.Nullable`1<int64>,!!a>::Invoke(!0)
IL_001b: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<valuetype [runtime]System.Nullable`1<int64>,!!a>::Invoke(!0)
IL_0020: stloc.2
IL_0020: stloc.2
IL_0021: ret"""
]
IL_0021: ret"""
]
[<
FSharp
.
Test
.
FactForNETCOREAPP
>]
let
``Zero init performed in state machine MoveNext despite the attribute``
()
=
FSharp
"""
module SkipLocalsInit
open System
[<System.Runtime.CompilerServices.SkipLocalsInit>]
let compute () =
task {
try
do! System.Threading.Tasks.Task.Delay 10
with e ->
printfn "
%
s
" (e.ToString())
}
"""
|>
compile
|>
shouldSucceed
|>
verifyIL
[
"""
.override [runtime]System.Runtime.CompilerServices.IAsyncStateMachine::MoveNext
.maxstack 5
.locals init (int32 V_0,
"""
"""
.method public static class [runtime]System.Threading.Tasks.Task`1<class [FSharp.Core]Microsoft.FSharp.Core.Unit>
compute() cil managed
{
.custom instance void [runtime]System.Runtime.CompilerServices.SkipLocalsInitAttribute::.ctor() = ( 01 00 00 00 )
.maxstack 4
.locals (valuetype SkipLocalsInit/compute@7 V_0,"""
]
\ No newline at end of file
tests/FSharp.Compiler.ComponentTests/Language/StateMachineTests.fs
浏览文件 @
448da58c
...
@@ -84,3 +84,25 @@ foo()
...
@@ -84,3 +84,25 @@ foo()
"""
"""
|>
verify3511AndRun
|>
verify3511AndRun
|>
shouldSucceed
|>
shouldSucceed
[<
FSharp
.
Test
.
FactForNETCOREAPP
>]
// https://github.com/dotnet/fsharp/issues/13386
let
``SkipLocalsInit does not cause an exception``
()
=
FSharp
"""
module TestProject1
[<System.Runtime.CompilerServices.SkipLocalsInit>]
let compute () =
task {
try
do! System.Threading.Tasks.Task.Delay 10
with e ->
printfn "
%
s
" (e.ToString())
}
// multiple invocations to trigger tiered compilation
for i in 1 .. 100 do
compute().Wait ()
"""
|>
withOptimize
|>
compileExeAndRun
|>
shouldSucceed
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录