Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
bfd57cd
Builds with write barrier moved
davidwrighton Apr 22, 2025
02b9ea6
More adjustment
davidwrighton Apr 22, 2025
273b640
Merge branch 'main' of https://github.com/dotnet/runtime into WriteBa…
davidwrighton Apr 22, 2025
17ad508
In theory all mucked up to make this work on Windows Amd64... Or at l…
davidwrighton Apr 23, 2025
4669265
Fix config settings for write barrier
davidwrighton Apr 23, 2025
a24a67e
Get the Arm64 build to work on Windows
davidwrighton Apr 23, 2025
a858993
Fix arm64 build
davidwrighton Apr 25, 2025
1c4c79a
Fix arm build
davidwrighton Apr 25, 2025
999b466
Fix RiscV build
davidwrighton Apr 25, 2025
547fb96
Fix Loongarch64 build
davidwrighton Apr 25, 2025
9fd2921
Fix Windows X86 build
davidwrighton Apr 26, 2025
9c2e247
Attempt to fix Windows Arm64 and Windows X86 issues
davidwrighton Apr 28, 2025
4601ff8
Attempt to fix Linux Arm build
davidwrighton Apr 28, 2025
ff8a695
Fix Linux Arm32
davidwrighton Apr 29, 2025
a882fbf
Alternative approach to fixing the EH issue that may fix OSX as well.…
davidwrighton Apr 29, 2025
f5a07a7
Revert "Alternative approach to fixing the EH issue that may fix OSX …
davidwrighton Apr 29, 2025
45a866b
Fix the Linux Arm32 Rhp write barrier to support FEATURE_USE_SOFTWARE…
davidwrighton Apr 29, 2025
516656e
Remove ALTERNATE_ENTRY AVLocations
davidwrighton Apr 30, 2025
2b791c6
Reapply "Alternative approach to fixing the EH issue that may fix OSX…
davidwrighton Apr 30, 2025
ecc06a7
Use the different style of lookup only on apple platforms on CoreCLR
davidwrighton Apr 30, 2025
e8c9a34
Fix build breaks
davidwrighton May 1, 2025
e992b86
Go back to using AVLocation alternate entries (The stae of Fix th Lin…
davidwrighton May 1, 2025
db5d24f
Attempt to fix arm32 build issue
davidwrighton May 1, 2025
f3f9320
Attempt to fix NullRefernce problem by moving ALTERNATE_ENTRY to star…
davidwrighton May 1, 2025
c35cbbd
Fix Windows X86 build
davidwrighton May 1, 2025
0fa2885
Linux X86 builds, and probably works
davidwrighton May 1, 2025
89422b6
Fix arm build
davidwrighton May 2, 2025
fd2cc83
Attempt to workaround build failures on apple platforms
davidwrighton May 2, 2025
4dd7420
Sigh...
davidwrighton May 2, 2025
5ab9e76
Fix more build breaks
davidwrighton May 2, 2025
9467e25
Put the write watch table update in the right spot
davidwrighton May 2, 2025
4e1ee53
Set UseGCWriteBarrierCopy to its production value
davidwrighton May 5, 2025
3383a68
Merge branch 'main' of github.com:dotnet/runtime into WriteBarrier_Wi…
davidwrighton May 5, 2025
6ca2479
Fix Windows X86 issue where the we failed to stack walk out of a writ…
davidwrighton May 5, 2025
435c220
Code review feedback
davidwrighton May 6, 2025
2950b1f
Try the cfi_startproc/cfi_endproc wrappers for ALTERNATE_ENTRY to see…
davidwrighton May 13, 2025
247ae5f
Merge branch 'main' of https://github.com/dotnet/runtime into WriteBa…
davidwrighton May 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/coreclr/runtime/arm/WriteBarriers.S
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ GLOBAL_LABEL RhpCheckedAssignRefAVLocation
LEAF_END RhpCheckedAssignRef\EXPORT_REG_NAME, _TEXT
.endm

LEAF_ENTRY RhpWriteBarriers, _TEXT
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW this would not work anyway... we compile all code on Apple platforms as .subsections_via_symbols and the Apple linker is free to reorder the functions (or discard unused ones if told to). Compiling without subsections_via_symbols is not an option due to various bugs in different linker versions. The only other option to keep the desired order is to mark the successive symbols as .alt_entry, which also happens to run into linker bugs if not done extremely carefully...

bx lr
LEAF_END RhpWriteBarriers, _TEXT

// One day we might have write barriers for all the possible argument registers but for now we have
// just one write barrier that assumes the input register is RSI.
DEFINE_CHECKED_WRITE_BARRIER r1, r1
Expand Down Expand Up @@ -302,3 +306,7 @@ LOCAL_LABEL(RhpByRefAssignRef_NotInHeap):
add r1, #4
bx lr
LEAF_END RhpByRefAssignRef, _TEXT

LEAF_ENTRY RhpWriteBarriers_End, _TEXT
bx lr
LEAF_END RhpWriteBarriers_End, _TEXT
9 changes: 9 additions & 0 deletions src/coreclr/runtime/arm64/WriteBarriers.S
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@
// Exit label
.endm

LEAF_ENTRY RhpWriteBarriers, _TEXT
ret
LEAF_END RhpWriteBarriers, _TEXT

// void JIT_ByRefWriteBarrier
// On entry:
// x13 : the source address (points to object reference to write)
Expand Down Expand Up @@ -397,3 +401,8 @@ LOCAL_LABEL(NoBarrierXchg):
.arch_extension nolse
#endif
#endif // FEATURE_NATIVEAOT

LEAF_ENTRY RhpWriteBarriers_End, _TEXT
ret
LEAF_END RhpWriteBarriers_End, _TEXT

8 changes: 8 additions & 0 deletions src/coreclr/runtime/arm64/WriteBarriers.asm
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ INVALIDGCVALUE EQU 0xCCCCCCCD
;; Exit label
MEND

LEAF_ENTRY RhpWriteBarriers
ret
LEAF_END RhpWriteBarriers

;; void JIT_ByRefWriteBarrier
;; On entry:
;; x13 : the source address (points to object reference to write)
Expand Down Expand Up @@ -391,4 +395,8 @@ NoBarrierXchg
LEAF_END RhpCheckedXchg
#endif // FEATURE_NATIVEAOT

LEAF_ENTRY RhpWriteBarriers_End
ret
LEAF_END RhpWriteBarriers_End

end
3 changes: 2 additions & 1 deletion src/coreclr/runtime/i386/WriteBarriers.S
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

// TODO: Implement
#include "AsmMacros_Shared.h"

23 changes: 14 additions & 9 deletions src/coreclr/vm/excep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5895,9 +5895,14 @@ BOOL IsIPinVirtualStub(PCODE f_IP)
#endif // FEATURE_VIRTUAL_STUB_DISPATCH
}

