author | valeriep |
Fri, 29 Mar 2019 00:39:49 +0000 | |
changeset 54333 | 2a29e62446bd |
parent 54069 | c4fb912f3085 |
child 59247 | 56bf71d64d51 |
permissions | -rw-r--r-- |
22831
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1 |
/* |
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
50029
diff
changeset
|
2 |
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. |
54069
c4fb912f3085
8220441: [PPC64] Clobber memory effect missing for memory barriers in atomics
mdoerr
parents:
53244
diff
changeset
|
3 |
* Copyright (c) 2012, 2019 SAP SE. All rights reserved. |
22831
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5 |
* |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
6 |
* This code is free software; you can redistribute it and/or modify it |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
7 |
* under the terms of the GNU General Public License version 2 only, as |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
8 |
* published by the Free Software Foundation. |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
9 |
* |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
10 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
11 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
12 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
13 |
* version 2 for more details (a copy is included in the LICENSE file that |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
14 |
* accompanied this code). |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
15 |
* |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
16 |
* You should have received a copy of the GNU General Public License version |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
17 |
* 2 along with this work; if not, write to the Free Software Foundation, |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
18 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
19 |
* |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
20 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
21 |
* or visit www.oracle.com if you need additional information or have any |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
22 |
* questions. |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
23 |
* |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
24 |
*/ |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
25 |
|
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
50029
diff
changeset
|
26 |
#ifndef OS_CPU_AIX_PPC_ATOMIC_AIX_PPC_HPP |
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
50029
diff
changeset
|
27 |
#define OS_CPU_AIX_PPC_ATOMIC_AIX_PPC_HPP |
22831
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
28 |
|
50029
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
29 |
#ifndef PPC64 |
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
30 |
#error "Atomic currently only implemented for PPC64" |
22831
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
31 |
#endif |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
32 |
|
46973
149e5319c938
8186734: AIX build broken after 8186166: Generalize Atomic::cmpxchg with templates
mdoerr
parents:
46958
diff
changeset
|
33 |
#include "utilities/debug.hpp" |
149e5319c938
8186734: AIX build broken after 8186166: Generalize Atomic::cmpxchg with templates
mdoerr
parents:
46958
diff
changeset
|
34 |
|
22831
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
35 |
// Implementation of class atomic |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
36 |
|
22867 | 37 |
// |
50029
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
38 |
// machine barrier instructions: |
22867 | 39 |
// |
50029
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
40 |
// - sync two-way memory barrier, aka fence |
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
41 |
// - lwsync orders Store|Store, |
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
42 |
// Load|Store, |
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
43 |
// Load|Load, |
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
44 |
// but not Store|Load |
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
45 |
// - eieio orders memory accesses for device memory (only) |
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
46 |
// - isync invalidates speculatively executed instructions |
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
47 |
// From the POWER ISA 2.06 documentation: |
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
48 |
// "[...] an isync instruction prevents the execution of |
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
49 |
// instructions following the isync until instructions |
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
50 |
// preceding the isync have completed, [...]" |
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
51 |
// From IBM's AIX assembler reference: |
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
52 |
// "The isync [...] instructions causes the processor to |
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
53 |
// refetch any instructions that might have been fetched |
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
54 |
// prior to the isync instruction. The instruction isync |
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
55 |
// causes the processor to wait for all previous instructions |
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
56 |
// to complete. Then any instructions already fetched are |
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
57 |
// discarded and instruction processing continues in the |
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
58 |
// environment established by the previous instructions." |
22867 | 59 |
// |
50029
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
60 |
// semantic barrier instructions: |
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
61 |
// (as defined in orderAccess.hpp) |
22867 | 62 |
// |
50029
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
63 |
// - release orders Store|Store, (maps to lwsync) |
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
64 |
// Load|Store |
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
65 |
// - acquire orders Load|Store, (maps to lwsync) |
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
66 |
// Load|Load |
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
67 |
// - fence orders Store|Store, (maps to sync) |
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
68 |
// Load|Store, |
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
69 |
// Load|Load, |
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
70 |
// Store|Load |
22867 | 71 |
// |
22831
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
72 |
|
50029
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
73 |
inline void pre_membar(atomic_memory_order order) { |
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
74 |
switch (order) { |
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
75 |
case memory_order_relaxed: |
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
76 |
case memory_order_acquire: break; |
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
77 |
case memory_order_release: |
54069
c4fb912f3085
8220441: [PPC64] Clobber memory effect missing for memory barriers in atomics
mdoerr
parents:
53244
diff
changeset
|
78 |
case memory_order_acq_rel: __asm__ __volatile__ ("lwsync" : : : "memory"); break; |
c4fb912f3085
8220441: [PPC64] Clobber memory effect missing for memory barriers in atomics
mdoerr
parents:
53244
diff
changeset
|
79 |
default /*conservative*/ : __asm__ __volatile__ ("sync" : : : "memory"); break; |
50029
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
80 |
} |
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
81 |
} |
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
82 |
|
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
83 |
inline void post_membar(atomic_memory_order order) { |
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
84 |
switch (order) { |
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
85 |
case memory_order_relaxed: |
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
86 |
case memory_order_release: break; |
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
87 |
case memory_order_acquire: |
54069
c4fb912f3085
8220441: [PPC64] Clobber memory effect missing for memory barriers in atomics
mdoerr
parents:
53244
diff
changeset
|
88 |
case memory_order_acq_rel: __asm__ __volatile__ ("isync" : : : "memory"); break; |
c4fb912f3085
8220441: [PPC64] Clobber memory effect missing for memory barriers in atomics
mdoerr
parents:
53244
diff
changeset
|
89 |
default /*conservative*/ : __asm__ __volatile__ ("sync" : : : "memory"); break; |
50029
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
90 |
} |
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
91 |
} |
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
92 |
|
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
93 |
|
46993
dd0f91c85ffc
8186476: Generalize Atomic::add with templates
eosterlund
parents:
46973
diff
changeset
|
94 |
template<size_t byte_size> |
dd0f91c85ffc
8186476: Generalize Atomic::add with templates
eosterlund
parents:
46973
diff
changeset
|
95 |
struct Atomic::PlatformAdd |
dd0f91c85ffc
8186476: Generalize Atomic::add with templates
eosterlund
parents:
46973
diff
changeset
|
96 |
: Atomic::AddAndFetch<Atomic::PlatformAdd<byte_size> > |
dd0f91c85ffc
8186476: Generalize Atomic::add with templates
eosterlund
parents:
46973
diff
changeset
|
97 |
{ |
dd0f91c85ffc
8186476: Generalize Atomic::add with templates
eosterlund
parents:
46973
diff
changeset
|
98 |
template<typename I, typename D> |
50029
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
99 |
D add_and_fetch(I add_value, D volatile* dest, atomic_memory_order order) const; |
46993
dd0f91c85ffc
8186476: Generalize Atomic::add with templates
eosterlund
parents:
46973
diff
changeset
|
100 |
}; |
22831
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
101 |
|
46993
dd0f91c85ffc
8186476: Generalize Atomic::add with templates
eosterlund
parents:
46973
diff
changeset
|
102 |
template<> |
dd0f91c85ffc
8186476: Generalize Atomic::add with templates
eosterlund
parents:
46973
diff
changeset
|
103 |
template<typename I, typename D> |
50029
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
104 |
inline D Atomic::PlatformAdd<4>::add_and_fetch(I add_value, D volatile* dest, |
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
105 |
atomic_memory_order order) const { |
47091
4cc46bb5057b
8186855: Multiple platforms broken after 8186476: Generalize Atomic::add with templates
glaubitz
parents:
46993
diff
changeset
|
106 |
STATIC_ASSERT(4 == sizeof(I)); |
4cc46bb5057b
8186855: Multiple platforms broken after 8186476: Generalize Atomic::add with templates
glaubitz
parents:
46993
diff
changeset
|
107 |
STATIC_ASSERT(4 == sizeof(D)); |
46993
dd0f91c85ffc
8186476: Generalize Atomic::add with templates
eosterlund
parents:
46973
diff
changeset
|
108 |
|
dd0f91c85ffc
8186476: Generalize Atomic::add with templates
eosterlund
parents:
46973
diff
changeset
|
109 |
D result; |
22831
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
110 |
|
50029
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
111 |
pre_membar(order); |
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
112 |
|
22831
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
113 |
__asm__ __volatile__ ( |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
114 |
"1: lwarx %0, 0, %2 \n" |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
115 |
" add %0, %0, %1 \n" |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
116 |
" stwcx. %0, 0, %2 \n" |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
117 |
" bne- 1b \n" |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
118 |
: /*%0*/"=&r" (result) |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
119 |
: /*%1*/"r" (add_value), /*%2*/"r" (dest) |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
120 |
: "cc", "memory" ); |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
121 |
|
50029
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
122 |
post_membar(order); |
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
123 |
|
46993
dd0f91c85ffc
8186476: Generalize Atomic::add with templates
eosterlund
parents:
46973
diff
changeset
|
124 |
return result; |
22831
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
125 |
} |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
126 |
|
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
127 |
|
46993
dd0f91c85ffc
8186476: Generalize Atomic::add with templates
eosterlund
parents:
46973
diff
changeset
|
128 |
template<> |
dd0f91c85ffc
8186476: Generalize Atomic::add with templates
eosterlund
parents:
46973
diff
changeset
|
129 |
template<typename I, typename D> |
50029
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
130 |
inline D Atomic::PlatformAdd<8>::add_and_fetch(I add_value, D volatile* dest, |
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
131 |
atomic_memory_order order) const { |
47091
4cc46bb5057b
8186855: Multiple platforms broken after 8186476: Generalize Atomic::add with templates
glaubitz
parents:
46993
diff
changeset
|
132 |
STATIC_ASSERT(8 == sizeof(I)); |
4cc46bb5057b
8186855: Multiple platforms broken after 8186476: Generalize Atomic::add with templates
glaubitz
parents:
46993
diff
changeset
|
133 |
STATIC_ASSERT(8 == sizeof(D)); |
22831
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
134 |
|
46993
dd0f91c85ffc
8186476: Generalize Atomic::add with templates
eosterlund
parents:
46973
diff
changeset
|
135 |
D result; |
22831
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
136 |
|
50029
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
137 |
pre_membar(order); |
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
138 |
|
22831
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
139 |
__asm__ __volatile__ ( |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
140 |
"1: ldarx %0, 0, %2 \n" |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
141 |
" add %0, %0, %1 \n" |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
142 |
" stdcx. %0, 0, %2 \n" |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
143 |
" bne- 1b \n" |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
144 |
: /*%0*/"=&r" (result) |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
145 |
: /*%1*/"r" (add_value), /*%2*/"r" (dest) |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
146 |
: "cc", "memory" ); |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
147 |
|
50029
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
148 |
post_membar(order); |
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
149 |
|
46993
dd0f91c85ffc
8186476: Generalize Atomic::add with templates
eosterlund
parents:
46973
diff
changeset
|
150 |
return result; |
22831
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
151 |
} |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
152 |
|
47578
09c41c4913d9
8187977: Generalize Atomic::xchg to use templates
eosterlund
parents:
47552
diff
changeset
|
153 |
template<> |
09c41c4913d9
8187977: Generalize Atomic::xchg to use templates
eosterlund
parents:
47552
diff
changeset
|
154 |
template<typename T> |
09c41c4913d9
8187977: Generalize Atomic::xchg to use templates
eosterlund
parents:
47552
diff
changeset
|
155 |
inline T Atomic::PlatformXchg<4>::operator()(T exchange_value, |
50029
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
156 |
T volatile* dest, |
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
157 |
atomic_memory_order order) const { |
47634
6a0c42c40cd1
8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents:
47593
diff
changeset
|
158 |
// Note that xchg doesn't necessarily do an acquire |
22831
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
159 |
// (see synchronizer.cpp). |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
160 |
|
47578
09c41c4913d9
8187977: Generalize Atomic::xchg to use templates
eosterlund
parents:
47552
diff
changeset
|
161 |
T old_value; |
22831
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
162 |
const uint64_t zero = 0; |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
163 |
|
50029
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
164 |
pre_membar(order); |
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
165 |
|
22831
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
166 |
__asm__ __volatile__ ( |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
167 |
/* atomic loop */ |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
168 |
"1: \n" |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
169 |
" lwarx %[old_value], %[dest], %[zero] \n" |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
170 |
" stwcx. %[exchange_value], %[dest], %[zero] \n" |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
171 |
" bne- 1b \n" |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
172 |
/* exit */ |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
173 |
"2: \n" |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
174 |
/* out */ |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
175 |
: [old_value] "=&r" (old_value), |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
176 |
"=m" (*dest) |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
177 |
/* in */ |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
178 |
: [dest] "b" (dest), |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
179 |
[zero] "r" (zero), |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
180 |
[exchange_value] "r" (exchange_value), |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
181 |
"m" (*dest) |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
182 |
/* clobber */ |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
183 |
: "cc", |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
184 |
"memory" |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
185 |
); |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
186 |
|
50029
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
187 |
post_membar(order); |
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
188 |
|
47578
09c41c4913d9
8187977: Generalize Atomic::xchg to use templates
eosterlund
parents:
47552
diff
changeset
|
189 |
return old_value; |
22831
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
190 |
} |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
191 |
|
47578
09c41c4913d9
8187977: Generalize Atomic::xchg to use templates
eosterlund
parents:
47552
diff
changeset
|
192 |
template<> |
09c41c4913d9
8187977: Generalize Atomic::xchg to use templates
eosterlund
parents:
47552
diff
changeset
|
193 |
template<typename T> |
09c41c4913d9
8187977: Generalize Atomic::xchg to use templates
eosterlund
parents:
47552
diff
changeset
|
194 |
inline T Atomic::PlatformXchg<8>::operator()(T exchange_value, |
50029
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
195 |
T volatile* dest, |
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
196 |
atomic_memory_order order) const { |
47578
09c41c4913d9
8187977: Generalize Atomic::xchg to use templates
eosterlund
parents:
47552
diff
changeset
|
197 |
STATIC_ASSERT(8 == sizeof(T)); |
47634
6a0c42c40cd1
8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents:
47593
diff
changeset
|
198 |
// Note that xchg doesn't necessarily do an acquire |
22831
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
199 |
// (see synchronizer.cpp). |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
200 |
|
47578
09c41c4913d9
8187977: Generalize Atomic::xchg to use templates
eosterlund
parents:
47552
diff
changeset
|
201 |
T old_value; |
22831
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
202 |
const uint64_t zero = 0; |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
203 |
|
50029
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
204 |
pre_membar(order); |
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
205 |
|
22831
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
206 |
__asm__ __volatile__ ( |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
207 |
/* atomic loop */ |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
208 |
"1: \n" |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
209 |
" ldarx %[old_value], %[dest], %[zero] \n" |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
210 |
" stdcx. %[exchange_value], %[dest], %[zero] \n" |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
211 |
" bne- 1b \n" |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
212 |
/* exit */ |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
213 |
"2: \n" |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
214 |
/* out */ |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
215 |
: [old_value] "=&r" (old_value), |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
216 |
"=m" (*dest) |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
217 |
/* in */ |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
218 |
: [dest] "b" (dest), |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
219 |
[zero] "r" (zero), |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
220 |
[exchange_value] "r" (exchange_value), |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
221 |
"m" (*dest) |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
222 |
/* clobber */ |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
223 |
: "cc", |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
224 |
"memory" |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
225 |
); |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
226 |
|
50029
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
227 |
post_membar(order); |
22831
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
228 |
|
50029
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
229 |
return old_value; |
39404 | 230 |
} |
231 |
||
46958
a13bd8c6b7a2
8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents:
46523
diff
changeset
|
232 |
template<> |
a13bd8c6b7a2
8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents:
46523
diff
changeset
|
233 |
template<typename T> |
a13bd8c6b7a2
8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents:
46523
diff
changeset
|
234 |
inline T Atomic::PlatformCmpxchg<1>::operator()(T exchange_value, |
a13bd8c6b7a2
8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents:
46523
diff
changeset
|
235 |
T volatile* dest, |
a13bd8c6b7a2
8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents:
46523
diff
changeset
|
236 |
T compare_value, |
50029
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
237 |
atomic_memory_order order) const { |
46973
149e5319c938
8186734: AIX build broken after 8186166: Generalize Atomic::cmpxchg with templates
mdoerr
parents:
46958
diff
changeset
|
238 |
STATIC_ASSERT(1 == sizeof(T)); |
35063
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
25715
diff
changeset
|
239 |
|
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
25715
diff
changeset
|
240 |
// Note that cmpxchg guarantees a two-way memory barrier across |
39404 | 241 |
// the cmpxchg, so it's really a a 'fence_cmpxchg_fence' if not |
242 |
// specified otherwise (see atomic.hpp). |
|
35063
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
25715
diff
changeset
|
243 |
|
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
25715
diff
changeset
|
244 |
// Using 32 bit internally. |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
25715
diff
changeset
|
245 |
volatile int *dest_base = (volatile int*)((uintptr_t)dest & ~3); |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
25715
diff
changeset
|
246 |
|
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
25715
diff
changeset
|
247 |
#ifdef VM_LITTLE_ENDIAN |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
25715
diff
changeset
|
248 |
const unsigned int shift_amount = ((uintptr_t)dest & 3) * 8; |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
25715
diff
changeset
|
249 |
#else |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
25715
diff
changeset
|
250 |
const unsigned int shift_amount = ((~(uintptr_t)dest) & 3) * 8; |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
25715
diff
changeset
|
251 |
#endif |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
25715
diff
changeset
|
252 |
const unsigned int masked_compare_val = ((unsigned int)(unsigned char)compare_value), |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
25715
diff
changeset
|
253 |
masked_exchange_val = ((unsigned int)(unsigned char)exchange_value), |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
25715
diff
changeset
|
254 |
xor_value = (masked_compare_val ^ masked_exchange_val) << shift_amount; |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
25715
diff
changeset
|
255 |
|
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
25715
diff
changeset
|
256 |
unsigned int old_value, value32; |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
25715
diff
changeset
|
257 |
|
50029
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
258 |
pre_membar(order); |
39404 | 259 |
|
35063
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
25715
diff
changeset
|
260 |
__asm__ __volatile__ ( |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
25715
diff
changeset
|
261 |
/* simple guard */ |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
25715
diff
changeset
|
262 |
" lbz %[old_value], 0(%[dest]) \n" |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
25715
diff
changeset
|
263 |
" cmpw %[masked_compare_val], %[old_value] \n" |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
25715
diff
changeset
|
264 |
" bne- 2f \n" |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
25715
diff
changeset
|
265 |
/* atomic loop */ |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
25715
diff
changeset
|
266 |
"1: \n" |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
25715
diff
changeset
|
267 |
" lwarx %[value32], 0, %[dest_base] \n" |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
25715
diff
changeset
|
268 |
/* extract byte and compare */ |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
25715
diff
changeset
|
269 |
" srd %[old_value], %[value32], %[shift_amount] \n" |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
25715
diff
changeset
|
270 |
" clrldi %[old_value], %[old_value], 56 \n" |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
25715
diff
changeset
|
271 |
" cmpw %[masked_compare_val], %[old_value] \n" |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
25715
diff
changeset
|
272 |
" bne- 2f \n" |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
25715
diff
changeset
|
273 |
/* replace byte and try to store */ |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
25715
diff
changeset
|
274 |
" xor %[value32], %[xor_value], %[value32] \n" |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
25715
diff
changeset
|
275 |
" stwcx. %[value32], 0, %[dest_base] \n" |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
25715
diff
changeset
|
276 |
" bne- 1b \n" |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
25715
diff
changeset
|
277 |
/* exit */ |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
25715
diff
changeset
|
278 |
"2: \n" |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
25715
diff
changeset
|
279 |
/* out */ |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
25715
diff
changeset
|
280 |
: [old_value] "=&r" (old_value), |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
25715
diff
changeset
|
281 |
[value32] "=&r" (value32), |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
25715
diff
changeset
|
282 |
"=m" (*dest), |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
25715
diff
changeset
|
283 |
"=m" (*dest_base) |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
25715
diff
changeset
|
284 |
/* in */ |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
25715
diff
changeset
|
285 |
: [dest] "b" (dest), |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
25715
diff
changeset
|
286 |
[dest_base] "b" (dest_base), |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
25715
diff
changeset
|
287 |
[shift_amount] "r" (shift_amount), |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
25715
diff
changeset
|
288 |
[masked_compare_val] "r" (masked_compare_val), |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
25715
diff
changeset
|
289 |
[xor_value] "r" (xor_value), |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
25715
diff
changeset
|
290 |
"m" (*dest), |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
25715
diff
changeset
|
291 |
"m" (*dest_base) |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
25715
diff
changeset
|
292 |
/* clobber */ |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
25715
diff
changeset
|
293 |
: "cc", |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
25715
diff
changeset
|
294 |
"memory" |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
25715
diff
changeset
|
295 |
); |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
25715
diff
changeset
|
296 |
|
50029
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
297 |
post_membar(order); |
39404 | 298 |
|
46958
a13bd8c6b7a2
8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents:
46523
diff
changeset
|
299 |
return PrimitiveConversions::cast<T>((unsigned char)old_value); |
35063
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
25715
diff
changeset
|
300 |
} |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
25715
diff
changeset
|
301 |
|
46958
a13bd8c6b7a2
8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents:
46523
diff
changeset
|
302 |
template<> |
a13bd8c6b7a2
8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents:
46523
diff
changeset
|
303 |
template<typename T> |
a13bd8c6b7a2
8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents:
46523
diff
changeset
|
304 |
inline T Atomic::PlatformCmpxchg<4>::operator()(T exchange_value, |
a13bd8c6b7a2
8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents:
46523
diff
changeset
|
305 |
T volatile* dest, |
a13bd8c6b7a2
8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents:
46523
diff
changeset
|
306 |
T compare_value, |
50029
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
307 |
atomic_memory_order order) const { |
46973
149e5319c938
8186734: AIX build broken after 8186166: Generalize Atomic::cmpxchg with templates
mdoerr
parents:
46958
diff
changeset
|
308 |
STATIC_ASSERT(4 == sizeof(T)); |
22831
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
309 |
|
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
310 |
// Note that cmpxchg guarantees a two-way memory barrier across |
39404 | 311 |
// the cmpxchg, so it's really a a 'fence_cmpxchg_fence' if not |
312 |
// specified otherwise (see atomic.hpp). |
|
22831
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
313 |
|
46958
a13bd8c6b7a2
8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents:
46523
diff
changeset
|
314 |
T old_value; |
22831
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
315 |
const uint64_t zero = 0; |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
316 |
|
50029
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
317 |
pre_membar(order); |
39404 | 318 |
|
22831
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
319 |
__asm__ __volatile__ ( |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
320 |
/* simple guard */ |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
321 |
" lwz %[old_value], 0(%[dest]) \n" |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
322 |
" cmpw %[compare_value], %[old_value] \n" |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
323 |
" bne- 2f \n" |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
324 |
/* atomic loop */ |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
325 |
"1: \n" |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
326 |
" lwarx %[old_value], %[dest], %[zero] \n" |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
327 |
" cmpw %[compare_value], %[old_value] \n" |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
328 |
" bne- 2f \n" |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
329 |
" stwcx. %[exchange_value], %[dest], %[zero] \n" |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
330 |
" bne- 1b \n" |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
331 |
/* exit */ |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
332 |
"2: \n" |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
333 |
/* out */ |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
334 |
: [old_value] "=&r" (old_value), |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
335 |
"=m" (*dest) |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
336 |
/* in */ |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
337 |
: [dest] "b" (dest), |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
338 |
[zero] "r" (zero), |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
339 |
[compare_value] "r" (compare_value), |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
340 |
[exchange_value] "r" (exchange_value), |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
341 |
"m" (*dest) |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
342 |
/* clobber */ |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
343 |
: "cc", |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
344 |
"memory" |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
345 |
); |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
346 |
|
50029
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
347 |
post_membar(order); |
39404 | 348 |
|
46958
a13bd8c6b7a2
8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents:
46523
diff
changeset
|
349 |
return old_value; |
22831
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
350 |
} |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
351 |
|
46958
a13bd8c6b7a2
8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents:
46523
diff
changeset
|
352 |
template<> |
a13bd8c6b7a2
8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents:
46523
diff
changeset
|
353 |
template<typename T> |
a13bd8c6b7a2
8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents:
46523
diff
changeset
|
354 |
inline T Atomic::PlatformCmpxchg<8>::operator()(T exchange_value, |
a13bd8c6b7a2
8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents:
46523
diff
changeset
|
355 |
T volatile* dest, |
a13bd8c6b7a2
8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents:
46523
diff
changeset
|
356 |
T compare_value, |
50029
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
357 |
atomic_memory_order order) const { |
46973
149e5319c938
8186734: AIX build broken after 8186166: Generalize Atomic::cmpxchg with templates
mdoerr
parents:
46958
diff
changeset
|
358 |
STATIC_ASSERT(8 == sizeof(T)); |
22831
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
359 |
|
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
360 |
// Note that cmpxchg guarantees a two-way memory barrier across |
39404 | 361 |
// the cmpxchg, so it's really a a 'fence_cmpxchg_fence' if not |
362 |
// specified otherwise (see atomic.hpp). |
|
22831
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
363 |
|
46958
a13bd8c6b7a2
8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents:
46523
diff
changeset
|
364 |
T old_value; |
22831
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
365 |
const uint64_t zero = 0; |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
366 |
|
50029
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
367 |
pre_membar(order); |
39404 | 368 |
|
22831
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
369 |
__asm__ __volatile__ ( |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
370 |
/* simple guard */ |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
371 |
" ld %[old_value], 0(%[dest]) \n" |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
372 |
" cmpd %[compare_value], %[old_value] \n" |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
373 |
" bne- 2f \n" |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
374 |
/* atomic loop */ |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
375 |
"1: \n" |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
376 |
" ldarx %[old_value], %[dest], %[zero] \n" |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
377 |
" cmpd %[compare_value], %[old_value] \n" |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
378 |
" bne- 2f \n" |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
379 |
" stdcx. %[exchange_value], %[dest], %[zero] \n" |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
380 |
" bne- 1b \n" |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
381 |
/* exit */ |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
382 |
"2: \n" |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
383 |
/* out */ |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
384 |
: [old_value] "=&r" (old_value), |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
385 |
"=m" (*dest) |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
386 |
/* in */ |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
387 |
: [dest] "b" (dest), |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
388 |
[zero] "r" (zero), |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
389 |
[compare_value] "r" (compare_value), |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
390 |
[exchange_value] "r" (exchange_value), |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
391 |
"m" (*dest) |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
392 |
/* clobber */ |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
393 |
: "cc", |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
394 |
"memory" |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
395 |
); |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
396 |
|
50029
ea0a16ba6ac0
8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents:
47634
diff
changeset
|
397 |
post_membar(order); |
39404 | 398 |
|
46958
a13bd8c6b7a2
8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents:
46523
diff
changeset
|
399 |
return old_value; |
22831
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
400 |
} |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
401 |
|
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
50029
diff
changeset
|
402 |
#endif // OS_CPU_AIX_PPC_ATOMIC_AIX_PPC_HPP |