-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[NativeAOT] Move Interlocked null checks to managed, RhpLockCmpXchg64 to C #100021
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
Changes from 9 commits
1d81cec
3b2e99e
fb6ec76
9447a82
1cb0367
a414651
6a96d20
cd2d77d
0c166b6
78b9258
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,15 +7,11 @@ | |
| #include <AsmOffsets.inc> // generated by the build from AsmOffsets.cpp | ||
| #include <unixasmmacros.inc> | ||
|
|
||
| // WARNING: Code in EHHelpers.cpp makes assumptions about this helper, in particular: | ||
| // - Function "InWriteBarrierHelper" assumes an AV due to passed in null pointer will happen at RhpLockCmpXchg32AVLocation | ||
| // - Function "UnwindSimpleHelperToCaller" assumes no registers were pushed and LR contains the return address | ||
| // r0 = destination address | ||
| // r1 = value | ||
| // r2 = comparand | ||
| LEAF_ENTRY RhpLockCmpXchg32, _TEXT | ||
| dmb | ||
| GLOBAL_LABEL RhpLockCmpXchg32AVLocation | ||
| LOCAL_LABEL(CmpXchg32Retry): | ||
| ldrex r3, [r0] | ||
| cmp r2, r3 | ||
|
|
@@ -28,30 +24,3 @@ LOCAL_LABEL(CmpXchg32Exit): | |
| dmb | ||
| bx lr | ||
| LEAF_END RhpLockCmpXchg32, _TEXT | ||
|
|
||
| // WARNING: Code in EHHelpers.cpp makes assumptions about this helper, in particular: | ||
| // - Function "InWriteBarrierHelper" assumes an AV due to passed in null pointer will happen at RhpLockCmpXchg64AVLocation | ||
| // - Function "UnwindSimpleHelperToCaller" assumes no registers were pushed and LR contains the return address | ||
| // r0 = destination address | ||
| // {r2,r3} = value | ||
| // sp[0+8] = comparand | ||
| LEAF_ENTRY RhpLockCmpXchg64, _TEXT | ||
| GLOBAL_LABEL RhpLockCmpXchg64AVLocation | ||
| ldr r12, [r0] // dummy read for null check | ||
| PROLOG_PUSH "{r4-r6,lr}" | ||
| dmb | ||
| ldrd r4, r5, [sp,#0x10] | ||
| LOCAL_LABEL(CmpXchg64Retry): | ||
| ldrexd r6, r1, [r0] | ||
| cmp r6, r4 | ||
| bne LOCAL_LABEL(CmpXchg64Exit) | ||
| cmp r1, r5 | ||
| bne LOCAL_LABEL(CmpXchg64Exit) | ||
| strexd r12, r2, r3, [r0] | ||
| cmp r12, #0 | ||
| bne LOCAL_LABEL(CmpXchg64Retry) | ||
| LOCAL_LABEL(CmpXchg64Exit): | ||
| mov r0, r6 | ||
| dmb | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The native AOT PAL implementation of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added it but I noticed that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
IIRC the native compilers already emit a barrier of their own there so it'd do two barriers (so I guess it's kinda relying on an implementation detail). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
At very least ARM gcc and ARM clang does, so that explains why it wasn't a problem for ARM32 on CoreCLR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ARM64: clang generates barrier at the end (should still be fine); gcc doesn't generate a barrier |
||
| EPILOG_POP "{r4-r6,pc}" | ||
| LEAF_END RhpLockCmpXchg64, _TEXT | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -286,10 +286,6 @@ NotInHeap | |
| ;; Interlocked operation helpers where the location is an objectref, thus requiring a GC write barrier upon | ||
| ;; successful updates. | ||
|
|
||
| ;; WARNING: Code in EHHelpers.cpp makes assumptions about write barrier code, in particular: | ||
| ;; - Function "InWriteBarrierHelper" assumes an AV due to passed in null pointer will happen at RhpCheckedLockCmpXchgAVLocation | ||
| ;; - Function "UnwindSimpleHelperToCaller" assumes no registers were pushed and LR contains the return address | ||
|
|
||
| ;; RhpCheckedLockCmpXchg(Object** dest, Object* value, Object* comparand) | ||
| ;; | ||
| ;; Interlocked compare exchange on objectref. | ||
|
|
@@ -311,7 +307,6 @@ NotInHeap | |
| #endif | ||
|
|
||
| mov x10, x2 | ||
| ALTERNATE_ENTRY RhpCheckedLockCmpXchgAVLocation | ||
| casal x10, x1, [x0] ;; exchange | ||
| cmp x2, x10 | ||
| bne CmpXchgNoUpdate | ||
|
|
@@ -320,7 +315,6 @@ NotInHeap | |
| b DoCardsCmpXchg | ||
| CmpXchgRetry | ||
| ;; Check location value is what we expect. | ||
| ALTERNATE_ENTRY RhpCheckedLockCmpXchgAVLocation2 | ||
| ldaxr x10, [x0] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
| cmp x10, x2 | ||
| bne CmpXchgNoUpdate | ||
|
|
@@ -350,10 +344,6 @@ NoBarrierCmpXchg | |
|
|
||
| LEAF_END RhpCheckedLockCmpXchg | ||
|
|
||
| ;; WARNING: Code in EHHelpers.cpp makes assumptions about write barrier code, in particular: | ||
| ;; - Function "InWriteBarrierHelper" assumes an AV due to passed in null pointer will happen within at RhpCheckedXchgAVLocation | ||
| ;; - Function "UnwindSimpleHelperToCaller" assumes no registers were pushed and LR contains the return address | ||
|
|
||
| ;; RhpCheckedXchg(Object** destination, Object* value) | ||
| ;; | ||
| ;; Interlocked exchange on objectref. | ||
|
|
@@ -374,14 +364,12 @@ NoBarrierCmpXchg | |
| tbz x16, #ARM64_ATOMICS_FEATURE_FLAG_BIT, ExchangeRetry | ||
| #endif | ||
|
|
||
| ALTERNATE_ENTRY RhpCheckedXchgAVLocation | ||
| swpal x1, x10, [x0] ;; exchange | ||
|
|
||
| #ifndef LSE_INSTRUCTIONS_ENABLED_BY_DEFAULT | ||
| b DoCardsXchg | ||
| ExchangeRetry | ||
| ;; Read the existing memory location. | ||
| ALTERNATE_ENTRY RhpCheckedXchgAVLocation2 | ||
| ldaxr x10, [x0] | ||
|
|
||
| ;; Attempt to update with the new value. | ||
|
|
||
This file was deleted.
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.