Tue, 09 Oct 2012 10:09:34 -0700
7197424: update copyright year to match last edit in jdk8 hotspot repository
Summary: Update copyright year to 2012 for relevant files
Reviewed-by: dholmes, coleenp
duke@435 | 1 | /* |
stefank@2314 | 2 | * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. |
duke@435 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@435 | 4 | * |
duke@435 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@435 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@435 | 7 | * published by the Free Software Foundation. |
duke@435 | 8 | * |
duke@435 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@435 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@435 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@435 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@435 | 13 | * accompanied this code). |
duke@435 | 14 | * |
duke@435 | 15 | * You should have received a copy of the GNU General Public License version |
duke@435 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@435 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@435 | 18 | * |
trims@1907 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
trims@1907 | 20 | * or visit www.oracle.com if you need additional information or have any |
trims@1907 | 21 | * questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
stefank@2314 | 25 | #include "precompiled.hpp" |
stefank@2314 | 26 | #include "runtime/atomic.hpp" |
stefank@2314 | 27 | #ifdef TARGET_OS_FAMILY_linux |
stefank@2314 | 28 | # include "os_linux.inline.hpp" |
stefank@2314 | 29 | #endif |
stefank@2314 | 30 | #ifdef TARGET_OS_FAMILY_solaris |
stefank@2314 | 31 | # include "os_solaris.inline.hpp" |
stefank@2314 | 32 | #endif |
stefank@2314 | 33 | #ifdef TARGET_OS_FAMILY_windows |
stefank@2314 | 34 | # include "os_windows.inline.hpp" |
stefank@2314 | 35 | #endif |
never@3156 | 36 | #ifdef TARGET_OS_FAMILY_bsd |
never@3156 | 37 | # include "os_bsd.inline.hpp" |
never@3156 | 38 | #endif |
stefank@2314 | 39 | #ifdef TARGET_OS_ARCH_linux_x86 |
stefank@2314 | 40 | # include "atomic_linux_x86.inline.hpp" |
stefank@2314 | 41 | #endif |
stefank@2314 | 42 | #ifdef TARGET_OS_ARCH_linux_sparc |
stefank@2314 | 43 | # include "atomic_linux_sparc.inline.hpp" |
stefank@2314 | 44 | #endif |
stefank@2314 | 45 | #ifdef TARGET_OS_ARCH_linux_zero |
stefank@2314 | 46 | # include "atomic_linux_zero.inline.hpp" |
stefank@2314 | 47 | #endif |
stefank@2314 | 48 | #ifdef TARGET_OS_ARCH_solaris_x86 |
stefank@2314 | 49 | # include "atomic_solaris_x86.inline.hpp" |
stefank@2314 | 50 | #endif |
stefank@2314 | 51 | #ifdef TARGET_OS_ARCH_solaris_sparc |
stefank@2314 | 52 | # include "atomic_solaris_sparc.inline.hpp" |
stefank@2314 | 53 | #endif |
stefank@2314 | 54 | #ifdef TARGET_OS_ARCH_windows_x86 |
stefank@2314 | 55 | # include "atomic_windows_x86.inline.hpp" |
stefank@2314 | 56 | #endif |
jcoomes@2993 | 57 | #ifdef TARGET_OS_ARCH_linux_arm |
jcoomes@2993 | 58 | # include "atomic_linux_arm.inline.hpp" |
jcoomes@2993 | 59 | #endif |
jcoomes@2993 | 60 | #ifdef TARGET_OS_ARCH_linux_ppc |
jcoomes@2993 | 61 | # include "atomic_linux_ppc.inline.hpp" |
jcoomes@2993 | 62 | #endif |
never@3156 | 63 | #ifdef TARGET_OS_ARCH_bsd_x86 |
never@3156 | 64 | # include "atomic_bsd_x86.inline.hpp" |
never@3156 | 65 | #endif |
never@3156 | 66 | #ifdef TARGET_OS_ARCH_bsd_zero |
never@3156 | 67 | # include "atomic_bsd_zero.inline.hpp" |
never@3156 | 68 | #endif |
duke@435 | 69 | |
duke@435 | 70 | jbyte Atomic::cmpxchg(jbyte exchange_value, volatile jbyte* dest, jbyte compare_value) { |
duke@435 | 71 | assert(sizeof(jbyte) == 1, "assumption."); |
duke@435 | 72 | uintptr_t dest_addr = (uintptr_t)dest; |
duke@435 | 73 | uintptr_t offset = dest_addr % sizeof(jint); |
duke@435 | 74 | volatile jint* dest_int = (volatile jint*)(dest_addr - offset); |
duke@435 | 75 | jint cur = *dest_int; |
duke@435 | 76 | jbyte* cur_as_bytes = (jbyte*)(&cur); |
duke@435 | 77 | jint new_val = cur; |
duke@435 | 78 | jbyte* new_val_as_bytes = (jbyte*)(&new_val); |
duke@435 | 79 | new_val_as_bytes[offset] = exchange_value; |
duke@435 | 80 | while (cur_as_bytes[offset] == compare_value) { |
duke@435 | 81 | jint res = cmpxchg(new_val, dest_int, cur); |
duke@435 | 82 | if (res == cur) break; |
duke@435 | 83 | cur = res; |
duke@435 | 84 | new_val = cur; |
duke@435 | 85 | new_val_as_bytes[offset] = exchange_value; |
duke@435 | 86 | } |
duke@435 | 87 | return cur_as_bytes[offset]; |
duke@435 | 88 | } |
coleenp@548 | 89 | |
coleenp@548 | 90 | unsigned Atomic::xchg(unsigned int exchange_value, volatile unsigned int* dest) { |
coleenp@548 | 91 | assert(sizeof(unsigned int) == sizeof(jint), "more work to do"); |
coleenp@548 | 92 | return (unsigned int)Atomic::xchg((jint)exchange_value, (volatile jint*)dest); |
coleenp@548 | 93 | } |
coleenp@548 | 94 | |
coleenp@548 | 95 | unsigned Atomic::cmpxchg(unsigned int exchange_value, |
coleenp@548 | 96 | volatile unsigned int* dest, unsigned int compare_value) { |
coleenp@548 | 97 | assert(sizeof(unsigned int) == sizeof(jint), "more work to do"); |
coleenp@548 | 98 | return (unsigned int)Atomic::cmpxchg((jint)exchange_value, (volatile jint*)dest, |
coleenp@548 | 99 | (jint)compare_value); |
coleenp@548 | 100 | } |
minqi@2964 | 101 | |
minqi@2964 | 102 | jlong Atomic::add(jlong add_value, volatile jlong* dest) { |
minqi@2964 | 103 | jlong old = load(dest); |
minqi@2964 | 104 | jlong new_value = old + add_value; |
minqi@2964 | 105 | while (old != cmpxchg(new_value, dest, old)) { |
minqi@2964 | 106 | old = load(dest); |
minqi@2964 | 107 | new_value = old + add_value; |
minqi@2964 | 108 | } |
minqi@2964 | 109 | return old; |
minqi@2964 | 110 | } |