Skip to content

Commit d9ac263

Browse files
EgorBoCopilot
andcommitted
Remove per-source-register x86 write barrier helpers and related dead code
Follow-up to the prior JIT-only cleanup. Removes the now-dead infrastructure for the per-source-register x86 write barriers across the JIT-EE interface, R2R format, AOT tools (crossgen2 / NativeAOT compiler), and the CoreCLR + NativeAOT runtimes. Changes: - JIT-EE interface: remove the 12 CORINFO_HELP_(CHECKED_)ASSIGN_REF_E[reg] enum values from corinfo.h, jithelpers.h, and the managed mirror; bump JITEEVersionIdentifier; remove the X86 case-label block in utils.cpp's HelperCallProperties::init. - R2R format: bump major version to 20; mark slots 0x100-0x10B (READYTORUN_HELPER_(Checked)WriteBarrier_E[reg]) as unused (kept for image-compat parsing); update botr/readytorun-format.md, ModuleHeaders.h/cs, ReadyToRunConstants.cs; remove HELPER() lines in readytorunhelpers.h. - AOT tools: remove switch cases in CorInfoImpl.RyuJit.cs, CorInfoImpl.ReadyToRun.cs, ReadyToRunSignature.cs, and JitHelper.cs. - NativeAOT runtime: remove the per-register DEFINE_(CHECKED_)WRITE_BARRIER invocations and the corresponding RhpAssignRefE[reg]AVLocation references in EHHelpers.cpp. - CoreCLR x86 VM: remove all per-register variants except EAX from vm/i386/jithelp.asm/.S (EAX is kept as the patched target of the universal @JIT_WriteBarrier@8 trampoline). Drop the never-called @JIT_CheckedWriteBarrier@8 trampoline entirely (x86's CORINFO_HELP_CHECKED_ASSIGN_REF maps to RhpCheckedAssignRef, not JIT_CheckedWriteBarrier). Simplify the c_rgWriteBarriers/c_rgDebugWriteBarriers tables and patching loops in vm/i386/jitinterfacex86.cpp to operate on the single EAX entry. Drop the dead per-reg AV location declarations from vm/excep.cpp and the X86_WRITE_BARRIER_REGISTER macro in vm/threads.cpp and vm/jitinterface.h. Validation: clr+libs builds cleanly for x86 and x64; clr.tools and clr.nativeaotruntime build cleanly; x64 GC write-barrier exercising test passes with the rebuilt JIT (exit 100). The same x86 e2e test cannot be run on this machine due to a pre-existing testhost startup issue that affects baseline main as well. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 4e1c5af commit d9ac263

24 files changed

Lines changed: 71 additions & 537 deletions

File tree

docs/design/coreclr/botr/readytorun-format.md

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -982,20 +982,6 @@ enum ReadyToRunHelper
982982
// Deprecated/legacy
983983
//
984984

985-
// JIT32 x86-specific write barriers
986-
READYTORUN_HELPER_WriteBarrier_EAX = 0x100,
987-
READYTORUN_HELPER_WriteBarrier_EBX = 0x101,
988-
READYTORUN_HELPER_WriteBarrier_ECX = 0x102,
989-
READYTORUN_HELPER_WriteBarrier_ESI = 0x103,
990-
READYTORUN_HELPER_WriteBarrier_EDI = 0x104,
991-
READYTORUN_HELPER_WriteBarrier_EBP = 0x105,
992-
READYTORUN_HELPER_CheckedWriteBarrier_EAX = 0x106,
993-
READYTORUN_HELPER_CheckedWriteBarrier_EBX = 0x107,
994-
READYTORUN_HELPER_CheckedWriteBarrier_ECX = 0x108,
995-
READYTORUN_HELPER_CheckedWriteBarrier_ESI = 0x109,
996-
READYTORUN_HELPER_CheckedWriteBarrier_EDI = 0x10A,
997-
READYTORUN_HELPER_CheckedWriteBarrier_EBP = 0x10B,
998-
999985
// JIT32 x86-specific exception handling
1000986
READYTORUN_HELPER_EndCatch = 0x110,
1001987
};