#if defined(TARGET_ARM64) || defined(TARGET_ARM)
EXTERN_C void RhpWriteBarriers();
EXTERN_C void RhpWriteBarriers_End();
#endif

typedef uint8_t CODE_LOCATION;
EXTERN_C CODE_LOCATION RhpAssignRefAVLocation;
#if defined(HOST_X86)
#if defined(TARGET_X86)
EXTERN_C CODE_LOCATION RhpAssignRefEAXAVLocation;
EXTERN_C CODE_LOCATION RhpAssignRefECXAVLocation;
EXTERN_C CODE_LOCATION RhpAssignRefEBXAVLocation;
Expand All @@ -5906,7 +5911,7 @@ EXTERN_C CODE_LOCATION RhpAssignRefEDIAVLocation;
EXTERN_C CODE_LOCATION RhpAssignRefEBPAVLocation;
#endif
EXTERN_C CODE_LOCATION RhpCheckedAssignRefAVLocation;
#if defined(HOST_X86)
#if defined(TARGET_X86)
EXTERN_C CODE_LOCATION RhpCheckedAssignRefEAXAVLocation;
EXTERN_C CODE_LOCATION RhpCheckedAssignRefECXAVLocation;
EXTERN_C CODE_LOCATION RhpCheckedAssignRefEBXAVLocation;
Expand All @@ -5916,14 +5921,14 @@ EXTERN_C CODE_LOCATION RhpCheckedAssignRefEBPAVLocation;
#endif
EXTERN_C CODE_LOCATION RhpByRefAssignRefAVLocation1;

#if !defined(HOST_ARM64) && !defined(HOST_LOONGARCH64) && !defined(HOST_RISCV64)
#if !defined(TARGET_ARM64) && !defined(TARGET_LOONGARCH64) && !defined(TARGET_RISCV64)
EXTERN_C CODE_LOCATION RhpByRefAssignRefAVLocation2;
#endif

static uintptr_t writeBarrierAVLocations[] =
{
(uintptr_t)&RhpAssignRefAVLocation,
#if defined(HOST_X86)
#if defined(TARGET_X86)
(uintptr_t)&RhpAssignRefEAXAVLocation,
(uintptr_t)&RhpAssignRefECXAVLocation,
(uintptr_t)&RhpAssignRefEBXAVLocation,
Expand All @@ -5941,7 +5946,7 @@ static uintptr_t writeBarrierAVLocations[] =
(uintptr_t)&RhpCheckedAssignRefEBPAVLocation,
#endif
(uintptr_t)&RhpByRefAssignRefAVLocation1,
#if !defined(HOST_ARM64) && !defined(HOST_LOONGARCH64) && !defined(HOST_RISCV64)
#if !defined(TARGET_ARM64) && !defined(TARGET_LOONGARCH64) && !defined(TARGET_RISCV64)
(uintptr_t)&RhpByRefAssignRefAVLocation2,
#endif
};
Expand All @@ -5961,17 +5966,17 @@ bool IsIPInMarkedJitHelper(UINT_PTR uControlPc)
ASSERT(*(uint8_t*)writeBarrierAVLocations[i] != 0xE9); // jmp XXXXXXXX
#endif

#ifdef TARGET_ARM
if ((writeBarrierAVLocations[i] | THUMB_CODE) == (uControlPc | THUMB_CODE))
#else
if (writeBarrierAVLocations[i] == uControlPc)
#endif
return true;
}

#define CHECK_RANGE(name) \
if (GetEEFuncEntryPoint(name) <= uControlPc && uControlPc < GetEEFuncEntryPoint(name##_End)) return true;

#if defined(TARGET_ARM64) || defined(TARGET_ARM)
CHECK_RANGE(RhpWriteBarriers)
#endif

#ifndef TARGET_X86
CHECK_RANGE(JIT_WriteBarrier)
CHECK_RANGE(JIT_CheckedWriteBarrier)
Expand Down
Loading