Skip to content
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
5 changes: 5 additions & 0 deletions src/coreclr/clrdefinitions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,11 @@ if (FEATURE_STUBPRECODE_DYNAMIC_HELPERS)
add_definitions(-DFEATURE_STUBPRECODE_DYNAMIC_HELPERS)
endif()

if (CLR_CMAKE_TARGET_APPLE)
# Re-enable when dbgshim containing https://github.com/dotnet/diagnostics/pull/5487 is generally available
# add_definitions(-DFEATURE_MAP_THUNKS_FROM_IMAGE)
endif()

# Use this function to enable building with a specific target OS and architecture set of defines
# This is known to work for the set of defines used by the JIT and gcinfo, it is not likely correct for
# other components of the runtime
Expand Down
15 changes: 15 additions & 0 deletions src/coreclr/inc/executableallocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ class ExecutableAllocator
// Return true if double mapping is enabled.
static bool IsDoubleMappingEnabled();

// Release memory allocated via DoubleMapping for either templates or normal double mapped data
void ReleaseWorker(void* pRX, bool releaseTemplate);

// Initialize the allocator instance
bool Initialize();

Expand Down Expand Up @@ -262,6 +265,18 @@ class ExecutableAllocator

// Unmap the RW mapping at the specified address
void UnmapRW(void* pRW);

// Allocate thunks from a template. pTemplate is the return value from CreateTemplate
void* AllocateThunksFromTemplate(void *pTemplate, size_t templateSize);

// Free a set of thunks allocated from templates. pThunks must have been returned from AllocateThunksFromTemplate
void FreeThunksFromTemplate(void *pThunks, size_t templateSize);

// Create a template
// If templateInImage is not null, it will attempt to use it as the template, otherwise it will create an temporary in memory file to serve as the template
// Some OS/Architectures may/may not be able to work with this, so this api is permitted to return NULL, and callers should have an alternate approach using
// the codePageGenerator directly.
void* CreateTemplate(void* templateInImage, size_t templateSize, void (*codePageGenerator)(uint8_t* pageBase, uint8_t* pageBaseRX, size_t size));
};

#define ExecutableWriterHolder ExecutableWriterHolderNoLog
Expand Down
24 changes: 14 additions & 10 deletions src/coreclr/inc/loaderheap.h
Original file line number Diff line number Diff line change
Expand Up @@ -455,10 +455,19 @@ class UnlockedLoaderHeap : public UnlockedLoaderHeapBase
static void WeGotAFaultNowWhat(UnlockedLoaderHeap *pHeap);
};

struct InterleavedLoaderHeapConfig
{
uint32_t StubSize;
void* Template;
void (*CodePageGenerator)(uint8_t* pageBase, uint8_t* pageBaseRX, size_t size);
};

void InitializeLoaderHeapConfig(InterleavedLoaderHeapConfig *pConfig, size_t stubSize, void* templateInImage, void (*codePageGenerator)(uint8_t* pageBase, uint8_t* pageBaseRX, size_t size));

//===============================================================================
// This is the base class for InterleavedLoaderHeap It's used as a simple
// allocator for stubs in a scheme where each stub is a small fixed size, and is paired
// with memory which is GetOSStubPageSize() bytes away. In addition there is an
// with memory which is GetStubCodePageSize() bytes away. In addition there is an
// ability to free is via a "backout" mechanism that is not considered to have good performance.
//
//===============================================================================
Expand Down Expand Up @@ -492,16 +501,13 @@ class UnlockedInterleavedLoaderHeap : public UnlockedLoaderHeapBase

InterleavedStubFreeListNode *m_pFreeListHead;

public:
public:
void (*m_codePageGenerator)(BYTE* pageBase, BYTE* pageBaseRX, SIZE_T size);
const InterleavedLoaderHeapConfig *m_pConfig;

#ifndef DACCESS_COMPILE
protected:
UnlockedInterleavedLoaderHeap(
RangeList *pRangeList,
void (*codePageGenerator)(BYTE* pageBase, BYTE* pageBaseRX, SIZE_T size),
DWORD dwGranularity);
const InterleavedLoaderHeapConfig *pConfig);

virtual ~UnlockedInterleavedLoaderHeap();
#endif
Expand Down Expand Up @@ -1039,13 +1045,11 @@ class InterleavedLoaderHeap : public UnlockedInterleavedLoaderHeap
public:
InterleavedLoaderHeap(RangeList *pRangeList,
BOOL fUnlocked,
void (*codePageGenerator)(BYTE* pageBase, BYTE* pageBaseRX, SIZE_T size),
DWORD dwGranularity
const InterleavedLoaderHeapConfig *pConfig
)
: UnlockedInterleavedLoaderHeap(
pRangeList,
codePageGenerator,
dwGranularity),
pConfig),
m_CriticalSection(fUnlocked ? NULL : CreateLoaderHeapLock())
{
WRAPPER_NO_CONTRACT;
Expand Down
Loading
Loading