Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFadi Hanna <fadim@microsoft.com>2017-08-07 21:28:17 +0300
committerFadi Hanna <fadim@microsoft.com>2017-08-07 21:28:17 +0300
commit95c4bdb748edbbfa1d27f7de007925a36a7936c8 (patch)
tree49fede6a9e38acf44bf4ea8091fbfe67dbebd3df /src/System.Private.Reflection.Execution
parentd1c4689abe76bda148cda44973d7178123265184 (diff)
This changeset includes a couple of workitems that are related to each other:
1) Enable field access for USG cases (Rooting reflectable fields in the graph, filling TODOs in the FieldAccessMap and StaticsInfoHashtable structures) 2) Implementation of TLS fields reflection support for ProjectX (CoreRT is still TODO) 3) Refactoring/simplification of TLS access (deleting the ThreadStaticFieldOffsets struct from the native runtime, and simplifying TLS access code) 4) Adding more tests to the PX DynamicGenerics unit test. [tfs-changeset: 1669403]
Diffstat (limited to 'src/System.Private.Reflection.Execution')
-rw-r--r--src/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/ExecutionEnvironmentImplementation.MappingTables.cs19
-rw-r--r--src/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/FieldAccessors/ReferenceTypeFieldAccessorForThreadStaticFields.cs12
-rw-r--r--src/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/FieldAccessors/ReferenceTypeFieldAccessorForUniversalThreadStaticFields.cs43
-rw-r--r--src/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/FieldAccessors/ValueTypeFieldAccessorForThreadStaticFields.cs12
-rw-r--r--src/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/FieldAccessors/ValueTypeFieldAccessorForUniversalThreadStaticFields.cs45
-rw-r--r--src/System.Private.Reflection.Execution/src/System.Private.Reflection.Execution.csproj2
6 files changed, 21 insertions, 112 deletions
diff --git a/src/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/ExecutionEnvironmentImplementation.MappingTables.cs b/src/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/ExecutionEnvironmentImplementation.MappingTables.cs
index e269bf6b5..1ee698705 100644
--- a/src/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/ExecutionEnvironmentImplementation.MappingTables.cs
+++ b/src/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/ExecutionEnvironmentImplementation.MappingTables.cs
@@ -1367,26 +1367,21 @@ namespace Internal.Reflection.Execution
}
case FieldTableFlags.ThreadStatic:
- if (fieldAccessMetadata.Cookie == IntPtr.Zero)
{
return RuntimeAugments.IsValueType(fieldTypeHandle) ?
- (FieldAccessor)new ValueTypeFieldAccessorForUniversalThreadStaticFields(
- TryGetStaticClassConstructionContext(declaringTypeHandle),
- declaringTypeHandle,
+ (FieldAccessor)new ValueTypeFieldAccessorForThreadStaticFields(
+ TryGetStaticClassConstructionContext(declaringTypeHandle),
+ declaringTypeHandle,
+ (int)fieldAccessMetadata.Cookie,
fieldAccessMetadata.Offset,
fieldTypeHandle) :
- (FieldAccessor)new ReferenceTypeFieldAccessorForUniversalThreadStaticFields(
- TryGetStaticClassConstructionContext(declaringTypeHandle),
+ (FieldAccessor)new ReferenceTypeFieldAccessorForThreadStaticFields(
+ TryGetStaticClassConstructionContext(declaringTypeHandle),
declaringTypeHandle,
+ (int)fieldAccessMetadata.Cookie,
fieldAccessMetadata.Offset,
fieldTypeHandle);
}
- else
- {
- return RuntimeAugments.IsValueType(fieldTypeHandle) ?
- (FieldAccessor)new ValueTypeFieldAccessorForThreadStaticFields(TryGetStaticClassConstructionContext(declaringTypeHandle), declaringTypeHandle, fieldAccessMetadata.Cookie, fieldTypeHandle) :
- (FieldAccessor)new ReferenceTypeFieldAccessorForThreadStaticFields(TryGetStaticClassConstructionContext(declaringTypeHandle), declaringTypeHandle, fieldAccessMetadata.Cookie, fieldTypeHandle);
- }
}
return null;
diff --git a/src/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/FieldAccessors/ReferenceTypeFieldAccessorForThreadStaticFields.cs b/src/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/FieldAccessors/ReferenceTypeFieldAccessorForThreadStaticFields.cs
index 8d6a7758d..68fe3c817 100644
--- a/src/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/FieldAccessors/ReferenceTypeFieldAccessorForThreadStaticFields.cs
+++ b/src/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/FieldAccessors/ReferenceTypeFieldAccessorForThreadStaticFields.cs
@@ -16,25 +16,27 @@ namespace Internal.Reflection.Execution.FieldAccessors
{
internal sealed class ReferenceTypeFieldAccessorForThreadStaticFields : WritableStaticFieldAccessor
{
- private IntPtr _cookie;
+ private int _threadStaticsBlockOffset;
+ private int _fieldOffset;
private RuntimeTypeHandle _declaringTypeHandle;
- public ReferenceTypeFieldAccessorForThreadStaticFields(IntPtr cctorContext, RuntimeTypeHandle declaringTypeHandle, IntPtr cookie, RuntimeTypeHandle fieldTypeHandle)
+ public ReferenceTypeFieldAccessorForThreadStaticFields(IntPtr cctorContext, RuntimeTypeHandle declaringTypeHandle, int threadStaticsBlockOffset, int fieldOffset, RuntimeTypeHandle fieldTypeHandle)
: base(cctorContext, fieldTypeHandle)
{
- _cookie = cookie;
+ _threadStaticsBlockOffset = threadStaticsBlockOffset;
+ _fieldOffset = fieldOffset;
_declaringTypeHandle = declaringTypeHandle;
}
protected sealed override Object GetFieldBypassCctor()
{
- IntPtr fieldAddress = RuntimeAugments.GetThreadStaticFieldAddress(_declaringTypeHandle, _cookie);
+ IntPtr fieldAddress = RuntimeAugments.GetThreadStaticFieldAddress(_declaringTypeHandle, _threadStaticsBlockOffset, _fieldOffset);
return RuntimeAugments.LoadReferenceTypeField(fieldAddress);
}
protected sealed override void UncheckedSetFieldBypassCctor(Object value)
{
- IntPtr fieldAddress = RuntimeAugments.GetThreadStaticFieldAddress(_declaringTypeHandle, _cookie);
+ IntPtr fieldAddress = RuntimeAugments.GetThreadStaticFieldAddress(_declaringTypeHandle, _threadStaticsBlockOffset, _fieldOffset);
RuntimeAugments.StoreReferenceTypeField(fieldAddress, value);
}
}
diff --git a/src/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/FieldAccessors/ReferenceTypeFieldAccessorForUniversalThreadStaticFields.cs b/src/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/FieldAccessors/ReferenceTypeFieldAccessorForUniversalThreadStaticFields.cs
deleted file mode 100644
index a273eaead..000000000
--- a/src/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/FieldAccessors/ReferenceTypeFieldAccessorForUniversalThreadStaticFields.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using global::System;
-using global::System.Threading;
-using global::System.Reflection;
-using global::System.Diagnostics;
-using global::System.Collections.Generic;
-
-using global::Internal.Runtime.Augments;
-using global::Internal.Reflection.Execution;
-using global::Internal.Reflection.Core.Execution;
-
-namespace Internal.Reflection.Execution.FieldAccessors
-{
- internal sealed class ReferenceTypeFieldAccessorForUniversalThreadStaticFields : WritableStaticFieldAccessor
- {
- private int _fieldOffset;
- private RuntimeTypeHandle _declaringTypeHandle;
-
- public ReferenceTypeFieldAccessorForUniversalThreadStaticFields(IntPtr cctorContext, RuntimeTypeHandle declaringTypeHandle, int fieldOffset, RuntimeTypeHandle fieldTypeHandle)
- : base(cctorContext, fieldTypeHandle)
- {
- _fieldOffset = fieldOffset;
- _declaringTypeHandle = declaringTypeHandle;
- }
-
- protected sealed override Object GetFieldBypassCctor()
- {
- IntPtr tlsFieldsStartAddress = RuntimeAugments.GetThreadStaticFieldAddress(_declaringTypeHandle, IntPtr.Zero);
- IntPtr fieldAddress = tlsFieldsStartAddress + _fieldOffset;
- return RuntimeAugments.LoadReferenceTypeField(fieldAddress);
- }
-
- protected sealed override void UncheckedSetFieldBypassCctor(Object value)
- {
- IntPtr tlsFieldsStartAddress = RuntimeAugments.GetThreadStaticFieldAddress(_declaringTypeHandle, IntPtr.Zero);
- IntPtr fieldAddress = tlsFieldsStartAddress + _fieldOffset;
- RuntimeAugments.StoreReferenceTypeField(fieldAddress, value);
- }
- }
-}
diff --git a/src/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/FieldAccessors/ValueTypeFieldAccessorForThreadStaticFields.cs b/src/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/FieldAccessors/ValueTypeFieldAccessorForThreadStaticFields.cs
index 3c77fba29..9b03d4a16 100644
--- a/src/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/FieldAccessors/ValueTypeFieldAccessorForThreadStaticFields.cs
+++ b/src/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/FieldAccessors/ValueTypeFieldAccessorForThreadStaticFields.cs
@@ -18,25 +18,27 @@ namespace Internal.Reflection.Execution.FieldAccessors
{
internal sealed class ValueTypeFieldAccessorForThreadStaticFields : WritableStaticFieldAccessor
{
- private IntPtr _cookie;
+ private int _threadStaticsBlockOffset;
+ private int _fieldOffset;
private RuntimeTypeHandle _declaringTypeHandle;
- public ValueTypeFieldAccessorForThreadStaticFields(IntPtr cctorContext, RuntimeTypeHandle declaringTypeHandle, IntPtr cookie, RuntimeTypeHandle fieldTypeHandle)
+ public ValueTypeFieldAccessorForThreadStaticFields(IntPtr cctorContext, RuntimeTypeHandle declaringTypeHandle, int threadStaticsBlockOffset, int fieldOffset, RuntimeTypeHandle fieldTypeHandle)
: base(cctorContext, fieldTypeHandle)
{
- _cookie = cookie;
+ _threadStaticsBlockOffset = threadStaticsBlockOffset;
+ _fieldOffset = fieldOffset;
_declaringTypeHandle = declaringTypeHandle;
}
protected sealed override Object GetFieldBypassCctor()
{
- IntPtr fieldAddress = RuntimeAugments.GetThreadStaticFieldAddress(_declaringTypeHandle, _cookie);
+ IntPtr fieldAddress = RuntimeAugments.GetThreadStaticFieldAddress(_declaringTypeHandle, _threadStaticsBlockOffset, _fieldOffset);
return RuntimeAugments.LoadValueTypeField(fieldAddress, FieldTypeHandle);
}
protected sealed override void UncheckedSetFieldBypassCctor(Object value)
{
- IntPtr fieldAddress = RuntimeAugments.GetThreadStaticFieldAddress(_declaringTypeHandle, _cookie);
+ IntPtr fieldAddress = RuntimeAugments.GetThreadStaticFieldAddress(_declaringTypeHandle, _threadStaticsBlockOffset, _fieldOffset);
RuntimeAugments.StoreValueTypeField(fieldAddress, value, FieldTypeHandle);
}
}
diff --git a/src/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/FieldAccessors/ValueTypeFieldAccessorForUniversalThreadStaticFields.cs b/src/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/FieldAccessors/ValueTypeFieldAccessorForUniversalThreadStaticFields.cs
deleted file mode 100644
index 916854c96..000000000
--- a/src/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/FieldAccessors/ValueTypeFieldAccessorForUniversalThreadStaticFields.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using global::System;
-using global::System.Threading;
-using global::System.Reflection;
-using global::System.Diagnostics;
-using global::System.Collections.Generic;
-
-using global::Internal.Runtime.Augments;
-using global::Internal.Reflection.Execution;
-using global::Internal.Reflection.Core.Execution;
-
-using global::Internal.Metadata.NativeFormat;
-
-namespace Internal.Reflection.Execution.FieldAccessors
-{
- internal sealed class ValueTypeFieldAccessorForUniversalThreadStaticFields : WritableStaticFieldAccessor
- {
- private int _fieldOffset;
- private RuntimeTypeHandle _declaringTypeHandle;
-
- public ValueTypeFieldAccessorForUniversalThreadStaticFields(IntPtr cctorContext, RuntimeTypeHandle declaringTypeHandle, int fieldOffset, RuntimeTypeHandle fieldTypeHandle)
- : base(cctorContext, fieldTypeHandle)
- {
- _fieldOffset = fieldOffset;
- _declaringTypeHandle = declaringTypeHandle;
- }
-
- protected sealed override Object GetFieldBypassCctor()
- {
- IntPtr tlsFieldsStartAddress = RuntimeAugments.GetThreadStaticFieldAddress(_declaringTypeHandle, IntPtr.Zero);
- IntPtr fieldAddress = tlsFieldsStartAddress + _fieldOffset;
- return RuntimeAugments.LoadValueTypeField(fieldAddress, FieldTypeHandle);
- }
-
- protected sealed override void UncheckedSetFieldBypassCctor(Object value)
- {
- IntPtr tlsFieldsStartAddress = RuntimeAugments.GetThreadStaticFieldAddress(_declaringTypeHandle, IntPtr.Zero);
- IntPtr fieldAddress = tlsFieldsStartAddress + _fieldOffset;
- RuntimeAugments.StoreValueTypeField(fieldAddress, value, FieldTypeHandle);
- }
- }
-}
diff --git a/src/System.Private.Reflection.Execution/src/System.Private.Reflection.Execution.csproj b/src/System.Private.Reflection.Execution/src/System.Private.Reflection.Execution.csproj
index 75bcf70dc..c4aa1119c 100644
--- a/src/System.Private.Reflection.Execution/src/System.Private.Reflection.Execution.csproj
+++ b/src/System.Private.Reflection.Execution/src/System.Private.Reflection.Execution.csproj
@@ -74,12 +74,10 @@
<Compile Include="Internal\Reflection\Execution\FieldAccessors\ReferenceTypeFieldAccessorForInstanceFields.cs" />
<Compile Include="Internal\Reflection\Execution\FieldAccessors\ReferenceTypeFieldAccessorForStaticFields.cs" />
<Compile Include="Internal\Reflection\Execution\FieldAccessors\ReferenceTypeFieldAccessorForThreadStaticFields.cs" />
- <Compile Include="Internal\Reflection\Execution\FieldAccessors\ReferenceTypeFieldAccessorForUniversalThreadStaticFields.cs" />
<Compile Include="Internal\Reflection\Execution\FieldAccessors\StaticFieldAccessor.cs" />
<Compile Include="Internal\Reflection\Execution\FieldAccessors\ValueTypeFieldAccessorForInstanceFields.cs" />
<Compile Include="Internal\Reflection\Execution\FieldAccessors\ValueTypeFieldAccessorForStaticFields.cs" />
<Compile Include="Internal\Reflection\Execution\FieldAccessors\ValueTypeFieldAccessorForThreadStaticFields.cs" />
- <Compile Include="Internal\Reflection\Execution\FieldAccessors\ValueTypeFieldAccessorForUniversalThreadStaticFields.cs" />
<Compile Include="Internal\Reflection\Execution\FieldAccessors\WritableStaticFieldAccessor.cs" />
<Compile Include="Internal\Reflection\Execution\MethodInvokers\MethodInvokerWithMethodInvokeInfo.cs" />
<Compile Include="Internal\Reflection\Execution\MethodInvokers\InstanceMethodInvoker.cs" />