1 /* 2 * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. 3 * Copyright (c) 2014, 2016 SAP SE. 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 #include "utilities/macros.hpp" 31 32 #include OS_CPU_HEADER_INLINE(orderAccess) 33 34 template<> inline void ScopedFenceGeneral<X_ACQUIRE>::postfix() { OrderAccess::acquire(); } 35 template<> inline void ScopedFenceGeneral<RELEASE_X>::prefix() { OrderAccess::release(); } 36 template<> inline void ScopedFenceGeneral<RELEASE_X_FENCE>::prefix() { OrderAccess::release(); } 37 template<> inline void ScopedFenceGeneral<RELEASE_X_FENCE>::postfix() { OrderAccess::fence(); } 38 39 40 template <typename FieldType, ScopedFenceType FenceType> 41 inline void OrderAccess::ordered_store(volatile FieldType* p, FieldType v) { 42 ScopedFence<FenceType> f((void*)p); 43 Atomic::store(v, p); 44 } 45 46 template <typename FieldType, ScopedFenceType FenceType> 47 inline FieldType OrderAccess::ordered_load(const volatile FieldType* p) { 48 ScopedFence<FenceType> f((void*)p); 49 return Atomic::load(p); 50 } 51 52 template <typename T> 53 inline T OrderAccess::load_acquire(const volatile T* p) { 54 return LoadImpl<T, PlatformOrderedLoad<sizeof(T), X_ACQUIRE> >()(p); 55 } 56 57 template <typename T, typename D> 58 inline void OrderAccess::release_store(volatile D* p, T v) { 59 StoreImpl<T, D, PlatformOrderedStore<sizeof(D), RELEASE_X> >()(v, p); 60 } 61 62 template <typename T, typename D> 63 inline void OrderAccess::release_store_fence(volatile D* p, T v) { 64 StoreImpl<T, D, PlatformOrderedStore<sizeof(D), RELEASE_X_FENCE> >()(v, p); 65 } 66 #endif // SHARE_VM_RUNTIME_ORDERACCESS_INLINE_HPP