Skip to content

Commit f23657a

Browse files
authored
[LoongArch64] Fix some bugs to make NativeAOT stable. (#114618)
* [LoongArch64] Fix some bugs to make NativeAOT stable. * Also checked some riskpoints on LA64 with PR#112736. * restrict 'UnixNativeCodeManager::IsInProlog()' in '#if (defined(TARGET_APPLE) && defined(TARGET_ARM64)) || defined(TARGET_ARM)'. update src/coreclr/nativeaot/Runtime/loongarch64/WriteBarriers.S * Update 'RhpCheckedLockCmpXchg' in 'WriteBarriers.S' * revert the modify of `src/installer/tests/Assets/Projects/HelloWorld/SelfContained.csproj` within PR#114666.
1 parent bb09451 commit f23657a

File tree

27 files changed

+224
-352
lines changed

27 files changed

+224
-352
lines changed

src/coreclr/nativeaot/Common/src/Internal/Runtime/TransitionBlock.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,6 @@ internal struct ReturnBlock
312312
{
313313
private IntPtr returnValue;
314314
private IntPtr returnValue2;
315-
private IntPtr returnValue3;
316-
private IntPtr returnValue4;
317315
}
318316

319317
[StructLayout(LayoutKind.Sequential)]
@@ -353,8 +351,8 @@ internal struct ArchitectureConstants
353351

354352
public const int NUM_ARGUMENT_REGISTERS = 8;
355353
public const int ARGUMENTREGISTERS_SIZE = NUM_ARGUMENT_REGISTERS * 8;
356-
public const int ENREGISTERED_RETURNTYPE_MAXSIZE = 32; // bytes (four FP registers: d0,d1,d2 and d3)
357-
public const int ENREGISTERED_RETURNTYPE_INTEGER_MAXSIZE = 16; // bytes (two int registers: x0 and x1)
354+
public const int ENREGISTERED_RETURNTYPE_MAXSIZE = 16; // bytes (two FP registers: f0, f1)
355+
public const int ENREGISTERED_RETURNTYPE_INTEGER_MAXSIZE = 16; // bytes (two int registers: a0, a1)
358356
public const int ENREGISTERED_RETURNTYPE_INTEGER_MAXSIZE_PRIMITIVE = 8;
359357
public const int ENREGISTERED_PARAMTYPE_MAXSIZE = 16; // bytes (max value type size that can be passed by value)
360358
public const int STACK_ELEM_SIZE = 8;

src/coreclr/nativeaot/Runtime/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ endif()
245245

246246
add_definitions(-DFEATURE_BASICFREEZE)
247247
add_definitions(-DFEATURE_CONSERVATIVE_GC)
248-
if(CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_ARM64 OR CLR_CMAKE_TARGET_ARCH_RISCV64)
248+
if(CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_ARM64 OR CLR_CMAKE_TARGET_ARCH_RISCV64 OR CLR_CMAKE_TARGET_ARCH_LOONGARCH64)
249249
add_definitions(-DFEATURE_USE_SOFTWARE_WRITE_WATCH_FOR_GC_HEAP)
250250
add_definitions(-DFEATURE_MANUALLY_MANAGED_CARD_BUNDLES)
251251
endif()

src/coreclr/nativeaot/Runtime/MiscHelpers.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ FCIMPL1(uint8_t *, RhGetCodeTarget, uint8_t * pCodeOrg)
345345
pCode++;
346346
}
347347
// is this an indirect jump?
348-
// pcalau12i $t7, imm20; ld.d $t7, $t7, imm12; jirl $r0, $t7, 0
348+
// pcalau12i $rd, imm20; ld.d $rd, $rj, imm12; jirl $rd, $rj, 0
349349
if ((pCode[0] & 0xfe000000) == 0x1a000000 &&
350350
(pCode[1] & 0xffc00000) == 0x28c00000 &&
351351
(pCode[2] & 0xfc000000) == 0x4c000000)

