Skip to content

Commit bb69c0b

Browse files
authored
[RISC-V][JIT] Fix assetion in System.Threading.LowLevelLifoSemaphore.Wait (#89826)
* [RISC-v][JIT] Update 4 bytes value in JCMP * Fix some mistakes
1 parent 59f57a8 commit bb69c0b

3 files changed

Lines changed: 23 additions & 7 deletions

File tree

src/coreclr/jit/codegenriscv64.cpp

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3749,6 +3749,24 @@ void CodeGen::genCodeForJumpCompare(GenTreeOpCC* tree)
37493749
emit->emitLoadImmediate(EA_PTRSIZE, REG_RA, imm);
37503750
regs = (int)REG_RA << 5;
37513751
}
3752+
else
3753+
{
3754+
if (cmpSize == EA_4BYTE)
3755+
{
3756+
regNumber tmpRegOp1 = rsGetRsvdReg();
3757+
assert(regOp1 != tmpRegOp1);
3758+
if (cond.IsUnsigned())
3759+
{
3760+
emit->emitIns_R_R_I(INS_slli, EA_8BYTE, tmpRegOp1, regOp1, 32);
3761+
emit->emitIns_R_R_I(INS_srli, EA_8BYTE, tmpRegOp1, tmpRegOp1, 32);
3762+
}
3763+
else
3764+
{
3765+
emit->emitIns_R_R_I(INS_addiw, EA_8BYTE, tmpRegOp1, regOp1, 0);
3766+
}
3767+
regOp1 = tmpRegOp1;
3768+
}
3769+
}
37523770

37533771
switch (cond.GetCode())
37543772
{
@@ -5201,8 +5219,7 @@ void CodeGen::genPutArgSplit(GenTreePutArgSplit* treeNode)
52015219
}
52025220

52035221
// Pick a register to store intermediate values in for the to-stack
5204-
// copy. It must not conflict with addrReg. We try to prefer an
5205-
// argument register since those can always use thumb encoding.
5222+
// copy. It must not conflict with addrReg.
52065223
valueReg = treeNode->GetRegNumByIdx(0);
52075224
if (valueReg == addrReg)
52085225
{
@@ -5212,7 +5229,6 @@ void CodeGen::genPutArgSplit(GenTreePutArgSplit* treeNode)
52125229
}
52135230
else
52145231
{
5215-
// Prefer argument register that can always use thumb encoding.
52165232
valueReg = treeNode->GetRegNumByIdx(1);
52175233
}
52185234
}
@@ -7192,7 +7208,7 @@ void CodeGen::genPushCalleeSavedRegisters(regNumber initReg, bool* pInitRegZeroe
71927208
}
71937209
#endif
71947210

7195-
// On LA we push the FP (frame-pointer) here along with all other callee saved registers
7211+
// On RISCV64 we push the FP (frame-pointer) here along with all other callee saved registers
71967212
if (isFramePointerUsed())
71977213
{
71987214
rsPushRegs |= RBM_FPBASE;
@@ -7866,7 +7882,7 @@ void CodeGen::genFnPrologCalleeRegArgs()
78667882
// the struct is a split struct.
78677883
assert(varDsc->GetArgReg() == REG_ARG_LAST && varDsc->GetOtherArgReg() == REG_STK);
78687884

7869-
// For the LA's ABI, the split struct arg will be passed via `A7` and a stack slot on caller.
7885+
// For the RISCV64's ABI, the split struct arg will be passed via `A7` and a stack slot on caller.
78707886
// But if the `A7` is stored on stack on the callee side, the whole split struct should be
78717887
// stored continuous on the stack on the callee side.
78727888
// So, after we save `A7` on the stack in prolog, it has to copy the stack slot of the split struct

src/coreclr/vm/excep.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6350,7 +6350,7 @@ bool IsIPInMarkedJitHelper(UINT_PTR uControlPc)
63506350
CHECK_RANGE(JIT_WriteBarrier)
63516351
CHECK_RANGE(JIT_CheckedWriteBarrier)
63526352
CHECK_RANGE(JIT_ByRefWriteBarrier)
6353-
#if !defined(TARGET_ARM64) && !defined(TARGET_LOONGARCH64) && !(TARGET_RISCV64)
6353+
#if !defined(TARGET_ARM64) && !defined(TARGET_LOONGARCH64) && !defined(TARGET_RISCV64)
63546354
CHECK_RANGE(JIT_StackProbe)
63556355
#endif // !TARGET_ARM64 && !TARGET_LOONGARCH64 && !TARGET_RISCV64
63566356
#else

src/coreclr/vm/jitinterface.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ extern "C"
384384
void STDCALL JIT_MemCpy(void *dest, const void *src, SIZE_T count);
385385

386386
void STDMETHODCALLTYPE JIT_ProfilerEnterLeaveTailcallStub(UINT_PTR ProfilerHandle);
387-
#if !defined(TARGET_ARM64) && !defined(TARGET_LOONGARCH64) && !(TARGET_RISCV64)
387+
#if !defined(TARGET_ARM64) && !defined(TARGET_LOONGARCH64) && !defined(TARGET_RISCV64)
388388
void STDCALL JIT_StackProbe();
389389
#endif // TARGET_ARM64
390390
};

0 commit comments

Comments
 (0)