Skip to content
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
7 changes: 4 additions & 3 deletions src/coreclr/inc/corinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -3100,10 +3100,11 @@ class ICorDynamicInfo : public ICorStaticInfo
void **ppIndirection = NULL
) = 0;

// return the native entry point to an EE helper (see CorInfoHelpFunc)
virtual void* getHelperFtn (
// return the native entry point and/or managed method of an EE helper (see CorInfoHelpFunc)
virtual void getHelperFtn (
CorInfoHelpFunc ftnNum,
void **ppIndirection = NULL
CORINFO_CONST_LOOKUP * pNativeEntrypoint,
CORINFO_METHOD_HANDLE * pMethodHandle = NULL /* OUT */
) = 0;

// return a callable address of the function (native code). This function
Expand Down
5 changes: 3 additions & 2 deletions src/coreclr/inc/icorjitinfoimpl_generated.h
Original file line number Diff line number Diff line change
Expand Up @@ -535,9 +535,10 @@ uint32_t getThreadTLSIndex(
int32_t* getAddrOfCaptureThreadGlobal(
void** ppIndirection) override;

void* getHelperFtn(
void getHelperFtn(
CorInfoHelpFunc ftnNum,
void** ppIndirection) override;
CORINFO_CONST_LOOKUP* pNativeEntrypoint,
CORINFO_METHOD_HANDLE* pMethod) override;

void getFunctionEntryPoint(
CORINFO_METHOD_HANDLE ftn,
Expand Down
10 changes: 5 additions & 5 deletions src/coreclr/inc/jiteeversionguid.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@

#include <minipal/guid.h>

constexpr GUID JITEEVersionIdentifier = { /* ecc9bc7e-9223-4af6-af2f-b63e89c09279 */
0xecc9bc7e,
0x9223,
0x4af6,
{0xaf, 0x2f, 0xb6, 0x3e, 0x89, 0xc0, 0x92, 0x79}
constexpr GUID JITEEVersionIdentifier = { /* 2004006b-bdff-4357-8e60-3ae950a4f165 */
0x2004006b,
0xbdff,
0x4357,
{0x8e, 0x60, 0x3a, 0xe9, 0x50, 0xa4, 0xf1, 0x65}
};

#endif // JIT_EE_VERSIONING_GUID_H
17 changes: 10 additions & 7 deletions src/coreclr/interpreter/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2123,13 +2123,16 @@ int32_t InterpCompiler::GetMethodDataItemIndex(CORINFO_METHOD_HANDLE mHandle)
int32_t InterpCompiler::GetDataItemIndexForHelperFtn(CorInfoHelpFunc ftn)
{
// Interpreter-TODO: Find an existing data item index for this helper if possible and reuse it
void *indirect;
void *direct = m_compHnd->getHelperFtn(ftn, &indirect);
size_t data = !direct
? (size_t)indirect | INTERP_INDIRECT_HELPER_TAG
: (size_t)direct;
assert(data);
return GetDataItemIndex((void*)data);
CORINFO_CONST_LOOKUP ftnLookup;
m_compHnd->getHelperFtn(ftn, &ftnLookup);
void* addr = ftnLookup.addr;
if (ftnLookup.accessType == IAT_PVALUE)
{
addr = (void*)((size_t)addr | INTERP_INDIRECT_HELPER_TAG);
}
assert(ftnLookup.accessType == IAT_VALUE || ftnLookup.accessType == IAT_PVALUE);

return GetDataItemIndex(addr);
}

bool InterpCompiler::EmitCallIntrinsics(CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO sig)
Expand Down
8 changes: 4 additions & 4 deletions src/coreclr/jit/ICorJitInfo_wrapper_generated.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1269,14 +1269,14 @@ int32_t* WrapICorJitInfo::getAddrOfCaptureThreadGlobal(
return temp;
}

void* WrapICorJitInfo::getHelperFtn(
void WrapICorJitInfo::getHelperFtn(
CorInfoHelpFunc ftnNum,
void** ppIndirection)
CORINFO_CONST_LOOKUP* pNativeEntrypoint,
CORINFO_METHOD_HANDLE* pMethod)
{
API_ENTER(getHelperFtn);
void* temp = wrapHnd->getHelperFtn(ftnNum, ppIndirection);
wrapHnd->getHelperFtn(ftnNum, pNativeEntrypoint, pMethod);
API_LEAVE(getHelperFtn);
return temp;
}

void WrapICorJitInfo::getFunctionEntryPoint(
Expand Down
11 changes: 10 additions & 1 deletion src/coreclr/jit/codegenarm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1616,7 +1616,16 @@ void CodeGen::genEmitHelperCall(unsigned helper, int argSize, emitAttr retSize,
else
#endif
{
addr = compiler->compGetHelperFtn((CorInfoHelpFunc)helper, (void**)&pAddr);
CORINFO_CONST_LOOKUP helperFunction = compiler->compGetHelperFtn((CorInfoHelpFunc)helper);
if (helperFunction.accessType == IAT_VALUE)
{
addr = helperFunction.addr;
}
else
{
assert(helperFunction.accessType == IAT_PVALUE);
pAddr = (void**)helperFunction.addr;
}
}

EmitCallParams params;
Expand Down
18 changes: 13 additions & 5 deletions src/coreclr/jit/codegenarm64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5134,15 +5134,23 @@ bool CodeGen::IsSaveFpLrWithAllCalleeSavedRegisters() const

void CodeGen::genEmitHelperCall(unsigned helper, int argSize, emitAttr retSize, regNumber callTargetReg /*= REG_NA */)
{
void* pAddr = nullptr;

EmitCallParams params;
params.callType = EC_FUNC_TOKEN;
params.addr = compiler->compGetHelperFtn((CorInfoHelpFunc)helper, &pAddr);

CORINFO_CONST_LOOKUP helperFunction = compiler->compGetHelperFtn((CorInfoHelpFunc)helper);
regMaskTP killSet = compiler->compHelperCallKillSet((CorInfoHelpFunc)helper);

if (params.addr == nullptr)
params.callType = EC_FUNC_TOKEN;

if (helperFunction.accessType == IAT_VALUE)
{
params.addr = (void*)helperFunction.addr;
}
else
{
params.addr = nullptr;
assert(helperFunction.accessType == IAT_PVALUE);
void* pAddr = helperFunction.addr;
Copy link

Copilot AI Jun 12, 2025

Choose a reason for hiding this comment

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

The redundant declaration of 'pAddr' in the else branch is not used; consider removing it to simplify the code.

Suggested change
void* pAddr = helperFunction.addr;

Copilot uses AI. Check for mistakes.

// This is call to a runtime helper.
// adrp x, [reloc:rel page addr]
// add x, x, [reloc:page offset]
Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/jit/codegenarmarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3452,9 +3452,9 @@ void CodeGen::genCallInstruction(GenTreeCall* call)
CorInfoHelpFunc helperNum = compiler->eeGetHelperNum(params.methHnd);
noway_assert(helperNum != CORINFO_HELP_UNDEF);

void* pAddr = nullptr;
params.addr = compiler->compGetHelperFtn(helperNum, (void**)&pAddr);
assert(pAddr == nullptr);
CORINFO_CONST_LOOKUP helperLookup = compiler->compGetHelperFtn(helperNum);
params.addr = helperLookup.addr;
assert(helperLookup.accessType == IAT_VALUE);
}
else
{
Expand Down
3 changes: 1 addition & 2 deletions src/coreclr/jit/codegencommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1764,10 +1764,9 @@ void CodeGen::genGenerateCode(void** codePtr, uint32_t* nativeSizeOfCode)
//
if (genWriteBarrierUsed && JitConfig.EnableExtraSuperPmiQueries() && !compiler->IsAot())
{
void* ignored;
for (int i = CORINFO_HELP_ASSIGN_REF; i <= CORINFO_HELP_BULK_WRITEBARRIER; i++)
{
compiler->compGetHelperFtn((CorInfoHelpFunc)i, &ignored);
compiler->compGetHelperFtn((CorInfoHelpFunc)i);
}
}
#endif
Expand Down
55 changes: 39 additions & 16 deletions src/coreclr/jit/codegenloongarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2688,11 +2688,18 @@ void CodeGen::genCodeForReturnTrap(GenTreeOp* tree)

EmitCallParams params;

void* pAddr = nullptr;
params.addr = compiler->compGetHelperFtn(CORINFO_HELP_STOP_FOR_GC, &pAddr);

if (params.addr == nullptr)
CORINFO_CONST_LOOKUP helperFunction = compiler->compGetHelperFtn(CORINFO_HELP_STOP_FOR_GC);
if (helperFunction.accessType == IAT_VALUE)
{
// If the helper is a value, we need to use the address of the helper.
params.addr = helperFunction.addr;
}
else
{
params.addr = nullptr;
assert(helperFunction.accessType == IAT_PVALUE);
void* pAddr = helperFunction.addr;

params.callType = EC_INDIR_R;
params.ireg = REG_DEFAULT_HELPER_CALL_TARGET;

Expand Down Expand Up @@ -3758,15 +3765,23 @@ int CodeGenInterface::genCallerSPtoInitialSPdelta() const

void CodeGen::genEmitHelperCall(unsigned helper, int argSize, emitAttr retSize, regNumber callTargetReg /*= REG_NA */)
{
void* pAddr = nullptr;

EmitCallParams params;
params.callType = EC_FUNC_TOKEN;
params.addr = compiler->compGetHelperFtn((CorInfoHelpFunc)helper, &pAddr);

CORINFO_CONST_LOOKUP helperFunction = compiler->compGetHelperFtn((CorInfoHelpFunc)helper);
regMaskTP killSet = compiler->compHelperCallKillSet((CorInfoHelpFunc)helper);

if (params.addr == nullptr)
params.callType = EC_FUNC_TOKEN;

if (helperFunction.accessType == IAT_VALUE)
{
params.addr = (void*)helperFunction.addr;
}
else
{
params.addr = nullptr;
assert(helperFunction.accessType == IAT_PVALUE);
void* pAddr = helperFunction.addr;

// This is call to a runtime helper.
// li reg, pAddr #NOTE: this maybe multi-instructions.
// ld_d reg, reg
Expand Down Expand Up @@ -5793,9 +5808,9 @@ void CodeGen::genCallInstruction(GenTreeCall* call)
CorInfoHelpFunc helperNum = compiler->eeGetHelperNum(params.methHnd);
noway_assert(helperNum != CORINFO_HELP_UNDEF);

void* pAddr = nullptr;
params.addr = compiler->compGetHelperFtn(helperNum, (void**)&pAddr);
assert(pAddr == nullptr);
CORINFO_CONST_LOOKUP helperLookup = compiler->compGetHelperFtn(helperNum);
params.addr = helperLookup.addr;
assert(helperLookup.accessType == IAT_VALUE);
}
else
{
Expand Down Expand Up @@ -6483,10 +6498,8 @@ inline void CodeGen::genJumpToThrowHlpBlk_la(
// The code to throw the exception will be generated inline, and
// we will jump around it in the normal non-exception case.

void* pAddr = nullptr;
EmitCallParams params;
params.addr = compiler->compGetHelperFtn((CorInfoHelpFunc)(compiler->acdHelper(codeKind)), &pAddr);


// maybe optimize
// ins = (instruction)(ins^((ins != INS_beq)+(ins != INS_bne)));
if (ins == INS_blt)
Expand All @@ -6510,8 +6523,18 @@ inline void CodeGen::genJumpToThrowHlpBlk_la(
ins = ins == INS_beq ? INS_bne : INS_beq;
}

if (params.addr == nullptr)
CORINFO_CONST_LOOKUP helperFunction = compiler->compGetHelperFtn((CorInfoHelpFunc)(compiler->acdHelper(codeKind)));
if (helperFunction.accessType == IAT_VALUE)
{
// If the helper is a value, we need to use the address of the helper.
params.addr = helperFunction.addr;
}
else
{
params.addr = nullptr;
assert(helperFunction.accessType == IAT_PVALUE);
void* pAddr = helperFunction.addr;

params.callType = EC_INDIR_R;
params.ireg = REG_DEFAULT_HELPER_CALL_TARGET;

Expand Down
50 changes: 35 additions & 15 deletions src/coreclr/jit/codegenriscv64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2712,11 +2712,15 @@ void CodeGen::genCodeForReturnTrap(GenTreeOp* tree)

EmitCallParams params;

void* pAddr = nullptr;
params.addr = compiler->compGetHelperFtn(CORINFO_HELP_STOP_FOR_GC, &pAddr);

if (params.addr == nullptr)
CORINFO_CONST_LOOKUP helperFunction = compiler->compGetHelperFtn(CORINFO_HELP_STOP_FOR_GC);
if (helperFunction.accessType == IAT_VALUE)
{
// If the helper is a value, we need to use the address of the helper.
params.addr = helperFunction.addr;
}
else
{
params.addr = nullptr;
params.callType = EC_INDIR_R;
params.ireg = REG_DEFAULT_HELPER_CALL_TARGET;

Expand Down Expand Up @@ -3614,15 +3618,23 @@ static void emitLoadConstAtAddr(emitter* emit, regNumber dstRegister, ssize_t im

void CodeGen::genEmitHelperCall(unsigned helper, int argSize, emitAttr retSize, regNumber callTargetReg /*= REG_NA */)
{
void* pAddr = nullptr;

EmitCallParams params;
params.callType = EC_FUNC_TOKEN;
params.addr = compiler->compGetHelperFtn((CorInfoHelpFunc)helper, &pAddr);

CORINFO_CONST_LOOKUP helperFunction = compiler->compGetHelperFtn((CorInfoHelpFunc)helper);
regMaskTP killSet = compiler->compHelperCallKillSet((CorInfoHelpFunc)helper);

if (params.addr == nullptr)
params.callType = EC_FUNC_TOKEN;

if (helperFunction.accessType == IAT_VALUE)
{
params.addr = (void*)helperFunction.addr;
}
else
{
params.addr = nullptr;
assert(helperFunction.accessType == IAT_PVALUE);
void* pAddr = helperFunction.addr;

// This is call to a runtime helper.
// lui reg, pAddr #NOTE: this maybe multi-instructions.
// ld reg, reg
Expand Down Expand Up @@ -5872,9 +5884,9 @@ void CodeGen::genCallInstruction(GenTreeCall* call)
CorInfoHelpFunc helperNum = compiler->eeGetHelperNum(params.methHnd);
noway_assert(helperNum != CORINFO_HELP_UNDEF);

void* pAddr = nullptr;
params.addr = compiler->compGetHelperFtn(helperNum, (void**)&pAddr);
assert(pAddr == nullptr);
CORINFO_CONST_LOOKUP helperLookup = compiler->compGetHelperFtn(helperNum);
params.addr = helperLookup.addr;
assert(helperLookup.accessType == IAT_VALUE);
}
else
{
Expand Down Expand Up @@ -6495,9 +6507,7 @@ void CodeGen::genJumpToThrowHlpBlk_la(
// The code to throw the exception will be generated inline, and
// we will jump around it in the normal non-exception case.

void* pAddr = nullptr;
EmitCallParams params;
params.addr = compiler->compGetHelperFtn((CorInfoHelpFunc)(compiler->acdHelper(codeKind)), &pAddr);

// maybe optimize
// ins = (instruction)(ins^((ins != INS_beq)+(ins != INS_bne)));
Expand All @@ -6522,8 +6532,18 @@ void CodeGen::genJumpToThrowHlpBlk_la(
ins = ins == INS_beq ? INS_bne : INS_beq;
}

if (params.addr == nullptr)
CORINFO_CONST_LOOKUP helperFunction = compiler->compGetHelperFtn((CorInfoHelpFunc)(compiler->acdHelper(codeKind)));
if (helperFunction.accessType == IAT_VALUE)
{
// If the helper is a value, we need to use the address of the helper.
params.addr = helperFunction.addr;
}
else
{
params.addr = nullptr;
assert(helperFunction.accessType == IAT_PVALUE);
void* pAddr = helperFunction.addr;
Copy link

Copilot AI Jun 12, 2025

Choose a reason for hiding this comment

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

The variable 'pAddr' is declared in the else block but never used. Removing this redundant declaration would improve code clarity.

Copilot uses AI. Check for mistakes.

params.callType = EC_INDIR_R;
params.ireg = REG_DEFAULT_HELPER_CALL_TARGET;
if (compiler->opts.compReloc)
Expand Down
20 changes: 13 additions & 7 deletions src/coreclr/jit/codegenxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6504,9 +6504,9 @@ void CodeGen::genCallInstruction(GenTreeCall* call X86_ARG(target_ssize_t stackA
CorInfoHelpFunc helperNum = compiler->eeGetHelperNum(params.methHnd);
noway_assert(helperNum != CORINFO_HELP_UNDEF);

void* pAddr = nullptr;
addr = compiler->compGetHelperFtn(helperNum, (void**)&pAddr);
assert(pAddr == nullptr);
CORINFO_CONST_LOOKUP helperLookup = compiler->compGetHelperFtn(helperNum);
addr = helperLookup.addr;
assert(helperLookup.accessType == IAT_VALUE);
}
else
{
Expand Down Expand Up @@ -8832,15 +8832,21 @@ void CodeGen::genCreateAndStoreGCInfoX64(unsigned codeSize, unsigned prologSize

void CodeGen::genEmitHelperCall(unsigned helper, int argSize, emitAttr retSize, regNumber callTargetReg)
{
void* pAddr = nullptr;

EmitCallParams params;
params.callType = EC_FUNC_TOKEN;
params.addr = compiler->compGetHelperFtn((CorInfoHelpFunc)helper, &pAddr);

CORINFO_CONST_LOOKUP helperFunction = compiler->compGetHelperFtn((CorInfoHelpFunc)helper);
regMaskTP killMask = compiler->compHelperCallKillSet((CorInfoHelpFunc)helper);

if (params.addr == nullptr)
if (helperFunction.accessType == IAT_VALUE)
{
params.addr = (void*)helperFunction.addr;
}
else
{
params.addr = nullptr;
assert(helperFunction.accessType == IAT_PVALUE);
void* pAddr = helperFunction.addr;
assert(pAddr != nullptr);

// Absolute indirect call addr
Expand Down
Loading
Loading