Skip to content
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

Modify JIT to support double mapped memory #52600

Merged
merged 6 commits into from
May 12, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -1934,18 +1934,27 @@ void interceptor_ICJI::allocMem(uint32_t hotCodeSize, /* IN */
uint32_t roDataSize, /* IN */
uint32_t xcptnsCount, /* IN */
CorJitAllocMemFlag flag, /* IN */
void** hotCodeBlock, /* OUT */
void** coldCodeBlock, /* OUT */
void** roDataBlock /* OUT */
void ** hotCodeBlock, /* OUT */
void ** hotCodeBlockRW, /* OUT */
void ** coldCodeBlock, /* OUT */
void ** coldCodeBlockRW,/* OUT */
void ** roDataBlock, /* OUT */
void ** roDataBlockRW /* OUT */
)
{
mc->cr->AddCall("allocMem");
original_ICorJitInfo->allocMem(hotCodeSize, coldCodeSize, roDataSize, xcptnsCount, flag, hotCodeBlock,
coldCodeBlock, roDataBlock);
original_ICorJitInfo->allocMem(hotCodeSize, coldCodeSize, roDataSize, xcptnsCount, flag, hotCodeBlock, hotCodeBlockRW,
coldCodeBlock, coldCodeBlockRW, roDataBlock, roDataBlockRW);
mc->cr->recAllocMem(hotCodeSize, coldCodeSize, roDataSize, xcptnsCount, flag, hotCodeBlock, coldCodeBlock,
roDataBlock);
}

void interceptor_ICJI::doneWritingCode()
{
mc->cr->AddCall("doneWritingCode");
original_ICorJitInfo->doneWritingCode();
}

// Reserve memory for the method/funclet's unwind information.
// Note that this must be called before allocMem. It should be
// called once for the main method, once for every funclet, and
Expand Down Expand Up @@ -2101,14 +2110,15 @@ void interceptor_ICJI::recordCallSite(uint32_t instrOffset, /* IN *
// A relocation is recorded if we are pre-jitting.
// A jump thunk may be inserted if we are jitting
void interceptor_ICJI::recordRelocation(void* location, /* IN */
void* locationRW, /* IN */
void* target, /* IN */
uint16_t fRelocType, /* IN */
uint16_t slotNum, /* IN */
int32_t addlDelta /* IN */
)
{
mc->cr->AddCall("recordRelocation");
original_ICorJitInfo->recordRelocation(location, target, fRelocType, slotNum, addlDelta);
original_ICorJitInfo->recordRelocation(location, locationRW, target, fRelocType, slotNum, addlDelta);
mc->cr->recRecordRelocation(location, target, fRelocType, slotNum, addlDelta);
}

Expand Down
16 changes: 13 additions & 3 deletions src/coreclr/ToolBox/superpmi/superpmi-shim-counter/icorjitinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1256,11 +1256,14 @@ void interceptor_ICJI::allocMem(
uint32_t xcptnsCount,
CorJitAllocMemFlag flag,
void** hotCodeBlock,
void** hotCodeBlockRW,
void** coldCodeBlock,
void** roDataBlock)
void** coldCodeBlockRW,
void** roDataBlock,
void** roDataBlockRW)
{
mcs->AddCall("allocMem");
original_ICorJitInfo->allocMem(hotCodeSize, coldCodeSize, roDataSize, xcptnsCount, flag, hotCodeBlock, coldCodeBlock, roDataBlock);
original_ICorJitInfo->allocMem(hotCodeSize, coldCodeSize, roDataSize, xcptnsCount, flag, hotCodeBlock, hotCodeBlockRW, coldCodeBlock, coldCodeBlockRW, roDataBlock, roDataBlockRW);
}

