diff --git a/src/coreclr/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp b/src/coreclr/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp index d8f08208102782..d7a3b48fdacf53 100644 --- a/src/coreclr/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp +++ b/src/coreclr/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp @@ -1929,21 +1929,12 @@ bool interceptor_ICJI::runWithErrorTrap(void (*function)(void*), void* param) } // get a block of memory for the code, readonly data, and read-write data -void interceptor_ICJI::allocMem(uint32_t hotCodeSize, /* IN */ - uint32_t coldCodeSize, /* IN */ - uint32_t roDataSize, /* IN */ - uint32_t xcptnsCount, /* IN */ - CorJitAllocMemFlag flag, /* IN */ - void** hotCodeBlock, /* OUT */ - void** coldCodeBlock, /* OUT */ - void** roDataBlock /* OUT */ - ) +void interceptor_ICJI::allocMem(AllocMemArgs *pArgs) { mc->cr->AddCall("allocMem"); - original_ICorJitInfo->allocMem(hotCodeSize, coldCodeSize, roDataSize, xcptnsCount, flag, hotCodeBlock, - coldCodeBlock, roDataBlock); - mc->cr->recAllocMem(hotCodeSize, coldCodeSize, roDataSize, xcptnsCount, flag, hotCodeBlock, coldCodeBlock, - roDataBlock); + original_ICorJitInfo->allocMem(pArgs); + mc->cr->recAllocMem(pArgs->hotCodeSize, pArgs->coldCodeSize, pArgs->roDataSize, pArgs->xcptnsCount, pArgs->flag, &pArgs->hotCodeBlock, &pArgs->coldCodeBlock, + &pArgs->roDataBlock); } // Reserve memory for the method/funclet's unwind information. @@ -2101,6 +2092,7 @@ 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 */ @@ -2108,7 +2100,7 @@ void interceptor_ICJI::recordRelocation(void* location, /* 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); } diff --git a/src/coreclr/ToolBox/superpmi/superpmi-shim-counter/icorjitinfo.cpp b/src/coreclr/ToolBox/superpmi/superpmi-shim-counter/icorjitinfo.cpp index f0fa56d661dfdf..46ab7cb8489156 100644 --- a/src/coreclr/ToolBox/superpmi/superpmi-shim-counter/icorjitinfo.cpp +++ b/src/coreclr/ToolBox/superpmi/superpmi-shim-counter/icorjitinfo.cpp @@ -1250,17 +1250,10 @@ bool interceptor_ICJI::notifyInstructionSetUsage( } void interceptor_ICJI::allocMem( - uint32_t hotCodeSize, - uint32_t coldCodeSize, - uint32_t roDataSize, - uint32_t xcptnsCount, - CorJitAllocMemFlag flag, - void** hotCodeBlock, - void** coldCodeBlock, - void** roDataBlock) + AllocMemArgs* pArgs) { mcs->AddCall("allocMem"); - original_ICorJitInfo->allocMem(hotCodeSize, coldCodeSize, roDataSize, xcptnsCount, flag, hotCodeBlock, coldCodeBlock, roDataBlock); + original_ICorJitInfo->allocMem(pArgs); } void interceptor_ICJI::reserveUnwindInfo( @@ -1363,13 +1356,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( diff --git a/src/coreclr/ToolBox/superpmi/superpmi-shim-simple/icorjitinfo.cpp b/src/coreclr/ToolBox/superpmi/superpmi-shim-simple/icorjitinfo.cpp index bf1184f71cf8ca..1ab397077f06c2 100644 --- a/src/coreclr/ToolBox/superpmi/superpmi-shim-simple/icorjitinfo.cpp +++ b/src/coreclr/ToolBox/superpmi/superpmi-shim-simple/icorjitinfo.cpp @@ -1094,16 +1094,9 @@ bool interceptor_ICJI::notifyInstructionSetUsage( } void interceptor_ICJI::allocMem( - uint32_t hotCodeSize, - uint32_t coldCodeSize, - uint32_t roDataSize, - uint32_t xcptnsCount, - CorJitAllocMemFlag flag, - void** hotCodeBlock, - void** coldCodeBlock, - void** roDataBlock) + AllocMemArgs* pArgs) { - original_ICorJitInfo->allocMem(hotCodeSize, coldCodeSize, roDataSize, xcptnsCount, flag, hotCodeBlock, coldCodeBlock, roDataBlock); + original_ICorJitInfo->allocMem(pArgs); } void interceptor_ICJI::reserveUnwindInfo( @@ -1195,12 +1188,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( diff --git a/src/coreclr/ToolBox/superpmi/superpmi/icorjitinfo.cpp b/src/coreclr/ToolBox/superpmi/superpmi/icorjitinfo.cpp index b37de9e16e6ba5..ce20edd00be1d3 100644 --- a/src/coreclr/ToolBox/superpmi/superpmi/icorjitinfo.cpp +++ b/src/coreclr/ToolBox/superpmi/superpmi/icorjitinfo.cpp @@ -1601,54 +1601,46 @@ static void* ALIGN_UP_SPMI(void* val, size_t alignment) } // get a block of memory for the code, readonly data, and read-write data -void MyICJI::allocMem(uint32_t hotCodeSize, /* IN */ - uint32_t coldCodeSize, /* IN */ - uint32_t roDataSize, /* IN */ - uint32_t xcptnsCount, /* IN */ - CorJitAllocMemFlag flag, /* IN */ - void** hotCodeBlock, /* OUT */ - void** coldCodeBlock, /* OUT */ - void** roDataBlock /* OUT */ - ) +void MyICJI::allocMem(AllocMemArgs* pArgs) { jitInstance->mc->cr->AddCall("allocMem"); // TODO-Cleanup: Could hot block size be ever 0? size_t codeAlignment = sizeof(void*); - size_t hotCodeAlignedSize = static_cast(hotCodeSize); + size_t hotCodeAlignedSize = static_cast(pArgs->hotCodeSize); - if ((flag & CORJIT_ALLOCMEM_FLG_32BYTE_ALIGN) != 0) + if ((pArgs->flag & CORJIT_ALLOCMEM_FLG_32BYTE_ALIGN) != 0) { codeAlignment = 32; } - else if ((flag & CORJIT_ALLOCMEM_FLG_16BYTE_ALIGN) != 0) + else if ((pArgs->flag & CORJIT_ALLOCMEM_FLG_16BYTE_ALIGN) != 0) { codeAlignment = 16; } hotCodeAlignedSize = ALIGN_UP_SPMI(hotCodeAlignedSize, codeAlignment); hotCodeAlignedSize = hotCodeAlignedSize + (codeAlignment - sizeof(void*)); - *hotCodeBlock = jitInstance->mc->cr->allocateMemory(hotCodeAlignedSize); - *hotCodeBlock = ALIGN_UP_SPMI(*hotCodeBlock, codeAlignment); + pArgs->hotCodeBlock = jitInstance->mc->cr->allocateMemory(hotCodeAlignedSize); + pArgs->hotCodeBlock = ALIGN_UP_SPMI(pArgs->hotCodeBlock, codeAlignment); - if (coldCodeSize > 0) - *coldCodeBlock = jitInstance->mc->cr->allocateMemory(coldCodeSize); + if (pArgs->coldCodeSize > 0) + pArgs->coldCodeBlock = jitInstance->mc->cr->allocateMemory(pArgs->coldCodeSize); else - *coldCodeBlock = nullptr; + pArgs->coldCodeBlock = nullptr; - if (roDataSize > 0) + if (pArgs->roDataSize > 0) { size_t roDataAlignment = sizeof(void*); - size_t roDataAlignedSize = static_cast(roDataSize); + size_t roDataAlignedSize = static_cast(pArgs->roDataSize); - if ((flag & CORJIT_ALLOCMEM_FLG_RODATA_32BYTE_ALIGN) != 0) + if ((pArgs->flag & CORJIT_ALLOCMEM_FLG_RODATA_32BYTE_ALIGN) != 0) { roDataAlignment = 32; } - else if ((flag & CORJIT_ALLOCMEM_FLG_RODATA_16BYTE_ALIGN) != 0) + else if ((pArgs->flag & CORJIT_ALLOCMEM_FLG_RODATA_16BYTE_ALIGN) != 0) { roDataAlignment = 16; } - else if (roDataSize >= 8) + else if (pArgs->roDataSize >= 8) { roDataAlignment = 8; } @@ -1660,14 +1652,18 @@ void MyICJI::allocMem(uint32_t hotCodeSize, /* IN */ roDataAlignedSize = ALIGN_UP_SPMI(roDataAlignedSize, roDataAlignment); roDataAlignedSize = roDataAlignedSize + (roDataAlignment - sizeof(void*)); - *roDataBlock = jitInstance->mc->cr->allocateMemory(roDataAlignedSize); - *roDataBlock = ALIGN_UP_SPMI(*roDataBlock, roDataAlignment); + pArgs->roDataBlock = jitInstance->mc->cr->allocateMemory(roDataAlignedSize); + pArgs->roDataBlock = ALIGN_UP_SPMI(pArgs->roDataBlock, roDataAlignment); } else - *roDataBlock = nullptr; + pArgs->roDataBlock = nullptr; - jitInstance->mc->cr->recAllocMem(hotCodeSize, coldCodeSize, roDataSize, xcptnsCount, flag, hotCodeBlock, - coldCodeBlock, roDataBlock); + pArgs->hotCodeBlockRW = pArgs->hotCodeBlock; + pArgs->coldCodeBlockRW = pArgs->coldCodeBlock; + pArgs->roDataBlockRW = pArgs->roDataBlock; + + jitInstance->mc->cr->recAllocMem(pArgs->hotCodeSize, pArgs->coldCodeSize, pArgs->roDataSize, pArgs->xcptnsCount, pArgs->flag, &pArgs->hotCodeBlock, + &pArgs->coldCodeBlock, &pArgs->roDataBlock); } // Reserve memory for the method/funclet's unwind information. @@ -1841,6 +1837,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 */ diff --git a/src/coreclr/inc/corjit.h b/src/coreclr/inc/corjit.h index aaf4dcb646f11a..51fe431bbb8be5 100644 --- a/src/coreclr/inc/corjit.h +++ b/src/coreclr/inc/corjit.h @@ -142,6 +142,24 @@ enum CheckedWriteBarrierKinds { CWBKind_AddrOfLocal, // Store through the address of a local (arguably a bug that this happens at all). }; +struct AllocMemArgs +{ + // Input arguments + uint32_t hotCodeSize; + uint32_t coldCodeSize; + uint32_t roDataSize; + uint32_t xcptnsCount; + CorJitAllocMemFlag flag; + + // Output arguments + void* hotCodeBlock; + void* hotCodeBlockRW; + void* coldCodeBlock; + void* coldCodeBlockRW; + void* roDataBlock; + void* roDataBlockRW; +}; + #include "corjithost.h" extern "C" void jitStartup(ICorJitHost* host); @@ -212,14 +230,7 @@ class ICorJitInfo : public ICorDynamicInfo public: // get a block of memory for the code, readonly data, and read-write data virtual void allocMem ( - uint32_t hotCodeSize, /* IN */ - uint32_t coldCodeSize, /* IN */ - uint32_t roDataSize, /* IN */ - uint32_t xcptnsCount, /* IN */ - CorJitAllocMemFlag flag, /* IN */ - void ** hotCodeBlock, /* OUT */ - void ** coldCodeBlock, /* OUT */ - void ** roDataBlock /* OUT */ + AllocMemArgs *pArgs ) = 0; // Reserve memory for the method/funclet's unwind information. @@ -430,6 +441,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 */ diff --git a/src/coreclr/inc/icorjitinfoimpl_generated.h b/src/coreclr/inc/icorjitinfoimpl_generated.h index ae03ef525fe79d..ebd9813e2c4fd8 100644 --- a/src/coreclr/inc/icorjitinfoimpl_generated.h +++ b/src/coreclr/inc/icorjitinfoimpl_generated.h @@ -635,14 +635,7 @@ bool notifyInstructionSetUsage( bool supportEnabled) override; void allocMem( - uint32_t hotCodeSize, - uint32_t coldCodeSize, - uint32_t roDataSize, - uint32_t xcptnsCount, - CorJitAllocMemFlag flag, - void** hotCodeBlock, - void** coldCodeBlock, - void** roDataBlock) override; + AllocMemArgs* pArgs) override; void reserveUnwindInfo( bool isFunclet, @@ -700,6 +693,7 @@ void recordCallSite( void recordRelocation( void* location, + void* locationRW, void* target, uint16_t fRelocType, uint16_t slotNum, diff --git a/src/coreclr/inc/jiteeversionguid.h b/src/coreclr/inc/jiteeversionguid.h index b32d0edef000b8..1ae07e2b634430 100644 --- a/src/coreclr/inc/jiteeversionguid.h +++ b/src/coreclr/inc/jiteeversionguid.h @@ -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 diff --git a/src/coreclr/jit/ICorJitInfo_API_wrapper.hpp b/src/coreclr/jit/ICorJitInfo_API_wrapper.hpp index 42109b1883be3c..33f33056ff639f 100644 --- a/src/coreclr/jit/ICorJitInfo_API_wrapper.hpp +++ b/src/coreclr/jit/ICorJitInfo_API_wrapper.hpp @@ -1526,17 +1526,10 @@ bool WrapICorJitInfo::notifyInstructionSetUsage( } void WrapICorJitInfo::allocMem( - uint32_t hotCodeSize, - uint32_t coldCodeSize, - uint32_t roDataSize, - uint32_t xcptnsCount, - CorJitAllocMemFlag flag, - void** hotCodeBlock, - void** coldCodeBlock, - void** roDataBlock) + AllocMemArgs* pArgs) { API_ENTER(allocMem); - wrapHnd->allocMem(hotCodeSize, coldCodeSize, roDataSize, xcptnsCount, flag, hotCodeBlock, coldCodeBlock, roDataBlock); + wrapHnd->allocMem(pArgs); API_LEAVE(allocMem); } @@ -1656,13 +1649,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); } diff --git a/src/coreclr/jit/emit.cpp b/src/coreclr/jit/emit.cpp index b485b0f90cf214..7490a2e8de1d30 100644 --- a/src/coreclr/jit/emit.cpp +++ b/src/coreclr/jit/emit.cpp @@ -5355,8 +5355,11 @@ unsigned emitter::emitEndCodeGen(Compiler* comp, #endif BYTE* consBlock; + BYTE* consBlockRW; BYTE* codeBlock; + BYTE* codeBlockRW; BYTE* coldCodeBlock; + BYTE* coldCodeBlockRW; BYTE* cp; assert(emitCurIG == nullptr); @@ -5513,6 +5516,9 @@ unsigned emitter::emitEndCodeGen(Compiler* comp, allocMemFlag = static_cast(allocMemFlag | CORJIT_ALLOCMEM_FLG_RODATA_32BYTE_ALIGN); } + AllocMemArgs args; + memset(&args, 0, sizeof(args)); + #ifdef TARGET_ARM64 // For arm64, we want to allocate JIT data always adjacent to code similar to what native compiler does. // This way allows us to use a single `ldr` to access such data like float constant/jmp table. @@ -5529,14 +5535,40 @@ unsigned emitter::emitEndCodeGen(Compiler* comp, roDataAlignmentDelta = (UNATIVE_OFFSET)ALIGN_UP(emitTotalHotCodeSize, roDataAlignment) - emitTotalHotCodeSize; assert((roDataAlignmentDelta == 0) || (roDataAlignmentDelta == 4)); } - emitCmpHandle->allocMem(emitTotalHotCodeSize + roDataAlignmentDelta + emitConsDsc.dsdOffs, emitTotalColdCodeSize, 0, - xcptnsCount, allocMemFlag, (void**)&codeBlock, (void**)&coldCodeBlock, (void**)&consBlock); - consBlock = codeBlock + emitTotalHotCodeSize + roDataAlignmentDelta; + args.hotCodeSize = emitTotalHotCodeSize + roDataAlignmentDelta + emitConsDsc.dsdOffs; + args.coldCodeSize = emitTotalColdCodeSize; + args.roDataSize = 0; + args.xcptnsCount = xcptnsCount; + args.flag = allocMemFlag; + + emitCmpHandle->allocMem(&args); + + codeBlock = (BYTE*)args.hotCodeBlock; + codeBlockRW = (BYTE*)args.hotCodeBlockRW; + coldCodeBlock = (BYTE*)args.coldCodeBlock; + coldCodeBlockRW = (BYTE*)args.coldCodeBlockRW; + + consBlock = codeBlock + emitTotalHotCodeSize + roDataAlignmentDelta; + consBlockRW = codeBlockRW + emitTotalHotCodeSize + roDataAlignmentDelta; #else - emitCmpHandle->allocMem(emitTotalHotCodeSize, emitTotalColdCodeSize, emitConsDsc.dsdOffs, xcptnsCount, allocMemFlag, - (void**)&codeBlock, (void**)&coldCodeBlock, (void**)&consBlock); + + args.hotCodeSize = emitTotalHotCodeSize; + args.coldCodeSize = emitTotalColdCodeSize; + args.roDataSize = emitConsDsc.dsdOffs; + args.xcptnsCount = xcptnsCount; + args.flag = allocMemFlag; + + emitCmpHandle->allocMem(&args); + + codeBlock = (BYTE*)args.hotCodeBlock; + codeBlockRW = (BYTE*)args.hotCodeBlockRW; + coldCodeBlock = (BYTE*)args.coldCodeBlock; + coldCodeBlockRW = (BYTE*)args.coldCodeBlockRW; + consBlock = (BYTE*)args.roDataBlock; + consBlockRW = (BYTE*)args.roDataBlockRW; + #endif #ifdef DEBUG @@ -5761,7 +5793,8 @@ unsigned emitter::emitEndCodeGen(Compiler* comp, #endif /* Issue all instruction groups in order */ - cp = codeBlock; + cp = codeBlock; + writeableOffset = codeBlockRW - codeBlock; #define DEFAULT_CODE_BUFFER_INIT 0xcc @@ -5778,7 +5811,8 @@ unsigned emitter::emitEndCodeGen(Compiler* comp, assert(emitCurCodeOffs(cp) == emitTotalHotCodeSize); assert(coldCodeBlock); - cp = coldCodeBlock; + cp = coldCodeBlock; + writeableOffset = coldCodeBlockRW - coldCodeBlock; #ifdef DEBUG if (emitComp->opts.disAsm || emitComp->verbose) { @@ -6065,11 +6099,11 @@ unsigned emitter::emitEndCodeGen(Compiler* comp, // Patch Forward Short Jump CLANG_FORMAT_COMMENT_ANCHOR; #if defined(TARGET_XARCH) - *(BYTE*)adr -= (BYTE)adj; + *(BYTE*)(adr + writeableOffset) -= (BYTE)adj; #elif defined(TARGET_ARM) // The following works because the jump offset is in the low order bits of the instruction. // Presumably we could also just call "emitOutputLJ(NULL, adr, jmp)", like for long jumps? - *(short int*)adr -= (short)adj; + *(short int*)(adr + writeableOffset) -= (short)adj; #elif defined(TARGET_ARM64) assert(!jmp->idAddr()->iiaHasInstrCount()); emitOutputLJ(NULL, adr, jmp); @@ -6082,7 +6116,7 @@ unsigned emitter::emitEndCodeGen(Compiler* comp, // Patch Forward non-Short Jump CLANG_FORMAT_COMMENT_ANCHOR; #if defined(TARGET_XARCH) - *(int*)adr -= adj; + *(int*)(adr + writeableOffset) -= adj; #elif defined(TARGET_ARMARCH) assert(!jmp->idAddr()->iiaHasInstrCount()); emitOutputLJ(NULL, adr, jmp); @@ -6117,10 +6151,12 @@ unsigned emitter::emitEndCodeGen(Compiler* comp, JITDUMP("Allocated method code size = %4u , actual size = %4u, unused size = %4u\n", emitTotalCodeSize, actualCodeSize, unusedSize); + BYTE* cpRW = cp + writeableOffset; for (unsigned i = 0; i < unusedSize; ++i) { - *cp++ = DEFAULT_CODE_BUFFER_INIT; + *cpRW++ = DEFAULT_CODE_BUFFER_INIT; } + cp = cpRW - writeableOffset; assert(emitTotalCodeSize == emitCurCodeOffs(cp)); // Total code size is sum of all IG->size and doesn't include padding in the last IG. @@ -6634,6 +6670,8 @@ void emitter::emitOutputDataSec(dataSecDsc* sec, BYTE* dst) { size_t dscSize = dsc->dsSize; + BYTE* dstRW = dst + writeableOffset; + // absolute label table if (dsc->dsType == dataSection::blockAbsoluteAddr) { @@ -6641,7 +6679,7 @@ void emitter::emitOutputDataSec(dataSecDsc* sec, BYTE* dst) assert(dscSize && dscSize % TARGET_POINTER_SIZE == 0); size_t numElems = dscSize / TARGET_POINTER_SIZE; - target_size_t* bDst = (target_size_t*)dst; + target_size_t* bDstRW = (target_size_t*)dstRW; for (unsigned i = 0; i < numElems; i++) { BasicBlock* block = ((BasicBlock**)dsc->dsCont)[i]; @@ -6655,13 +6693,13 @@ void emitter::emitOutputDataSec(dataSecDsc* sec, BYTE* dst) #ifdef TARGET_ARM target = (BYTE*)((size_t)target | 1); // Or in thumb bit #endif - bDst[i] = (target_size_t)(size_t)target; + bDstRW[i] = (target_size_t)(size_t)target; if (emitComp->opts.compReloc) { - emitRecordRelocation(&(bDst[i]), target, IMAGE_REL_BASED_HIGHLOW); + emitRecordRelocation(&(bDstRW[i]), target, IMAGE_REL_BASED_HIGHLOW); } - JITDUMP(" " FMT_BB ": 0x%p\n", block->bbNum, bDst[i]); + JITDUMP(" " FMT_BB ": 0x%p\n", block->bbNum, bDstRW[i]); } } // relative label table @@ -6670,7 +6708,7 @@ void emitter::emitOutputDataSec(dataSecDsc* sec, BYTE* dst) JITDUMP(" section %u, size %u, block relative addr\n", secNum++, dscSize); size_t numElems = dscSize / 4; - unsigned* uDst = (unsigned*)dst; + unsigned* uDstRW = (unsigned*)dstRW; insGroup* labFirst = (insGroup*)emitCodeGetCookie(emitComp->fgFirstBB); for (unsigned i = 0; i < numElems; i++) @@ -6681,9 +6719,9 @@ void emitter::emitOutputDataSec(dataSecDsc* sec, BYTE* dst) insGroup* lab = (insGroup*)emitCodeGetCookie(block); assert(FitsIn(lab->igOffs - labFirst->igOffs)); - uDst[i] = lab->igOffs - labFirst->igOffs; + uDstRW[i] = lab->igOffs - labFirst->igOffs; - JITDUMP(" " FMT_BB ": 0x%x\n", block->bbNum, uDst[i]); + JITDUMP(" " FMT_BB ": 0x%x\n", block->bbNum, uDstRW[i]); } } else @@ -6691,7 +6729,7 @@ void emitter::emitOutputDataSec(dataSecDsc* sec, BYTE* dst) // Simple binary data: copy the bytes to the target assert(dsc->dsType == dataSection::data); - memcpy(dst, dsc->dsCont, dscSize); + memcpy(dstRW, dsc->dsCont, dscSize); #ifdef DEBUG if (EMITVERBOSE) @@ -7395,7 +7433,8 @@ void emitter::emitGCregDeadSet(GCtype gcType, regMaskTP regMask, BYTE* addr) unsigned char emitter::emitOutputByte(BYTE* dst, ssize_t val) { - *castto(dst, unsigned char*) = (unsigned char)val; + BYTE* dstRW = dst + writeableOffset; + *castto(dstRW, unsigned char*) = (unsigned char)val; #ifdef DEBUG #ifdef TARGET_AMD64 @@ -7414,7 +7453,8 @@ unsigned char emitter::emitOutputByte(BYTE* dst, ssize_t val) unsigned char emitter::emitOutputWord(BYTE* dst, ssize_t val) { - MISALIGNED_WR_I2(dst, (short)val); + BYTE* dstRW = dst + writeableOffset; + MISALIGNED_WR_I2(dstRW, (short)val); #ifdef DEBUG #ifdef TARGET_AMD64 @@ -7433,7 +7473,8 @@ unsigned char emitter::emitOutputWord(BYTE* dst, ssize_t val) unsigned char emitter::emitOutputLong(BYTE* dst, ssize_t val) { - MISALIGNED_WR_I4(dst, (int)val); + BYTE* dstRW = dst + writeableOffset; + MISALIGNED_WR_I4(dstRW, (int)val); #ifdef DEBUG #ifdef TARGET_AMD64 @@ -7452,10 +7493,11 @@ unsigned char emitter::emitOutputLong(BYTE* dst, ssize_t val) unsigned char emitter::emitOutputSizeT(BYTE* dst, ssize_t val) { + BYTE* dstRW = dst + writeableOffset; #if !defined(TARGET_64BIT) - MISALIGNED_WR_I4(dst, (int)val); + MISALIGNED_WR_I4(dstRW, (int)val); #else - MISALIGNED_WR_ST(dst, val); + MISALIGNED_WR_ST(dstRW, val); #endif return TARGET_POINTER_SIZE; @@ -8447,7 +8489,8 @@ void emitter::emitRecordRelocation(void* location, /* IN */ // late disassembly; maybe we'll need it? if (emitComp->info.compMatchedVM) { - emitCmpHandle->recordRelocation(location, target, fRelocType, slotNum, addlDelta); + void* locationRW = (BYTE*)location + writeableOffset; + emitCmpHandle->recordRelocation(location, locationRW, target, fRelocType, slotNum, addlDelta); } #if defined(LATE_DISASM) codeGen->getDisAssembler().disRecordRelocation((size_t)location, (size_t)target); diff --git a/src/coreclr/jit/emit.h b/src/coreclr/jit/emit.h index 6b57f4df2ef532..666201fc98bf00 100644 --- a/src/coreclr/jit/emit.h +++ b/src/coreclr/jit/emit.h @@ -1618,9 +1618,10 @@ class emitter bool emitIssuing; #endif - BYTE* emitCodeBlock; // Hot code block - BYTE* emitColdCodeBlock; // Cold code block - BYTE* emitConsBlock; // Read-only (constant) data block + BYTE* emitCodeBlock; // Hot code block + BYTE* emitColdCodeBlock; // Cold code block + BYTE* emitConsBlock; // Read-only (constant) data block + size_t writeableOffset; // Offset applied to a code address to get memory location that can be written UNATIVE_OFFSET emitTotalHotCodeSize; UNATIVE_OFFSET emitTotalColdCodeSize; diff --git a/src/coreclr/jit/emitarm.cpp b/src/coreclr/jit/emitarm.cpp index 58732c476d9e19..685c17f9293815 100644 --- a/src/coreclr/jit/emitarm.cpp +++ b/src/coreclr/jit/emitarm.cpp @@ -5094,7 +5094,7 @@ inline unsigned insEncodeImmT2_Mov(int imm) * Emit a Thumb-1 instruction (a 16-bit integer as code) */ -/*static*/ unsigned emitter::emitOutput_Thumb1Instr(BYTE* dst, code_t code) +unsigned emitter::emitOutput_Thumb1Instr(BYTE* dst, code_t code) { unsigned short word1 = code & 0xffff; assert(word1 == code); @@ -5104,7 +5104,8 @@ inline unsigned insEncodeImmT2_Mov(int imm) assert(top5bits < 29); #endif - MISALIGNED_WR_I2(dst, word1); + BYTE* dstRW = dst + writeableOffset; + MISALIGNED_WR_I2(dstRW, word1); return sizeof(short); } @@ -5113,7 +5114,7 @@ inline unsigned insEncodeImmT2_Mov(int imm) * Emit a Thumb-2 instruction (two 16-bit integers as code) */ -/*static*/ unsigned emitter::emitOutput_Thumb2Instr(BYTE* dst, code_t code) +unsigned emitter::emitOutput_Thumb2Instr(BYTE* dst, code_t code) { unsigned short word1 = (code >> 16) & 0xffff; unsigned short word2 = (code)&0xffff; @@ -5124,9 +5125,10 @@ inline unsigned insEncodeImmT2_Mov(int imm) assert(top5bits >= 29); #endif - MISALIGNED_WR_I2(dst, word1); - dst += 2; - MISALIGNED_WR_I2(dst, word2); + BYTE* dstRW = dst + writeableOffset; + MISALIGNED_WR_I2(dstRW, word1); + dstRW += 2; + MISALIGNED_WR_I2(dstRW, word2); return sizeof(short) * 2; } diff --git a/src/coreclr/jit/emitarm.h b/src/coreclr/jit/emitarm.h index e663a953e7a10b..27e5e9b1f6b7a7 100644 --- a/src/coreclr/jit/emitarm.h +++ b/src/coreclr/jit/emitarm.h @@ -20,8 +20,8 @@ BYTE* emitOutputIT(BYTE* dst, instruction ins, insFormat fmt, code_t condcode); BYTE* emitOutputLJ(insGroup* ig, BYTE* dst, instrDesc* id); BYTE* emitOutputShortBranch(BYTE* dst, instruction ins, insFormat fmt, ssize_t distVal, instrDescJmp* id); -static unsigned emitOutput_Thumb1Instr(BYTE* dst, code_t code); -static unsigned emitOutput_Thumb2Instr(BYTE* dst, code_t code); +unsigned emitOutput_Thumb1Instr(BYTE* dst, code_t code); +unsigned emitOutput_Thumb2Instr(BYTE* dst, code_t code); /************************************************************************/ /* Debug-only routines to display instructions */ diff --git a/src/coreclr/jit/emitarm64.cpp b/src/coreclr/jit/emitarm64.cpp index 3a37d7e893c35e..3badba90a0c032 100644 --- a/src/coreclr/jit/emitarm64.cpp +++ b/src/coreclr/jit/emitarm64.cpp @@ -10250,10 +10250,11 @@ unsigned emitter::emitOutputCall(insGroup* ig, BYTE* dst, instrDesc* id, code_t * Emit a 32-bit Arm64 instruction */ -/*static*/ unsigned emitter::emitOutput_Instr(BYTE* dst, code_t code) +unsigned emitter::emitOutput_Instr(BYTE* dst, code_t code) { assert(sizeof(code_t) == 4); - *((code_t*)dst) = code; + BYTE* dstRW = dst + writeableOffset; + *((code_t*)dstRW) = code; return sizeof(code_t); } diff --git a/src/coreclr/jit/emitarm64.h b/src/coreclr/jit/emitarm64.h index 2ab236282623cc..841f10bf297fbc 100644 --- a/src/coreclr/jit/emitarm64.h +++ b/src/coreclr/jit/emitarm64.h @@ -101,7 +101,7 @@ emitter::code_t emitInsCode(instruction ins, insFormat fmt); void emitInsLoadStoreOp(instruction ins, emitAttr attr, regNumber dataReg, GenTreeIndir* indir); // Emit the 32-bit Arm64 instruction 'code' into the 'dst' buffer -static unsigned emitOutput_Instr(BYTE* dst, code_t code); +unsigned emitOutput_Instr(BYTE* dst, code_t code); // A helper method to return the natural scale for an EA 'size' static unsigned NaturalScale_helper(emitAttr size); diff --git a/src/coreclr/jit/emitxarch.cpp b/src/coreclr/jit/emitxarch.cpp index 3af1528a314740..516c976fe009ae 100644 --- a/src/coreclr/jit/emitxarch.cpp +++ b/src/coreclr/jit/emitxarch.cpp @@ -9270,7 +9270,7 @@ void emitter::emitDispIns( * Output nBytes bytes of NOP instructions */ -static BYTE* emitOutputNOP(BYTE* dst, size_t nBytes) +static BYTE* emitOutputNOP(BYTE* dstRW, size_t nBytes) { assert(nBytes <= 15); @@ -9284,49 +9284,49 @@ static BYTE* emitOutputNOP(BYTE* dst, size_t nBytes) switch (nBytes) { case 15: - *dst++ = 0x90; + *dstRW++ = 0x90; FALLTHROUGH; case 14: - *dst++ = 0x90; + *dstRW++ = 0x90; FALLTHROUGH; case 13: - *dst++ = 0x90; + *dstRW++ = 0x90; FALLTHROUGH; case 12: - *dst++ = 0x90; + *dstRW++ = 0x90; FALLTHROUGH; case 11: - *dst++ = 0x90; + *dstRW++ = 0x90; FALLTHROUGH; case 10: - *dst++ = 0x90; + *dstRW++ = 0x90; FALLTHROUGH; case 9: - *dst++ = 0x90; + *dstRW++ = 0x90; FALLTHROUGH; case 8: - *dst++ = 0x90; + *dstRW++ = 0x90; FALLTHROUGH; case 7: - *dst++ = 0x90; + *dstRW++ = 0x90; FALLTHROUGH; case 6: - *dst++ = 0x90; + *dstRW++ = 0x90; FALLTHROUGH; case 5: - *dst++ = 0x90; + *dstRW++ = 0x90; FALLTHROUGH; case 4: - *dst++ = 0x90; + *dstRW++ = 0x90; FALLTHROUGH; case 3: - *dst++ = 0x90; + *dstRW++ = 0x90; FALLTHROUGH; case 2: - *dst++ = 0x90; + *dstRW++ = 0x90; FALLTHROUGH; case 1: - *dst++ = 0x90; + *dstRW++ = 0x90; break; case 0: break; @@ -9335,82 +9335,82 @@ static BYTE* emitOutputNOP(BYTE* dst, size_t nBytes) switch (nBytes) { case 2: - *dst++ = 0x66; + *dstRW++ = 0x66; FALLTHROUGH; case 1: - *dst++ = 0x90; + *dstRW++ = 0x90; break; case 0: break; case 3: - *dst++ = 0x0F; - *dst++ = 0x1F; - *dst++ = 0x00; + *dstRW++ = 0x0F; + *dstRW++ = 0x1F; + *dstRW++ = 0x00; break; case 4: - *dst++ = 0x0F; - *dst++ = 0x1F; - *dst++ = 0x40; - *dst++ = 0x00; + *dstRW++ = 0x0F; + *dstRW++ = 0x1F; + *dstRW++ = 0x40; + *dstRW++ = 0x00; break; case 6: - *dst++ = 0x66; + *dstRW++ = 0x66; FALLTHROUGH; case 5: - *dst++ = 0x0F; - *dst++ = 0x1F; - *dst++ = 0x44; - *dst++ = 0x00; - *dst++ = 0x00; + *dstRW++ = 0x0F; + *dstRW++ = 0x1F; + *dstRW++ = 0x44; + *dstRW++ = 0x00; + *dstRW++ = 0x00; break; case 7: - *dst++ = 0x0F; - *dst++ = 0x1F; - *dst++ = 0x80; - *dst++ = 0x00; - *dst++ = 0x00; - *dst++ = 0x00; - *dst++ = 0x00; + *dstRW++ = 0x0F; + *dstRW++ = 0x1F; + *dstRW++ = 0x80; + *dstRW++ = 0x00; + *dstRW++ = 0x00; + *dstRW++ = 0x00; + *dstRW++ = 0x00; break; case 15: // More than 3 prefixes is slower than just 2 NOPs - dst = emitOutputNOP(emitOutputNOP(dst, 7), 8); + dstRW = emitOutputNOP(emitOutputNOP(dstRW, 7), 8); break; case 14: // More than 3 prefixes is slower than just 2 NOPs - dst = emitOutputNOP(emitOutputNOP(dst, 7), 7); + dstRW = emitOutputNOP(emitOutputNOP(dstRW, 7), 7); break; case 13: // More than 3 prefixes is slower than just 2 NOPs - dst = emitOutputNOP(emitOutputNOP(dst, 5), 8); + dstRW = emitOutputNOP(emitOutputNOP(dstRW, 5), 8); break; case 12: // More than 3 prefixes is slower than just 2 NOPs - dst = emitOutputNOP(emitOutputNOP(dst, 4), 8); + dstRW = emitOutputNOP(emitOutputNOP(dstRW, 4), 8); break; case 11: - *dst++ = 0x66; + *dstRW++ = 0x66; FALLTHROUGH; case 10: - *dst++ = 0x66; + *dstRW++ = 0x66; FALLTHROUGH; case 9: - *dst++ = 0x66; + *dstRW++ = 0x66; FALLTHROUGH; case 8: - *dst++ = 0x0F; - *dst++ = 0x1F; - *dst++ = 0x84; - *dst++ = 0x00; - *dst++ = 0x00; - *dst++ = 0x00; - *dst++ = 0x00; - *dst++ = 0x00; + *dstRW++ = 0x0F; + *dstRW++ = 0x1F; + *dstRW++ = 0x84; + *dstRW++ = 0x00; + *dstRW++ = 0x00; + *dstRW++ = 0x00; + *dstRW++ = 0x00; + *dstRW++ = 0x00; break; } #endif // TARGET_AMD64 - return dst; + return dstRW; } //-------------------------------------------------------------------- @@ -9454,7 +9454,9 @@ BYTE* emitter::emitOutputAlign(insGroup* ig, instrDesc* id, BYTE* dst) emitComp->loopsAligned++; #endif - return emitOutputNOP(dst, paddingToAdd); + BYTE* dstRW = dst + writeableOffset; + dstRW = emitOutputNOP(dstRW, paddingToAdd); + return dstRW - writeableOffset; } /***************************************************************************** @@ -12775,7 +12777,9 @@ size_t emitter::emitOutputInstr(insGroup* ig, instrDesc* id, BYTE** dp) if (ins == INS_nop) { - dst = emitOutputNOP(dst, id->idCodeSize()); + BYTE* dstRW = dst + writeableOffset; + dstRW = emitOutputNOP(dstRW, id->idCodeSize()); + dst = dstRW - writeableOffset; break; } @@ -13897,7 +13901,9 @@ size_t emitter::emitOutputInstr(insGroup* ig, instrDesc* id, BYTE** dp) } #endif - dst = emitOutputNOP(dst, diff); + BYTE* dstRW = dst + writeableOffset; + dstRW = emitOutputNOP(dstRW, diff); + dst = dstRW - writeableOffset; } assert((id->idCodeSize() - ((UNATIVE_OFFSET)(dst - *dp))) == 0); } diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoBase.cs b/src/coreclr/tools/Common/JitInterface/CorInfoBase.cs index d8b1857b943c2e..7125dfc59b9042 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoBase.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoBase.cs @@ -2317,12 +2317,12 @@ static byte _notifyInstructionSetUsage(IntPtr thisHandle, IntPtr* ppException, I } [UnmanagedCallersOnly] - static void _allocMem(IntPtr thisHandle, IntPtr* ppException, uint hotCodeSize, uint coldCodeSize, uint roDataSize, uint xcptnsCount, CorJitAllocMemFlag flag, void** hotCodeBlock, void** coldCodeBlock, void** roDataBlock) + static void _allocMem(IntPtr thisHandle, IntPtr* ppException, AllocMemArgs* pArgs) { var _this = GetThis(thisHandle); try { - _this.allocMem(hotCodeSize, coldCodeSize, roDataSize, xcptnsCount, flag, ref *hotCodeBlock, ref *coldCodeBlock, ref *roDataBlock); + _this.allocMem(ref *pArgs); } catch (Exception ex) { @@ -2490,12 +2490,12 @@ static void _recordCallSite(IntPtr thisHandle, IntPtr* ppException, uint instrOf } [UnmanagedCallersOnly] - static void _recordRelocation(IntPtr thisHandle, IntPtr* ppException, void* location, void* target, ushort fRelocType, ushort slotNum, int addlDelta) + static void _recordRelocation(IntPtr thisHandle, IntPtr* ppException, void* location, void* locationRW, void* target, ushort fRelocType, ushort slotNum, int addlDelta) { var _this = GetThis(thisHandle); try { - _this.recordRelocation(location, target, fRelocType, slotNum, addlDelta); + _this.recordRelocation(location, locationRW, target, fRelocType, slotNum, addlDelta); } catch (Exception ex) { @@ -2709,7 +2709,7 @@ static IntPtr GetUnmanagedCallbacks() callbacks[153] = (delegate* unmanaged)&_getTailCallHelpers; callbacks[154] = (delegate* unmanaged)&_convertPInvokeCalliToCall; callbacks[155] = (delegate* unmanaged)&_notifyInstructionSetUsage; - callbacks[156] = (delegate* unmanaged)&_allocMem; + callbacks[156] = (delegate* unmanaged)&_allocMem; callbacks[157] = (delegate* unmanaged)&_reserveUnwindInfo; callbacks[158] = (delegate* unmanaged)&_allocUnwindInfo; callbacks[159] = (delegate* unmanaged)&_allocGCInfo; @@ -2721,7 +2721,7 @@ static IntPtr GetUnmanagedCallbacks() callbacks[165] = (delegate* unmanaged)&_getPgoInstrumentationResults; callbacks[166] = (delegate* unmanaged)&_allocPgoInstrumentationBySchema; callbacks[167] = (delegate* unmanaged)&_recordCallSite; - callbacks[168] = (delegate* unmanaged)&_recordRelocation; + callbacks[168] = (delegate* unmanaged)&_recordRelocation; callbacks[169] = (delegate* unmanaged)&_getRelocTypeHint; callbacks[170] = (delegate* unmanaged)&_getExpectedTargetArchitecture; callbacks[171] = (delegate* unmanaged)&_getJitFlags; diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs index 396769e2eb53e5..65137fad8c029d 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs @@ -3066,45 +3066,50 @@ private bool getTailCallHelpers(ref CORINFO_RESOLVED_TOKEN callToken, CORINFO_SI private byte[] _gcInfo; private CORINFO_EH_CLAUSE[] _ehClauses; - private void allocMem(uint hotCodeSize, uint coldCodeSize, uint roDataSize, uint xcptnsCount, CorJitAllocMemFlag flag, ref void* hotCodeBlock, ref void* coldCodeBlock, ref void* roDataBlock) + private void allocMem(ref AllocMemArgs args) { - hotCodeBlock = (void*)GetPin(_code = new byte[hotCodeSize]); + args.hotCodeBlock = (void*)GetPin(_code = new byte[args.hotCodeSize]); + args.hotCodeBlockRW = args.hotCodeBlock; - if (coldCodeSize != 0) - coldCodeBlock = (void*)GetPin(_coldCode = new byte[coldCodeSize]); + if (args.coldCodeSize != 0) + { + args.coldCodeBlock = (void*)GetPin(_coldCode = new byte[args.coldCodeSize]); + args.coldCodeBlockRW = args.coldCodeBlock; + } _codeAlignment = -1; - if ((flag & CorJitAllocMemFlag.CORJIT_ALLOCMEM_FLG_32BYTE_ALIGN) != 0) + if ((args.flag & CorJitAllocMemFlag.CORJIT_ALLOCMEM_FLG_32BYTE_ALIGN) != 0) { _codeAlignment = 32; } - else if ((flag & CorJitAllocMemFlag.CORJIT_ALLOCMEM_FLG_16BYTE_ALIGN) != 0) + else if ((args.flag & CorJitAllocMemFlag.CORJIT_ALLOCMEM_FLG_16BYTE_ALIGN) != 0) { _codeAlignment = 16; } - if (roDataSize != 0) + if (args.roDataSize != 0) { _roDataAlignment = 8; - if ((flag & CorJitAllocMemFlag.CORJIT_ALLOCMEM_FLG_RODATA_32BYTE_ALIGN) != 0) + if ((args.flag & CorJitAllocMemFlag.CORJIT_ALLOCMEM_FLG_RODATA_32BYTE_ALIGN) != 0) { _roDataAlignment = 32; } - else if ((flag & CorJitAllocMemFlag.CORJIT_ALLOCMEM_FLG_RODATA_16BYTE_ALIGN) != 0) + else if ((args.flag & CorJitAllocMemFlag.CORJIT_ALLOCMEM_FLG_RODATA_16BYTE_ALIGN) != 0) { _roDataAlignment = 16; } - else if (roDataSize < 8) + else if (args.roDataSize < 8) { _roDataAlignment = PointerSize; } - _roData = new byte[roDataSize]; + _roData = new byte[args.roDataSize]; _roDataBlob = new MethodReadOnlyDataNode(MethodBeingCompiled); - roDataBlock = (void*)GetPin(_roData); + args.roDataBlock = (void*)GetPin(_roData); + args.roDataBlockRW = args.roDataBlock; } if (_numFrameInfos > 0) @@ -3280,7 +3285,7 @@ private static RelocType GetRelocType(TargetArchitecture targetArchitecture, ush }; } - private void recordRelocation(void* location, void* target, ushort fRelocType, ushort slotNum, int addlDelta) + private void recordRelocation(void* location, void* locationRW, void* target, ushort fRelocType, ushort slotNum, int addlDelta) { // slotNum is not used Debug.Assert(slotNum == 0); diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoTypes.cs b/src/coreclr/tools/Common/JitInterface/CorInfoTypes.cs index e787a52dc3fc1a..84f1ba7a4ddac7 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoTypes.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoTypes.cs @@ -313,6 +313,25 @@ public struct PgoInstrumentationSchema public int Other; } + [StructLayout(LayoutKind.Sequential)] + public unsafe struct AllocMemArgs + { + // Input arguments + public uint hotCodeSize; + public uint coldCodeSize; + public uint roDataSize; + public uint xcptnsCount; + public CorJitAllocMemFlag flag; + + // Output arguments + public void* hotCodeBlock; + public void* hotCodeBlockRW; + public void* coldCodeBlock; + public void* coldCodeBlockRW; + public void* roDataBlock; + public void* roDataBlockRW; + } + // Flags computed by a runtime compiler public enum CorInfoMethodRuntimeFlags { diff --git a/src/coreclr/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt b/src/coreclr/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt index c623119840327a..18ac90d0b459ed 100644 --- a/src/coreclr/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt +++ b/src/coreclr/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt @@ -101,6 +101,8 @@ CORINFO_JUST_MY_CODE_HANDLE**,ref CORINFO_JUST_MY_CODE_HANDLE_* ICorJitInfo::PgoInstrumentationSchema**,ref PgoInstrumentationSchema* ICorJitInfo::PgoInstrumentationSchema*,PgoInstrumentationSchema* +AllocMemArgs*, ref AllocMemArgs + ; Enums CorInfoClassId CorInfoHelpFunc @@ -306,7 +308,7 @@ FUNCTIONS bool getTailCallHelpers(CORINFO_RESOLVED_TOKEN* callToken, CORINFO_SIG_INFO* sig, CORINFO_GET_TAILCALL_HELPERS_FLAGS flags, CORINFO_TAILCALL_HELPERS* pResult); bool convertPInvokeCalliToCall(CORINFO_RESOLVED_TOKEN * pResolvedToken, bool mustConvert); bool notifyInstructionSetUsage(CORINFO_InstructionSet instructionSet,bool supportEnabled); - void allocMem( uint32_t hotCodeSize, uint32_t coldCodeSize, uint32_t roDataSize, uint32_t xcptnsCount, CorJitAllocMemFlag flag, void** hotCodeBlock, void** coldCodeBlock, void** roDataBlock ); + void allocMem(AllocMemArgs* pArgs); void reserveUnwindInfo(bool isFunclet, bool isColdCode, uint32_t unwindSize) void allocUnwindInfo(uint8_t* pHotCode, uint8_t* pColdCode, uint32_t startOffset, uint32_t endOffset, uint32_t unwindSize, uint8_t* pUnwindBlock, CorJitFuncKind funcKind) void* allocGCInfo(size_t size) @@ -318,7 +320,7 @@ FUNCTIONS JITINTERFACE_HRESULT getPgoInstrumentationResults(CORINFO_METHOD_HANDLE ftnHnd, ICorJitInfo::PgoInstrumentationSchema** pSchema, uint32_t* pCountSchemaItems, uint8_t**pInstrumentationData) JITINTERFACE_HRESULT allocPgoInstrumentationBySchema(CORINFO_METHOD_HANDLE ftnHnd, ICorJitInfo::PgoInstrumentationSchema* pSchema, uint32_t countSchemaItems, uint8_t** pInstrumentationData) void recordCallSite(uint32_t instrOffset, CORINFO_SIG_INFO* callSig, CORINFO_METHOD_HANDLE methodHandle) - void recordRelocation(void* location, void* target, uint16_t fRelocType, uint16_t slotNum, int32_t addlDelta) + void recordRelocation(void* location, void* locationRW, void* target, uint16_t fRelocType, uint16_t slotNum, int32_t addlDelta) uint16_t getRelocTypeHint(void* target) uint32_t getExpectedTargetArchitecture() uint32_t getJitFlags(CORJIT_FLAGS* flags, uint32_t sizeInBytes) diff --git a/src/coreclr/tools/aot/jitinterface/jitinterface.h b/src/coreclr/tools/aot/jitinterface/jitinterface.h index 3520b7f9484a0b..78daddda066b57 100644 --- a/src/coreclr/tools/aot/jitinterface/jitinterface.h +++ b/src/coreclr/tools/aot/jitinterface/jitinterface.h @@ -167,7 +167,7 @@ struct JitInterfaceCallbacks bool (* getTailCallHelpers)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_RESOLVED_TOKEN* callToken, CORINFO_SIG_INFO* sig, CORINFO_GET_TAILCALL_HELPERS_FLAGS flags, CORINFO_TAILCALL_HELPERS* pResult); bool (* convertPInvokeCalliToCall)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken, bool mustConvert); bool (* notifyInstructionSetUsage)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_InstructionSet instructionSet, bool supportEnabled); - void (* allocMem)(void * thisHandle, CorInfoExceptionClass** ppException, uint32_t hotCodeSize, uint32_t coldCodeSize, uint32_t roDataSize, uint32_t xcptnsCount, CorJitAllocMemFlag flag, void** hotCodeBlock, void** coldCodeBlock, void** roDataBlock); + void (* allocMem)(void * thisHandle, CorInfoExceptionClass** ppException, AllocMemArgs* pArgs); void (* reserveUnwindInfo)(void * thisHandle, CorInfoExceptionClass** ppException, bool isFunclet, bool isColdCode, uint32_t unwindSize); void (* allocUnwindInfo)(void * thisHandle, CorInfoExceptionClass** ppException, uint8_t* pHotCode, uint8_t* pColdCode, uint32_t startOffset, uint32_t endOffset, uint32_t unwindSize, uint8_t* pUnwindBlock, CorJitFuncKind funcKind); void* (* allocGCInfo)(void * thisHandle, CorInfoExceptionClass** ppException, size_t size); @@ -179,7 +179,7 @@ struct JitInterfaceCallbacks JITINTERFACE_HRESULT (* getPgoInstrumentationResults)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_METHOD_HANDLE ftnHnd, ICorJitInfo::PgoInstrumentationSchema** pSchema, uint32_t* pCountSchemaItems, uint8_t** pInstrumentationData); JITINTERFACE_HRESULT (* allocPgoInstrumentationBySchema)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_METHOD_HANDLE ftnHnd, ICorJitInfo::PgoInstrumentationSchema* pSchema, uint32_t countSchemaItems, uint8_t** pInstrumentationData); void (* recordCallSite)(void * thisHandle, CorInfoExceptionClass** ppException, uint32_t instrOffset, CORINFO_SIG_INFO* callSig, CORINFO_METHOD_HANDLE methodHandle); - void (* recordRelocation)(void * thisHandle, CorInfoExceptionClass** ppException, void* location, void* target, uint16_t fRelocType, uint16_t slotNum, int32_t addlDelta); + void (* recordRelocation)(void * thisHandle, CorInfoExceptionClass** ppException, void* location, void* locationRW, void* target, uint16_t fRelocType, uint16_t slotNum, int32_t addlDelta); uint16_t (* getRelocTypeHint)(void * thisHandle, CorInfoExceptionClass** ppException, void* target); uint32_t (* getExpectedTargetArchitecture)(void * thisHandle, CorInfoExceptionClass** ppException); uint32_t (* getJitFlags)(void * thisHandle, CorInfoExceptionClass** ppException, CORJIT_FLAGS* flags, uint32_t sizeInBytes); @@ -1695,17 +1695,10 @@ class JitInterfaceWrapper : public ICorJitInfo } virtual void allocMem( - uint32_t hotCodeSize, - uint32_t coldCodeSize, - uint32_t roDataSize, - uint32_t xcptnsCount, - CorJitAllocMemFlag flag, - void** hotCodeBlock, - void** coldCodeBlock, - void** roDataBlock) + AllocMemArgs* pArgs) { CorInfoExceptionClass* pException = nullptr; - _callbacks->allocMem(_thisHandle, &pException, hotCodeSize, coldCodeSize, roDataSize, xcptnsCount, flag, hotCodeBlock, coldCodeBlock, roDataBlock); + _callbacks->allocMem(_thisHandle, &pException, pArgs); if (pException != nullptr) throw pException; } @@ -1825,13 +1818,14 @@ class JitInterfaceWrapper : public ICorJitInfo virtual void recordRelocation( void* location, + void* locationRW, void* target, uint16_t fRelocType, uint16_t slotNum, int32_t addlDelta) { CorInfoExceptionClass* pException = nullptr; - _callbacks->recordRelocation(_thisHandle, &pException, location, target, fRelocType, slotNum, addlDelta); + _callbacks->recordRelocation(_thisHandle, &pException, location, locationRW, target, fRelocType, slotNum, addlDelta); if (pException != nullptr) throw pException; } diff --git a/src/coreclr/vm/jitinterface.cpp b/src/coreclr/vm/jitinterface.cpp index f629b76991001a..14e1c153c116ab 100644 --- a/src/coreclr/vm/jitinterface.cpp +++ b/src/coreclr/vm/jitinterface.cpp @@ -11153,7 +11153,7 @@ void CEEJitInfo::BackoutJitData(EEJitManager * jitMgr) GC_TRIGGERS; } CONTRACTL_END; - CodeHeader* pCodeHeader = GetCodeHeader(); + CodeHeader* pCodeHeader = m_CodeHeader; if (pCodeHeader) jitMgr->RemoveJitData(pCodeHeader, m_GCinfo_len, m_EHinfo_len); } @@ -11276,7 +11276,7 @@ void CEEJitInfo::CompressDebugInfo() NULL, m_pMethodBeingCompiled->GetLoaderAllocator()->GetLowFrequencyHeap()); - GetCodeHeader()->SetDebugInfo(pDebugInfo); + m_CodeHeader->SetDebugInfo(pDebugInfo); } EX_CATCH { @@ -11551,6 +11551,7 @@ void CEEJitInfo::recordCallSite(uint32_t instrOffset, // A jump thunk may be inserted if we are jitting void CEEJitInfo::recordRelocation(void * location, + void * locationRW, void * target, WORD fRelocType, WORD slot, @@ -11571,7 +11572,7 @@ void CEEJitInfo::recordRelocation(void * location, { case IMAGE_REL_BASED_DIR64: // Write 64-bits into location - *((UINT64 *) ((BYTE *) location + slot)) = (UINT64) target; + *((UINT64 *) ((BYTE *) locationRW + slot)) = (UINT64) target; break; #ifdef TARGET_AMD64 @@ -11580,6 +11581,7 @@ void CEEJitInfo::recordRelocation(void * location, target = (BYTE *)target + addlDelta; INT32 * fixupLocation = (INT32 *) ((BYTE *) location + slot); + INT32 * fixupLocationRW = (INT32 *) ((BYTE *) locationRW + slot); BYTE * baseAddr = (BYTE *)fixupLocation + sizeof(INT32); delta = (INT64)((BYTE *)target - baseAddr); @@ -11625,7 +11627,7 @@ void CEEJitInfo::recordRelocation(void * location, DBG_ADDR(fixupLocation), DBG_ADDR(target), addlDelta, delta)); // Write the 32-bits pc-relative delta into location - *fixupLocation = (INT32) delta; + *fixupLocationRW = (INT32) delta; } break; #endif // TARGET_AMD64 @@ -11640,6 +11642,7 @@ void CEEJitInfo::recordRelocation(void * location, _ASSERTE((branchTarget & 0x3) == 0); // the low two bits must be zero PCODE fixupLocation = (PCODE) location; + PCODE fixupLocationRW = (PCODE) locationRW; _ASSERTE((fixupLocation & 0x3) == 0); // the low two bits must be zero delta = (INT64)(branchTarget - fixupLocation); @@ -11703,7 +11706,7 @@ void CEEJitInfo::recordRelocation(void * location, _ASSERTE(FitsInRel28(delta)); - PutArm64Rel28((UINT32*) fixupLocation, (INT32)delta); + PutArm64Rel28((UINT32*) fixupLocationRW, (INT32)delta); } break; @@ -11717,7 +11720,7 @@ void CEEJitInfo::recordRelocation(void * location, INT64 locationPage = (INT64)location & 0xFFFFFFFFFFFFF000LL; INT64 relPage = (INT64)(targetPage - locationPage); INT32 imm21 = (INT32)(relPage >> 12) & 0x1FFFFF; - PutArm64Rel21((UINT32 *)location, imm21); + PutArm64Rel21((UINT32 *)locationRW, imm21); } break; @@ -11728,7 +11731,7 @@ void CEEJitInfo::recordRelocation(void * location, // Write the 12 bits page offset into location. INT32 imm12 = (INT32)(SIZE_T)target & 0xFFFLL; - PutArm64Rel12((UINT32 *)location, imm12); + PutArm64Rel12((UINT32 *)locationRW, imm12); } break; @@ -12141,16 +12144,7 @@ HRESULT CEEJitInfo::getPgoInstrumentationResults( return hr; } -void CEEJitInfo::allocMem ( - uint32_t hotCodeSize, /* IN */ - uint32_t coldCodeSize, /* IN */ - uint32_t roDataSize, /* IN */ - uint32_t xcptnsCount, /* IN */ - CorJitAllocMemFlag flag, /* IN */ - void ** hotCodeBlock, /* OUT */ - void ** coldCodeBlock, /* OUT */ - void ** roDataBlock /* OUT */ - ) +void CEEJitInfo::allocMem (AllocMemArgs *pArgs) { CONTRACTL { THROWS; @@ -12160,39 +12154,40 @@ void CEEJitInfo::allocMem ( JIT_TO_EE_TRANSITION(); - _ASSERTE(coldCodeSize == 0); - if (coldCodeBlock) + _ASSERTE(pArgs->coldCodeSize == 0); + if (pArgs->coldCodeBlock) { - *coldCodeBlock = NULL; + pArgs->coldCodeBlock = NULL; } - ULONG codeSize = hotCodeSize; - void **codeBlock = hotCodeBlock; + ULONG codeSize = pArgs->hotCodeSize; + void **codeBlock = &pArgs->hotCodeBlock; + void **codeBlockRW = &pArgs->hotCodeBlockRW; S_SIZE_T totalSize = S_SIZE_T(codeSize); size_t roDataAlignment = sizeof(void*); - if ((flag & CORJIT_ALLOCMEM_FLG_RODATA_32BYTE_ALIGN)!= 0) + if ((pArgs->flag & CORJIT_ALLOCMEM_FLG_RODATA_32BYTE_ALIGN)!= 0) { roDataAlignment = 32; } - else if ((flag & CORJIT_ALLOCMEM_FLG_RODATA_16BYTE_ALIGN)!= 0) + else if ((pArgs->flag & CORJIT_ALLOCMEM_FLG_RODATA_16BYTE_ALIGN)!= 0) { roDataAlignment = 16; } - else if (roDataSize >= 8) + else if (pArgs->roDataSize >= 8) { roDataAlignment = 8; } - if (roDataSize > 0) + if (pArgs->roDataSize > 0) { size_t codeAlignment = sizeof(void*); - if ((flag & CORJIT_ALLOCMEM_FLG_32BYTE_ALIGN) != 0) + if ((pArgs->flag & CORJIT_ALLOCMEM_FLG_32BYTE_ALIGN) != 0) { codeAlignment = 32; } - else if ((flag & CORJIT_ALLOCMEM_FLG_16BYTE_ALIGN) != 0) + else if ((pArgs->flag & CORJIT_ALLOCMEM_FLG_16BYTE_ALIGN) != 0) { codeAlignment = 16; } @@ -12202,7 +12197,7 @@ void CEEJitInfo::allocMem ( // Add padding to align read-only data. totalSize += (roDataAlignment - codeAlignment); } - totalSize += roDataSize; + totalSize += pArgs->roDataSize; } #ifdef FEATURE_EH_FUNCLETS @@ -12236,10 +12231,10 @@ void CEEJitInfo::allocMem ( } FireEtwMethodJitMemoryAllocatedForCode(ullMethodIdentifier, ullModuleID, - hotCodeSize + coldCodeSize, roDataSize, totalSize.Value(), flag, GetClrInstanceId()); + pArgs->hotCodeSize + pArgs->coldCodeSize, pArgs->roDataSize, totalSize.Value(), pArgs->flag, GetClrInstanceId()); } - m_CodeHeader = m_jitManager->allocCode(m_pMethodBeingCompiled, totalSize.Value(), GetReserveForJumpStubs(), flag + m_CodeHeader = m_jitManager->allocCode(m_pMethodBeingCompiled, totalSize.Value(), GetReserveForJumpStubs(), pArgs->flag #ifdef FEATURE_EH_FUNCLETS , m_totalUnwindInfos , &m_moduleBase @@ -12249,17 +12244,20 @@ void CEEJitInfo::allocMem ( BYTE* current = (BYTE *)m_CodeHeader->GetCodeStartAddress(); *codeBlock = current; + *codeBlockRW = current; current += codeSize; - if (roDataSize > 0) + if (pArgs->roDataSize > 0) { current = (BYTE *)ALIGN_UP(current, roDataAlignment); - *roDataBlock = current; - current += roDataSize; + pArgs->roDataBlock = current; + pArgs->roDataBlockRW = current; + current += pArgs->roDataSize; } else { - *roDataBlock = NULL; + pArgs->roDataBlock = NULL; + pArgs->roDataBlockRW = NULL; } #ifdef FEATURE_EH_FUNCLETS @@ -12413,6 +12411,8 @@ void CEEJitInfo::getEHinfo( EE_TO_JIT_TRANSITION(); } + + #endif // CROSSGEN_COMPILE #if defined(CROSSGEN_COMPILE) @@ -14238,16 +14238,7 @@ bool CEEInfo::convertPInvokeCalliToCall(CORINFO_RESOLVED_TOKEN * pResolvedToken, return false; } -void CEEInfo::allocMem ( - uint32_t hotCodeSize, /* IN */ - uint32_t coldCodeSize, /* IN */ - uint32_t roDataSize, /* IN */ - uint32_t xcptnsCount, /* IN */ - CorJitAllocMemFlag flag, /* IN */ - void ** hotCodeBlock, /* OUT */ - void ** coldCodeBlock, /* OUT */ - void ** roDataBlock /* OUT */ - ) +void CEEInfo::allocMem (AllocMemArgs *pArgs) { LIMITED_METHOD_CONTRACT; UNREACHABLE(); // only called on derived class. @@ -14402,6 +14393,7 @@ void CEEInfo::recordCallSite( void CEEInfo::recordRelocation( void * location, /* IN */ + void * locationRW, /* IN */ void * target, /* IN */ WORD fRelocType, /* IN */ WORD slotNum, /* IN */ diff --git a/src/coreclr/vm/jitinterface.h b/src/coreclr/vm/jitinterface.h index bddc24fc4c3dfd..9a68805e02453a 100644 --- a/src/coreclr/vm/jitinterface.h +++ b/src/coreclr/vm/jitinterface.h @@ -636,16 +636,7 @@ class CEEJitInfo : public CEEInfo public: // ICorJitInfo stuff - void allocMem ( - uint32_t hotCodeSize, /* IN */ - uint32_t coldCodeSize, /* IN */ - uint32_t roDataSize, /* IN */ - uint32_t xcptnsCount, /* IN */ - CorJitAllocMemFlag flag, /* IN */ - void ** hotCodeBlock, /* OUT */ - void ** coldCodeBlock, /* OUT */ - void ** roDataBlock /* OUT */ - ) override final; + void allocMem (AllocMemArgs *pArgs) override final; void reserveUnwindInfo(bool isFunclet, bool isColdCode, uint32_t unwindSize) override final; @@ -695,6 +686,7 @@ class CEEJitInfo : public CEEInfo void recordRelocation( void *location, + void *locationRW, void *target, uint16_t fRelocType, uint16_t slot, @@ -704,18 +696,6 @@ class CEEJitInfo : public CEEInfo uint32_t getExpectedTargetArchitecture() override final; - CodeHeader* GetCodeHeader() - { - LIMITED_METHOD_CONTRACT; - return m_CodeHeader; - } - - void SetCodeHeader(CodeHeader* pValue) - { - LIMITED_METHOD_CONTRACT; - m_CodeHeader = pValue; - } - void ResetForJitRetry() { CONTRACTL { diff --git a/src/coreclr/zap/zapinfo.cpp b/src/coreclr/zap/zapinfo.cpp index de7b6688ffde17..11a27f7d1a2ebe 100644 --- a/src/coreclr/zap/zapinfo.cpp +++ b/src/coreclr/zap/zapinfo.cpp @@ -1138,45 +1138,38 @@ HRESULT ZapInfo::getPgoInstrumentationResults(CORINFO_METHOD_HANDLE ftnHnd, return pgoResults->m_hr; } -void ZapInfo::allocMem( - uint32_t hotCodeSize, /* IN */ - uint32_t coldCodeSize, /* IN */ - uint32_t roDataSize, /* IN */ - uint32_t xcptnsCount, /* IN */ - CorJitAllocMemFlag flag, /* IN */ - void ** hotCodeBlock, /* OUT */ - void ** coldCodeBlock, /* OUT */ - void ** roDataBlock /* OUT */ - ) +void ZapInfo::allocMem(AllocMemArgs *pArgs) { bool optForSize = m_zapper->m_pOpt->m_compilerFlags.IsSet(CORJIT_FLAGS::CORJIT_FLAG_SIZE_OPT); UINT align = DEFAULT_CODE_ALIGN; - if ((flag & CORJIT_ALLOCMEM_FLG_16BYTE_ALIGN) && !IsReadyToRunCompilation()) align = max(align, 16); + if ((pArgs->flag & CORJIT_ALLOCMEM_FLG_16BYTE_ALIGN) && !IsReadyToRunCompilation()) align = max(align, 16); - m_pCode = ZapCodeBlob::NewAlignedBlob(m_pImage, NULL, hotCodeSize, align); - *hotCodeBlock = m_pCode->GetData(); + m_pCode = ZapCodeBlob::NewAlignedBlob(m_pImage, NULL, pArgs->hotCodeSize, align); + pArgs->hotCodeBlock = m_pCode->GetData(); + pArgs->hotCodeBlockRW = m_pCode->GetData(); - if (coldCodeSize != 0) + if (pArgs->coldCodeSize != 0) { align = sizeof(DWORD); - m_pColdCode = ZapCodeBlob::NewAlignedBlob(m_pImage, NULL, coldCodeSize, align); - *coldCodeBlock = m_pColdCode->GetData(); + m_pColdCode = ZapCodeBlob::NewAlignedBlob(m_pImage, NULL, pArgs->coldCodeSize, align); + pArgs->coldCodeBlock = m_pColdCode->GetData(); + pArgs->coldCodeBlockRW = m_pColdCode->GetData(); } // // Allocate data // - if (roDataSize > 0) + if (pArgs->roDataSize > 0) { - if (flag & CORJIT_ALLOCMEM_FLG_RODATA_16BYTE_ALIGN) + if (pArgs->flag & CORJIT_ALLOCMEM_FLG_RODATA_16BYTE_ALIGN) { align = 16; } - else if (optForSize || (roDataSize < 8)) + else if (optForSize || (pArgs->roDataSize < 8)) { align = TARGET_POINTER_SIZE; } @@ -1184,35 +1177,36 @@ void ZapInfo::allocMem( { align = 8; } - m_pROData = ZapBlobWithRelocs::NewAlignedBlob(m_pImage, NULL, roDataSize, align); - *roDataBlock = m_pROData->GetData(); + m_pROData = ZapBlobWithRelocs::NewAlignedBlob(m_pImage, NULL, pArgs->roDataSize, align); + pArgs->roDataBlock = m_pROData->GetData(); + pArgs->roDataBlockRW = m_pROData->GetData(); } if (m_pImage->m_stats) { - m_pImage->m_stats->m_nativeCodeSize += hotCodeSize; - m_pImage->m_stats->m_nativeColdCodeSize += coldCodeSize; - m_pImage->m_stats->m_nativeRODataSize += roDataSize; + m_pImage->m_stats->m_nativeCodeSize += pArgs->hotCodeSize; + m_pImage->m_stats->m_nativeColdCodeSize += pArgs->coldCodeSize; + m_pImage->m_stats->m_nativeRODataSize += pArgs->roDataSize; BOOL haveProfileData = CurrentMethodHasProfileData(); if (haveProfileData) { - m_pImage->m_stats->m_nativeCodeSizeInProfiledMethods += hotCodeSize; - m_pImage->m_stats->m_nativeColdCodeSizeInProfiledMethods += coldCodeSize; + m_pImage->m_stats->m_nativeCodeSizeInProfiledMethods += pArgs->hotCodeSize; + m_pImage->m_stats->m_nativeColdCodeSizeInProfiledMethods += pArgs->coldCodeSize; } - if (coldCodeSize) + if (pArgs->coldCodeSize) { m_pImage->m_stats->m_NumHotColdAllocations++; - m_pImage->m_stats->m_nativeCodeSizeInSplitMethods += hotCodeSize; - m_pImage->m_stats->m_nativeColdCodeSizeInSplitMethods += coldCodeSize; + m_pImage->m_stats->m_nativeCodeSizeInSplitMethods += pArgs->hotCodeSize; + m_pImage->m_stats->m_nativeColdCodeSizeInSplitMethods += pArgs->coldCodeSize; if (haveProfileData) { - m_pImage->m_stats->m_nativeCodeSizeInSplitProfiledMethods += hotCodeSize; - m_pImage->m_stats->m_nativeColdCodeSizeInSplitProfiledMethods += coldCodeSize; + m_pImage->m_stats->m_nativeCodeSizeInSplitProfiledMethods += pArgs->hotCodeSize; + m_pImage->m_stats->m_nativeColdCodeSizeInSplitProfiledMethods += pArgs->coldCodeSize; } } else @@ -2803,7 +2797,7 @@ void ZapInfo::recordCallSite(uint32_t instrOffset, CORINFO_SIG_INFO *callSig, CO return; } -void ZapInfo::recordRelocation(void *location, void *target, +void ZapInfo::recordRelocation(void *location, void *locationRW, void *target, uint16_t fRelocType, uint16_t slotNum, int32_t addlDelta) { // Factor slotNum into the location address