From e0652258ac6178df9d3124df17b416b1e6ac7654 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 9 Apr 2026 02:17:12 +0000 Subject: [PATCH 1/2] Move Thread::m_pInterpThreadContext near top of Thread class after m_thAllocContextObj This makes the offset more stable for asm code. The field is no longer at the end of the class (offsets were 0x290-0xaf8 depending on config), and is now at a stable offset of 0x30 (64-bit) or 0x1c (32-bit) near the top of the class. Update OFFSETOF__Thread__m_pInterpThreadContext in all asmconstants.h files (amd64, arm64, arm, loongarch64, riscv64) to the new stable values. The conditional compilation guards for _DEBUG and TARGET_UNIX are removed since the value is now the same in all configurations for each architecture. Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/21a58369-8e3e-4715-98ba-f11a627ecdfe Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com> --- src/coreclr/vm/amd64/asmconstants.h | 14 +------------- src/coreclr/vm/arm/asmconstants.h | 6 +----- src/coreclr/vm/arm64/asmconstants.h | 10 +--------- src/coreclr/vm/loongarch64/asmconstants.h | 2 +- src/coreclr/vm/riscv64/asmconstants.h | 2 +- src/coreclr/vm/threads.h | 5 ++++- 6 files changed, 9 insertions(+), 30 deletions(-) diff --git a/src/coreclr/vm/amd64/asmconstants.h b/src/coreclr/vm/amd64/asmconstants.h index 09aa3fc8d29705..128faf9429ad84 100644 --- a/src/coreclr/vm/amd64/asmconstants.h +++ b/src/coreclr/vm/amd64/asmconstants.h @@ -557,19 +557,7 @@ ASMCONSTANTS_C_ASSERT(OFFSETOF__ThreadLocalInfo__m_pThread == offsetof(ThreadLoc #endif ASMCONSTANTS_C_ASSERT(OFFSETOF__InterpMethod__pCallStub == offsetof(InterpMethod, pCallStub)) -#ifdef TARGET_UNIX -#ifdef _DEBUG -#define OFFSETOF__Thread__m_pInterpThreadContext 0xaf8 -#else // _DEBUG -#define OFFSETOF__Thread__m_pInterpThreadContext 0x290 -#endif // _DEBUG -#else // TARGET_UNIX -#ifdef _DEBUG -#define OFFSETOF__Thread__m_pInterpThreadContext 0xb50 -#else // _DEBUG -#define OFFSETOF__Thread__m_pInterpThreadContext 0x2d8 -#endif // _DEBUG -#endif // TARGET_UNIX +#define OFFSETOF__Thread__m_pInterpThreadContext 0x30 ASMCONSTANTS_C_ASSERT(OFFSETOF__Thread__m_pInterpThreadContext == offsetof(Thread, m_pInterpThreadContext)) #define OFFSETOF__InterpThreadContext__pStackPointer 0x10 diff --git a/src/coreclr/vm/arm/asmconstants.h b/src/coreclr/vm/arm/asmconstants.h index fd810c0ec5ec86..79c27095656a39 100644 --- a/src/coreclr/vm/arm/asmconstants.h +++ b/src/coreclr/vm/arm/asmconstants.h @@ -211,11 +211,7 @@ ASMCONSTANTS_C_ASSERT(OFFSETOF__ThreadLocalInfo__m_pThread == offsetof(ThreadLoc #endif ASMCONSTANTS_C_ASSERT(OFFSETOF__InterpMethod__pCallStub == offsetof(InterpMethod, pCallStub)) -#ifdef TARGET_UNIX -#define OFFSETOF__Thread__m_pInterpThreadContext 0x630 -#else // TARGET_UNIX -#define OFFSETOF__Thread__m_pInterpThreadContext 0x0 -#endif // TARGET_UNIX +#define OFFSETOF__Thread__m_pInterpThreadContext 0x1c ASMCONSTANTS_C_ASSERT(OFFSETOF__Thread__m_pInterpThreadContext == offsetof(Thread, m_pInterpThreadContext)) #define OFFSETOF__InterpThreadContext__pStackPointer 0x8 diff --git a/src/coreclr/vm/arm64/asmconstants.h b/src/coreclr/vm/arm64/asmconstants.h index 1fda62d215f7f4..a79697e3ad1927 100644 --- a/src/coreclr/vm/arm64/asmconstants.h +++ b/src/coreclr/vm/arm64/asmconstants.h @@ -292,15 +292,7 @@ ASMCONSTANTS_C_ASSERT(OFFSETOF__ThreadLocalInfo__m_pThread == offsetof(ThreadLoc #endif ASMCONSTANTS_C_ASSERT(OFFSETOF__InterpMethod__pCallStub == offsetof(InterpMethod, pCallStub)) -#ifdef TARGET_UNIX -#ifdef _DEBUG -#define OFFSETOF__Thread__m_pInterpThreadContext 0xb20 -#else // _DEBUG -#define OFFSETOF__Thread__m_pInterpThreadContext 0x2b8 -#endif // _DEBUG -#else // TARGET_UNIX -#define OFFSETOF__Thread__m_pInterpThreadContext 0xb48 -#endif // TARGET_UNIX +#define OFFSETOF__Thread__m_pInterpThreadContext 0x30 ASMCONSTANTS_C_ASSERT(OFFSETOF__Thread__m_pInterpThreadContext == offsetof(Thread, m_pInterpThreadContext)) #define OFFSETOF__InterpThreadContext__pStackPointer 0x10 diff --git a/src/coreclr/vm/loongarch64/asmconstants.h b/src/coreclr/vm/loongarch64/asmconstants.h index 3ddc93bf34c396..d675d3180638aa 100644 --- a/src/coreclr/vm/loongarch64/asmconstants.h +++ b/src/coreclr/vm/loongarch64/asmconstants.h @@ -218,7 +218,7 @@ ASMCONSTANTS_C_ASSERT(StubPrecodeData__SecretParam == offsetof(StubPrecod #define OFFSETOF__InterpMethod__pCallStub 0x20 ASMCONSTANTS_C_ASSERT(OFFSETOF__InterpMethod__pCallStub == offsetof(InterpMethod, pCallStub)) -#define OFFSETOF__Thread__m_pInterpThreadContext 0xB20 +#define OFFSETOF__Thread__m_pInterpThreadContext 0x30 ASMCONSTANTS_C_ASSERT(OFFSETOF__Thread__m_pInterpThreadContext == offsetof(Thread, m_pInterpThreadContext)) #define OFFSETOF__InterpThreadContext__pStackPointer 0x10 diff --git a/src/coreclr/vm/riscv64/asmconstants.h b/src/coreclr/vm/riscv64/asmconstants.h index bc8f8a02444529..de493c425bf66e 100644 --- a/src/coreclr/vm/riscv64/asmconstants.h +++ b/src/coreclr/vm/riscv64/asmconstants.h @@ -231,7 +231,7 @@ ASMCONSTANTS_C_ASSERT(OFFSETOF__ThreadLocalInfo__m_pThread == offsetof(ThreadLoc #endif ASMCONSTANTS_C_ASSERT(OFFSETOF__InterpMethod__pCallStub == offsetof(InterpMethod, pCallStub)) -#define OFFSETOF__Thread__m_pInterpThreadContext 0xB20 +#define OFFSETOF__Thread__m_pInterpThreadContext 0x30 ASMCONSTANTS_C_ASSERT(OFFSETOF__Thread__m_pInterpThreadContext == offsetof(Thread, m_pInterpThreadContext)) #define OFFSETOF__InterpThreadContext__pStackPointer 0x10 diff --git a/src/coreclr/vm/threads.h b/src/coreclr/vm/threads.h index 07273a9b9c2843..96d8a09f41b336 100644 --- a/src/coreclr/vm/threads.h +++ b/src/coreclr/vm/threads.h @@ -902,6 +902,10 @@ class Thread // we fire the AllocationTick event. It's only for tooling purpose. TypeHandle m_thAllocContextObj; +#ifdef FEATURE_INTERPRETER + InterpThreadContext *m_pInterpThreadContext; +#endif // FEATURE_INTERPRETER + #ifndef TARGET_UNIX private: _NT_TIB *m_pTEB; @@ -3753,7 +3757,6 @@ class Thread #ifdef FEATURE_INTERPRETER public: - InterpThreadContext *m_pInterpThreadContext; InterpThreadContext* GetInterpThreadContext(); InterpThreadContext* GetOrCreateInterpThreadContext(); #endif // FEATURE_INTERPRETER From 449142922dea64b30daf86058179c2e9c7aadfbb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 9 Apr 2026 02:33:25 +0000 Subject: [PATCH 2/2] Consolidate FEATURE_INTERPRETER block: move field and methods together near top of Thread class Move the entire #ifdef FEATURE_INTERPRETER block (public: access specifier, m_pInterpThreadContext field, and both method declarations) from the end of the Thread class to just after m_thAllocContextObj. This consolidates all interpreter-related declarations into a single #ifdef block near the top of the class, while keeping the stable offset for m_pInterpThreadContext. Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/b426d848-547f-405d-97e3-1e21bf94368d Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com> --- src/coreclr/vm/threads.h | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/coreclr/vm/threads.h b/src/coreclr/vm/threads.h index 96d8a09f41b336..45c39a3354033d 100644 --- a/src/coreclr/vm/threads.h +++ b/src/coreclr/vm/threads.h @@ -903,7 +903,10 @@ class Thread TypeHandle m_thAllocContextObj; #ifdef FEATURE_INTERPRETER +public: InterpThreadContext *m_pInterpThreadContext; + InterpThreadContext* GetInterpThreadContext(); + InterpThreadContext* GetOrCreateInterpThreadContext(); #endif // FEATURE_INTERPRETER #ifndef TARGET_UNIX @@ -3754,12 +3757,6 @@ class Thread bool m_hasPendingActivation; friend struct ::cdac_data; - -#ifdef FEATURE_INTERPRETER -public: - InterpThreadContext* GetInterpThreadContext(); - InterpThreadContext* GetOrCreateInterpThreadContext(); -#endif // FEATURE_INTERPRETER }; template<>