Skip to content

Use VM's copy of daccess.h #97751

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 7, 2024
Merged
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
19 changes: 15 additions & 4 deletions src/coreclr/inc/daccess.h
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,7 @@
#ifndef __daccess_h__
#define __daccess_h__

#ifndef NATIVEAOT
#include <stdint.h>

#include "switches.h"
Expand Down Expand Up @@ -661,6 +662,8 @@ typedef struct _DacGlobals
#undef VPTR_CLASS
} DacGlobals;

#endif // !NATIVEAOT

#ifdef DACCESS_COMPILE

#ifdef __cplusplus
Expand Down Expand Up @@ -2365,10 +2368,17 @@ inline type* DacUnsafeMarshalSingleElement( ArrayDPTR(type) arrayPtr )
//
//----------------------------------------------------------------------------

typedef ArrayDPTR(BYTE) PTR_BYTE;
typedef DPTR(size_t) PTR_size_t;
typedef ArrayDPTR(uint8_t) PTR_uint8_t;
typedef DPTR(PTR_uint8_t) PTR_PTR_uint8_t;
typedef DPTR(int32_t) PTR_int32_t;
typedef DPTR(uint32_t) PTR_uint32_t;
typedef DPTR(uint64_t) PTR_uint64_t;
typedef DPTR(uintptr_t) PTR_uintptr_t;

#ifndef NATIVEAOT
typedef ArrayDPTR(BYTE) PTR_BYTE;
typedef DPTR(PTR_BYTE) PTR_PTR_BYTE;
typedef DPTR(PTR_uint8_t) PTR_PTR_uint8_t;
typedef DPTR(PTR_PTR_BYTE) PTR_PTR_PTR_BYTE;
typedef ArrayDPTR(signed char) PTR_SBYTE;
typedef ArrayDPTR(const BYTE) PTR_CBYTE;
Expand All @@ -2378,7 +2388,6 @@ typedef DPTR(UINT16) PTR_UINT16;
typedef DPTR(WORD) PTR_WORD;
typedef DPTR(USHORT) PTR_USHORT;
typedef DPTR(DWORD) PTR_DWORD;
typedef DPTR(uint32_t) PTR_uint32_t;
typedef DPTR(LONG) PTR_LONG;
typedef DPTR(ULONG) PTR_ULONG;
typedef DPTR(INT32) PTR_INT32;
Expand All @@ -2387,7 +2396,6 @@ typedef DPTR(ULONG64) PTR_ULONG64;
typedef DPTR(INT64) PTR_INT64;
typedef DPTR(UINT64) PTR_UINT64;
typedef DPTR(SIZE_T) PTR_SIZE_T;
typedef DPTR(size_t) PTR_size_t;
typedef DPTR(TADDR) PTR_TADDR;
typedef DPTR(int) PTR_int;
typedef DPTR(BOOL) PTR_BOOL;
Expand Down Expand Up @@ -2417,13 +2425,15 @@ typedef DPTR(IMAGE_NT_HEADERS64) PTR_IMAGE_NT_HEADERS64;
typedef DPTR(IMAGE_SECTION_HEADER) PTR_IMAGE_SECTION_HEADER;
typedef DPTR(IMAGE_EXPORT_DIRECTORY) PTR_IMAGE_EXPORT_DIRECTORY;
typedef DPTR(IMAGE_TLS_DIRECTORY) PTR_IMAGE_TLS_DIRECTORY;
#endif

#if defined(DACCESS_COMPILE)
#include <corhdr.h>
#include <clrdata.h>
#include <xclrdata.h>
#endif

#ifndef NATIVEAOT
#if defined(TARGET_X86) && defined(TARGET_UNIX)
typedef DPTR(struct _UNWIND_INFO) PTR_UNWIND_INFO;
#endif
Expand All @@ -2439,6 +2449,7 @@ typedef DPTR(union _UNWIND_CODE) PTR_UNWIND_CODE;
#ifdef TARGET_ARM
typedef DPTR(T_RUNTIME_FUNCTION) PTR_RUNTIME_FUNCTION;
#endif
#endif

//----------------------------------------------------------------------------
//
Expand Down
18 changes: 9 additions & 9 deletions src/coreclr/nativeaot/Runtime/CachedInterfaceDispatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ bool InitializeInterfaceDispatch()
return true;
}