src/coreclr/nativeaot/Runtime/PalRedhawkCommon.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ struct PAL_LIMITED_CONTEXT
115115
uint64_t F[32 - 24]; // Only the F registers F24..F31 need to be preserved
116116
// (F0-F23 are not preserved according to the ABI spec).
117117

118-
119118
uintptr_t GetIp() const { return IP; }
120119
uintptr_t GetSp() const { return SP; }
121120
uintptr_t GetFp() const { return FP; }

src/coreclr/nativeaot/Runtime/StackFrameIterator.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ void StackFrameIterator::InternalInit(Thread * pThreadToWalk, PTR_PAL_LIMITED_CO
495495
m_RegDisplay.pRA = (PTR_uintptr_t)PTR_TO_MEMBER_TADDR(PAL_LIMITED_CONTEXT, pCtx, RA);
496496

497497
//
498-
// preserved vfp regs
498+
// preserved fp regs
499499
//
500500
for (int32_t i = 0; i < 16 - 8; i++)
501501
{
@@ -1282,6 +1282,7 @@ void StackFrameIterator::UnwindFuncletInvokeThunk()
12821282
m_RegDisplay.pR29 = SP++;
12831283
m_RegDisplay.pR30 = SP++;
12841284
m_RegDisplay.pR31 = SP++;
1285+
SP++; // for alignment padding
12851286

12861287
#elif defined(TARGET_RISCV64)
12871288
PTR_uint64_t f = (PTR_uint64_t)(m_RegDisplay.SP);
@@ -1476,12 +1477,12 @@ struct UniversalTransitionStackFrame
14761477
// Conservative GC reporting must be applied to everything between the base of the
14771478
// ReturnBlock and the top of the StackPassedArgs.
14781479
private:
1479-
uintptr_t m_pushedFP; // ChildSP+000 CallerSP-0F0 (0x08 bytes) (fp)
1480-
uintptr_t m_pushedRA; // ChildSP+008 CallerSP-0E8 (0x08 bytes) (ra)
1481-
Fp128 m_fpArgRegs[8]; // ChildSP+010 CallerSP-0E0 (0x80 bytes) (fa0-fa7)
1482-
uintptr_t m_returnBlock[4]; // ChildSP+090 CallerSP-060 (0x20 bytes)
1483-
uintptr_t m_intArgRegs[8]; // ChildSP+0B0 CallerSP-040 (0x40 bytes) (a0-a7)
1484-
uintptr_t m_stackPassedArgs[1]; // ChildSP+0F0 CallerSP+000 (unknown size)
1480+
uintptr_t m_pushedFP; // ChildSP+000 CallerSP-0A0 (0x08 bytes) (fp)
1481+
uintptr_t m_pushedRA; // ChildSP+008 CallerSP-098 (0x08 bytes) (ra)
1482+
uint64_t m_fpArgRegs[8]; // ChildSP+010 CallerSP-090 (0x40 bytes) (fa0-fa7)
1483+
uintptr_t m_returnBlock[2]; // ChildSP+050 CallerSP-050 (0x10 bytes)
1484+
uintptr_t m_intArgRegs[8]; // ChildSP+060 CallerSP-040 (0x40 bytes) (a0-a7)
1485+
uintptr_t m_stackPassedArgs[1]; // ChildSP+0A0 CallerSP+000 (unknown size)
14851486

14861487
public:
14871488
PTR_uintptr_t get_CallerSP() { return GET_POINTER_TO_FIELD(m_stackPassedArgs[0]); }

src/coreclr/nativeaot/Runtime/ThunksMapping.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,10 +244,14 @@ EXTERN_C void* QCALLTYPE RhAllocateThunksMapping()
244244
//jirl $r0, $t8, 0
245245

246246
int delta = (int)(pCurrentDataAddress - pCurrentThunkAddress);
247+
ASSERT((-0x200000 <= delta) && (delta < 0x200000));
248+
247249
*((uint32_t*)pCurrentThunkAddress) = 0x18000013 | (((delta & 0x3FFFFC) >> 2) << 5);
248250
pCurrentThunkAddress += 4;
249251

250252
delta += OS_PAGE_SIZE - POINTER_SIZE - (i * POINTER_SIZE * 2) - 4;
253+
ASSERT((-0x200000 <= delta) && (delta < 0x200000));
254+
251255
*((uint32_t*)pCurrentThunkAddress) = 0x18000014 | (((delta & 0x3FFFFC) >> 2) << 5);
252256
pCurrentThunkAddress += 4;
253257

src/coreclr/nativeaot/Runtime/gcenv.ee.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ void GCToEEInterface::StompWriteBarrier(WriteBarrierParameters* args)
399399
// On architectures with strong ordering, we only need to prevent compiler reordering.
400400
// Otherwise we put a process-wide fence here (so that we could use an ordinary read in the barrier)
401401

402-
#if defined(HOST_ARM64) || defined(HOST_ARM)
402+
#if defined(HOST_ARM64) || defined(HOST_ARM) || defined(HOST_LOONGARCH64) || defined(HOST_RISCV64)
403403
if (!is_runtime_suspended)
404404
{
405405
// If runtime is not suspended, force all threads to see the changed table before seeing updated heap boundaries.
@@ -411,7 +411,7 @@ void GCToEEInterface::StompWriteBarrier(WriteBarrierParameters* args)
411411
g_lowest_address = args->lowest_address;
412412
g_highest_address = args->highest_address;
413413

414-
#if defined(HOST_ARM64) || defined(HOST_ARM)
414+
#if defined(HOST_ARM64) || defined(HOST_ARM) || defined(HOST_LOONGARCH64) || defined(HOST_RISCV64)
415415
if (!is_runtime_suspended)
416416
{
417417
// If runtime is not suspended, force all threads to see the changed state before observing future allocations.

src/coreclr/nativeaot/Runtime/inc/rhbinder.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,6 @@ enum PInvokeTransitionFrameFlags : uint64_t
341341
#elif defined(TARGET_LOONGARCH64)
342342
enum PInvokeTransitionFrameFlags : uint64_t
343343
{
344-
// NOTE: Keep in sync with src\coreclr\nativeaot\Runtime\loongarch64\AsmMacros.h
345-
346344
// NOTE: The order in which registers get pushed in the PInvokeTransitionFrame's m_PreservedRegs list has
347345
// to match the order of these flags (that's also the order in which they are read in StackFrameIterator.cpp
348346

src/coreclr/nativeaot/Runtime/loongarch64/AllocFast.S

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
#define OFFSETOF__Thread__m_alloc_context__alloc_ptr (OFFSETOF__Thread__m_eeAllocContext + OFFSETOF__ee_alloc_context__m_rgbAllocContextBuffer + OFFSETOF__gc_alloc_context__alloc_ptr)
1414
#define OFFSETOF__Thread__m_eeAllocContext__combined_limit (OFFSETOF__Thread__m_eeAllocContext + OFFSETOF__ee_alloc_context__combined_limit)
1515

16-
17-
1816
// Allocate non-array, non-finalizable object. If the allocation doesn't fit into the current thread's
1917
// allocation context then automatically fallback to the slow allocation path.
2018
// $a0 == MethodTable
@@ -83,7 +81,7 @@ LOCAL_LABEL(RhpNewFast_RarePath):
8381
bl C_FUNC(RhpGcAlloc)
8482

8583
// Set the new objects MethodTable pointer on success.
86-
beq $a0, $zero, LOCAL_LABEL(NewOutOfMemory)
84+
beqz $a0, LOCAL_LABEL(NewOutOfMemory)
8785

8886
.cfi_remember_state
8987
POP_COOP_PINVOKE_FRAME
@@ -245,7 +243,7 @@ LOCAL_LABEL(RhpNewArray_Rare):
245243
bl C_FUNC(RhpGcAlloc)
246244

247245
// Set the new objects MethodTable pointer and length on success.
248-
beq $a0, $zero, LOCAL_LABEL(ArrayOutOfMemory)
246+
beqz $a0, LOCAL_LABEL(ArrayOutOfMemory)
249247

250248
.cfi_remember_state
251249
POP_COOP_PINVOKE_FRAME

src/coreclr/nativeaot/Runtime/loongarch64/AsmOffsetsCpu.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ PLAT_ASM_OFFSET(8, ExInfo, m_pExContext)
1313
PLAT_ASM_OFFSET(10, ExInfo, m_exception)
1414
PLAT_ASM_OFFSET(18, ExInfo, m_kind)
1515
PLAT_ASM_OFFSET(19, ExInfo, m_passNumber)
16-
PLAT_ASM_OFFSET(1c, ExInfo, m_idxCurClause)
16+
PLAT_ASM_OFFSET(1C, ExInfo, m_idxCurClause)
1717
PLAT_ASM_OFFSET(20, ExInfo, m_frameIter)
1818
PLAT_ASM_OFFSET(268, ExInfo, m_notifyDebuggerSP)
1919

@@ -51,16 +51,16 @@ PLAT_ASM_OFFSET(70, PAL_LIMITED_CONTEXT, IP)
5151
PLAT_ASM_SIZEOF(148, REGDISPLAY)
5252
PLAT_ASM_OFFSET(18, REGDISPLAY, SP)
5353

54-
PLAT_ASM_OFFSET(b8, REGDISPLAY, pR23)
55-
PLAT_ASM_OFFSET(c0, REGDISPLAY, pR24)
56-
PLAT_ASM_OFFSET(c8, REGDISPLAY, pR25)
57-
PLAT_ASM_OFFSET(d0, REGDISPLAY, pR26)
58-
PLAT_ASM_OFFSET(d8, REGDISPLAY, pR27)
59-
PLAT_ASM_OFFSET(e0, REGDISPLAY, pR28)
60-
PLAT_ASM_OFFSET(e8, REGDISPLAY, pR29)
61-
PLAT_ASM_OFFSET(f0, REGDISPLAY, pR30)
62-
PLAT_ASM_OFFSET(f8, REGDISPLAY, pR31)
54+
PLAT_ASM_OFFSET(B8, REGDISPLAY, pR23)
55+
PLAT_ASM_OFFSET(C0, REGDISPLAY, pR24)
56+
PLAT_ASM_OFFSET(C8, REGDISPLAY, pR25)
57+
PLAT_ASM_OFFSET(D0, REGDISPLAY, pR26)
58+
PLAT_ASM_OFFSET(D8, REGDISPLAY, pR27)
59+
PLAT_ASM_OFFSET(E0, REGDISPLAY, pR28)
60+
PLAT_ASM_OFFSET(E8, REGDISPLAY, pR29)
61+
PLAT_ASM_OFFSET(F0, REGDISPLAY, pR30)
62+
PLAT_ASM_OFFSET(F8, REGDISPLAY, pR31)
6363
PLAT_ASM_OFFSET(10, REGDISPLAY, pR2)
64-
PLAT_ASM_OFFSET(b0, REGDISPLAY, pFP)
64+
PLAT_ASM_OFFSET(B0, REGDISPLAY, pFP)
6565
PLAT_ASM_OFFSET(8, REGDISPLAY, pRA)
6666
PLAT_ASM_OFFSET(108, REGDISPLAY, F)

src/coreclr/nativeaot/Runtime/loongarch64/ExceptionHandling.S

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@
1818
ori $a3, $sp, 0
1919

2020
// Setup a PAL_LIMITED_CONTEXT on the stack {
21+
// Total stack: 0xC0 (0x68+0x58)
2122
.if \exceptionType == HARDWARE_EXCEPTION
22-
addi.d $sp, $sp, -0x50
23-
.cfi_adjust_cfa_offset 0x50
23+
addi.d $sp, $sp, -0x58
24+
.cfi_adjust_cfa_offset 0x58
2425
st.d $a3, $sp, 0 // a3 is the SP and a1 is the IP of the fault site
2526
st.d $a1, $sp, 8
2627
.else
27-
PROLOG_STACK_ALLOC 0x50
28-
.cfi_adjust_cfa_offset 0x50
28+
PROLOG_STACK_ALLOC 0x58
29+
.cfi_adjust_cfa_offset 0x58
2930
st.d $a3, $sp, 0 // a3 is the SP and ra is the IP of the fault site
3031
st.d $ra, $sp, 8
3132
.endif
@@ -37,6 +38,8 @@
3738
fst.d $f29, $sp, 0x38
3839
fst.d $f30, $sp, 0x40
3940
fst.d $f31, $sp, 0x48
41+
// Slot at $sp+0x50 is alignment padding
42+
4043
PROLOG_SAVE_REG_PAIR_INDEXED 22, 1, 0x68
4144
st.d $zero, $sp, 0x10 // locations reserved for return value, not used for exception handling
4245
st.d $zero, $sp, 0x18
@@ -61,7 +64,7 @@
6164
// sp in fp. If sp is saved in fp in prolog then it is not expected that fp can change in the body
6265
// of method. However, this method needs to be able to change fp before calling funclet.
6366
// This is required to access locals in funclet.
64-
PROLOG_SAVE_REG_PAIR_NO_FP_INDEXED 22, 1, 0x58
67+
PROLOG_SAVE_REG_PAIR_NO_FP_INDEXED 22, 1, 0x60
6568
PROLOG_SAVE_REG_PAIR 23, 24, 0x10
6669
PROLOG_SAVE_REG_PAIR 25, 26, 0x20
6770
PROLOG_SAVE_REG_PAIR 27, 28, 0x30
@@ -92,7 +95,7 @@
9295
EPILOG_RESTORE_REG_PAIR 27, 28, 0x30
9396
EPILOG_RESTORE_REG_PAIR 29, 30, 0x40
9497
EPILOG_RESTORE_REG 31, 0x50
95-
EPILOG_RESTORE_REG_PAIR_INDEXED 22, 1, 0x58
98+
EPILOG_RESTORE_REG_PAIR_INDEXED 22, 1, 0x60
9699
.endm
97100

98101

@@ -160,7 +163,7 @@
160163
ld.d $t3, \regdisplayReg, OFFSETOF__REGDISPLAY__pFP
161164
st.d $fp, $t3, 0
162165
//
163-
// store vfp preserved regs
166+
// store fp preserved regs
164167
//
165168
addi.d $t3, \regdisplayReg, OFFSETOF__REGDISPLAY__F
166169
fst.d $f24, $t3, 0x00
@@ -288,7 +291,7 @@
288291
// where the tail-calling thread had saved RA, which may not match where we have saved RA.
289292

290293
ld.d $a1, $a2, OFFSETOF__Thread__m_pvHijackedReturnAddress
291-
beq $a1, $zero, LOCAL_LABEL(NotHijacked)
294+
beqz $a1, LOCAL_LABEL(NotHijacked)
292295

293296
ld.d $a3, $a2, OFFSETOF__Thread__m_ppvHijackedReturnAddressLocation
294297

@@ -504,7 +507,7 @@ LOCAL_LABEL(NotHijacked):
504507

505508
LOCAL_LABEL(PopExInfoLoop):
506509
ld.d $a3, $a3, OFFSETOF__ExInfo__m_pPrevExInfo // a3 <- next ExInfo
507-
beq $a3, $zero, LOCAL_LABEL(DonePopping) // if (pExInfo == null) { we're done }
510+
beqz $a3, LOCAL_LABEL(DonePopping) // if (pExInfo == null) { we're done }
508511
blt $a3, $a2, LOCAL_LABEL(PopExInfoLoop) // if (pExInfo < resume SP} { keep going }
509512

510513
LOCAL_LABEL(DonePopping):
@@ -513,10 +516,10 @@ LOCAL_LABEL(DonePopping):
513516
PREPARE_EXTERNAL_VAR_INDIRECT_W RhpTrapThreads, $a3
514517

515518
bstrpick.d $t7, $a3, TrapThreadsFlags_AbortInProgress_Bit, TrapThreadsFlags_AbortInProgress_Bit
516-
beq $t7, $zero, LOCAL_LABEL(NoAbort)
519+
beqz $t7, LOCAL_LABEL(NoAbort)
517520

518521
ld.d $a3, $sp, rsp_offset_is_not_handling_thread_abort
519-
bne $a3, $zero, LOCAL_LABEL(NoAbort)
522+
bnez $a3, LOCAL_LABEL(NoAbort)
520523

521524
// It was the ThreadAbortException, so rethrow it
522525
// reset SP
@@ -773,7 +776,7 @@ LOCAL_LABEL(NoAbort):
773776

774777
LOCAL_LABEL(Propagate_PopExInfoLoop):
775778
ld.d $a3, $a3, OFFSETOF__ExInfo__m_pPrevExInfo // a3 <- next ExInfo
776-
beq $a3, $zero, LOCAL_LABEL(Propagate_DonePopping) // if (pExInfo == null) { we're done }
779+
beqz $a3, LOCAL_LABEL(Propagate_DonePopping) // if (pExInfo == null) { we're done }
777780
blt $a3, $a2, LOCAL_LABEL(Propagate_PopExInfoLoop) // if (pExInfo < resume SP} { keep going }
778781

779782
LOCAL_LABEL(Propagate_DonePopping):

src/coreclr/nativeaot/Runtime/loongarch64/GcProbe.S

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44
#include <unixasmmacros.inc>
55
#include "AsmOffsets.inc"
66

7-
#define PROBE_FRAME_SIZE 0xC8 // 4 * 8 for fixed part of PInvokeTransitionFrame (fp, ra, m_pThread, m_Flags) +
8-
// 9 * 8 for callee saved registers +
7+
#define PROBE_FRAME_SIZE 0x90 // 4 * 8 for fixed part of PInvokeTransitionFrame (fp, ra, m_pThread, m_Flags) +
8+
// 9 * 8 for callee saved registers +
99
// 1 * 8 for caller SP +
1010
// 2 * 8 for int returns +
11-
// 1 * 8 for alignment padding +
12-
// 4 * 16 for FP returns
11+
// 2 * 8 for FP returns
1312

1413
// See PUSH_COOP_PINVOKE_FRAME, this macro is very similar, but also saves return registers
1514
// and accepts the register bitmask
@@ -42,13 +41,9 @@
4241
st.d $a0, $sp, 0x70
4342
st.d $a1, $sp, 0x78
4443

45-
// Slot at $sp+0x80 is alignment padding
46-
4744
// Save the FP return registers
48-
fst.d $f0, $sp, 0x88
49-
fst.d $f1, $sp, 0x90
50-
fst.d $f2, $sp, 0x98
51-
fst.d $f3, $sp, 0xA0
45+
fst.d $f0, $sp, 0x80
46+
fst.d $f1, $sp, 0x88
5247

5348
// Perform the rest of the PInvokeTransitionFrame initialization.
5449
st.d \threadReg, $sp, OFFSETOF__PInvokeTransitionFrame__m_pThread // Thread * (unused by stackwalker)
@@ -58,8 +53,7 @@
5853
st.d \trashReg, $sp, 0x68 // save caller's SP
5954

6055
// link the frame into the Thread
61-
ori \trashReg, $sp, 0
62-
st.d \trashReg, \threadReg, OFFSETOF__Thread__m_pDeferredTransitionFrame
56+
st.d $sp, \threadReg, OFFSETOF__Thread__m_pDeferredTransitionFrame
6357
.endm
6458

6559
//
@@ -74,10 +68,8 @@
7468
ld.d $a1, $sp, 0x78
7569

7670
// Restore the FP return registers
77-
fld.d $f0, $sp, 0x88
78-
fld.d $f1, $sp, 0x90
79-
fld.d $f2, $sp, 0x98
80-
fld.d $f3, $sp, 0xA0
71+
fld.d $f0, $sp, 0x80
72+
fld.d $f1, $sp, 0x88
8173

8274
// Restore callee saved registers
8375
EPILOG_RESTORE_REG_PAIR 23, 24, 0x20
@@ -126,12 +118,11 @@ NESTED_ENTRY RhpGcProbeHijack, _TEXT, NoHandler
126118

127119
PREPARE_EXTERNAL_VAR_INDIRECT_W RhpTrapThreads, $a3
128120
bstrpick.d $t8, $a3, TrapThreadsFlags_TrapThreads_Bit, TrapThreadsFlags_TrapThreads_Bit
129-
bne $t8, $zero, LOCAL_LABEL(WaitForGC)
121+
bnez $t8, LOCAL_LABEL(WaitForGC)
130122
jirl $r0, $ra, 0
131123

132124
LOCAL_LABEL(WaitForGC):
133-
lu12i.w $t3, ((DEFAULT_FRAME_SAVE_FLAGS + PTFF_SAVE_R4 + PTFF_SAVE_R5 + PTFF_THREAD_HIJACK_HI) >> 12) & 0xfffff
134-
ori $t3, $t3, (DEFAULT_FRAME_SAVE_FLAGS + PTFF_SAVE_R4 + PTFF_SAVE_R5 + PTFF_THREAD_HIJACK_HI) & 0xfff
125+
li.d $t3, (DEFAULT_FRAME_SAVE_FLAGS + PTFF_SAVE_R4 + PTFF_SAVE_R5 + (PTFF_THREAD_HIJACK_HI << 32))
135126
b C_FUNC(RhpWaitForGC)
136127
NESTED_END RhpGcProbeHijack
137128

@@ -145,7 +136,7 @@ NESTED_ENTRY RhpWaitForGC, _TEXT, NoHandler
145136

146137
ld.d $a2,$sp, OFFSETOF__PInvokeTransitionFrame__m_Flags
147138
bstrpick.d $t8, $a2, PTFF_THREAD_ABORT_BIT, PTFF_THREAD_ABORT_BIT
148-
bne $t8, $zero, LOCAL_LABEL(ThrowThreadAbort)
139+
bnez $t8, LOCAL_LABEL(ThrowThreadAbort)
149140

150141
.cfi_remember_state
151142
POP_PROBE_FRAME
@@ -163,7 +154,7 @@ NESTED_END RhpWaitForGC
163154

164155
LEAF_ENTRY RhpGcPoll
165156
PREPARE_EXTERNAL_VAR_INDIRECT_W RhpTrapThreads, $a0
166-
bne $a0, $zero, C_FUNC(RhpGcPollRare)
157+
bnez $a0, C_FUNC(RhpGcPollRare)
167158
jirl $r0, $ra, 0
168159
LEAF_END RhpGcPoll
169160

src/coreclr/nativeaot/Runtime/loongarch64/InteropThunksHelpers.S

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@
1212
//
1313
// RhCommonStub
1414
//
15-
// INPUT: tp: thunk's data block
15+
// INPUT: t7: thunk's data block
1616
//
17-
// TRASHES: t0, t1, tp
17+
// TRASHES: t0, t1, t7
1818
//
1919
LEAF_ENTRY RhCommonStub, _TEXT
2020
// There are arbitrary callers passing arguments with arbitrary signatures.
2121
// Custom calling convention:
22-
// tp pointer to the current thunk's data block (data contains 2 pointer values: context + target pointers)
22+
// t7 pointer to the current thunk's data block (data contains 2 pointer values: context + target pointers)
2323

2424
INLINE_GET_TLS_VAR $t0, C_FUNC(tls_thunkData)
2525

2626
// t0 = base address of TLS data
27-
// tp = address of context cell in thunk's data
27+
// t7 = address of context cell in thunk's data
2828

2929
// store thunk address in thread static
3030
ld.d $t1, $t7, 0

0 commit comments

Comments
 (0)