Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/coreclr/nativeaot/Runtime/RuntimeInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ enum GenericVarianceType : uint8_t;

#include "forward_declarations.h"
#include "ICodeManager.h"
#include "cdacdata.h"

extern "C" void PopulateDebugHeaders();

Expand All @@ -20,6 +21,7 @@ class RuntimeInstance
friend class AsmOffsets;
friend class Thread;
friend void PopulateDebugHeaders();
friend struct ::cdac_data<RuntimeInstance>;

HANDLE m_hPalInstance; // this is the HANDLE passed into DllMain

Expand Down Expand Up @@ -109,6 +111,13 @@ class RuntimeInstance
};
typedef DPTR(RuntimeInstance) PTR_RuntimeInstance;

template<> struct cdac_data<RuntimeInstance>
{
static constexpr size_t OsModuleList = offsetof(RuntimeInstance, m_OsModuleList) + offsetof(SList<RuntimeInstance::OsModuleEntry>, m_pHead);
static constexpr size_t TypeManagerList = offsetof(RuntimeInstance, m_TypeManagerList) + offsetof(SList<RuntimeInstance::TypeManagerEntry>, m_pHead);
static constexpr size_t ManagedCodeStartRange = offsetof(RuntimeInstance, m_pvManagedCodeStartRange);
static constexpr size_t ManagedCodeRangeSize = offsetof(RuntimeInstance, m_cbManagedCodeRange);
};

PTR_RuntimeInstance GetRuntimeInstance();

Expand Down
9 changes: 9 additions & 0 deletions src/coreclr/nativeaot/Runtime/TypeManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
#pragma once
#include "ModuleHeaders.h"
#include "ICodeManager.h"
#include "cdacdata.h"

class TypeManager
{
friend struct ::cdac_data<TypeManager>;

// NOTE: Part of this layout is a contract with the managed side in TypeManagerHandle.cs
HANDLE m_osModule;
ReadyToRunHeader * m_pHeader;
Expand Down Expand Up @@ -55,3 +58,9 @@ struct TypeManagerHandle
TypeManager* AsTypeManager();
};

template<> struct cdac_data<TypeManager>
{
static constexpr size_t OsModule = offsetof(TypeManager, m_osModule);
static constexpr size_t Header = offsetof(TypeManager, m_pHeader);
};

Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "Pal.h"
#include "holder.h"
#include "RuntimeInstance.h"
#include "TypeManager.h"
#include "regdisplay.h"
#include "StackFrameIterator.h"
#include "thread.h"
Expand All @@ -21,6 +22,7 @@

GPTR_DECL(MethodTable, g_pFreeObjectEEType);
GPTR_DECL(StressLog, g_pStressLog);
GPTR_DECL(RuntimeInstance, g_pTheRuntimeInstance);

// ILC emits a ContractDescriptor named "DotNetManagedContractDescriptor" with
// managed type layouts. We take its address so datadescriptor.inc can reference
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,36 @@ CDAC_TYPE_INDETERMINATE(ThreadStore)
CDAC_TYPE_FIELD(ThreadStore, T_POINTER, FirstThreadLink, cdac_data<ThreadStore>::FirstThreadLink)
CDAC_TYPE_END(ThreadStore)

// ========================
// Loader (RuntimeInstance / TypeManager / module entries)
// ========================

CDAC_TYPE_BEGIN(RuntimeInstance)
CDAC_TYPE_INDETERMINATE(RuntimeInstance)
CDAC_TYPE_FIELD(RuntimeInstance, T_POINTER, OsModuleList, cdac_data<RuntimeInstance>::OsModuleList)
CDAC_TYPE_FIELD(RuntimeInstance, T_POINTER, TypeManagerList, cdac_data<RuntimeInstance>::TypeManagerList)
CDAC_TYPE_FIELD(RuntimeInstance, T_POINTER, ManagedCodeStartRange, cdac_data<RuntimeInstance>::ManagedCodeStartRange)
CDAC_TYPE_FIELD(RuntimeInstance, T_UINT32, ManagedCodeRangeSize, cdac_data<RuntimeInstance>::ManagedCodeRangeSize)
CDAC_TYPE_END(RuntimeInstance)