src/coreclr/inc/corinfo.h

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -524,25 +524,6 @@ enum CorInfoHelpFunc
524524
CORINFO_HELP_EE_PERSONALITY_ROUTINE,// Not real JIT helper. Used in native images.
525525
CORINFO_HELP_EE_PERSONALITY_ROUTINE_FILTER_FUNCLET,// Not real JIT helper. Used in native images to detect filter funclets.
526526

527-
// ASSIGN_REF_EAX - CHECKED_ASSIGN_REF_EBP: NOGC_WRITE_BARRIERS JIT helper calls
528-
//
529-
// For unchecked versions EDX is required to point into GC heap.
530-
//
531-
// NOTE: these helpers are only used for x86.
532-
CORINFO_HELP_ASSIGN_REF_EAX, // EAX holds GC ptr, do a 'mov [EDX], EAX' and inform GC
533-
CORINFO_HELP_ASSIGN_REF_EBX, // EBX holds GC ptr, do a 'mov [EDX], EBX' and inform GC
534-
CORINFO_HELP_ASSIGN_REF_ECX, // ECX holds GC ptr, do a 'mov [EDX], ECX' and inform GC
535-
CORINFO_HELP_ASSIGN_REF_ESI, // ESI holds GC ptr, do a 'mov [EDX], ESI' and inform GC
536-
CORINFO_HELP_ASSIGN_REF_EDI, // EDI holds GC ptr, do a 'mov [EDX], EDI' and inform GC
537-
CORINFO_HELP_ASSIGN_REF_EBP, // EBP holds GC ptr, do a 'mov [EDX], EBP' and inform GC
538-
539-
CORINFO_HELP_CHECKED_ASSIGN_REF_EAX, // These are the same as ASSIGN_REF above ...
540-
CORINFO_HELP_CHECKED_ASSIGN_REF_EBX, // ... but also check if EDX points into heap.
541-
CORINFO_HELP_CHECKED_ASSIGN_REF_ECX,
542-
CORINFO_HELP_CHECKED_ASSIGN_REF_ESI,
543-
CORINFO_HELP_CHECKED_ASSIGN_REF_EDI,
544-
CORINFO_HELP_CHECKED_ASSIGN_REF_EBP,
545-
546527
CORINFO_HELP_LOOP_CLONE_CHOICE_ADDR, // Return the reference to a counter to decide to take cloned path in debug stress.
547528
CORINFO_HELP_DEBUG_LOG_LOOP_CLONING, // Print a message that a loop cloning optimization has occurred in debug mode.
548529

src/coreclr/inc/jiteeversionguid.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@
3737

3838
#include <minipal/guid.h>
3939

