hotspot/src/os_cpu/linux_sparc/vm/atomic_linux_sparc.inline.hpp
author sherman
Mon, 24 May 2010 16:41:03 -0400
changeset 5621 9e3da62f30aa
parent 670 ddf3e9583f2f
child 5547 f4b087cbb361
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
380
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
     1
/*
670
ddf3e9583f2f 6719955: Update copyright year
xdono
parents: 380
diff changeset
     2
 * Copyright 1999-2008 Sun Microsystems, Inc.  All Rights Reserved.
380
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
     4
 *
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
     7
 * published by the Free Software Foundation.
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
     8
 *
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    13
 * accompanied this code).
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    14
 *
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    18
 *
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    21
 * have any questions.
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    22
 *
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    23
 */
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    24
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    25
// Implementation of class atomic
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    26
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    27
inline void Atomic::store    (jbyte    store_value, jbyte*    dest) { *dest = store_value; }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    28
inline void Atomic::store    (jshort   store_value, jshort*   dest) { *dest = store_value; }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    29
inline void Atomic::store    (jint     store_value, jint*     dest) { *dest = store_value; }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    30
inline void Atomic::store    (jlong    store_value, jlong*    dest) { *dest = store_value; }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    31
inline void Atomic::store_ptr(intptr_t store_value, intptr_t* dest) { *dest = store_value; }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    32
inline void Atomic::store_ptr(void*    store_value, void*     dest) { *(void**)dest = store_value; }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    33
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    34
inline void Atomic::store    (jbyte    store_value, volatile jbyte*    dest) { *dest = store_value; }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    35
inline void Atomic::store    (jshort   store_value, volatile jshort*   dest) { *dest = store_value; }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    36
inline void Atomic::store    (jint     store_value, volatile jint*     dest) { *dest = store_value; }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    37
inline void Atomic::store    (jlong    store_value, volatile jlong*    dest) { *dest = store_value; }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    38
inline void Atomic::store_ptr(intptr_t store_value, volatile intptr_t* dest) { *dest = store_value; }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    39
inline void Atomic::store_ptr(void*    store_value, volatile void*     dest) { *(void* volatile *)dest = store_value; }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    40
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    41
inline void Atomic::inc    (volatile jint*     dest) { (void)add    (1, dest); }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    42
inline void Atomic::inc_ptr(volatile intptr_t* dest) { (void)add_ptr(1, dest); }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    43
inline void Atomic::inc_ptr(volatile void*     dest) { (void)add_ptr(1, dest); }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    44
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    45
inline void Atomic::dec    (volatile jint*     dest) { (void)add    (-1, dest); }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    46
inline void Atomic::dec_ptr(volatile intptr_t* dest) { (void)add_ptr(-1, dest); }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    47
inline void Atomic::dec_ptr(volatile void*     dest) { (void)add_ptr(-1, dest); }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    48
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    49
inline jint     Atomic::add    (jint     add_value, volatile jint*     dest) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    50
  intptr_t rv;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    51
  __asm__ volatile(
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    52
    "1: \n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    53
    " ld     [%2], %%o2\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    54
    " add    %1, %%o2, %%o3\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    55
    " cas    [%2], %%o2, %%o3\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    56
    " cmp    %%o2, %%o3\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    57
    " bne    1b\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    58
    "  nop\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    59
    " add    %1, %%o2, %0\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    60
    : "=r" (rv)
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    61
    : "r" (add_value), "r" (dest)
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    62
    : "memory", "o2", "o3");
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    63
  return rv;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    64
}
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    65
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    66
inline intptr_t Atomic::add_ptr(intptr_t add_value, volatile intptr_t* dest) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    67
  intptr_t rv;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    68
#ifdef _LP64
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    69
  __asm__ volatile(
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    70
    "1: \n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    71
    " ldx    [%2], %%o2\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    72
    " add    %0, %%o2, %%o3\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    73
    " casx   [%2], %%o2, %%o3\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    74
    " cmp    %%o2, %%o3\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    75
    " bne    %%xcc, 1b\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    76
    "  nop\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    77
    " add    %0, %%o2, %0\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    78
    : "=r" (rv)
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    79
    : "r" (add_value), "r" (dest)
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    80
    : "memory", "o2", "o3");
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    81
#else
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    82
  __asm__ volatile(
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    83
    "1: \n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    84
    " ld     [%2], %%o2\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    85
    " add    %1, %%o2, %%o3\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    86
    " cas    [%2], %%o2, %%o3\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    87
    " cmp    %%o2, %%o3\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    88
    " bne    1b\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    89
    "  nop\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    90
    " add    %1, %%o2, %0\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    91
    : "=r" (rv)
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    92
    : "r" (add_value), "r" (dest)
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    93
    : "memory", "o2", "o3");
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    94
#endif // _LP64
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    95
  return rv;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    96
}
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    97
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    98
inline void*    Atomic::add_ptr(intptr_t add_value, volatile void*     dest) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    99
  return (void*)add_ptr((intptr_t)add_value, (volatile intptr_t*)dest);
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   100
}
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   101
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   102
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   103
inline jint     Atomic::xchg    (jint     exchange_value, volatile jint*     dest) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   104
  intptr_t rv = exchange_value;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   105
  __asm__ volatile(
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   106
    " swap   [%2],%1\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   107
    : "=r" (rv)
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   108
    : "0" (exchange_value) /* we use same register as for return value */, "r" (dest)
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   109
    : "memory");
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   110
  return rv;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   111
}
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   112
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   113
inline intptr_t Atomic::xchg_ptr(intptr_t exchange_value, volatile intptr_t* dest) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   114
  intptr_t rv = exchange_value;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   115