CDAC_TYPE_BEGIN(TypeManagerEntry)
CDAC_TYPE_INDETERMINATE(TypeManagerEntry)
CDAC_TYPE_FIELD(TypeManagerEntry, T_POINTER, Next, offsetof(RuntimeInstance::TypeManagerEntry, m_pNext))
CDAC_TYPE_FIELD(TypeManagerEntry, T_POINTER, TypeManager, offsetof(RuntimeInstance::TypeManagerEntry, m_pTypeManager))
CDAC_TYPE_END(TypeManagerEntry)

CDAC_TYPE_BEGIN(OsModuleEntry)
CDAC_TYPE_INDETERMINATE(OsModuleEntry)
CDAC_TYPE_FIELD(OsModuleEntry, T_POINTER, Next, offsetof(RuntimeInstance::OsModuleEntry, m_pNext))
CDAC_TYPE_FIELD(OsModuleEntry, T_POINTER, OsModule, offsetof(RuntimeInstance::OsModuleEntry, m_osModule))
CDAC_TYPE_END(OsModuleEntry)

Comment on lines +44 to +64
CDAC_TYPE_BEGIN(TypeManager)
CDAC_TYPE_INDETERMINATE(TypeManager)
CDAC_TYPE_FIELD(TypeManager, T_POINTER, OsModule, cdac_data<TypeManager>::OsModule)
CDAC_TYPE_FIELD(TypeManager, T_POINTER, Header, cdac_data<TypeManager>::Header)
CDAC_TYPE_END(TypeManager)

