Skip to content

Commit dbe9f2a

Browse files
Minor fixes to write barriers (#75478)
* Minor fixes to write barriers * use the same predicated compare as on Unix when checking ephemeral low/high --------- Co-authored-by: vsadov <[email protected]>
1 parent 981445c commit dbe9f2a

File tree

8 files changed

+19
-15
lines changed

8 files changed

+19
-15
lines changed

src/coreclr/vm/amd64/JitHelpers_Fast.asm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ ifdef WRITE_BARRIER_CHECK
279279
; Check that our adjusted destination is somewhere in the shadow gc
280280
add r10, [g_GCShadow]
281281
cmp r10, [g_GCShadowEnd]
282-
ja NoShadow
282+
jnb NoShadow
283283

284284
; Write ref into real GC
285285
mov [rdi], rcx

src/coreclr/vm/amd64/JitHelpers_Slow.asm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ ifdef WRITE_BARRIER_CHECK
8181
; Check that our adjusted destination is somewhere in the shadow gc
8282
add r10, [g_GCShadow]
8383
cmp r10, [g_GCShadowEnd]
84-
ja NoShadow
84+
jnb NoShadow
8585

8686
; Write ref into real GC; see comment below about possibility of AV
8787
mov [rcx], rdx

src/coreclr/vm/amd64/jithelpers_fast.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ LEAF_ENTRY JIT_ByRefWriteBarrier, _TEXT
300300
add r10, [rax]
301301
PREPARE_EXTERNAL_VAR g_GCShadowEnd, rax
302302
cmp r10, [rax]
303-
ja NoShadow_ByRefWriteBarrier
303+
jnb NoShadow_ByRefWriteBarrier
304304

305305
// Write ref into real GC
306306
mov [rdi], rcx

src/coreclr/vm/amd64/jithelpers_slow.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ LEAF_ENTRY JIT_WriteBarrier_Debug, _TEXT
2828
add r10, [rax]
2929
PREPARE_EXTERNAL_VAR g_GCShadowEnd, r11
3030
cmp r10, [r11]
31-
ja NoShadow
31+
jnb NoShadow
3232

3333
// Write ref into real GC// see comment below about possibility of AV
3434
mov [rdi], rsi

src/coreclr/vm/arm64/asmhelpers.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ LOCAL_LABEL(CheckCardTable):
420420
// branch to exit is taken.
421421
ccmp x15, x12, #0x2, hs
422422

423-
bhi LOCAL_LABEL(Exit)
423+
bhs LOCAL_LABEL(Exit)
424424

425425
LOCAL_LABEL(SkipEphemeralCheck):
426426
// Check if we need to update the card table

src/coreclr/vm/arm64/asmhelpers.asm

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -474,15 +474,19 @@ ShadowUpdateDisabled
474474
CheckCardTable
475475
; Branch to Exit if the reference is not in the Gen0 heap
476476
;
477-
adr x12, wbs_ephemeral_low
478-
ldp x12, x16, [x12]
477+
ldr x12, wbs_ephemeral_low
479478
cbz x12, SkipEphemeralCheck
480-
481479
cmp x15, x12
482-
blo Exit
483480

484-
cmp x15, x16
485-
bhi Exit
481+
ldr x12, wbs_ephemeral_high
482+
483+
; Compare against the upper bound if the previous comparison indicated
484+
; that the destination address is greater than or equal to the lower
485+
; bound. Otherwise, set the C flag (specified by the 0x2) so that the
486+
; branch to exit is taken.
487+
ccmp x15, x12, #0x2, hs
488+
489+
bhs Exit
486490

487491
SkipEphemeralCheck
488492
; Check if we need to update the card table

src/coreclr/vm/i386/jithelp.S

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ PATCH_LABEL JIT_DebugWriteBarrier\rg
109109
mov [edx], edx
110110
cmp ecx, [edx]
111111
pop edx
112-
ja LOCAL_LABEL(WriteBarrier_NoShadow_\rg)
112+
jae LOCAL_LABEL(WriteBarrier_NoShadow_\rg)
113113

114114
// TODO: In Orcas timeframe if we move to P4+ only on X86 we should enable
115115
// mfence barriers on either side of these two writes to make sure that
@@ -281,7 +281,7 @@ LEAF_ENTRY JIT_ByRefWriteBarrier, _TEXT
281281
mov eax, [eax]
282282
cmp edx, [eax]
283283
pop eax
284-
ja LOCAL_LABEL(ByRefWriteBarrier_NoShadow)
284+
jae LOCAL_LABEL(ByRefWriteBarrier_NoShadow)
285285

286286
// TODO: In Orcas timeframe if we move to P4+ only on X86 we should enable
287287
// mfence barriers on either side of these two writes to make sure that

src/coreclr/vm/i386/jithelp.asm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ ifdef WRITE_BARRIER_CHECK
193193
jb WriteBarrier_NoShadow_&rg
194194
add ecx, [g_GCShadow]
195195
cmp ecx, [g_GCShadowEnd]
196-
ja WriteBarrier_NoShadow_&rg
196+
jae WriteBarrier_NoShadow_&rg
197197

198198
; TODO: In Orcas timeframe if we move to P4+ only on X86 we should enable
199199
; mfence barriers on either side of these two writes to make sure that
@@ -330,7 +330,7 @@ ifdef WRITE_BARRIER_CHECK
330330
jb ByRefWriteBarrier_NoShadow
331331
add edx, [g_GCShadow]
332332
cmp edx, [g_GCShadowEnd]
333-
ja ByRefWriteBarrier_NoShadow
333+
jae ByRefWriteBarrier_NoShadow
334334

335335
; TODO: In Orcas timeframe if we move to P4+ only on X86 we should enable
336336
; mfence barriers on either side of these two writes to make sure that

0 commit comments

Comments
 (0)