1 /*
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
3 * Copyright 2014 SAP AG. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
24 */
25
26 #ifndef SHARE_VM_RUNTIME_ORDERACCESS_INLINE_HPP
27 #define SHARE_VM_RUNTIME_ORDERACCESS_INLINE_HPP
28
29 #include "runtime/orderAccess.hpp"
30
31 // Linux
32 #ifdef TARGET_OS_ARCH_linux_x86
33 # include "orderAccess_linux_x86.inline.hpp"
34 #endif
35 #ifdef TARGET_OS_ARCH_linux_sparc
36 # include "orderAccess_linux_sparc.inline.hpp"
37 #endif
38 #ifdef TARGET_OS_ARCH_linux_zero
39 # include "orderAccess_linux_zero.inline.hpp"
40 #endif
41 #ifdef TARGET_OS_ARCH_linux_arm
42 # include "orderAccess_linux_arm.inline.hpp"
43 #endif
44 #ifdef TARGET_OS_ARCH_linux_ppc
45 # include "orderAccess_linux_ppc.inline.hpp"
46 #endif
47
48 // Solaris
53 # include "orderAccess_solaris_sparc.inline.hpp"
54 #endif
55
56 // Windows
57 #ifdef TARGET_OS_ARCH_windows_x86
58 # include "orderAccess_windows_x86.inline.hpp"
59 #endif
60
61 // AIX
62 #ifdef TARGET_OS_ARCH_aix_ppc
63 # include "orderAccess_aix_ppc.inline.hpp"
64 #endif
65
66 // BSD
67 #ifdef TARGET_OS_ARCH_bsd_x86
68 # include "orderAccess_bsd_x86.inline.hpp"
69 #endif
70 #ifdef TARGET_OS_ARCH_bsd_zero
71 # include "orderAccess_bsd_zero.inline.hpp"
72 #endif
73
74 #endif // SHARE_VM_RUNTIME_ORDERACCESS_INLINE_HPP
|
1 /*
2 * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
3 * Copyright 2014 SAP AG. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
24 */
25
26 #ifndef SHARE_VM_RUNTIME_ORDERACCESS_INLINE_HPP
27 #define SHARE_VM_RUNTIME_ORDERACCESS_INLINE_HPP
28
29 #include "runtime/atomic.inline.hpp"
30 #include "runtime/orderAccess.hpp"
31
32 // Linux
33 #ifdef TARGET_OS_ARCH_linux_x86
34 # include "orderAccess_linux_x86.inline.hpp"
35 #endif
36 #ifdef TARGET_OS_ARCH_linux_sparc
37 # include "orderAccess_linux_sparc.inline.hpp"
38 #endif
39 #ifdef TARGET_OS_ARCH_linux_zero
40 # include "orderAccess_linux_zero.inline.hpp"
41 #endif
42 #ifdef TARGET_OS_ARCH_linux_arm
43 # include "orderAccess_linux_arm.inline.hpp"
44 #endif
45 #ifdef TARGET_OS_ARCH_linux_ppc
46 # include "orderAccess_linux_ppc.inline.hpp"
47 #endif
48
49 // Solaris
54 # include "orderAccess_solaris_sparc.inline.hpp"
55 #endif
56
57 // Windows
58 #ifdef TARGET_OS_ARCH_windows_x86
59 # include "orderAccess_windows_x86.inline.hpp"
60 #endif
61
62 // AIX
63 #ifdef TARGET_OS_ARCH_aix_ppc
64 # include "orderAccess_aix_ppc.inline.hpp"
65 #endif
66
67 // BSD
68 #ifdef TARGET_OS_ARCH_bsd_x86
69 # include "orderAccess_bsd_x86.inline.hpp"
70 #endif
71 #ifdef TARGET_OS_ARCH_bsd_zero
72 # include "orderAccess_bsd_zero.inline.hpp"
73 #endif
74
75 #ifdef VM_HAS_GENERALIZED_ORDER_ACCESS
76
77 template<> inline void ScopedFenceGeneral<X_ACQUIRE>::postfix() { OrderAccess::acquire(); }
78 template<> inline void ScopedFenceGeneral<RELEASE_X>::prefix() { OrderAccess::release(); }
79 template<> inline void ScopedFenceGeneral<RELEASE_X_FENCE>::prefix() { OrderAccess::release(); }
80 template<> inline void ScopedFenceGeneral<RELEASE_X_FENCE>::postfix() { OrderAccess::fence(); }
81
82
83 template <typename FieldType, ScopedFenceType FenceType>
84 inline void OrderAccess::ordered_store(volatile FieldType* p, FieldType v) {
85 ScopedFence<FenceType> f((void*)p);
86 store(p, v);
87 }
88
89 template <typename FieldType, ScopedFenceType FenceType>
90 inline FieldType OrderAccess::ordered_load(volatile FieldType* p) {
91 ScopedFence<FenceType> f((void*)p);
92 return load(p);
93 }
94
95 inline jbyte OrderAccess::load_acquire(volatile jbyte* p) { return specialized_load_acquire(p); }
96 inline jshort OrderAccess::load_acquire(volatile jshort* p) { return specialized_load_acquire(p); }
97 inline jint OrderAccess::load_acquire(volatile jint* p) { return specialized_load_acquire(p); }
98 inline jlong OrderAccess::load_acquire(volatile jlong* p) { return specialized_load_acquire(p); }
99 inline jfloat OrderAccess::load_acquire(volatile jfloat* p) { return specialized_load_acquire(p); }
100 inline jdouble OrderAccess::load_acquire(volatile jdouble* p) { return specialized_load_acquire(p); }
101 inline jubyte OrderAccess::load_acquire(volatile jubyte* p) { return (jubyte) specialized_load_acquire((volatile jbyte*)p); }
102 inline jushort OrderAccess::load_acquire(volatile jushort* p) { return (jushort)specialized_load_acquire((volatile jshort*)p); }
103 inline juint OrderAccess::load_acquire(volatile juint* p) { return (juint) specialized_load_acquire((volatile jint*)p); }
104 inline julong OrderAccess::load_acquire(volatile julong* p) { return (julong) specialized_load_acquire((volatile jlong*)p); }
105
106 inline intptr_t OrderAccess::load_ptr_acquire(volatile intptr_t* p) { return (intptr_t)specialized_load_acquire(p); }
107 inline void* OrderAccess::load_ptr_acquire(volatile void* p) { return (void*)specialized_load_acquire((volatile intptr_t*)p); }
108 inline void* OrderAccess::load_ptr_acquire(const volatile void* p) { return (void*)specialized_load_acquire((volatile intptr_t*)p); }
109
110 inline void OrderAccess::release_store(volatile jbyte* p, jbyte v) { specialized_release_store(p, v); }
111 inline void OrderAccess::release_store(volatile jshort* p, jshort v) { specialized_release_store(p, v); }
112 inline void OrderAccess::release_store(volatile jint* p, jint v) { specialized_release_store(p, v); }
113 inline void OrderAccess::release_store(volatile jlong* p, jlong v) { specialized_release_store(p, v); }
114 inline void OrderAccess::release_store(volatile jfloat* p, jfloat v) { specialized_release_store(p, v); }
115 inline void OrderAccess::release_store(volatile jdouble* p, jdouble v) { specialized_release_store(p, v); }
116 inline void OrderAccess::release_store(volatile jubyte* p, jubyte v) { specialized_release_store((volatile jbyte*) p, (jbyte) v); }
117 inline void OrderAccess::release_store(volatile jushort* p, jushort v) { specialized_release_store((volatile jshort*)p, (jshort)v); }
118 inline void OrderAccess::release_store(volatile juint* p, juint v) { specialized_release_store((volatile jint*) p, (jint) v); }
119 inline void OrderAccess::release_store(volatile julong* p, julong v) { specialized_release_store((volatile jlong*) p, (jlong) v); }
120
121 inline void OrderAccess::release_store_ptr(volatile intptr_t* p, intptr_t v) { specialized_release_store(p, v); }
122 inline void OrderAccess::release_store_ptr(volatile void* p, void* v) { specialized_release_store((volatile intptr_t*)p, (intptr_t)v); }
123
124 inline void OrderAccess::release_store_fence(volatile jbyte* p, jbyte v) { specialized_release_store_fence(p, v); }
125 inline void OrderAccess::release_store_fence(volatile jshort* p, jshort v) { specialized_release_store_fence(p, v); }
126 inline void OrderAccess::release_store_fence(volatile jint* p, jint v) { specialized_release_store_fence(p, v); }
127 inline void OrderAccess::release_store_fence(volatile jlong* p, jlong v) { specialized_release_store_fence(p, v); }
128 inline void OrderAccess::release_store_fence(volatile jfloat* p, jfloat v) { specialized_release_store_fence(p, v); }
129 inline void OrderAccess::release_store_fence(volatile jdouble* p, jdouble v) { specialized_release_store_fence(p, v); }
130 inline void OrderAccess::release_store_fence(volatile jubyte* p, jubyte v) { specialized_release_store_fence((volatile jbyte*) p, (jbyte) v); }
131 inline void OrderAccess::release_store_fence(volatile jushort* p, jushort v) { specialized_release_store_fence((volatile jshort*)p, (jshort)v); }
132 inline void OrderAccess::release_store_fence(volatile juint* p, juint v) { specialized_release_store_fence((volatile jint*) p, (jint) v); }
133 inline void OrderAccess::release_store_fence(volatile julong* p, julong v) { specialized_release_store_fence((volatile jlong*) p, (jlong) v); }
134
135 inline void OrderAccess::release_store_ptr_fence(volatile intptr_t* p, intptr_t v) { specialized_release_store_fence(p, v); }
136 inline void OrderAccess::release_store_ptr_fence(volatile void* p, void* v) { specialized_release_store_fence((volatile intptr_t*)p, (intptr_t)v); }
137
138 // The following methods can be specialized using simple template specialization
139 // in the platform specific files for optimization purposes. Otherwise the
140 // generalized variant is used.
141 template<typename T> inline T OrderAccess::specialized_load_acquire (volatile T* p) { return ordered_load<T, X_ACQUIRE>(p); }
142 template<typename T> inline void OrderAccess::specialized_release_store (volatile T* p, T v) { ordered_store<T, RELEASE_X>(p, v); }
143 template<typename T> inline void OrderAccess::specialized_release_store_fence(volatile T* p, T v) { ordered_store<T, RELEASE_X_FENCE>(p, v); }
144
145 // Generalized atomic volatile accesses valid in OrderAccess
146 // All other types can be expressed in terms of these.
147 inline void OrderAccess::store(volatile jbyte* p, jbyte v) { *p = v; }
148 inline void OrderAccess::store(volatile jshort* p, jshort v) { *p = v; }
149 inline void OrderAccess::store(volatile jint* p, jint v) { *p = v; }
150 inline void OrderAccess::store(volatile jlong* p, jlong v) { Atomic::store(v, p); }
151 inline void OrderAccess::store(volatile jdouble* p, jdouble v) { Atomic::store(jlong_cast(v), (volatile jlong*)p); }
152 inline void OrderAccess::store(volatile jfloat* p, jfloat v) { *p = v; }
153
154 inline jbyte OrderAccess::load(volatile jbyte* p) { return *p; }
155 inline jshort OrderAccess::load(volatile jshort* p) { return *p; }
156 inline jint OrderAccess::load(volatile jint* p) { return *p; }
157 inline jlong OrderAccess::load(volatile jlong* p) { return Atomic::load(p); }
158 inline jdouble OrderAccess::load(volatile jdouble* p) { return jdouble_cast(Atomic::load((volatile jlong*)p)); }
159 inline jfloat OrderAccess::load(volatile jfloat* p) { return *p; }
160
161 #endif // VM_HAS_GENERALIZED_ORDER_ACCESS
162
163 #endif // SHARE_VM_RUNTIME_ORDERACCESS_INLINE_HPP
|