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:
authorDavid Wrighton <davidwr@microsoft.com>2017-02-15 02:35:19 +0300
committerDavid Wrighton <davidwr@microsoft.com>2017-02-15 02:35:19 +0300
commit720e17f599c1d8aca941dbca8a9492f3474f3b05 (patch)
tree544ecb53dbff7736b2945c7b58c5b6f997ee4734 /src/Test.CoreLib
parent1a8e729b2e9e3915947cace8c3bf316237d519e6 (diff)
Refactor use of TypeManager and Module pointers within the BCL
- Move from using an IntPtr which may represent a TypeManager* or a OS module pointer to using a struct TypeManagerHandle consistently - Except for RuntimeSignature, which has a third possible meaning of its IntPtr. That work will be done in a seperate change, and wil result in removal of nearly all of the new TypeManagerHandle calls in this delta. - This struct contains a bit which indicates which form of pointer is being worked with, as well as routines for performing RVA access as appropriate - Added new api to redhawk to get the OS module list (Used in crash dump generation) - Added new api to get the OS module of of a pointer. These are not yet enabled for TypeManager based scenarios, but that will be done in a followon change. Eventually these will exclusively be use for instruction pointers, and will tie into diagnostic scenarios around stack traces, etc. Currently, it is also used in a few reflection scenarios. Those code patterns will be removed soon. - Similarly distinguished between getting the OS module for an EEType, and getting the module for an EEType. This is used in error message scenarios. - Update RhFindBlob to work with both types of module pointers [tfs-changeset: 1647831]
Diffstat (limited to 'src/Test.CoreLib')
-rw-r--r--src/Test.CoreLib/src/System/Object.cs93
-rw-r--r--src/Test.CoreLib/src/System/Runtime/RuntimeImports.cs8
-rw-r--r--src/Test.CoreLib/src/Test.CoreLib.csproj9
3 files changed, 104 insertions, 6 deletions
diff --git a/src/Test.CoreLib/src/System/Object.cs b/src/Test.CoreLib/src/System/Object.cs
new file mode 100644
index 000000000..a6addf96b
--- /dev/null
+++ b/src/Test.CoreLib/src/System/Object.cs
@@ -0,0 +1,93 @@
+// 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.
+
+/*============================================================
+**
+**
+**
+** Object is the root class for all CLR objects. This class
+** defines only the basics.
+**
+**
+===========================================================*/
+
+using System.Runtime;
+using System.Diagnostics;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// TODO: remove when m_pEEType becomes EETypePtr
+using EEType = Internal.Runtime.EEType;
+
+namespace System
+{
+ // CONTRACT with Runtime
+ // The Object type is one of the primitives understood by the compilers and runtime
+ // Data Contract: Single field of type EEType*
+ // VTable Contract: The first vtable slot should be the finalizer for object => The first virtual method in the object class should be the Finalizer
+
+ // The Object is the root class for all object in the CLR System. Object
+ // is the super class for all other CLR objects and provide a set of methods and low level
+ // services to subclasses.
+
+ public unsafe class Object
+ {
+ // CS0649: Field '{blah}' is never assigned to, and will always have its default value
+#pragma warning disable 649
+
+ // Marked as internal for now so that some classes can use C#'s fixed statement on objects.
+ // Wouldn't have to do this if we could directly declared pinned locals.
+ // TODO: Consider making this EETypePtr instead of EEType*.
+ internal EEType* m_pEEType;
+
+#pragma warning restore
+
+ // Creates a new instance of an Object.
+ public Object()
+ {
+ }
+
+ // Allow an object to free resources before the object is reclaimed by the GC.
+ // CONTRACT with runtime: This method's virtual slot number is hardcoded in the binder. It is an
+ // implementation detail where it winds up at runtime.
+ // **** Do not add any virtual methods in this class ahead of this ****
+
+ ~Object()
+ {
+ }
+
+ public virtual bool Equals(object o)
+ {
+ return false;
+ }
+
+ public virtual int GetHashCode()
+ {
+ return 0;
+ }
+
+ internal unsafe EEType* EEType
+ {
+ get
+ {
+ // NOTE: if managed code can be run when the GC has objects marked, then this method is
+ // unsafe. But, generically, we don't expect managed code such as this to be allowed
+ // to run while the GC is running.
+ return m_pEEType;
+ //PREFER m_pEEType.ToPointer();
+ }
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ private class RawData
+ {
+ public byte Data;
+ }
+
+ internal ref byte GetRawData()
+ {
+ return ref Unsafe.As<RawData>(this).Data;
+ }
+ }
+}
diff --git a/src/Test.CoreLib/src/System/Runtime/RuntimeImports.cs b/src/Test.CoreLib/src/System/Runtime/RuntimeImports.cs
index a11525da7..555420e54 100644
--- a/src/Test.CoreLib/src/System/Runtime/RuntimeImports.cs
+++ b/src/Test.CoreLib/src/System/Runtime/RuntimeImports.cs
@@ -47,11 +47,15 @@ namespace System.Runtime
[RuntimeImport(RuntimeLibrary, "RhpGetModuleSection")]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- internal static extern IntPtr RhGetModuleSection(IntPtr module, ReadyToRunSectionType section, out int length);
+ internal static extern IntPtr RhGetModuleSection(TypeManagerHandle module, ReadyToRunSectionType section, out int length);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
[RuntimeImport(RuntimeLibrary, "RhpCreateTypeManager")]
- internal static extern unsafe IntPtr RhpCreateTypeManager(IntPtr moduleHeader);
+ internal static extern unsafe TypeManagerHandle RhpCreateTypeManager(IntPtr osModule, IntPtr moduleHeader);
+
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ [RuntimeImport(RuntimeLibrary, "RhpRegisterOsModule")]
+ internal static extern unsafe IntPtr RhpRegisterOsModule(IntPtr osModule);
//
// calls to runtime for allocation
diff --git a/src/Test.CoreLib/src/Test.CoreLib.csproj b/src/Test.CoreLib/src/Test.CoreLib.csproj
index 1a89528ab..8bbec76b9 100644
--- a/src/Test.CoreLib/src/Test.CoreLib.csproj
+++ b/src/Test.CoreLib/src/Test.CoreLib.csproj
@@ -160,9 +160,6 @@
<Compile Include="..\..\Runtime.Base\src\System\Nullable.cs">
<Link>System\Nullable.cs</Link>
</Compile>
- <Compile Include="..\..\Runtime.Base\src\System\Object.cs">
- <Link>System\Object.cs</Link>
- </Compile>
<Compile Include="..\..\Runtime.Base\src\System\ParamArrayAttribute.cs">
<Link>System\ParamArrayAttribute.cs</Link>
</Compile>
@@ -252,6 +249,10 @@
<Compile Include="System\Runtime\RuntimeImports.cs" />
<Compile Include="System\Threading\Interlocked.cs" />
<Compile Include="System\RuntimeExceptionHelpers.cs" />
+ <Compile Include="System\Object.cs" />
+ <Compile Include="..\..\Common\src\Internal\Runtime\TypeManagerHandle.cs">
+ <Link>Internal\Runtime\TypeManagerHandle.cs</Link>
+ </Compile>
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
<PropertyGroup>
@@ -259,4 +260,4 @@
<AssemblyInfoPartialFile>
</AssemblyInfoPartialFile>
</PropertyGroup>
-</Project> \ No newline at end of file
+</Project>