[release/8.0] Update FixupPrecode and StubPrecode types for ARM (#92075)
authorgithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Fri, 15 Sep 2023 16:36:40 +0000 (09:36 -0700)
committerGitHub <noreply@github.com>
Fri, 15 Sep 2023 16:36:40 +0000 (09:36 -0700)
* Update FixupPrecode and StubPrecode types for ARM

Co-authored-by: Jan Vorlicek <janvorli@microsoft.com>
* Update ThisPtrRetBufPrecode and NDirectImportPrecode types for arm

Co-authored-by: Jan Vorlicek <janvorli@microsoft.com>
* Addressing PR feedback - remove unnecessary #ifdef's

* FIx riscv64 build break due to NDirectImportPrecode::Type conflict with ThisPtrRetBufPrecode::Type

---------

Co-authored-by: Tom McDonald <tommcdon@microsoft.com>
Co-authored-by: Jan Vorlicek <janvorli@microsoft.com>
src/coreclr/vm/arm/cgencpu.h
src/coreclr/vm/precode.h

index d31700e..6538cea 100644 (file)
@@ -996,7 +996,7 @@ inline BOOL ClrFlushInstructionCache(LPCVOID pCodeAddr, size_t sizeOfCode, bool
 // Precode to shuffle this and retbuf for closed delegates over static methods with return buffer
 struct ThisPtrRetBufPrecode {
 
-    static const int Type = 0x46;
+    static const int Type = 0x01;
 
     // mov r12, r0
     // mov r0, r1
index 158c1ab..3f6a2f5 100644 (file)
@@ -36,8 +36,8 @@ EXTERN_C VOID STDCALL PrecodeRemotingThunk();
 
 #elif defined(TARGET_ARM)
 
-#define SIZEOF_PRECODE_BASE         CODE_SIZE_ALIGN
-#define OFFSETOF_PRECODE_TYPE       3
+#define SIZEOF_PRECODE_BASE         CODE_SIZE_ALIGN * 2
+#define OFFSETOF_PRECODE_TYPE       7
 
 #elif defined(TARGET_LOONGARCH64)
 
@@ -100,7 +100,7 @@ struct StubPrecode
     static const int Type = 0x4A;
     static const SIZE_T CodeSize = 24;
 #elif defined(TARGET_ARM)
-    static const int Type = 0xCF;
+    static const int Type = 0xFF;
     static const SIZE_T CodeSize = 12;
 #elif defined(TARGET_LOONGARCH64)
     static const int Type = 0x4;
@@ -189,7 +189,7 @@ typedef DPTR(StubPrecode) PTR_StubPrecode;
 // (This is fake precode. VTable slot does not point to it.)
 struct NDirectImportPrecode : StubPrecode
 {
-    static const int Type = 0x01;
+    static const int Type = 0x05;
 
     void Init(NDirectImportPrecode* pPrecodeRX, MethodDesc* pMD, LoaderAllocator *pLoaderAllocator);
 
@@ -237,7 +237,7 @@ struct FixupPrecode
     static const SIZE_T CodeSize = 24;
     static const int FixupCodeOffset = 8;
 #elif defined(TARGET_ARM)
-    static const int Type = 0xFF;
+    static const int Type = 0xCF;
     static const SIZE_T CodeSize = 12;
     static const int FixupCodeOffset = 4 + THUMB_CODE;
 #elif defined(TARGET_LOONGARCH64)
@@ -614,4 +614,8 @@ static_assert_no_msg(FixupPrecode::Type != NDirectImportPrecode::Type);
 static_assert_no_msg(FixupPrecode::Type != ThisPtrRetBufPrecode::Type);
 static_assert_no_msg(NDirectImportPrecode::Type != ThisPtrRetBufPrecode::Type);
 
+// Verify that the base type for each precode fits into each specific precode type
+static_assert_no_msg(sizeof(Precode) <= sizeof(NDirectImportPrecode));
+static_assert_no_msg(sizeof(Precode) <= sizeof(FixupPrecode));
+static_assert_no_msg(sizeof(Precode) <= sizeof(ThisPtrRetBufPrecode));
 #endif // __PRECODE_H__