annotate src/os_cpu/windows_x86/vm/orderAccess_windows_x86.inline.hpp @ 0:a61af66fc99e

Initial load
author duke
date Sat, 01 Dec 2007 00:00:00 +0000
parents
children d0994e5bebce
rev   line source
duke@0 1 /*
duke@0 2 * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved.
duke@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@0 4 *
duke@0 5 * This code is free software; you can redistribute it and/or modify it
duke@0 6 * under the terms of the GNU General Public License version 2 only, as
duke@0 7 * published by the Free Software Foundation.
duke@0 8 *
duke@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@0 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@0 13 * accompanied this code).
duke@0 14 *
duke@0 15 * You should have received a copy of the GNU General Public License version
duke@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@0 18 *
duke@0 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@0 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@0 21 * have any questions.
duke@0 22 *
duke@0 23 */
duke@0 24
duke@0 25 #pragma warning(disable: 4035) // Disables warnings reporting missing return statement
duke@0 26
duke@0 27 // Implementation of class OrderAccess.
duke@0 28
duke@0 29 inline void OrderAccess::loadload() { acquire(); }
duke@0 30 inline void OrderAccess::storestore() { release(); }
duke@0 31 inline void OrderAccess::loadstore() { acquire(); }
duke@0 32 inline void OrderAccess::storeload() { fence(); }
duke@0 33
duke@0 34 inline void OrderAccess::acquire() {
duke@0 35 #ifndef AMD64
duke@0 36 __asm {
duke@0 37 mov eax, dword ptr [esp];
duke@0 38 }
duke@0 39 #endif // !AMD64
duke@0 40 }
duke@0 41
duke@0 42 inline void OrderAccess::release() {
duke@0 43 // A volatile store has release semantics.
duke@0 44 dummy = 0;
duke@0 45 }
duke@0 46
duke@0 47 inline void OrderAccess::fence() {
duke@0 48 #ifdef AMD64
duke@0 49 (*os::fence_func)();
duke@0 50 #else
duke@0 51 if (os::is_MP()) {
duke@0 52 __asm {
duke@0 53 lock add dword ptr [esp], 0;
duke@0 54 }
duke@0 55 }
duke@0 56 #endif // AMD64
duke@0 57 }
duke@0 58
duke@0 59 inline jbyte OrderAccess::load_acquire(volatile jbyte* p) { return *p; }
duke@0 60 inline jshort OrderAccess::load_acquire(volatile jshort* p) { return *p; }
duke@0 61 inline jint OrderAccess::load_acquire(volatile jint* p) { return *p; }
duke@0 62 inline jlong OrderAccess::load_acquire(volatile jlong* p) { return *p; }
duke@0 63 inline jubyte OrderAccess::load_acquire(volatile jubyte* p) { return *p; }
duke@0 64 inline jushort OrderAccess::load_acquire(volatile jushort* p) { return *p; }
duke@0 65 inline juint OrderAccess::load_acquire(volatile juint* p) { return *p; }
duke@0 66 inline julong OrderAccess::load_acquire(volatile julong* p) { return *p; }
duke@0 67 inline jfloat OrderAccess::load_acquire(volatile jfloat* p) { return *p; }
duke@0 68 inline jdouble OrderAccess::load_acquire(volatile jdouble* p) { return *p; }
duke@0 69
duke@0 70 inline intptr_t OrderAccess::load_ptr_acquire(volatile intptr_t* p) { return *p; }
duke@0 71 inline void* OrderAccess::load_ptr_acquire(volatile void* p) { return *(void* volatile *)p; }
duke@0 72 inline void* OrderAccess::load_ptr_acquire(const volatile void* p) { return *(void* const volatile *)p; }
duke@0 73
duke@0 74 inline void OrderAccess::release_store(volatile jbyte* p, jbyte v) { *p = v; }
duke@0 75 inline void OrderAccess::release_store(volatile jshort* p, jshort v) { *p = v; }
duke@0 76 inline void OrderAccess::release_store(volatile jint* p, jint v) { *p = v; }
duke@0 77 inline void OrderAccess::release_store(volatile jlong* p, jlong v) { *p = v; }
duke@0 78 inline void OrderAccess::release_store(volatile jubyte* p, jubyte v) { *p = v; }
duke@0 79 inline void OrderAccess::release_store(volatile jushort* p, jushort v) { *p = v; }
duke@0 80 inline void OrderAccess::release_store(volatile juint* p, juint v) { *p = v; }
duke@0 81 inline void OrderAccess::release_store(volatile julong* p, julong v) { *p = v; }
duke@0 82 inline void OrderAccess::release_store(volatile jfloat* p, jfloat v) { *p = v; }
duke@0 83 inline void OrderAccess::release_store(volatile jdouble* p, jdouble v) { *p = v; }
duke@0 84
duke@0 85 inline void OrderAccess::release_store_ptr(volatile intptr_t* p, intptr_t v) { *p = v; }
duke@0 86 inline void OrderAccess::release_store_ptr(volatile void* p, void* v) { *(void* volatile *)p = v; }
duke@0 87
duke@0 88 inline void OrderAccess::store_fence(jbyte* p, jbyte v) {
duke@0 89 #ifdef AMD64
duke@0 90 *p = v; fence();
duke@0 91 #else
duke@0 92 __asm {
duke@0 93 mov edx, p;
duke@0 94 mov al, v;
duke@0 95 xchg al, byte ptr [edx];
duke@0 96 }
duke@0 97 #endif // AMD64
duke@0 98 }
duke@0 99
duke@0 100 inline void OrderAccess::store_fence(jshort* p, jshort v) {
duke@0 101 #ifdef AMD64
duke@0 102 *p = v; fence();
duke@0 103 #else
duke@0 104 __asm {
duke@0 105 mov edx, p;
duke@0 106 mov ax, v;
duke@0 107 xchg ax, word ptr [edx];
duke@0 108 }
duke@0 109 #endif // AMD64
duke@0 110 }
duke@0 111
duke@0 112 inline void OrderAccess::store_fence(jint* p, jint v) {
duke@0 113 #ifdef AMD64
duke@0 114 *p = v; fence();
duke@0 115 #else
duke@0 116 __asm {
duke@0 117 mov edx, p;
duke@0 118 mov eax, v;
duke@0 119 xchg eax, dword ptr [edx];
duke@0 120 }
duke@0 121 #endif // AMD64
duke@0 122 }
duke@0 123
duke@0 124 inline void OrderAccess::store_fence(jlong* p, jlong v) { *p = v; fence(); }
duke@0 125 inline void OrderAccess::store_fence(jubyte* p, jubyte v) { store_fence((jbyte*)p, (jbyte)v); }
duke@0 126 inline void OrderAccess::store_fence(jushort* p, jushort v) { store_fence((jshort*)p, (jshort)v); }
duke@0 127 inline void OrderAccess::store_fence(juint* p, juint v) { store_fence((jint*)p, (jint)v); }
duke@0 128 inline void OrderAccess::store_fence(julong* p, julong v) { store_fence((jlong*)p, (jlong)v); }
duke@0 129 inline void OrderAccess::store_fence(jfloat* p, jfloat v) { *p = v; fence(); }
duke@0 130 inline void OrderAccess::store_fence(jdouble* p, jdouble v) { *p = v; fence(); }
duke@0 131
duke@0 132 inline void OrderAccess::store_ptr_fence(intptr_t* p, intptr_t v) {
duke@0 133 #ifdef AMD64
duke@0 134 *p = v; fence();
duke@0 135 #else
duke@0 136 store_fence((jint*)p, (jint)v);
duke@0 137 #endif // AMD64
duke@0 138 }
duke@0 139
duke@0 140 inline void OrderAccess::store_ptr_fence(void** p, void* v) {
duke@0 141 #ifdef AMD64
duke@0 142 *p = v; fence();
duke@0 143 #else
duke@0 144 store_fence((jint*)p, (jint)v);
duke@0 145 #endif // AMD64
duke@0 146 }
duke@0 147
duke@0 148 // Must duplicate definitions instead of calling store_fence because we don't want to cast away volatile.
duke@0 149 inline void OrderAccess::release_store_fence(volatile jbyte* p, jbyte v) {
duke@0 150 #ifdef AMD64
duke@0 151 *p = v; fence();
duke@0 152 #else
duke@0 153 __asm {
duke@0 154 mov edx, p;
duke@0 155 mov al, v;
duke@0 156 xchg al, byte ptr [edx];
duke@0 157 }
duke@0 158 #endif // AMD64
duke@0 159 }
duke@0 160
duke@0 161 inline void OrderAccess::release_store_fence(volatile jshort* p, jshort v) {
duke@0 162 #ifdef AMD64
duke@0 163 *p = v; fence();
duke@0 164 #else
duke@0 165 __asm {
duke@0 166 mov edx, p;
duke@0 167 mov ax, v;
duke@0 168 xchg ax, word ptr [edx];
duke@0 169 }
duke@0 170 #endif // AMD64
duke@0 171 }
duke@0 172
duke@0 173 inline void OrderAccess::release_store_fence(volatile jint* p, jint v) {
duke@0 174 #ifdef AMD64
duke@0 175 *p = v; fence();
duke@0 176 #else
duke@0 177 __asm {
duke@0 178 mov edx, p;
duke@0 179 mov eax, v;
duke@0 180 xchg eax, dword ptr [edx];
duke@0 181 }
duke@0 182 #endif // AMD64
duke@0 183 }
duke@0 184
duke@0 185 inline void OrderAccess::release_store_fence(volatile jlong* p, jlong v) { *p = v; fence(); }
duke@0 186
duke@0 187 inline void OrderAccess::release_store_fence(volatile jubyte* p, jubyte v) { release_store_fence((volatile jbyte*)p, (jbyte)v); }
duke@0 188 inline void OrderAccess::release_store_fence(volatile jushort* p, jushort v) { release_store_fence((volatile jshort*)p, (jshort)v); }
duke@0 189 inline void OrderAccess::release_store_fence(volatile juint* p, juint v) { release_store_fence((volatile jint*)p, (jint)v); }
duke@0 190 inline void OrderAccess::release_store_fence(volatile julong* p, julong v) { release_store_fence((volatile jlong*)p, (jlong)v); }
duke@0 191 inline void OrderAccess::release_store_fence(volatile jfloat* p, jfloat v) { *p = v; fence(); }
duke@0 192 inline void OrderAccess::release_store_fence(volatile jdouble* p, jdouble v) { *p = v; fence(); }
duke@0 193
duke@0 194 inline void OrderAccess::release_store_ptr_fence(volatile intptr_t* p, intptr_t v) {
duke@0 195 #ifdef AMD64
duke@0 196 *p = v; fence();
duke@0 197 #else
duke@0 198 release_store_fence((volatile jint*)p, (jint)v);
duke@0 199 #endif // AMD64
duke@0 200 }
duke@0 201
duke@0 202 inline void OrderAccess::release_store_ptr_fence(volatile void* p, void* v) {
duke@0 203 #ifdef AMD64
duke@0 204 *(void* volatile *)p = v; fence();
duke@0 205 #else
duke@0 206 release_store_fence((volatile jint*)p, (jint)v);
duke@0 207 #endif // AMD64
duke@0 208 }
duke@0 209
duke@0 210 #pragma warning(default: 4035) // Enables warnings reporting missing return statement