Skip to content

Commit 4dbe95c

Browse files
committed
Fix riscv64 nativeaot native build
1 parent 8b819a5 commit 4dbe95c

File tree

7 files changed

+15
-100
lines changed

7 files changed

+15
-100
lines changed

src/coreclr/nativeaot/Runtime/AsmOffsetsVerify.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,12 @@ class AsmOffsets
2828
static_assert(offsetof(Array, m_Length) == offsetof(String, m_Length), "The length field of String and Array have different offsets");
2929
static_assert(sizeof(((Array*)0)->m_Length) == sizeof(((String*)0)->m_Length), "The length field of String and Array have different sizes");
3030

31+
#define TO_STRING(x) #x
32+
#define OFFSET_STRING(cls, member) TO_STRING(offsetof(cls, member))
33+
34+
// Macro definition
3135
#define PLAT_ASM_OFFSET(offset, cls, member) \
32-
static_assert((offsetof(cls, member) == 0x##offset) || (offsetof(cls, member) > 0x##offset), "Bad asm offset for '" #cls "." #member "', the actual offset is smaller than 0x" #offset "."); \
33-
static_assert((offsetof(cls, member) == 0x##offset) || (offsetof(cls, member) < 0x##offset), "Bad asm offset for '" #cls "." #member "', the actual offset is larger than 0x" #offset ".");
36+
static_assert(offsetof(cls, member) == 0x##offset, "Bad asm offset for '" #cls "." #member "'. Actual offset: " OFFSET_STRING(cls, member));
3437

3538
#define PLAT_ASM_SIZEOF(size, cls ) \
3639
static_assert((sizeof(cls) == 0x##size) || (sizeof(cls) > 0x##size), "Bad asm size for '" #cls "', the actual size is smaller than 0x" #size "."); \

src/coreclr/nativeaot/Runtime/StackFrameIterator.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
3+
34
#include "common.h"
45
#include "gcenv.h"
56
#include "CommonTypes.h"
@@ -794,15 +795,11 @@ void StackFrameIterator::InternalInit(Thread * pThreadToWalk, NATIVE_CONTEXT* pC
794795
m_RegDisplay.pS9 = (PTR_uintptr_t)PTR_TO_REG(pCtx, S9);
795796
m_RegDisplay.pS10 = (PTR_uintptr_t)PTR_TO_REG(pCtx, S10);
796797
m_RegDisplay.pS11 = (PTR_uintptr_t)PTR_TO_REG(pCtx, S11);
797-
m_RegDisplay.pFP = (PTR_uintptr_t)PTR_TO_REG(pCtx, FP);
798-
m_RegDisplay.pRA = (PTR_uintptr_t)PTR_TO_REG(pCtx, RA);
799-
798+
800799
//
801800
// scratch regs
802801
//
803802
m_RegDisplay.pR0 = (PTR_uintptr_t)PTR_TO_REG(pCtx, R0);
804-
m_RegDisplay.pGP = (PTR_uintptr_t)PTR_TO_REG(pCtx, GP);
805-
m_RegDisplay.pTP = (PTR_uintptr_t)PTR_TO_REG(pCtx, TP);
806803
m_RegDisplay.pA0 = (PTR_uintptr_t)PTR_TO_REG(pCtx, A0);
807804
m_RegDisplay.pA1 = (PTR_uintptr_t)PTR_TO_REG(pCtx, A1);
808805
m_RegDisplay.pA2 = (PTR_uintptr_t)PTR_TO_REG(pCtx, A2);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
// Determine whether the end of the object would lie outside of the current allocation context. If so,
4343
// we abandon the attempt to allocate the object directly and fall back to the slow helper.
4444
add a2, a2, t3
45-
ld t4, OFFSETOF__Thread__m_alloc_context__alloc_limit(a1)
45+
ld t4, OFFSETOF__Thread__m_eeAllocContext__combined_limit(a1)
4646
bltu t4, a2, LOCAL_LABEL(RhpNewFast_RarePath)
4747

4848
// Update the alloc pointer to account for the allocation.

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ PLAT_ASM_OFFSET(1C, ExInfo, m_idxCurClause)
1717
PLAT_ASM_OFFSET(20, ExInfo, m_frameIter)
1818
PLAT_ASM_OFFSET(348, ExInfo, m_notifyDebuggerSP)
1919

20-
PLAT_ASM_OFFSET(0, PInvokeTransitionFrame, m_RIP)
21-
PLAT_ASM_OFFSET(8, PInvokeTransitionFrame, m_FramePointer)
20+
PLAT_ASM_OFFSET(0, PInvokeTransitionFrame, m_FramePointer)
21+
PLAT_ASM_OFFSET(8, PInvokeTransitionFrame, m_RIP)
2222
PLAT_ASM_OFFSET(10, PInvokeTransitionFrame, m_pThread)
2323
PLAT_ASM_OFFSET(18, PInvokeTransitionFrame, m_Flags)
2424
PLAT_ASM_OFFSET(20, PInvokeTransitionFrame, m_PreservedRegs)
@@ -52,7 +52,7 @@ PLAT_ASM_OFFSET(80, PAL_LIMITED_CONTEXT, IP)
5252

5353
PLAT_ASM_SIZEOF(208, REGDISPLAY)
5454

55-
PLAT_ASM_OFFSET(F8, REGDISPLAY, SP)
55+
PLAT_ASM_OFFSET(10, REGDISPLAY, SP)
5656

5757
PLAT_ASM_OFFSET(48, REGDISPLAY, pS1)
5858
PLAT_ASM_OFFSET(90, REGDISPLAY, pS2)

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ LOCAL_LABEL(NotHijacked):
493493
addi t3, a5, OFFSETOF__Thread__m_ThreadStateFlags
494494

495495
addiw a6, zero, -17 // Mask value (0xFFFFFFEF)
496-
amoand.w a4, t3, a6
496+
amoand.w a4, a6, (t3)
497497

498498
// Set preserved regs to the values expected by the funclet
499499
RESTORE_PRESERVED_REGISTERS a2
@@ -623,7 +623,7 @@ LOCAL_LABEL(NoAbort):
623623
// Set the DoNotTriggerGc flag
624624
addi t3, a2, OFFSETOF__Thread__m_ThreadStateFlags
625625
addiw a3, zero, -17 // Mask value (0xFFFFFFEF)
626-
amoand.w a4, t3, a3
626+
amoand.w a4, a3, (t3)
627627

628628
// Restore preserved registers
629629
RESTORE_PRESERVED_REGISTERS a1
@@ -646,7 +646,7 @@ LOCAL_LABEL(NoAbort):
646646

647647
addi t3, a2, OFFSETOF__Thread__m_ThreadStateFlags
648648
addiw a3, zero, 16 // Mask value (0x10)
649-
amoor.w a1, t3, a3
649+
amoor.w a1, a3, (t3)
650650

651651
// Restore floating-point registers
652652
fld fs0, 0x00(sp)

src/coreclr/nativeaot/Runtime/riscv64/WriteBarriers.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ LEAF_END RhpCheckedAssignRef, _TEXT
261261
// On exit:
262262
// t3, t4 : trashed
263263
// t6 : incremented by 8
264-
LEAF_ENTRY RhpAssignRefRiscVh64, _TEXT
264+
LEAF_ENTRY RhpAssignRefRiscV64, _TEXT
265265

266266
ALTERNATE_ENTRY RhpAssignRefAVLocation
267267
sd t6, 0(t5)

src/coreclr/nativeaot/Runtime/unix/UnwindHelpers.cpp

Lines changed: 0 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,40 +1157,6 @@ inline uint64_t Registers_REGDISPLAY::getRegister(int regNum) const {
11571157
return *pT5;
11581158
case UNW_RISCV_X6:
11591159
return *pT6;
1160-
case UNW_RISCV_X7:
1161-
return *pT7;
1162-
case UNW_RISCV_X8:
1163-
return *pT8;
1164-
case UNW_RISCV_X9:
1165-
return *pT9;
1166-
case UNW_RISCV_X10:
1167-
return *pT10;
1168-
case UNW_RISCV_X11:
1169-
return *pT11;
1170-
case UNW_RISCV_X12:
1171-
return *pT12;
1172-
case UNW_RISCV_X13:
1173-
return *pT13;
1174-
case UNW_RISCV_X14:
1175-
return *pT14;
1176-
case UNW_RISCV_X15:
1177-
return *pT15;
1178-
case UNW_RISCV_X16:
1179-
return *pT16;
1180-
case UNW_RISCV_X17:
1181-
return *pT17;
1182-
case UNW_RISCV_X18:
1183-
return *pT18;
1184-
case UNW_RISCV_X19:
1185-
return *pT19;
1186-
case UNW_RISCV_X20:
1187-
return *pT20;
1188-
case UNW_RISCV_X21:
1189-
return *pT21;
1190-
case UNW_RISCV_X22:
1191-
return *pT22;
1192-
case UNW_RISCV_X23:
1193-
return *pT23;
11941160
// Add other general-purpose registers if needed
11951161

11961162
case UNW_RISCV_F0:
@@ -1291,57 +1257,6 @@ void Registers_REGDISPLAY::setRegister(int regNum, uint64_t value, uint64_t loca
12911257
case UNW_RISCV_X6:
12921258
*pT6 = value;
12931259
break;
1294-
case UNW_RISCV_X7:
1295-
*pT7 = value;
1296-
break;
1297-
case UNW_RISCV_X8:
1298-
*pT8 = value;
1299-
break;
1300-
case UNW_RISCV_X9:
1301-
*pT9 = value;
1302-
break;
1303-
case UNW_RISCV_X10:
1304-
*pT10 = value;
1305-
break;
1306-
case UNW_RISCV_X11:
1307-
*pT11 = value;
1308-
break;
1309-
case UNW_RISCV_X12:
1310-
*pT12 = value;
1311-
break;
1312-
case UNW_RISCV_X13:
1313-
*pT13 = value;
1314-
break;
1315-
case UNW_RISCV_X14:
1316-
*pT14 = value;
1317-
break;
1318-
case UNW_RISCV_X15:
1319-
*pT15 = value;
1320-
break;
1321-
case UNW_RISCV_X16:
1322-
*pT16 = value;
1323-
break;
1324-
case UNW_RISCV_X17:
1325-
*pT17 = value;
1326-
break;
1327-
case UNW_RISCV_X18:
1328-
*pT18 = value;
1329-
break;
1330-
case UNW_RISCV_X19:
1331-
*pT19 = value;
1332-
break;
1333-
case UNW_RISCV_X20:
1334-
*pT20 = value;
1335-
break;
1336-
case UNW_RISCV_X21:
1337-
*pT21 = value;
1338-
break;
1339-
case UNW_RISCV_X22:
1340-
*pT22 = value;
1341-
break;
1342-
case UNW_RISCV_X23:
1343-
*pT23 = value;
1344-
break;
13451260

13461261
// Add other general-purpose registers if needed
13471262

0 commit comments

Comments
 (0)