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
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 = { /* f9f14a77-1225-42d0-a21e-6d8b45506fc6 */
0xf9f14a77,
0x1225,
0x42d0,
{0xa2, 0x1e, 0x6d, 0x8b, 0x45, 0x50, 0x6f, 0xc6}
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
20 changes: 14 additions & 6 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);
regMaskTP killSet = compiler->compHelperCallKillSet((CorInfoHelpFunc)helper);

if (params.addr == nullptr)
CORINFO_CONST_LOOKUP helperFunction = compiler->compGetHelperFtn((CorInfoHelpFunc)helper);
regMaskTP killSet = compiler->compHelperCallKillSet((CorInfoHelpFunc)helper);

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
84 changes: 52 additions & 32 deletions src/coreclr/jit/codegenloongarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2688,11 +2688,19 @@ 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;
params.callType = EC_FUNC_TOKEN;
}
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 All @@ -2712,10 +2720,6 @@ void CodeGen::genCodeForReturnTrap(GenTreeOp* tree)
}
regSet.verifyRegUsed(params.ireg);
}
else
{
params.callType = EC_FUNC_TOKEN;
}

// TODO-LOONGARCH64: can optimize further !!!
// TODO-LOONGARCH64: Why does this not use genEmitHelperCall?
Expand Down Expand Up @@ -3758,15 +3762,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);
regMaskTP killSet = compiler->compHelperCallKillSet((CorInfoHelpFunc)helper);

if (params.addr == nullptr)
CORINFO_CONST_LOOKUP helperFunction = compiler->compGetHelperFtn((CorInfoHelpFunc)helper);
regMaskTP killSet = compiler->compHelperCallKillSet((CorInfoHelpFunc)helper);

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 +5805,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,9 +6495,7 @@ 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)));
Expand All @@ -6510,8 +6520,30 @@ 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)
{
// INS_OPTS_C

// If the helper is a value, we need to use the address of the helper.
params.addr = helperFunction.addr;
params.callType = EC_FUNC_TOKEN;

ssize_t imm = 5 << 2;
if (compiler->opts.compReloc)
{
imm = 3 << 2;
}

emit->emitIns_R_R_I(ins, EA_PTRSIZE, reg1, reg2, imm);
}
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 All @@ -6534,18 +6566,6 @@ inline void CodeGen::genJumpToThrowHlpBlk_la(
((ssize_t)pAddr & 0xfff) >> 2);
}
}
else
{ // INS_OPTS_C
params.callType = EC_FUNC_TOKEN;

ssize_t imm = 5 << 2;
if (compiler->opts.compReloc)
{
imm = 3 << 2;
}

emit->emitIns_R_R_I(ins, EA_PTRSIZE, reg1, reg2, imm);
}

BasicBlock* skipLabel = genCreateTempLabel();

Expand Down
Loading
Loading