#ifdef _LP64
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   116
  __asm__ volatile(
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   117
    "1:\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   118
    " mov    %1, %%o3\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   119
    " ldx    [%2], %%o2\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   120
    " casx   [%2], %%o2, %%o3\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   121
    " cmp    %%o2, %%o3\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   122
    " bne    %%xcc, 1b\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   123
    "  nop\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   124
    " mov    %%o2, %0\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   125
    : "=r" (rv)
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   126
    : "r" (exchange_value), "r" (dest)
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   127
    : "memory", "o2", "o3");
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   128
#else
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   129
  __asm__ volatile(
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   130
    "swap    [%2],%1\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   131
    : "=r" (rv)
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   132
    : "0" (exchange_value) /* we use same register as for return value */, "r" (dest)
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   133
    : "memory");
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   134
#endif // _LP64
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   135
  return rv;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   136
}
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   137
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   138
inline void*    Atomic::xchg_ptr(void*    exchange_value, volatile void*     dest) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   139
  return (void*)xchg_ptr((intptr_t)exchange_value, (volatile intptr_t*)dest);
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   140
}
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   141
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   142
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   143
inline jint     Atomic::cmpxchg    (jint     exchange_value, volatile jint*     dest, jint     compare_value) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   144
  jint rv;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   145
  __asm__ volatile(
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   146
    " cas    [%2], %3, %0"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   147
    : "=r" (rv)
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   148
    : "0" (exchange_value), "r" (dest), "r" (compare_value)
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   149
    : "memory");
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   150
  return rv;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   151
}
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   152
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   153
inline jlong    Atomic::cmpxchg    (jlong    exchange_value, volatile jlong*    dest, jlong    compare_value) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   154
#ifdef _LP64
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   155
  jlong rv;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   156
  __asm__ volatile(
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   157
    " casx   [%2], %3, %0"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   158
    : "=r" (rv)
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   159
    : "0" (exchange_value), "r" (dest), "r" (compare_value)
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   160
    : "memory");
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   161
  return rv;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   162
#else
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   163
  assert(VM_Version::v9_instructions_work(), "cas only supported on v9");
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   164
  volatile jlong_accessor evl, cvl, rv;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   165
  evl.long_value = exchange_value;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   166
  cvl.long_value = compare_value;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   167
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   168
  __asm__ volatile(
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   169
    " sllx   %2, 32, %2\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   170
    " srl    %3, 0,  %3\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   171
    " or     %2, %3, %2\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   172
    " sllx   %5, 32, %5\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   173
    " srl    %6, 0,  %6\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   174
    " or     %5, %6, %5\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   175
    " casx   [%4], %5, %2\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   176
    " srl    %2, 0, %1\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   177
    " srlx   %2, 32, %0\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   178
    : "=r" (rv.words[0]), "=r" (rv.words[1])
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   179
    : "r"  (evl.words[0]), "r" (evl.words[1]), "r" (dest), "r" (cvl.words[0]), "r" (cvl.words[1])
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   180
    : "memory");
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   181
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   182
  return rv.long_value;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   183
#endif
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   184
}
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   185
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   186
inline intptr_t Atomic::cmpxchg_ptr(intptr_t exchange_value, volatile intptr_t* dest, intptr_t compare_value) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   187
  intptr_t rv;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   188
#ifdef _LP64
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   189
  __asm__ volatile(
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   190
    " casx    [%2], %3, %0"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   191
    : "=r" (rv)
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   192
    : "0" (exchange_value), "r" (dest), "r" (compare_value)
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   193
    : "memory");
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   194
#else
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   195
  __asm__ volatile(
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   196
    " cas     [%2], %3, %0"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   197
    : "=r" (rv)
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   198
    : "0" (exchange_value), "r" (dest), "r" (compare_value)
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   199
    : "memory");
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   200
#endif // _LP64
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   201
  return rv;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   202
}
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   203
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   204
inline void*    Atomic::cmpxchg_ptr(void*    exchange_value, volatile void*     dest, void*    compare_value) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   205
  return (void*)cmpxchg_ptr((intptr_t)exchange_value, (volatile intptr_t*)dest, (intptr_t)compare_value);
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   206
}