diff options
author | Manu <manu-silicon@users.noreply.github.com> | 2016-01-07 06:00:13 +0300 |
---|---|---|
committer | Manu <manu-silicon@users.noreply.github.com> | 2016-01-07 06:00:13 +0300 |
commit | 76b5427a8d93bab66bc9c067d67be8ac3e6e205b (patch) | |
tree | a474ddc54a4bea45330bfcf465a812f82baee283 /src/Native | |
parent | d4e62e45c049e4df5dabcbbf2fd309d5d7d1061b (diff) |
Initial support for Interlocked on arm/arm64
Added initial implementation for RhpLockCmpXchg32 and RhpLockCmpXchg64
for arm64. The arm version is not implemented yet.
Diffstat (limited to 'src/Native')
-rw-r--r-- | src/Native/Runtime/arm/Interlocked.S | 29 | ||||
-rw-r--r-- | src/Native/Runtime/arm64/Interlocked.S | 43 | ||||
-rw-r--r-- | src/Native/Runtime/unix/unixasmmacrosarm.inc | 5 | ||||
-rw-r--r-- | src/Native/Runtime/unix/unixasmmacrosarm64.inc | 5 |
4 files changed, 82 insertions, 0 deletions
diff --git a/src/Native/Runtime/arm/Interlocked.S b/src/Native/Runtime/arm/Interlocked.S new file mode 100644 index 000000000..c6eb31e12 --- /dev/null +++ b/src/Native/Runtime/arm/Interlocked.S @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +// TODO: Implement InterLocked routines +#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 "UnwindWriteBarrierToCaller" assumes the stack contains just the pushed return address +// r0 = destination address +// r1 = value +// r2 = comparand +LEAF_ENTRY RhpLockCmpXchg32, _TEXT +ALTERNATE_ENTRY RhpLockCmpXchg32AVLocation + 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 "UnwindWriteBarrierToCaller" assumes the stack contains just the pushed return address +// r0 = destination address +// r1 = value +// r2 = comparand +LEAF_ENTRY RhpLockCmpXchg64, _TEXT +ALTERNATE_ENTRY RhpLockCmpXchg64AVLocation + bx lr +LEAF_END RhpLockCmpXchg64, _TEXT diff --git a/src/Native/Runtime/arm64/Interlocked.S b/src/Native/Runtime/arm64/Interlocked.S new file mode 100644 index 000000000..aa70733c7 --- /dev/null +++ b/src/Native/Runtime/arm64/Interlocked.S @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +#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 "UnwindWriteBarrierToCaller" assumes the stack contains just the pushed return address +// x0 = destination address +// w1 = value +// w2 = comparand +LEAF_ENTRY RhpLockCmpXchg32, _TEXT + mov x8, x0 // Save value of x0 into x8 as x0 is used for the return value +ALTERNATE_ENTRY RhpLockCmpXchg32AVLocation +1: // loop + ldaxr w0, [x8] // w0 = *x8 + cmp w0, w2 + bne 2f // if (w0 != w2) goto exit + stlxr w9, w1, [x8] // if (w0 == w2) { try *x8 = w1 and goto loop if failed or goto exit } + cbnz w9, 1b +2: // exit + ret +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 "UnwindWriteBarrierToCaller" assumes the stack contains just the pushed return address +// x0 = destination address +// x1 = value +// x2 = comparand +LEAF_ENTRY RhpLockCmpXchg64, _TEXT + mov x8, x0 // Save value of x0 into x8 as x0 is used for the return value +ALTERNATE_ENTRY RhpLockCmpXchg64AVLocation +1: // loop + ldaxr x0, [x8] // x0 = *x8 + cmp x0, x2 + bne 2f // if (x0 != x2) goto exit + stlxr w9, x1, [x8] // if (x0 == x2) { try *x8 = x1 and goto loop if failed or goto exit } + cbnz w9, 1b +2: // exit + ret +LEAF_END RhpLockCmpXchg64, _TEXT diff --git a/src/Native/Runtime/unix/unixasmmacrosarm.inc b/src/Native/Runtime/unix/unixasmmacrosarm.inc index 837ffd788..4aa8729d3 100644 --- a/src/Native/Runtime/unix/unixasmmacrosarm.inc +++ b/src/Native/Runtime/unix/unixasmmacrosarm.inc @@ -20,6 +20,11 @@ C_FUNC(\Name): .endm +.macro ALTERNATE_ENTRY Name + .global C_FUNC(\Name) +C_FUNC(\Name): +.endm + .macro LEAF_ENTRY Name, Section .thumb_func .global C_FUNC(\Name) diff --git a/src/Native/Runtime/unix/unixasmmacrosarm64.inc b/src/Native/Runtime/unix/unixasmmacrosarm64.inc index 12c6c3648..1619592c5 100644 --- a/src/Native/Runtime/unix/unixasmmacrosarm64.inc +++ b/src/Native/Runtime/unix/unixasmmacrosarm64.inc @@ -19,6 +19,11 @@ C_FUNC(\Name): .endm +.macro ALTERNATE_ENTRY Name + .global C_FUNC(\Name) +C_FUNC(\Name): +.endm + .macro LEAF_ENTRY Name, Section .global C_FUNC(\Name) .type \Name, %function |