Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit b54399e

Browse files
committed
Review fixes
1 parent 0f5c702 commit b54399e

File tree

3 files changed

+27
-34
lines changed

3 files changed

+27
-34
lines changed

src/inc/stdmacros.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,12 @@
8787
#ifdef _TARGET_ARM_
8888
#define ARM_FIRST_ARG(x) x ,
8989
#define ARM_ARG(x) , x
90-
#define ARM_ARG_OR_ZERO(x) , x
9190
#define ARM_ONLY(x) x
9291
#define NOT_ARM(x)
9392
#define NOT_ARM_ARG(x)
9493
#else
9594
#define ARM_FIRST_ARG(x)
9695
#define ARM_ARG(x)
97-
#define ARM_ARG_OR_ZERO(x) , 0
9896
#define ARM_ONLY(x)
9997
#define NOT_ARM(x) x
10098
#define NOT_ARM_ARG(x) , x

src/jit/codegencommon.cpp

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8600,6 +8600,19 @@ void CodeGen::genFnEpilog(BasicBlock* block)
86008600

86018601
bool jmpEpilog = ((block->bbFlags & BBF_HAS_JMP) != 0);
86028602

8603+
GenTree* lastNode = block->lastNode();
8604+
8605+
// Method handle and address info used in case of jump epilog
8606+
CORINFO_METHOD_HANDLE methHnd = nullptr;
8607+
CORINFO_CONST_LOOKUP addrInfo;
8608+
addrInfo.addr = nullptr;
8609+
8610+
if (jmpEpilog && lastNode->gtOper == GT_JMP)
8611+
{
8612+
methHnd = (CORINFO_METHOD_HANDLE)lastNode->gtVal.gtVal1;
8613+
compiler->info.compCompHnd->getFunctionEntryPoint(methHnd, &addrInfo);
8614+
}
8615+
86038616
#ifdef _TARGET_ARM_
86048617
// We delay starting the unwind codes until we have an instruction which we know
86058618
// needs an unwind code. In particular, for large stack frames in methods without
@@ -8644,12 +8657,11 @@ void CodeGen::genFnEpilog(BasicBlock* block)
86448657
unwindStarted = true;
86458658
}
86468659

8647-
#ifdef FEATURE_NGEN_RELOCS_OPTIMIZATIONS
8648-
#if !FEATURE_FASTTAILCALL
8649-
if (jmpEpilog)
8660+
if (jmpEpilog && lastNode->gtOper == GT_JMP
8661+
&& addrInfo.accessType == IAT_RELPVALUE)
86508662
{
8651-
// In case of FEATURE_NGEN_RELOCS_OPTIMIZATIONS and IAT_RELPVALUE jump at the end is done using
8652-
// relative indirection, so, additional helper register is required.
8663+
// IAT_RELPVALUE jump at the end is done using relative indirection, so,
8664+
// additional helper register is required.
86538665
// We use LR just before it is going to be restored from stack, i.e.
86548666
//
86558667
// movw r12, laddr
@@ -8661,27 +8673,14 @@ void CodeGen::genFnEpilog(BasicBlock* block)
86618673
// ...
86628674
// bx r12
86638675

8664-
GenTree* jmpNode = block->lastNode();
8665-
8666-
noway_assert(jmpNode->gtOper == GT_JMP);
8676+
regNumber indCallReg = REG_R12;
8677+
regNumber vptrReg1 = REG_LR;
86678678

8668-
CORINFO_METHOD_HANDLE methHnd = (CORINFO_METHOD_HANDLE)jmpNode->gtVal.gtVal1;
8669-
CORINFO_CONST_LOOKUP addrInfo;
8670-
compiler->info.compCompHnd->getFunctionEntryPoint(methHnd, &addrInfo);
8671-
8672-
if (addrInfo.accessType == IAT_RELPVALUE)
8673-
{
8674-
regNumber indCallReg = REG_R12;
8675-
regNumber vptrReg1 = REG_LR;
8676-
8677-
instGen_Set_Reg_To_Imm(EA_HANDLE_CNS_RELOC, indCallReg, (ssize_t)addrInfo.addr);
8678-
getEmitter()->emitIns_R_R(INS_mov, EA_PTRSIZE, vptrReg1, indCallReg);
8679-
getEmitter()->emitIns_R_R_I(INS_ldr, EA_PTRSIZE, indCallReg, indCallReg, 0);
8680-
getEmitter()->emitIns_R_R(INS_add, EA_PTRSIZE, indCallReg, vptrReg1);
8681-
}
8679+
instGen_Set_Reg_To_Imm(EA_HANDLE_CNS_RELOC, indCallReg, (ssize_t)addrInfo.addr);
8680+
getEmitter()->emitIns_R_R(INS_mov, EA_PTRSIZE, vptrReg1, indCallReg);
8681+
getEmitter()->emitIns_R_R_I(INS_ldr, EA_PTRSIZE, indCallReg, indCallReg, 0);
8682+
getEmitter()->emitIns_R_R(INS_add, EA_PTRSIZE, indCallReg, vptrReg1);
86828683
}
8683-
#endif // !FEATURE_FASTTAILCALL
8684-
#endif // FEATURE_NGEN_RELOCS_OPTIMIZATIONS
86858684

