Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dotNET Platform
runtime
提交
13d8d2ec
R
runtime
项目概览
dotNET Platform
/
runtime
12 个月 前同步成功
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
runtime
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
13d8d2ec
编写于
8月 26, 2022
作者:
S
Steve Harter
提交者:
GitHub
8月 26, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
For perf, remove Invoker pattern for fields (#74614)
上级
6c3c2347
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
31 addition
and
140 deletion
+31
-140
src/coreclr/System.Private.CoreLib/src/System/Reflection/RtFieldInfo.cs
...stem.Private.CoreLib/src/System/Reflection/RtFieldInfo.cs
+29
-74
src/coreclr/System.Private.CoreLib/src/System/RuntimeHandles.cs
...reclr/System.Private.CoreLib/src/System/RuntimeHandles.cs
+0
-1
src/coreclr/vm/object.h
src/coreclr/vm/object.h
+0
-1
src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems
...ivate.CoreLib/src/System.Private.CoreLib.Shared.projitems
+0
-1
src/libraries/System.Private.CoreLib/src/System/Reflection/FieldAccessor.cs
...em.Private.CoreLib/src/System/Reflection/FieldAccessor.cs
+0
-34
src/mono/System.Private.CoreLib/src/System/Reflection/RuntimeFieldInfo.cs
...Private.CoreLib/src/System/Reflection/RuntimeFieldInfo.cs
+2
-29
未找到文件。
src/coreclr/System.Private.CoreLib/src/System/Reflection/RtFieldInfo.cs
浏览文件 @
13d8d2ec
...
...
@@ -18,23 +18,12 @@ internal sealed unsafe class RtFieldInfo : RuntimeFieldInfo, IRuntimeFieldInfo
// lazy caching
private
string
?
m_name
;
private
RuntimeType
?
m_fieldType
;
internal
FieldAccessor
?
m_invoker
;
private
InvocationFlags
m_invocationFlags
;
internal
InvocationFlags
InvocationFlags
{
[
MethodImpl
(
MethodImplOptions
.
AggressiveInlining
)]
get
=>
(
Invoker
.
_invocationFlags
&
InvocationFlags
.
Initialized
)
!=
0
?
Invoker
.
_invocationFlags
:
InitializeInvocationFlags
();
}
private
FieldAccessor
Invoker
{
[
MethodImpl
(
MethodImplOptions
.
AggressiveInlining
)]
get
{
m_invoker
??=
new
FieldAccessor
(
this
);
return
m_invoker
;
}
get
=>
(
m_invocationFlags
&
InvocationFlags
.
Initialized
)
!=
0
?
m_invocationFlags
:
InitializeInvocationFlags
();
}
[
MethodImpl
(
MethodImplOptions
.
NoInlining
)]
...
...
@@ -67,7 +56,7 @@ private InvocationFlags InitializeInvocationFlags()
}
// must be last to avoid threading problems
return
Invoker
.
_invocationFlags
=
invocationFlags
|
InvocationFlags
.
Initialized
;
return
m
_invocationFlags
=
invocationFlags
|
InvocationFlags
.
Initialized
;
}
#
endregion
...
...
@@ -113,63 +102,6 @@ internal override bool CacheEquals(object? o)
return
o
is
RtFieldInfo
m
&&
m
.
m_fieldHandle
==
m_fieldHandle
;
}
[
DebuggerStepThrough
]
[
DebuggerHidden
]
internal
object
?
GetValueNonEmit
(
object
?
obj
)
{
RuntimeType
?
declaringType
=
DeclaringType
as
RuntimeType
;
RuntimeType
fieldType
=
(
RuntimeType
)
FieldType
;
bool
domainInitialized
=
false
;
if
(
declaringType
==
null
)
{
return
RuntimeFieldHandle
.
GetValue
(
this
,
obj
,
fieldType
,
null
,
ref
domainInitialized
);
}
else
{
domainInitialized
=
declaringType
.
DomainInitialized
;
object
?
retVal
=
RuntimeFieldHandle
.
GetValue
(
this
,
obj
,
fieldType
,
declaringType
,
ref
domainInitialized
);
declaringType
.
DomainInitialized
=
domainInitialized
;
return
retVal
;
}
}
[
DebuggerStepThrough
]
[
DebuggerHidden
]
internal
void
SetValueNonEmit
(
object
?
obj
,
object
?
value
)
{
RuntimeType
?
declaringType
=
DeclaringType
as
RuntimeType
;
RuntimeType
fieldType
=
(
RuntimeType
)
FieldType
;
bool
domainInitialized
=
false
;
if
(
declaringType
==
null
)
{
RuntimeFieldHandle
.
SetValue
(
this
,
obj
,
value
,
fieldType
,
Attributes
,
declaringType
:
null
,
ref
domainInitialized
);
}
else
{
domainInitialized
=
declaringType
.
DomainInitialized
;
RuntimeFieldHandle
.
SetValue
(
this
,
obj
,
value
,
fieldType
,
Attributes
,
declaringType
,
ref
domainInitialized
);
declaringType
.
DomainInitialized
=
domainInitialized
;
}
}
#
endregion
#
region
MemberInfo
Overrides
...
...
@@ -211,7 +143,20 @@ internal override RuntimeModule GetRuntimeModule()
CheckConsistency
(
obj
);
return
Invoker
.
GetValue
(
obj
);
RuntimeType
fieldType
=
(
RuntimeType
)
FieldType
;
bool
domainInitialized
=
false
;
if
(
declaringType
==
null
)
{
return
RuntimeFieldHandle
.
GetValue
(
this
,
obj
,
fieldType
,
null
,
ref
domainInitialized
);
}
else
{
domainInitialized
=
declaringType
.
DomainInitialized
;
object
?
retVal
=
RuntimeFieldHandle
.
GetValue
(
this
,
obj
,
fieldType
,
declaringType
,
ref
domainInitialized
);
declaringType
.
DomainInitialized
=
domainInitialized
;
return
retVal
;
}
}
public
override
object
GetRawConstantValue
()
{
throw
new
InvalidOperationException
();
}
...
...
@@ -258,7 +203,17 @@ public override void SetValue(object? obj, object? value, BindingFlags invokeAtt
fieldType
.
CheckValue
(
ref
value
,
copyBack
:
ref
_ref
,
binder
,
culture
,
invokeAttr
);
}
Invoker
.
SetValue
(
obj
,
value
);
bool
domainInitialized
=
false
;
if
(
declaringType
is
null
)
{
RuntimeFieldHandle
.
SetValue
(
this
,
obj
,
value
,
fieldType
,
m_fieldAttributes
,
null
,
ref
domainInitialized
);
}
else
{
domainInitialized
=
declaringType
.
DomainInitialized
;
RuntimeFieldHandle
.
SetValue
(
this
,
obj
,
value
,
fieldType
,
m_fieldAttributes
,
declaringType
,
ref
domainInitialized
);
declaringType
.
DomainInitialized
=
domainInitialized
;
}
}
[
DebuggerStepThrough
]
...
...
src/coreclr/System.Private.CoreLib/src/System/RuntimeHandles.cs
浏览文件 @
13d8d2ec
...
...
@@ -1185,7 +1185,6 @@ public RuntimeFieldInfoStub(RuntimeFieldHandleInternal fieldHandle, object keepa
private
object
?
m_d
;
private
int
m_b
;
private
object
?
m_e
;
private
object
?
m_f
;
private
RuntimeFieldHandleInternal
m_fieldHandle
;
#pragma warning restore 414, 169
...
...
src/coreclr/vm/object.h
浏览文件 @
13d8d2ec
...
...
@@ -1153,7 +1153,6 @@ protected:
INT32
m_empty2
;
OBJECTREF
m_empty3
;
OBJECTREF
m_empty4
;
OBJECTREF
m_empty5
;
FieldDesc
*
m_pFD
;
public:
...
...
src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems
浏览文件 @
13d8d2ec
...
...
@@ -617,7 +617,6 @@
<Compile Include="$(MSBuildThisFileDirectory)System\Reflection\EventInfo.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Reflection\ExceptionHandlingClause.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Reflection\ExceptionHandlingClauseOptions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Reflection\FieldAccessor.cs" Condition="'$(FeatureNativeAot)' != 'true'" />
<Compile Include="$(MSBuildThisFileDirectory)System\Reflection\FieldAttributes.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Reflection\FieldInfo.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Reflection\GenericParameterAttributes.cs" />
...
...
src/libraries/System.Private.CoreLib/src/System/Reflection/FieldAccessor.cs
已删除
100644 → 0
浏览文件 @
6c3c2347
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using
System.Diagnostics
;
namespace
System.Reflection
{
internal
sealed
partial
class
FieldAccessor
{
private
readonly
RtFieldInfo
_fieldInfo
;
public
InvocationFlags
_invocationFlags
;
public
FieldAccessor
(
RtFieldInfo
fieldInfo
)
{
_fieldInfo
=
fieldInfo
;
}
[
DebuggerStepThrough
]
[
DebuggerHidden
]
public
object
?
GetValue
(
object
?
obj
)
{
// Todo: add strategy for calling IL Emit-based version
return
_fieldInfo
.
GetValueNonEmit
(
obj
);
}
[
DebuggerStepThrough
]
[
DebuggerHidden
]
public
void
SetValue
(
object
?
obj
,
object
?
value
)
{
// Todo: add strategy for calling IL Emit-based version
_fieldInfo
.
SetValueNonEmit
(
obj
,
value
);
}
}
}
src/mono/System.Private.CoreLib/src/System/Reflection/RuntimeFieldInfo.cs
浏览文件 @
13d8d2ec
...
...
@@ -38,8 +38,6 @@ internal abstract class RtFieldInfo : FieldInfo
internal
abstract
object
UnsafeGetValue
(
object
obj
);
internal
abstract
void
UnsafeSetValue
(
object
obj
,
object
value
,
BindingFlags
invokeAttr
,
Binder
binder
,
CultureInfo
culture
);
internal
abstract
void
CheckConsistency
(
object
target
);
internal
abstract
object
?
GetValueNonEmit
(
object
?
obj
);
internal
abstract
void
SetValueNonEmit
(
object
?
obj
,
object
?
value
);
}
[
StructLayout
(
LayoutKind
.
Sequential
)]
...
...
@@ -51,19 +49,8 @@ internal sealed class RuntimeFieldInfo : RtFieldInfo
private
string
?
name
;
private
Type
?
type
;
private
FieldAttributes
attrs
;
private
FieldAccessor
?
invoker
;
#pragma warning restore 649
private
FieldAccessor
Invoker
{
[
MethodImpl
(
MethodImplOptions
.
AggressiveInlining
)]
get
{
invoker
??=
new
FieldAccessor
(
this
);
return
invoker
;
}
}
public
override
Module
Module
{
get
...
...
@@ -128,13 +115,6 @@ public override void SetValueDirect(TypedReference obj, object value)
}
}
[
DebuggerStepThrough
]
[
DebuggerHidden
]
internal
override
void
SetValueNonEmit
(
object
?
obj
,
object
?
value
)
{
SetValueInternal
(
this
,
obj
,
value
);
}
[
DebuggerStepThrough
]
[
DebuggerHidden
]
public
override
object
GetValueDirect
(
TypedReference
obj
)
...
...
@@ -149,13 +129,6 @@ public override object GetValueDirect(TypedReference obj)
}
}
[
DebuggerStepThrough
]
[
DebuggerHidden
]
internal
override
object
?
GetValueNonEmit
(
object
?
obj
)
{
return
GetValueInternal
(
obj
);
}
public
override
FieldAttributes
Attributes
{
get
...
...
@@ -239,7 +212,7 @@ public override object[] GetCustomAttributes(Type attributeType, bool inherit)
if
(!
IsLiteral
)
CheckGeneric
();
return
Invoker
.
GetValue
(
obj
);
return
GetValueInternal
(
obj
);
}
public
override
string
ToString
()
...
...
@@ -278,7 +251,7 @@ public override void SetValue(object? obj, object? val, BindingFlags invokeAttr,
}
}
Invoker
.
SetValue
(
obj
,
val
);
SetValueInternal
(
this
,
obj
,
val
);
}
internal
RuntimeFieldInfo
Clone
(
string
newName
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录