1 /*
2 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
56 if (os::is_MP()) {
57 // always use locked addl since mfence is sometimes expensive
58 #ifdef AMD64
59 __asm__ volatile ("lock; addl $0,0(%%rsp)" : : : "cc", "memory");
60 #else
61 __asm__ volatile ("lock; addl $0,0(%%esp)" : : : "cc", "memory");
62 #endif
63 }
64 }
65
66 inline jbyte OrderAccess::load_acquire(volatile jbyte* p) { return *p; }
67 inline jshort OrderAccess::load_acquire(volatile jshort* p) { return *p; }
68 inline jint OrderAccess::load_acquire(volatile jint* p) { return *p; }
69 inline jlong OrderAccess::load_acquire(volatile jlong* p) { return Atomic::load(p); }
70 inline jubyte OrderAccess::load_acquire(volatile jubyte* p) { return *p; }
71 inline jushort OrderAccess::load_acquire(volatile jushort* p) { return *p; }
72 inline juint OrderAccess::load_acquire(volatile juint* p) { return *p; }
73 inline julong OrderAccess::load_acquire(volatile julong* p) { return Atomic::load((volatile jlong*)p); }
74 inline jfloat OrderAccess::load_acquire(volatile jfloat* p) { return *p; }
75 inline jdouble OrderAccess::load_acquire(volatile jdouble* p) { return jdouble_cast(Atomic::load((volatile jlong*)p)); }
76
77 inline intptr_t OrderAccess::load_ptr_acquire(volatile intptr_t* p) { return *p; }
78 inline void* OrderAccess::load_ptr_acquire(volatile void* p) { return *(void* volatile *)p; }
79 inline void* OrderAccess::load_ptr_acquire(const volatile void* p) { return *(void* const volatile *)p; }
80
81 inline void OrderAccess::release_store(volatile jbyte* p, jbyte v) { *p = v; }
82 inline void OrderAccess::release_store(volatile jshort* p, jshort v) { *p = v; }
83 inline void OrderAccess::release_store(volatile jint* p, jint v) { *p = v; }
84 inline void OrderAccess::release_store(volatile jlong* p, jlong v) { Atomic::store(v, p); }
85 inline void OrderAccess::release_store(volatile jubyte* p, jubyte v) { *p = v; }
86 inline void OrderAccess::release_store(volatile jushort* p, jushort v) { *p = v; }
87 inline void OrderAccess::release_store(volatile juint* p, juint v) { *p = v; }
88 inline void OrderAccess::release_store(volatile julong* p, julong v) { Atomic::store((jlong)v, (volatile jlong*)p); }
89 inline void OrderAccess::release_store(volatile jfloat* p, jfloat v) { *p = v; }
90 inline void OrderAccess::release_store(volatile jdouble* p, jdouble v) { release_store((volatile jlong *)p, jlong_cast(v)); }
91
92 inline void OrderAccess::release_store_ptr(volatile intptr_t* p, intptr_t v) { *p = v; }
93 inline void OrderAccess::release_store_ptr(volatile void* p, void* v) { *(void* volatile *)p = v; }
94
95 inline void OrderAccess::store_fence(jbyte* p, jbyte v) {
96 __asm__ volatile ( "xchgb (%2),%0"
97 : "=q" (v)
|
1 /*
2 * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
56 if (os::is_MP()) {
57 // always use locked addl since mfence is sometimes expensive
58 #ifdef AMD64
59 __asm__ volatile ("lock; addl $0,0(%%rsp)" : : : "cc", "memory");
60 #else
61 __asm__ volatile ("lock; addl $0,0(%%esp)" : : : "cc", "memory");
62 #endif
63 }
64 }
65
66 inline jbyte OrderAccess::load_acquire(volatile jbyte* p) { return *p; }
67 inline jshort OrderAccess::load_acquire(volatile jshort* p) { return *p; }
68 inline jint OrderAccess::load_acquire(volatile jint* p) { return *p; }
69 inline jlong OrderAccess::load_acquire(volatile jlong* p) { return Atomic::load(p); }
70 inline jubyte OrderAccess::load_acquire(volatile jubyte* p) { return *p; }
71 inline jushort OrderAccess::load_acquire(volatile jushort* p) { return *p; }
72 inline juint OrderAccess::load_acquire(volatile juint* p) { return *p; }
73 inline julong OrderAccess::load_acquire(volatile julong* p) { return Atomic::load((volatile jlong*)p); }
74 inline jfloat OrderAccess::load_acquire(volatile jfloat* p) { return *p; }
75 inline jdouble OrderAccess::load_acquire(volatile jdouble* p) { return jdouble_cast(Atomic::load((volatile jlong*)p)); }
76 inline bool OrderAccess::load_acquire(const volatile bool* p) {
77 assert(EnableJFR, "sanity check");
78 return *p;
79 }
80 inline julong OrderAccess::load_acquire(const volatile julong* p) {
81 assert(EnableJFR, "sanity check");
82 return Atomic::load((volatile jlong*)p);
83 }
84
85 inline intptr_t OrderAccess::load_ptr_acquire(volatile intptr_t* p) { return *p; }
86 inline uintptr_t OrderAccess::load_ptr_acquire(const volatile uintptr_t* p) {
87 assert(EnableJFR, "sanity check");
88 return *p;
89 }
90
91 inline void* OrderAccess::load_ptr_acquire(volatile void* p) { return *(void* volatile *)p; }
92 inline void* OrderAccess::load_ptr_acquire(const volatile void* p) { return *(void* const volatile *)p; }
93
94 inline void OrderAccess::release_store(volatile jbyte* p, jbyte v) { *p = v; }
95 inline void OrderAccess::release_store(volatile jshort* p, jshort v) { *p = v; }
96 inline void OrderAccess::release_store(volatile jint* p, jint v) { *p = v; }
97 inline void OrderAccess::release_store(volatile jlong* p, jlong v) { Atomic::store(v, p); }
98 inline void OrderAccess::release_store(volatile jubyte* p, jubyte v) { *p = v; }
99 inline void OrderAccess::release_store(volatile jushort* p, jushort v) { *p = v; }
100 inline void OrderAccess::release_store(volatile juint* p, juint v) { *p = v; }
101 inline void OrderAccess::release_store(volatile julong* p, julong v) { Atomic::store((jlong)v, (volatile jlong*)p); }
102 inline void OrderAccess::release_store(volatile jfloat* p, jfloat v) { *p = v; }
103 inline void OrderAccess::release_store(volatile jdouble* p, jdouble v) { release_store((volatile jlong *)p, jlong_cast(v)); }
104
105 inline void OrderAccess::release_store_ptr(volatile intptr_t* p, intptr_t v) { *p = v; }
106 inline void OrderAccess::release_store_ptr(volatile void* p, void* v) { *(void* volatile *)p = v; }
107
108 inline void OrderAccess::store_fence(jbyte* p, jbyte v) {
109 __asm__ volatile ( "xchgb (%2),%0"
110 : "=q" (v)
|