Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ARM64] Add g_GCShadowEnd to JIT_WriteBarrier_Table #91342

Merged
merged 4 commits into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
26 changes: 16 additions & 10 deletions src/coreclr/vm/arm64/asmhelpers.S
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ LEAF_END ThePreStubPatch, _TEXT
WRITE_BARRIER_ENTRY JIT_UpdateWriteBarrierState
PROLOG_SAVE_REG_PAIR_INDEXED fp, lr, -16

// x0-x7 will contain intended new state
// x0-x7, x10 will contain intended new state
// x8 will preserve skipEphemeralCheck
// x12 will be used for pointers

Expand All @@ -226,29 +226,32 @@ WRITE_BARRIER_ENTRY JIT_UpdateWriteBarrierState
#ifdef WRITE_BARRIER_CHECK
PREPARE_EXTERNAL_VAR g_GCShadow, x12
ldr x2, [x12]

PREPARE_EXTERNAL_VAR g_GCShadowEnd, x12
ldr x3, [x12]
#endif

#ifdef FEATURE_USE_SOFTWARE_WRITE_WATCH_FOR_GC_HEAP
PREPARE_EXTERNAL_VAR g_sw_ww_table, x12
ldr x3, [x12]
ldr x4, [x12]
#endif

PREPARE_EXTERNAL_VAR g_ephemeral_low, x12
ldr x4, [x12]
ldr x5, [x12]

PREPARE_EXTERNAL_VAR g_ephemeral_high, x12
ldr x5, [x12]
ldr x6, [x12]

cbz x8, LOCAL_LABEL(EphemeralCheckEnabled)
movz x4, #0
movn x5, #0
movz x5, #0
movn x6, #0
LOCAL_LABEL(EphemeralCheckEnabled):

PREPARE_EXTERNAL_VAR g_lowest_address, x12
ldr x6, [x12]
ldr x7, [x12]

PREPARE_EXTERNAL_VAR g_highest_address, x12
ldr x7, [x12]
ldr x10, [x12]

// Update wbs state
PREPARE_EXTERNAL_VAR JIT_WriteBarrier_Table_Loc, x12
Expand All @@ -259,6 +262,8 @@ LOCAL_LABEL(EphemeralCheckEnabled):
stp x2, x3, [x12], 16
stp x4, x5, [x12], 16
stp x6, x7, [x12], 16
str x10, [x12], 8


EPILOG_RESTORE_REG_PAIR_INDEXED fp, lr, 16
EPILOG_RETURN
Expand Down Expand Up @@ -367,8 +372,7 @@ WRITE_BARRIER_ENTRY JIT_WriteBarrier
add x12, x13, x12

// if (pShadow >= g_GCShadowEnd) goto end
PREPARE_EXTERNAL_VAR g_GCShadowEnd, x13
ldr x13, [x13]
ldr x13, LOCAL_LABEL(wbs_GCShadowEnd)
cmp x12, x13
bhs LOCAL_LABEL(ShadowUpdateEnd)

Expand Down Expand Up @@ -462,6 +466,8 @@ LOCAL_LABEL(wbs_card_bundle_table):
.quad 0
LOCAL_LABEL(wbs_GCShadow):
.quad 0
LOCAL_LABEL(wbs_GCShadowEnd):
.quad 0
LOCAL_LABEL(wbs_sw_ww_table):
.quad 0
LOCAL_LABEL(wbs_ephemeral_low):
Expand Down
25 changes: 15 additions & 10 deletions src/coreclr/vm/arm64/asmhelpers.asm
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ ThePreStubPatchLabel
WRITE_BARRIER_ENTRY JIT_UpdateWriteBarrierState
PROLOG_SAVE_REG_PAIR fp, lr, #-16!

; x0-x7 will contain intended new state
; x0-x7, x10 will contain intended new state
; x8 will preserve skipEphemeralCheck
; x12 will be used for pointers

Expand All @@ -296,30 +296,33 @@ ThePreStubPatchLabel
#ifdef WRITE_BARRIER_CHECK
adrp x12, $g_GCShadow
ldr x2, [x12, $g_GCShadow]

adrp x12, $g_GCShadowEnd
ldr x3, [x12, $g_GCShadowEnd]
#endif

#ifdef FEATURE_USE_SOFTWARE_WRITE_WATCH_FOR_GC_HEAP
adrp x12, g_sw_ww_table
ldr x3, [x12, g_sw_ww_table]
ldr x4, [x12, g_sw_ww_table]
#endif

adrp x12, g_ephemeral_low
ldr x4, [x12, g_ephemeral_low]
ldr x5, [x12, g_ephemeral_low]

adrp x12, g_ephemeral_high
ldr x5, [x12, g_ephemeral_high]
ldr x6, [x12, g_ephemeral_high]

; Check skipEphemeralCheck
cbz x8, EphemeralCheckEnabled
movz x4, #0
movn x5, #0
movz x5, #0
movn x6, #0

EphemeralCheckEnabled
adrp x12, g_lowest_address
ldr x6, [x12, g_lowest_address]
ldr x7, [x12, g_lowest_address]

adrp x12, g_highest_address
ldr x7, [x12, g_highest_address]
ldr x10, [x12, g_highest_address]

; Update wbs state
adrp x12, JIT_WriteBarrier_Table_Loc
Expand All @@ -329,6 +332,7 @@ EphemeralCheckEnabled
stp x2, x3, [x12], 16
stp x4, x5, [x12], 16
stp x6, x7, [x12], 16
str x10, [x12], 8

EPILOG_RESTORE_REG_PAIR fp, lr, #16!
EPILOG_RETURN
Expand All @@ -345,6 +349,8 @@ wbs_card_bundle_table
DCQ 0
wbs_GCShadow
DCQ 0
wbs_GCShadowEnd
DCQ 0
Copy link
Member

Choose a reason for hiding this comment

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

Could you please move wbs_GCShadow and wbs_GCShadowEnd to the end of the wbs block? These are debug-only fields, having them at the end would be a tiny bit better for cache locality.

Copy link
Author

Choose a reason for hiding this comment

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

@jkotas moved to the end of the wbs

wbs_sw_ww_table
DCQ 0
wbs_ephemeral_low
Expand Down Expand Up @@ -433,8 +439,7 @@ NotInHeap
add x12, x13, x12

; if (pShadow >= $g_GCShadowEnd) goto end
adrp x13, $g_GCShadowEnd
ldr x13, [x13, $g_GCShadowEnd]
ldr x13, wbs_GCShadowEnd
cmp x12, x13
bhs ShadowUpdateEnd

Expand Down