Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
e84ce90f
R
roslyn
项目概览
lwm1986
/
roslyn
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
roslyn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e84ce90f
编写于
1月 06, 2018
作者:
V
vsadov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Call rewrite could overwrite "out" with "ref". Should not do that.
上级
bbf0a2e6
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
62 addition
and
12 deletion
+62
-12
src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_Call.cs
...arp/Portable/Lowering/LocalRewriter/LocalRewriter_Call.cs
+2
-12
src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenRefOutTests.cs
src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenRefOutTests.cs
+60
-0
未找到文件。
src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_Call.cs
浏览文件 @
e84ce90f
...
...
@@ -464,7 +464,7 @@ private static bool IsSafeForReordering(BoundExpression expression, RefKind kind
// Optimize away unnecessary temporaries.
// Necessary temporaries have their store instructions merged into the appropriate
// argument expression.
OptimizeTemporaries
(
actualArguments
,
refKinds
,
storesToTemps
,
temporariesBuilder
);
OptimizeTemporaries
(
actualArguments
,
storesToTemps
,
temporariesBuilder
);
// Step two: If we have a params array, build the array and fill in the argument.
if
(
expanded
)
...
...
@@ -942,19 +942,16 @@ private static BoundExpression MakeLiteral(SyntaxNode syntax, ConstantValue cons
private
static
void
OptimizeTemporaries
(
BoundExpression
[]
arguments
,
ArrayBuilder
<
RefKind
>
refKinds
,
ArrayBuilder
<
BoundAssignmentOperator
>
storesToTemps
,
ArrayBuilder
<
LocalSymbol
>
temporariesBuilder
)
{
Debug
.
Assert
(
arguments
!=
null
);
Debug
.
Assert
(
refKinds
!=
null
);
Debug
.
Assert
(
arguments
.
Length
==
refKinds
.
Count
);
Debug
.
Assert
(
storesToTemps
!=
null
);
Debug
.
Assert
(
temporariesBuilder
!=
null
);
if
(
storesToTemps
.
Count
>
0
)
{
int
tempsNeeded
=
MergeArgumentsAndSideEffects
(
arguments
,
refKinds
,
storesToTemps
);
int
tempsNeeded
=
MergeArgumentsAndSideEffects
(
arguments
,
storesToTemps
);
if
(
tempsNeeded
>
0
)
{
foreach
(
BoundAssignmentOperator
s
in
storesToTemps
)
...
...
@@ -975,11 +972,9 @@ private static BoundExpression MakeLiteral(SyntaxNode syntax, ConstantValue cons
/// </summary>
private
static
int
MergeArgumentsAndSideEffects
(
BoundExpression
[]
arguments
,
ArrayBuilder
<
RefKind
>
refKinds
,
ArrayBuilder
<
BoundAssignmentOperator
>
tempStores
)
{
Debug
.
Assert
(
arguments
!=
null
);
Debug
.
Assert
(
refKinds
!=
null
);
Debug
.
Assert
(
tempStores
!=
null
);
int
tempsRemainedInUse
=
tempStores
.
Count
;
...
...
@@ -1025,11 +1020,6 @@ private static BoundExpression MakeLiteral(SyntaxNode syntax, ConstantValue cons
{
var
value
=
tempStores
[
correspondingStore
].
Right
;
// When we created the temp, we dropped the argument RefKind
// since the local contained its own RefKind. Since we're removing
// the temp, the argument RefKind needs to be restored.
refKinds
[
a
]
=
((
BoundLocal
)
argument
).
LocalSymbol
.
RefKind
;
// the matched store will not need to go into side-effects, only ones before it will
// remove the store to signal that we are not using its temp.
tempStores
[
correspondingStore
]
=
null
;
...
...
src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenRefOutTests.cs
浏览文件 @
e84ce90f
...
...
@@ -369,5 +369,65 @@ .maxstack 2
}"
);
}
[
WorkItem
(
24014
,
"https://github.com/dotnet/roslyn/issues/24014"
)]
[
Fact
]
public
void
OutParamAdOptional
()
{
var
code
=
@"
using System;
public class C
{
public static C cc => new C();
readonly int x;
readonly int y;
public static void Main()
{
var v = new C(1);
System.Console.WriteLine('Q');
}
private C()
{
}
private C(int x)
{
var c = C.cc.Test(1, this, out x, out y);
}
public C Test(object arg1, C arg2, out int i1, out int i2, object opt = null)
{
i1 = 1;
i2 = 2;
return arg2;
}
}
"
;
var
compilation
=
CreateCompilationWithMscorlibAndSystemCore
(
code
,
options
:
TestOptions
.
ReleaseExe
);
var
verifier
=
CompileAndVerify
(
compilation
,
expectedOutput
:
"Q"
);
verifier
.
VerifyIL
(
"C..ctor(int)"
,
@"
{
// Code size 34 (0x22)
.maxstack 6
IL_0000: ldarg.0
IL_0001: call ""object..ctor()""
IL_0006: call ""C C.cc.get""
IL_000b: ldc.i4.1
IL_000c: box ""int""
IL_0011: ldarg.0
IL_0012: ldarga.s V_1
IL_0014: ldarg.0
IL_0015: ldflda ""int C.y""
IL_001a: ldnull
IL_001b: callvirt ""C C.Test(object, C, out int, out int, object)""
IL_0020: pop
IL_0021: ret
}"
);
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录