40-
constexpr GUID JITEEVersionIdentifier = { /* 31a04b06-915e-42a0-bbd2-c9c397677ae5 */
41-
0x31a04b06,
42-
0x915e,
43-
0x42a0,
44-
{0xbb, 0xd2, 0xc9, 0xc3, 0x97, 0x67, 0x7a, 0xe5}
40+
constexpr GUID JITEEVersionIdentifier = { /* 5fc51288-a3f3-4291-be1d-c626ccdd3235 */
41+
0x5fc51288,
42+
0xa3f3,
43+
0x4291,
44+
{0xbe, 0x1d, 0xc6, 0x26, 0xcc, 0xdd, 0x32, 0x35}
4545
};
4646

4747
#endif // JIT_EE_VERSIONING_GUID_H

src/coreclr/inc/jithelpers.h

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -262,36 +262,6 @@
262262
DYNAMICJITHELPER(CORINFO_HELP_EE_PERSONALITY_ROUTINE, ProcessCLRException, METHOD__NIL)
263263
DYNAMICJITHELPER(CORINFO_HELP_EE_PERSONALITY_ROUTINE_FILTER_FUNCLET, ProcessCLRException,METHOD__NIL)
264264

265-
#ifdef TARGET_X86
266-
DYNAMICJITHELPER(CORINFO_HELP_ASSIGN_REF_EAX, RhpAssignRefEAX, METHOD__NIL)
267-
DYNAMICJITHELPER(CORINFO_HELP_ASSIGN_REF_EBX, RhpAssignRefEBX, METHOD__NIL)
268-
DYNAMICJITHELPER(CORINFO_HELP_ASSIGN_REF_ECX, RhpAssignRefECX, METHOD__NIL)
269-
DYNAMICJITHELPER(CORINFO_HELP_ASSIGN_REF_ESI, RhpAssignRefESI, METHOD__NIL)
270-
DYNAMICJITHELPER(CORINFO_HELP_ASSIGN_REF_EDI, RhpAssignRefEDI, METHOD__NIL)
271-
DYNAMICJITHELPER(CORINFO_HELP_ASSIGN_REF_EBP, RhpAssignRefEBP, METHOD__NIL)
272-
273-
JITHELPER(CORINFO_HELP_CHECKED_ASSIGN_REF_EAX, RhpCheckedAssignRefEAX, METHOD__NIL)
274-
JITHELPER(CORINFO_HELP_CHECKED_ASSIGN_REF_EBX, RhpCheckedAssignRefEBX, METHOD__NIL)
275-
JITHELPER(CORINFO_HELP_CHECKED_ASSIGN_REF_ECX, RhpCheckedAssignRefECX, METHOD__NIL)
276-
JITHELPER(CORINFO_HELP_CHECKED_ASSIGN_REF_ESI, RhpCheckedAssignRefESI, METHOD__NIL)
277-
JITHELPER(CORINFO_HELP_CHECKED_ASSIGN_REF_EDI, RhpCheckedAssignRefEDI, METHOD__NIL)
278-
JITHELPER(CORINFO_HELP_CHECKED_ASSIGN_REF_EBP, RhpCheckedAssignRefEBP, METHOD__NIL)
279-
#else
280-
JITHELPER(CORINFO_HELP_ASSIGN_REF_EAX, NULL, METHOD__NIL)
281-
JITHELPER(CORINFO_HELP_ASSIGN_REF_EBX, NULL, METHOD__NIL)
282-
JITHELPER(CORINFO_HELP_ASSIGN_REF_ECX, NULL, METHOD__NIL)
283-
JITHELPER(CORINFO_HELP_ASSIGN_REF_ESI, NULL, METHOD__NIL)
284-
JITHELPER(CORINFO_HELP_ASSIGN_REF_EDI, NULL, METHOD__NIL)
285-
JITHELPER(CORINFO_HELP_ASSIGN_REF_EBP, NULL, METHOD__NIL)
286-
287-
JITHELPER(CORINFO_HELP_CHECKED_ASSIGN_REF_EAX, NULL, METHOD__NIL)
288-
JITHELPER(CORINFO_HELP_CHECKED_ASSIGN_REF_EBX, NULL, METHOD__NIL)
289-
JITHELPER(CORINFO_HELP_CHECKED_ASSIGN_REF_ECX, NULL, METHOD__NIL)
290-
JITHELPER(CORINFO_HELP_CHECKED_ASSIGN_REF_ESI, NULL, METHOD__NIL)
291-
JITHELPER(CORINFO_HELP_CHECKED_ASSIGN_REF_EDI, NULL, METHOD__NIL)
292-
JITHELPER(CORINFO_HELP_CHECKED_ASSIGN_REF_EBP, NULL, METHOD__NIL)
293-
#endif
294-
295265
JITHELPER(CORINFO_HELP_LOOP_CLONE_CHOICE_ADDR, JIT_LoopCloneChoiceAddr, METHOD__NIL)
296266
JITHELPER(CORINFO_HELP_DEBUG_LOG_LOOP_CLONING, JIT_DebugLogLoopCloning, METHOD__NIL)
297267

src/coreclr/inc/readytorun.h

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
// src/coreclr/nativeaot/Runtime/inc/ModuleHeaders.h
2020
// If you update this, ensure you run `git grep MINIMUM_READYTORUN_MAJOR_VERSION`
2121
// and handle pending work.
22-
#define READYTORUN_MAJOR_VERSION 19
22+
#define READYTORUN_MAJOR_VERSION 20
2323
#define READYTORUN_MINOR_VERSION 0x0000
2424

25-
#define MINIMUM_READYTORUN_MAJOR_VERSION 19
25+
#define MINIMUM_READYTORUN_MAJOR_VERSION 20
2626

2727
// R2R Version 2.1 adds the InliningInfo section
2828
// R2R Version 2.2 adds the ProfileDataInfo section
@@ -59,6 +59,7 @@
5959
// R2R Version 18.6 adds READYTORUN_FIXUP_InjectStringThunks for mapping strings to pregenerated code thunks
6060
// R2R Version 18.7 adds READYTORUN_HELPER_R2RToInterpreter
6161
// R2R Version 19 removes the READYTORUN_HELPER_ByRefWriteBarrier helper
62+
// R2R Version 20 removes the per-source-register x86 write barrier helpers (READYTORUN_HELPER_(Checked)WriteBarrier_E[reg])
6263

6364
struct READYTORUN_CORE_HEADER
6465
{
@@ -467,20 +468,6 @@ enum ReadyToRunHelper
467468
// Deprecated/legacy
468469
//
469470

470-
// JIT32 x86-specific write barriers
471-
READYTORUN_HELPER_WriteBarrier_EAX = 0x100,
472-
READYTORUN_HELPER_WriteBarrier_EBX = 0x101,
473-
READYTORUN_HELPER_WriteBarrier_ECX = 0x102,
474-
READYTORUN_HELPER_WriteBarrier_ESI = 0x103,
475-
READYTORUN_HELPER_WriteBarrier_EDI = 0x104,
476-
READYTORUN_HELPER_WriteBarrier_EBP = 0x105,
477-
READYTORUN_HELPER_CheckedWriteBarrier_EAX = 0x106,
478-
READYTORUN_HELPER_CheckedWriteBarrier_EBX = 0x107,
479-
READYTORUN_HELPER_CheckedWriteBarrier_ECX = 0x108,
480-
READYTORUN_HELPER_CheckedWriteBarrier_ESI = 0x109,
481-
READYTORUN_HELPER_CheckedWriteBarrier_EDI = 0x10A,
482-
READYTORUN_HELPER_CheckedWriteBarrier_EBP = 0x10B,
483-
484471
// JIT32 x86-specific exception handling
485472
READYTORUN_HELPER_EndCatch = 0x110, // Unused since READYTORUN_MAJOR_VERSION 14.0
486473

src/coreclr/inc/readytorunhelpers.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -99,21 +99,6 @@ HELPER(READYTORUN_HELPER_PersonalityRoutine, CORINFO_HELP_EE_PERSONALITY_
9999
HELPER(READYTORUN_HELPER_PersonalityRoutineFilterFunclet, CORINFO_HELP_EE_PERSONALITY_ROUTINE_FILTER_FUNCLET, OPTIMIZEFORSIZE)
100100
#endif
101101

102-
#ifdef TARGET_X86
103-
HELPER(READYTORUN_HELPER_WriteBarrier_EAX, CORINFO_HELP_ASSIGN_REF_EAX, )
104-
HELPER(READYTORUN_HELPER_WriteBarrier_EBX, CORINFO_HELP_ASSIGN_REF_EBX, )
105-
HELPER(READYTORUN_HELPER_WriteBarrier_ECX, CORINFO_HELP_ASSIGN_REF_ECX, )
106-
HELPER(READYTORUN_HELPER_WriteBarrier_ESI, CORINFO_HELP_ASSIGN_REF_ESI, )
107-
HELPER(READYTORUN_HELPER_WriteBarrier_EDI, CORINFO_HELP_ASSIGN_REF_EDI, )
108-
HELPER(READYTORUN_HELPER_WriteBarrier_EBP, CORINFO_HELP_ASSIGN_REF_EBP, )
109-
HELPER(READYTORUN_HELPER_CheckedWriteBarrier_EAX, CORINFO_HELP_CHECKED_ASSIGN_REF_EAX, )
110-
HELPER(READYTORUN_HELPER_CheckedWriteBarrier_EBX, CORINFO_HELP_CHECKED_ASSIGN_REF_EBX, )
111-
HELPER(READYTORUN_HELPER_CheckedWriteBarrier_ECX, CORINFO_HELP_CHECKED_ASSIGN_REF_ECX, )
112-
HELPER(READYTORUN_HELPER_CheckedWriteBarrier_ESI, CORINFO_HELP_CHECKED_ASSIGN_REF_ESI, )
113-
HELPER(READYTORUN_HELPER_CheckedWriteBarrier_EDI, CORINFO_HELP_CHECKED_ASSIGN_REF_EDI, )
114-
HELPER(READYTORUN_HELPER_CheckedWriteBarrier_EBP, CORINFO_HELP_CHECKED_ASSIGN_REF_EBP, )
115-
#endif
116-
117102
HELPER(READYTORUN_HELPER_PInvokeBegin, CORINFO_HELP_JIT_PINVOKE_BEGIN, )
118103
HELPER(READYTORUN_HELPER_PInvokeEnd, CORINFO_HELP_JIT_PINVOKE_END, )
119104
HELPER(READYTORUN_HELPER_GCPoll, CORINFO_HELP_POLL_GC, )

src/coreclr/jit/utils.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1670,20 +1670,6 @@ void HelperCallProperties::init()
16701670
nonNullReturn = true;
16711671
break;
16721672

1673-
#ifdef TARGET_X86
1674-
case CORINFO_HELP_ASSIGN_REF_EAX:
1675-
case CORINFO_HELP_ASSIGN_REF_ECX:
1676-
case CORINFO_HELP_ASSIGN_REF_EBX:
1677-
case CORINFO_HELP_ASSIGN_REF_EBP:
1678-
case CORINFO_HELP_ASSIGN_REF_ESI:
1679-
case CORINFO_HELP_ASSIGN_REF_EDI:
1680-
case CORINFO_HELP_CHECKED_ASSIGN_REF_EAX:
1681-
case CORINFO_HELP_CHECKED_ASSIGN_REF_ECX:
1682-
case CORINFO_HELP_CHECKED_ASSIGN_REF_EBX:
1683-
case CORINFO_HELP_CHECKED_ASSIGN_REF_EBP:
1684-
case CORINFO_HELP_CHECKED_ASSIGN_REF_ESI:
1685-
case CORINFO_HELP_CHECKED_ASSIGN_REF_EDI:
1686-
#endif
16871673
// GC Write barrier support
16881674
// TODO-ARM64-Bug?: Can these throw or not?
16891675
case CORINFO_HELP_ASSIGN_REF:

src/coreclr/nativeaot/Runtime/EHHelpers.cpp

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -202,23 +202,7 @@ LONG WINAPI RhpVectoredExceptionHandler(PEXCEPTION_POINTERS pExPtrs);
202202
FCDECL2(void, RhpThrowHwEx, int exceptionCode, TADDR faultingIP);
203203

204204
EXTERN_C CODE_LOCATION RhpAssignRefAVLocation;
205-
#if defined(HOST_X86)
206-
EXTERN_C CODE_LOCATION RhpAssignRefEAXAVLocation;
207-
EXTERN_C CODE_LOCATION RhpAssignRefECXAVLocation;
208-
EXTERN_C CODE_LOCATION RhpAssignRefEBXAVLocation;
209-
EXTERN_C CODE_LOCATION RhpAssignRefESIAVLocation;
210-
EXTERN_C CODE_LOCATION RhpAssignRefEDIAVLocation;
211-
EXTERN_C CODE_LOCATION RhpAssignRefEBPAVLocation;
212-
#endif
213205
EXTERN_C CODE_LOCATION RhpCheckedAssignRefAVLocation;
214-
#if defined(HOST_X86)
215-
EXTERN_C CODE_LOCATION RhpCheckedAssignRefEAXAVLocation;
216-
EXTERN_C CODE_LOCATION RhpCheckedAssignRefECXAVLocation;
217-
EXTERN_C CODE_LOCATION RhpCheckedAssignRefEBXAVLocation;
218-
EXTERN_C CODE_LOCATION RhpCheckedAssignRefESIAVLocation;
219-
EXTERN_C CODE_LOCATION RhpCheckedAssignRefEDIAVLocation;
220-
EXTERN_C CODE_LOCATION RhpCheckedAssignRefEBPAVLocation;
221-
#endif
222206

223207
#if defined(HOST_ARM64) && !defined(LSE_INSTRUCTIONS_ENABLED_BY_DEFAULT)
224208
EXTERN_C CODE_LOCATION RhpCheckedLockCmpXchgAVLocation2;
@@ -231,23 +215,7 @@ static bool InWriteBarrierHelper(uintptr_t faultingIP)
231215
static uintptr_t writeBarrierAVLocations[] =
232216
{
233217
(uintptr_t)&RhpAssignRefAVLocation,
234-
#if defined(HOST_X86)
235-
(uintptr_t)&RhpAssignRefEAXAVLocation,
236-
(uintptr_t)&RhpAssignRefECXAVLocation,
237-
(uintptr_t)&RhpAssignRefEBXAVLocation,
238-
(uintptr_t)&RhpAssignRefESIAVLocation,
239-
(uintptr_t)&RhpAssignRefEDIAVLocation,
240-
(uintptr_t)&RhpAssignRefEBPAVLocation,
241-
#endif
242218
(uintptr_t)&RhpCheckedAssignRefAVLocation,
243-
#if defined(HOST_X86)
244-
(uintptr_t)&RhpCheckedAssignRefEAXAVLocation,
245-
(uintptr_t)&RhpCheckedAssignRefECXAVLocation,
246-
(uintptr_t)&RhpCheckedAssignRefEBXAVLocation,
247-
(uintptr_t)&RhpCheckedAssignRefESIAVLocation,
248-
(uintptr_t)&RhpCheckedAssignRefEDIAVLocation,
249-
(uintptr_t)&RhpCheckedAssignRefEBPAVLocation,
250-
#endif
251219
};
252220

253221
// compare the IP against the list of known possible AV locations in the write barrier helpers

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ struct ReadyToRunHeaderConstants
1111
{
1212
static const uint32_t Signature = 0x00525452; // 'RTR'
1313

14-
static const uint32_t CurrentMajorVersion = 19;
14+
static const uint32_t CurrentMajorVersion = 20;
1515
static const uint32_t CurrentMinorVersion = 0;
1616
};
1717

src/coreclr/runtime/i386/WriteBarriers.S

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -207,20 +207,6 @@ LEAF_END RhpCheckedAssignRef\REFREG, _TEXT
207207
DEFINE_CHECKED_WRITE_BARRIER ECX, EDX, EAX
208208
DEFINE_WRITE_BARRIER ECX, EDX, EAX
209209

210-
DEFINE_WRITE_BARRIER EDX, EAX, ECX
211-
DEFINE_WRITE_BARRIER EDX, ECX, EAX
212-
DEFINE_WRITE_BARRIER EDX, EBX, EAX
213-
DEFINE_WRITE_BARRIER EDX, ESI, EAX
214-
DEFINE_WRITE_BARRIER EDX, EDI, EAX
215-
DEFINE_WRITE_BARRIER EDX, EBP, EAX
216-
217-
DEFINE_CHECKED_WRITE_BARRIER EDX, EAX, ECX
218-
DEFINE_CHECKED_WRITE_BARRIER EDX, ECX, EAX
219-
DEFINE_CHECKED_WRITE_BARRIER EDX, EBX, EAX
220-
DEFINE_CHECKED_WRITE_BARRIER EDX, ESI, EAX
221-
DEFINE_CHECKED_WRITE_BARRIER EDX, EDI, EAX
222-
DEFINE_CHECKED_WRITE_BARRIER EDX, EBP, EAX
223-
224210
LEAF_ENTRY RhpCheckedLockCmpXchg, _TEXT
225211
mov eax, [esp+4]
226212
lock cmpxchg [ecx], edx

0 commit comments

Comments
 (0)