// ========================
// Allocation Context
// ========================
Expand Down Expand Up @@ -94,6 +124,7 @@ CDAC_TYPE_FIELD(StressLog, T_INT32, TotalChunks, offsetof(StressLog, totalChunk)
CDAC_TYPE_FIELD(StressLog, T_POINTER, Logs, offsetof(StressLog, logs))
CDAC_TYPE_FIELD(StressLog, T_UINT64, TickFrequency, offsetof(StressLog, tickFrequency))
CDAC_TYPE_FIELD(StressLog, T_UINT64, StartTimestamp, offsetof(StressLog, startTimeStamp))
CDAC_TYPE_FIELD(StressLog, T_NUINT, ModuleOffset, offsetof(StressLog, moduleOffset))
CDAC_TYPE_END(StressLog)

CDAC_TYPE_BEGIN(ThreadStressLog)
Expand Down Expand Up @@ -136,6 +167,8 @@ CDAC_GLOBALS_BEGIN()

CDAC_GLOBAL_POINTER(ThreadStore, &ThreadStore::s_pThreadStore)

CDAC_GLOBAL_POINTER(RuntimeInstance, &g_pTheRuntimeInstance)

CDAC_GLOBAL_POINTER(FreeObjectMethodTable, &g_pFreeObjectEEType)

CDAC_GLOBAL_POINTER(GCLowestAddress, &g_lowest_address)
Expand All @@ -162,9 +195,12 @@ CDAC_GLOBAL(StressLogMaxMessageSize, T_UINT64, (uint64_t)StressMsg::maxMsgSize)

// Contracts: declare which contracts this runtime supports
CDAC_GLOBAL_CONTRACT(Thread, n1)
CDAC_GLOBAL_CONTRACT(Exception, c1)
CDAC_GLOBAL_CONTRACT(Exception, n1)
CDAC_GLOBAL_CONTRACT(RuntimeTypeSystem, n1)
CDAC_GLOBAL_CONTRACT(StressLog, c2)
Comment on lines 196 to 200
CDAC_GLOBAL_CONTRACT(Loader, n1)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These new contract versions should be described in docs\design\datacontracts\....

CDAC_GLOBAL_CONTRACT(ExecutionManager, n1)
CDAC_GLOBAL_CONTRACT(Object, n1)

// Managed type sub-descriptor: ILC emits a ContractDescriptor with managed type layouts
// that the cDAC reader merges as a sub-descriptor. This provides field offsets for managed
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/nativeaot/Runtime/threadstore.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ typedef DPTR(ThreadStore) PTR_ThreadStore;

template<> struct cdac_data<ThreadStore>
{
static constexpr size_t FirstThreadLink = offsetof(ThreadStore, m_ThreadList);
static constexpr size_t FirstThreadLink = offsetof(ThreadStore, m_ThreadList) + offsetof(SList<Thread>, m_pHead);
};

ThreadStore * GetThreadStore();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@
<Compile Include="System\RuntimeType.NativeAot.cs" />
<Compile Include="System\Runtime\ControlledExecution.NativeAot.cs" />
<Compile Include="System\Runtime\DependentHandle.cs" />
<Compile Include="System\Diagnostics\DataContractAttribute.cs" />
<Compile Include="System\Runtime\CompilerServices\EagerStaticClassConstructionAttribute.cs" />
<Compile Include="System\Runtime\CompilerServices\RuntimeFeature.NativeAot.cs" />
<Compile Include="System\Runtime\CompilerServices\StaticClassConstructionContext.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

namespace System
{
[DataContract]
public partial class Exception
{
public MethodBase? TargetSite
Expand All @@ -32,15 +33,20 @@ public MethodBase? TargetSite

private static string? SerializationWatsonBuckets => null;

[DataContract]
internal string? _message;
private IDictionary? _data;
[DataContract]
private Exception? _innerException;
private string? _helpURL;
private string? _source; // Mainly used by VB.
[DataContract]
private int _HResult; // HResult

// To maintain compatibility across runtimes, if this object was deserialized, it will store its stack trace as a string
[DataContract]
private string? _stackTraceString;
[DataContract]
private string? _remoteStackTraceString;

internal IntPtr[] GetStackIPs()
Expand All @@ -53,7 +59,9 @@ internal IntPtr[] GetStackIPs()
return ips;
}

[DataContract]
private IntPtr[]? _corDbgStackTrace;
[DataContract]
private int _idxFirstFreeStackTraceEntry;

internal static IntPtr EdiSeparator => (IntPtr)1; // Marks a boundary where an ExceptionDispatchInfo rethrew an exception.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@
<Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\Contracts\ContractException.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\Contracts\ContractFailedEventArgs.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\Contracts\Contracts.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\DataContractAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\Debug.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\DebuggableAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\Debugger.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,21 +111,26 @@ public enum TaskStatus
/// </remarks>
[DebuggerTypeProxy(typeof(SystemThreadingTasks_TaskDebugView))]
[DebuggerDisplay("Id = {Id}, Status = {Status}, Method = {DebuggerDisplayMethodDescription}")]
[DataContract]
public class Task : IAsyncResult, IDisposable
{
[ThreadStatic]
internal static Task? t_currentTask; // The currently executing task.

private static int s_taskIdCounter; // static counter used to generate unique task IDs

[DataContract]
private int m_taskId; // this task's unique ID. initialized only if it is ever requested

// The delegate to invoke for a delegate-backed Task.
// This field also may be used by async state machines to cache an Action.
[DataContract]
internal Delegate? m_action;
[DataContract]
private protected object? m_stateObject; // A state object that can be optionally supplied, passed to action.
internal TaskScheduler? m_taskScheduler; // The task scheduler this task runs under.

[DataContract]
internal volatile int m_stateFlags; // SOS DumpAsync command depends on this name

private Task? ParentForDebugger => m_contingentProperties?.m_parent; // Private property used by a debugger to access this Task's parent
Expand Down Expand Up @@ -164,6 +169,7 @@ internal enum TaskStateFlags

// Can be null, a single continuation, a list of continuations, or s_taskCompletionSentinel,
// in that order. The logic arround this object assumes it will never regress to a previous state.
[DataContract]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think DumpAsync can depend on symbols in NAOT case.

private volatile object? m_continuationObject; // SOS DumpAsync command depends on this name

// m_continuationObject is set to this when the task completes.
Expand Down
Loading