void interceptor_ICJI::reserveUnwindInfo(
Expand Down Expand Up @@ -1363,13 +1366,14 @@ void interceptor_ICJI::recordCallSite(

void interceptor_ICJI::recordRelocation(
void* location,
void* locationRW,
void* target,
uint16_t fRelocType,
uint16_t slotNum,
int32_t addlDelta)
{
mcs->AddCall("recordRelocation");
original_ICorJitInfo->recordRelocation(location, target, fRelocType, slotNum, addlDelta);
original_ICorJitInfo->recordRelocation(location, locationRW, target, fRelocType, slotNum, addlDelta);
}

uint16_t interceptor_ICJI::getRelocTypeHint(
Expand All @@ -1393,3 +1397,9 @@ uint32_t interceptor_ICJI::getJitFlags(
return original_ICorJitInfo->getJitFlags(flags, sizeInBytes);
}

void interceptor_ICJI::doneWritingCode()
{
mcs->AddCall("doneWritingCode");
original_ICorJitInfo->doneWritingCode();
}

15 changes: 12 additions & 3 deletions src/coreclr/ToolBox/superpmi/superpmi-shim-simple/icorjitinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1100,10 +1100,13 @@ void interceptor_ICJI::allocMem(
uint32_t xcptnsCount,
CorJitAllocMemFlag flag,
void** hotCodeBlock,
void** hotCodeBlockRW,
void** coldCodeBlock,
void** roDataBlock)
void** coldCodeBlockRW,
void** roDataBlock,
void** roDataBlockRW)
{
original_ICorJitInfo->allocMem(hotCodeSize, coldCodeSize, roDataSize, xcptnsCount, flag, hotCodeBlock, coldCodeBlock, roDataBlock);
original_ICorJitInfo->allocMem(hotCodeSize, coldCodeSize, roDataSize, xcptnsCount, flag, hotCodeBlock, hotCodeBlockRW, coldCodeBlock, coldCodeBlockRW, roDataBlock, roDataBlockRW);
}

void interceptor_ICJI::reserveUnwindInfo(
Expand Down Expand Up @@ -1195,12 +1198,13 @@ void interceptor_ICJI::recordCallSite(

void interceptor_ICJI::recordRelocation(
void* location,
void* locationRW,
void* target,
uint16_t fRelocType,
uint16_t slotNum,
int32_t addlDelta)
{
original_ICorJitInfo->recordRelocation(location, target, fRelocType, slotNum, addlDelta);
original_ICorJitInfo->recordRelocation(location, locationRW, target, fRelocType, slotNum, addlDelta);
}

uint16_t interceptor_ICJI::getRelocTypeHint(
Expand All @@ -1221,3 +1225,8 @@ uint32_t interceptor_ICJI::getJitFlags(
return original_ICorJitInfo->getJitFlags(flags, sizeInBytes);
}

void interceptor_ICJI::doneWritingCode()
{
original_ICorJitInfo->doneWritingCode();
}

19 changes: 16 additions & 3 deletions src/coreclr/ToolBox/superpmi/superpmi/icorjitinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1606,9 +1606,12 @@ void MyICJI::allocMem(uint32_t hotCodeSize, /* IN */
uint32_t roDataSize, /* IN */
uint32_t xcptnsCount, /* IN */
CorJitAllocMemFlag flag, /* IN */
void** hotCodeBlock, /* OUT */
void** coldCodeBlock, /* OUT */
void** roDataBlock /* OUT */
void ** hotCodeBlock, /* OUT */
void ** hotCodeBlockRW, /* OUT */
void ** coldCodeBlock, /* OUT */
void ** coldCodeBlockRW,/* OUT */
void ** roDataBlock, /* OUT */
void ** roDataBlockRW /* OUT */
)
{
jitInstance->mc->cr->AddCall("allocMem");
Expand Down Expand Up @@ -1666,6 +1669,10 @@ void MyICJI::allocMem(uint32_t hotCodeSize, /* IN */
else
*roDataBlock = nullptr;

*hotCodeBlockRW = *hotCodeBlock;
*coldCodeBlockRW = *coldCodeBlock;
*roDataBlockRW = *roDataBlock;

jitInstance->mc->cr->recAllocMem(hotCodeSize, coldCodeSize, roDataSize, xcptnsCount, flag, hotCodeBlock,
coldCodeBlock, roDataBlock);
}
Expand Down Expand Up @@ -1841,6 +1848,7 @@ void MyICJI::recordCallSite(uint32_t instrOffset, /* IN */
// A relocation is recorded if we are pre-jitting.
// A jump thunk may be inserted if we are jitting
void MyICJI::recordRelocation(void* location, /* IN */
void* locationRW, /* IN */
void* target, /* IN */
uint16_t fRelocType, /* IN */
uint16_t slotNum, /* IN */
Expand Down Expand Up @@ -1869,3 +1877,8 @@ uint32_t MyICJI::getExpectedTargetArchitecture()
DWORD result = jitInstance->mc->repGetExpectedTargetArchitecture();
return result;
}

void MyICJI::doneWritingCode()
{
jitInstance->mc->cr->AddCall("doneWritingCode");
}
9 changes: 8 additions & 1 deletion src/coreclr/inc/corjit.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,11 @@ class ICorJitInfo : public ICorDynamicInfo
uint32_t xcptnsCount, /* IN */
CorJitAllocMemFlag flag, /* IN */
void ** hotCodeBlock, /* OUT */
void ** hotCodeBlockRW, /* OUT */
void ** coldCodeBlock, /* OUT */
void ** roDataBlock /* OUT */
void ** coldCodeBlockRW,/* OUT */
void ** roDataBlock, /* OUT */
void ** roDataBlockRW /* OUT */
Copy link
Member

Choose a reason for hiding this comment

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

This method takes 11 arguments now and it is unlikely we are done adding more arguments to it. Would it be better to refactor it to take struct with everything instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

) = 0;

// Reserve memory for the method/funclet's unwind information.
Expand Down Expand Up @@ -430,6 +433,7 @@ class ICorJitInfo : public ICorDynamicInfo
// A jump thunk may be inserted if we are jitting
virtual void recordRelocation(
void * location, /* IN */
void * locationRW, /* IN */
void * target, /* IN */
uint16_t fRelocType, /* IN */
uint16_t slotNum = 0, /* IN */
Expand All @@ -452,6 +456,9 @@ class ICorJitInfo : public ICorDynamicInfo
uint32_t sizeInBytes /* IN: The size of the buffer. Note that this is effectively a
version number for the CORJIT_FLAGS value. */
) = 0;

// Notify the EE that JIT is done writing to the memory allocated for code
virtual void doneWritingCode() = 0;
};

/**********************************************************************************/
Expand Down
8 changes: 7 additions & 1 deletion src/coreclr/inc/icorjitinfoimpl_generated.h
Original file line number Diff line number Diff line change
Expand Up @@ -641,8 +641,11 @@ void allocMem(
uint32_t xcptnsCount,
CorJitAllocMemFlag flag,
void** hotCodeBlock,
void** hotCodeBlockRW,
void** coldCodeBlock,
void** roDataBlock) override;
void** coldCodeBlockRW,
void** roDataBlock,
void** roDataBlockRW) override;

void reserveUnwindInfo(
bool isFunclet,
Expand Down Expand Up @@ -700,6 +703,7 @@ void recordCallSite(

void recordRelocation(
void* location,
void* locationRW,
void* target,
uint16_t fRelocType,
uint16_t slotNum,
Expand All @@ -714,6 +718,8 @@ uint32_t getJitFlags(
CORJIT_FLAGS* flags,
uint32_t sizeInBytes) override;

void doneWritingCode() override;

/**********************************************************************************/
// clang-format on
/**********************************************************************************/
11 changes: 6 additions & 5 deletions src/coreclr/inc/jiteeversionguid.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,14 @@ typedef const GUID *LPCGUID;
#define GUID_DEFINED
#endif // !GUID_DEFINED

constexpr GUID JITEEVersionIdentifier = { /* 12234eca-dfc2-48bc-a320-6155cf25ce17 */
0x12234eca,
0xdfc2,
0x48bc,
{0xa3, 0x20, 0x61, 0x55, 0xcf, 0x25, 0xce, 0x17}
constexpr GUID JITEEVersionIdentifier = { /* 529be99f-ce88-426e-a099-7528a691226c */
0x529be99f,
0xce88,
0x426e,
{ 0xa0, 0x99, 0x75, 0x28, 0xa6, 0x91, 0x22, 0x6c }
};


//////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// END JITEEVersionIdentifier
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/jit/ICorJitInfo_API_names.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,5 +176,6 @@ DEF_CLR_API(recordRelocation)
DEF_CLR_API(getRelocTypeHint)
DEF_CLR_API(getExpectedTargetArchitecture)
DEF_CLR_API(getJitFlags)
DEF_CLR_API(doneWritingCode)

#undef DEF_CLR_API
17 changes: 14 additions & 3 deletions src/coreclr/jit/ICorJitInfo_API_wrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1532,11 +1532,14 @@ void WrapICorJitInfo::allocMem(
uint32_t xcptnsCount,
CorJitAllocMemFlag flag,
void** hotCodeBlock,
void** hotCodeBlockRW,
void** coldCodeBlock,
void** roDataBlock)
void** coldCodeBlockRW,
void** roDataBlock,
void** roDataBlockRW)
{
API_ENTER(allocMem);
wrapHnd->allocMem(hotCodeSize, coldCodeSize, roDataSize, xcptnsCount, flag, hotCodeBlock, coldCodeBlock, roDataBlock);
wrapHnd->allocMem(hotCodeSize, coldCodeSize, roDataSize, xcptnsCount, flag, hotCodeBlock, hotCodeBlockRW, coldCodeBlock, coldCodeBlockRW, roDataBlock, roDataBlockRW);
API_LEAVE(allocMem);
}

Expand Down Expand Up @@ -1656,13 +1659,14 @@ void WrapICorJitInfo::recordCallSite(

void WrapICorJitInfo::recordRelocation(
void* location,
void* locationRW,
void* target,
uint16_t fRelocType,
uint16_t slotNum,
int32_t addlDelta)
{
API_ENTER(recordRelocation);
wrapHnd->recordRelocation(location, target, fRelocType, slotNum, addlDelta);
wrapHnd->recordRelocation(location, locationRW, target, fRelocType, slotNum, addlDelta);
API_LEAVE(recordRelocation);
}

Expand Down Expand Up @@ -1693,6 +1697,13 @@ uint32_t WrapICorJitInfo::getJitFlags(
return temp;
}

void WrapICorJitInfo::doneWritingCode()
{
API_ENTER(doneWritingCode);
wrapHnd->doneWritingCode();
API_LEAVE(doneWritingCode);
}

/**********************************************************************************/
// clang-format on
/**********************************************************************************/
Loading