COOP_PINVOKE_HELPER(PTR_Code, RhpUpdateDispatchCellCache, (InterfaceDispatchCell * pCell, PTR_Code pTargetCode, MethodTable* pInstanceType, DispatchCellInfo *pNewCellInfo))
COOP_PINVOKE_HELPER(PCODE, RhpUpdateDispatchCellCache, (InterfaceDispatchCell * pCell, PCODE pTargetCode, MethodTable* pInstanceType, DispatchCellInfo *pNewCellInfo))
{
// Attempt to update the cache with this new mapping (if we have any cache at all, the initial state
// is none).
Expand All @@ -458,8 +458,8 @@ COOP_PINVOKE_HELPER(PTR_Code, RhpUpdateDispatchCellCache, (InterfaceDispatchCell
{
if (pCacheEntry->m_pInstanceType == NULL)
{
if (UpdateCacheEntryAtomically(pCacheEntry, pInstanceType, pTargetCode))
return (PTR_Code)pTargetCode;
if (UpdateCacheEntryAtomically(pCacheEntry, pInstanceType, dac_cast<PTR_VOID>(pTargetCode)))
return (PCODE)pTargetCode;
}
}

Expand All @@ -479,7 +479,7 @@ COOP_PINVOKE_HELPER(PTR_Code, RhpUpdateDispatchCellCache, (InterfaceDispatchCell
// but it's not clear whether we should do this or re-tune the cache max size, we need to measure
// this.
CID_COUNTER_INC(CacheSizeOverflows);
return (PTR_Code)pTargetCode;
return (PCODE)pTargetCode;
}

uint32_t cNewCacheEntries = cOldCacheEntries ? cOldCacheEntries * 2 : 1;
Expand All @@ -488,7 +488,7 @@ COOP_PINVOKE_HELPER(PTR_Code, RhpUpdateDispatchCellCache, (InterfaceDispatchCell
if (newCacheValue == 0)
{
CID_COUNTER_INC(CacheOutOfMemory);
return (PTR_Code)pTargetCode;
return (PCODE)pTargetCode;
}

if (InterfaceDispatchCell::IsCache(newCacheValue))
Expand All @@ -513,10 +513,10 @@ COOP_PINVOKE_HELPER(PTR_Code, RhpUpdateDispatchCellCache, (InterfaceDispatchCell
if (pDiscardedCache)
DiscardCache(pDiscardedCache);

return (PTR_Code)pTargetCode;
return (PCODE)pTargetCode;
}

COOP_PINVOKE_HELPER(PTR_Code, RhpSearchDispatchCellCache, (InterfaceDispatchCell * pCell, MethodTable* pInstanceType))
COOP_PINVOKE_HELPER(PCODE, RhpSearchDispatchCellCache, (InterfaceDispatchCell * pCell, MethodTable* pInstanceType))
{
// This function must be implemented in native code so that we do not take a GC while walking the cache
InterfaceDispatchCache * pCache = (InterfaceDispatchCache*)pCell->GetCache();
Expand All @@ -525,10 +525,10 @@ COOP_PINVOKE_HELPER(PTR_Code, RhpSearchDispatchCellCache, (InterfaceDispatchCell
InterfaceDispatchCacheEntry * pCacheEntry = pCache->m_rgEntries;
for (uint32_t i = 0; i < pCache->m_cEntries; i++, pCacheEntry++)
if (pCacheEntry->m_pInstanceType == pInstanceType)
return (PTR_Code)pCacheEntry->m_pTargetCode;
return pCacheEntry->m_pTargetCode;
}

return nullptr;
return (PCODE)nullptr;
}

// Given a dispatch cell, get the type and slot associated with it. This function MUST be implemented
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/nativeaot/Runtime/CachedInterfaceDispatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void ReclaimUnusedInterfaceDispatchCaches();
struct InterfaceDispatchCacheEntry
{
MethodTable * m_pInstanceType; // Potential type of the object instance being dispatched on
void * m_pTargetCode; // Method to dispatch to if the actual instance type matches the above
PCODE m_pTargetCode; // Method to dispatch to if the actual instance type matches the above
};

// The interface dispatch cache itself. As well as the entries we include the cache size (since logic such as
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/nativeaot/Runtime/GcEnum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static void GcEnumObjectsConservatively(PTR_PTR_Object ppLowerBound, PTR_PTR_Obj
// Only report values that lie in the GC heap range. This doesn't conclusively guarantee that the
// value is a GC heap reference but it's a cheap check that weeds out a lot of spurious values.
PTR_Object pObj = *ppObj;
if (((PTR_UInt8)pObj >= g_lowest_address) && ((PTR_UInt8)pObj <= g_highest_address))
if (((PTR_uint8_t)pObj >= g_lowest_address) && ((PTR_uint8_t)pObj <= g_highest_address))
PromoteCarefully(ppObj, GC_CALL_INTERIOR | GC_CALL_PINNED, fnGcEnumRef, pSc);
}
}
Expand Down Expand Up @@ -104,7 +104,7 @@ void EnumGcRefConservatively(PTR_OBJECTREF pRef, ScanFunc* fnGcEnumRef, ScanCont
// Only report values that lie in the GC heap range. This doesn't conclusively guarantee that the
// value is a GC heap reference but it's a cheap check that weeds out a lot of spurious values.
PTR_Object pObj = *pRef;
if (((PTR_UInt8)pObj >= g_lowest_address) && ((PTR_UInt8)pObj <= g_highest_address))
if (((PTR_uint8_t)pObj >= g_lowest_address) && ((PTR_uint8_t)pObj <= g_highest_address))
PromoteCarefully(pRef, GC_CALL_INTERIOR | GC_CALL_PINNED, fnGcEnumRef, pSc);
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/coreclr/nativeaot/Runtime/RuntimeInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ COOP_PINVOKE_HELPER(uint8_t *, RhFindMethodStartAddress, (void * codeAddr))
#endif
}

PTR_UInt8 RuntimeInstance::FindMethodStartAddress(PTR_VOID ControlPC)
PTR_uint8_t RuntimeInstance::FindMethodStartAddress(PTR_VOID ControlPC)
{
ICodeManager * pCodeManager = GetCodeManagerForAddress(ControlPC);
MethodInfo methodInfo;
if (pCodeManager != NULL && pCodeManager->FindMethodInfo(ControlPC, &methodInfo))
{
return (PTR_UInt8)pCodeManager->GetMethodStartAddress(&methodInfo);
return (PTR_uint8_t)pCodeManager->GetMethodStartAddress(&methodInfo);
}

return NULL;
Expand Down Expand Up @@ -139,18 +139,18 @@ void * RuntimeInstance::GetClasslibFunctionFromCodeAddress(PTR_VOID address, Cla

#endif // DACCESS_COMPILE

PTR_UInt8 RuntimeInstance::GetTargetOfUnboxingAndInstantiatingStub(PTR_VOID ControlPC)
PTR_uint8_t RuntimeInstance::GetTargetOfUnboxingAndInstantiatingStub(PTR_VOID ControlPC)
{
ICodeManager * pCodeManager = GetCodeManagerForAddress(ControlPC);
if (pCodeManager != NULL)
{
PTR_UInt8 pData = (PTR_UInt8)pCodeManager->GetAssociatedData(ControlPC);
PTR_uint8_t pData = (PTR_uint8_t)pCodeManager->GetAssociatedData(ControlPC);
if (pData != NULL)
{
uint8_t flags = *pData++;

if ((flags & (uint8_t)AssociatedDataFlags::HasUnboxingStubTarget) != 0)
return pData + *dac_cast<PTR_Int32>(pData);
return pData + *dac_cast<PTR_int32_t>(pData);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/nativeaot/Runtime/RuntimeInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ class RuntimeInstance
ThreadStore * GetThreadStore();
HANDLE GetPalInstance();

PTR_UInt8 FindMethodStartAddress(PTR_VOID ControlPC);
PTR_UInt8 GetTargetOfUnboxingAndInstantiatingStub(PTR_VOID ControlPC);
PTR_uint8_t FindMethodStartAddress(PTR_VOID ControlPC);
PTR_uint8_t GetTargetOfUnboxingAndInstantiatingStub(PTR_VOID ControlPC);
void EnableConservativeStackReporting();
bool IsConservativeStackReportingEnabled() { return m_conservativeStackReportingEnabled; }

Expand Down
Loading