86868685
genPopCalleeSavedRegisters(jmpEpilog);
86878686

@@ -8709,15 +8708,13 @@ void CodeGen::genFnEpilog(BasicBlock* block)
87098708

87108709
if (jmpEpilog)
87118710
{
8712-
#ifdef _TARGET_ARMARCH_
87138711
hasTailCalls = true;
8714-
#endif // _TARGET_ARMARCH_
87158712

87168713
noway_assert(block->bbJumpKind == BBJ_RETURN);
87178714
noway_assert(block->bbTreeList != nullptr);
87188715

87198716
/* figure out what jump we have */
8720-
GenTree* jmpNode = block->lastNode();
8717+
GenTree* jmpNode = lastNode;
87218718
#if !FEATURE_FASTTAILCALL
87228719
noway_assert(jmpNode->gtOper == GT_JMP);
87238720
#else // FEATURE_FASTTAILCALL
@@ -8736,10 +8733,8 @@ void CodeGen::genFnEpilog(BasicBlock* block)
87368733
{
87378734
// Simply emit a jump to the methodHnd. This is similar to a call so we can use
87388735
// the same descriptor with some minor adjustments.
8739-
CORINFO_METHOD_HANDLE methHnd = (CORINFO_METHOD_HANDLE)jmpNode->gtVal.gtVal1;
8740-
8741-
CORINFO_CONST_LOOKUP addrInfo;
8742-
compiler->info.compCompHnd->getFunctionEntryPoint(methHnd, &addrInfo);
8736+
assert(methHnd != nullptr);
8737+
assert(addrInfo.addr != nullptr)
87438738

87448739
#ifdef _TARGET_ARM_
87458740
emitter::EmitCallType callType;

src/vm/methodtable.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5057,7 +5057,7 @@ void MethodTable::Fixup(DataImage *image)
50575057
ZapNode * importThunk = image->GetVirtualImportThunk(pMD->GetMethodTable(), pMD, slotNumber);
50585058
// On ARM, make sure that the address to the virtual thunk that we write into the
50595059
// vtable "chunk" has the Thumb bit set.
5060-
image->FixupFieldToNode(slotBase, slotOffset, importThunk ARM_ARG_OR_ZERO(THUMB_CODE), relocType);
5060+
image->FixupFieldToNode(slotBase, slotOffset, importThunk ARM_ARG(THUMB_CODE) NOT_ARM_ARG(0), relocType);
50615061
}
50625062
else
50635063
{

0 commit comments

Comments
 (0)