diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/jit/codegencommon.cpp | 24 | ||||
-rw-r--r-- | src/jit/emit.cpp | 5 | ||||
-rw-r--r-- | src/jit/emitxarch.cpp | 2 |
3 files changed, 20 insertions, 11 deletions
diff --git a/src/jit/codegencommon.cpp b/src/jit/codegencommon.cpp index 34be5f7de7..8725619ceb 100644 --- a/src/jit/codegencommon.cpp +++ b/src/jit/codegencommon.cpp @@ -8905,20 +8905,30 @@ void CodeGen::genFnEpilog(BasicBlock* block) NO_WAY("Unsupported JMP indirection"); } - // If we have IAT_PVALUE, jump via register indirect, as sometimes the + // If we have IAT_PVALUE we might need to jump via register indirect, as sometimes the // indirection cell can't be reached by the jump. - emitter::EmitCallType callType; void* addr; regNumber indCallReg; if (addrInfo.accessType == IAT_PVALUE) { - callType = emitter::EC_INDIR_ARD; - indCallReg = REG_RAX; - addr = nullptr; - instGen_Set_Reg_To_Imm(EA_HANDLE_CNS_RELOC, indCallReg, (ssize_t)addrInfo.addr); - regSet.verifyRegUsed(indCallReg); + if (genCodeIndirAddrCanBeEncodedAsPCRelOffset((size_t)addrInfo.addr)) + { + // 32 bit displacement will work + callType = emitter::EC_FUNC_TOKEN_INDIR; + addr = addrInfo.addr; + indCallReg = REG_NA; + } + else + { + // 32 bit displacement won't work + callType = emitter::EC_INDIR_ARD; + indCallReg = REG_RAX; + addr = nullptr; + instGen_Set_Reg_To_Imm(EA_HANDLE_CNS_RELOC, indCallReg, (ssize_t)addrInfo.addr); + regSet.verifyRegUsed(indCallReg); + } } else { diff --git a/src/jit/emit.cpp b/src/jit/emit.cpp index e7c582feb9..6bad19d14e 100644 --- a/src/jit/emit.cpp +++ b/src/jit/emit.cpp @@ -2059,10 +2059,9 @@ void emitter::emitEndFnEpilog() // underestimation of the epilog size is harmless (since the EIP // can not be between instructions). assert(emitEpilogCnt == 1 || - (emitExitSeqSize - newSize) <= 6 // delta between size of various forms of jmp (size is either 6 or 5, - // or a 5 byte mov plus 2 byte jmp) + (emitExitSeqSize - newSize) <= 5 // delta between size of various forms of jmp (size is either 6 or 5), // and various forms of ret (size is either 1 or 3). The combination can - // be anything between 1 and 6. + // be anything between 1 and 5. ); emitExitSeqSize = newSize; } diff --git a/src/jit/emitxarch.cpp b/src/jit/emitxarch.cpp index 1f529ff694..8a6b34b2d4 100644 --- a/src/jit/emitxarch.cpp +++ b/src/jit/emitxarch.cpp @@ -7057,7 +7057,7 @@ void emitter::emitIns_Call(EmitCallType callType, if (isJump) { - assert(callType == EC_FUNC_TOKEN || callType == EC_INDIR_ARD); + assert(callType == EC_FUNC_TOKEN || callType == EC_FUNC_TOKEN_INDIR || callType == EC_INDIR_ARD); if (callType == EC_FUNC_TOKEN) { ins = INS_l_jmp; |