hotspot/src/os_cpu/linux_sparc/vm/atomic_linux_sparc.inline.hpp
author prr
Fri, 23 May 2014 09:05:24 -0700
changeset 24567 a0ebe5fd56ff
parent 24327 d8d91481f76e
child 25715 d5a8dbdc5150
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
/*
15855
2ac9ebea17f3 8008959: Fix non-PCH build on Linux, Windows and MacOS X
simonis
parents: 7885
diff changeset
     2
 * Copyright (c) 1999, 2013, Oracle and/or its affiliates. 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
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 670
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 670
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 670
diff changeset
    21
 * questions.
380
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
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#ifndef OS_CPU_LINUX_SPARC_VM_ATOMIC_LINUX_SPARC_INLINE_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#define OS_CPU_LINUX_SPARC_VM_ATOMIC_LINUX_SPARC_INLINE_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "runtime/atomic.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "runtime/os.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
#include "vm_version_sparc.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    31
380
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    32
// Implementation of class atomic
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, 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, 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, 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, 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, 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, void*     dest) { *(void**)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::store    (jbyte    store_value, volatile jbyte*    dest) { *dest = store_value; }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    42
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
    43
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
    44
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
    45
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
    46
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
    47
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    48
inline void Atomic::inc    (volatile jint*     dest) { (void)add    (1, dest); }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    49
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
    50
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
    51
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    52
inline void Atomic::dec    (volatile jint*     dest) { (void)add    (-1, dest); }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    53
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
    54
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
    55
7885
c02b05ba16a1 7009756: volatile variables could be broken throw reflection API
kvn
parents: 7397
diff changeset
    56
inline jlong Atomic::load(volatile jlong* src) { return *src; }
c02b05ba16a1 7009756: volatile variables could be broken throw reflection API
kvn
parents: 7397
diff changeset
    57
380
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    58
inline jint     Atomic::add    (jint     add_value, volatile jint*     dest) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    59
  intptr_t rv;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    60
  __asm__ volatile(
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    61
    "1: \n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    62
    " ld     [%2], %%o2\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    63
    " add    %1, %%o2, %%o3\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    64
    " cas    [%2], %%o2, %%o3\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    65
    " cmp    %%o2, %%o3\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    66
    " bne    1b\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    67
    "  nop\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    68
    " add    %1, %%o2, %0\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    69
    : "=r" (rv)
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    70
    : "r" (add_value), "r" (dest)
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    71
    : "memory", "o2", "o3");
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    72
  return rv;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    73
}
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    74
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    75
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
    76
  intptr_t rv;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    77
#ifdef _LP64
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    78
  __asm__ volatile(
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    79
    "1: \n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    80
    " ldx    [%2], %%o2\n\t"
24327
d8d91481f76e 8042059: Various fixes to linux/sparc
mikael
parents: 18097
diff changeset
    81
    " add    %1, %%o2, %%o3\n\t"
380
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    82
    " casx   [%2], %%o2, %%o3\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    83
    " cmp    %%o2, %%o3\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    84
    " bne    %%xcc, 1b\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    85
    "  nop\n\t"
24327
d8d91481f76e 8042059: Various fixes to linux/sparc
mikael
parents: 18097
diff changeset
    86
    " add    %1, %%o2, %0\n\t"
380
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    87
    : "=r" (rv)
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    88
    : "r" (add_value), "r" (dest)
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    89
    : "memory", "o2", "o3");
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    90
#else
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    91
  __asm__ volatile(
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    92
    "1: \n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    93
    " ld     [%2], %%o2\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    94
    " add    %1, %%o2, %%o3\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    95
    " cas    [%2], %%o2, %%o3\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    96
    " cmp    %%o2, %%o3\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    97
    " bne    1b\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    98
    "  nop\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    99
    " add    %1, %%o2, %0\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   100
    : "=r" (rv)
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   101
    : "r" (add_value), "r" (dest)
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   102
    : "memory", "o2", "o3");
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   103
#endif // _LP64
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   104
  return rv;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   105
}
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   106
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   107
inline void*    Atomic::add_ptr(intptr_t add_value, volatile void*     dest) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   108
  return (void*)add_ptr((intptr_t)add_value, (volatile intptr_t*)dest);
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   109
}
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   110
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
inline jint     Atomic::xchg    (jint     exchange_value, volatile jint*     dest) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   113
  intptr_t rv = exchange_value;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   114
  __asm__ volatile(
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   115
    " swap   [%2],%1\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   116
    : "=r" (rv)
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   117
    : "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
   118
    : "memory");
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   119
  return rv;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   120
}
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   121
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   122
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
   123
  intptr_t rv = exchange_value;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   124
#ifdef _LP64
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   125
  __asm__ volatile(
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   126
    "1:\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   127
    " mov    %1, %%o3\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   128
    " ldx    [%2], %%o2\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   129
    " casx   [%2], %%o2, %%o3\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   130
    " cmp    %%o2, %%o3\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   131
    " bne    %%xcc, 1b\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   132
    "  nop\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   133
    " mov    %%o2, %0\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   134
    : "=r" (rv)
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   135
    : "r" (exchange_value), "r" (dest)
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   136
    : "memory", "o2", "o3");
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   137
#else
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   138
  __asm__ volatile(
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   139
    "swap    [%2],%1\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   140
    : "=r" (rv)
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   141
    : "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
   142
    : "memory");
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   143
#endif // _LP64
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   144
  return rv;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   145
}
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   146
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   147
inline void*    Atomic::xchg_ptr(void*    exchange_value, volatile void*     dest) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   148
  return (void*)xchg_ptr((intptr_t)exchange_value, (volatile intptr_t*)dest);
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   149
}
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   150
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
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
   153
  jint rv;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   154
  __asm__ volatile(
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   155
    " cas    [%2], %3, %0"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   156
    : "=r" (rv)
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   157
    : "0" (exchange_value), "r" (dest), "r" (compare_value)
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   158
    : "memory");
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   159
  return rv;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   160
}
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   161
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   162
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
   163
#ifdef _LP64
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   164
  jlong rv;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   165
  __asm__ volatile(
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   166
    " casx   [%2], %3, %0"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   167
    : "=r" (rv)
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   168
    : "0" (exchange_value), "r" (dest), "r" (compare_value)
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   169
    : "memory");
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   170
  return rv;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   171
#else
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   172
  volatile jlong_accessor evl, cvl, rv;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   173
  evl.long_value = exchange_value;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   174
  cvl.long_value = compare_value;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   175
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   176
  __asm__ volatile(
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   177
    " sllx   %2, 32, %2\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   178
    " srl    %3, 0,  %3\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   179
    " or     %2, %3, %2\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   180
    " sllx   %5, 32, %5\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   181
    " srl    %6, 0,  %6\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   182
    " or     %5, %6, %5\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   183
    " casx   [%4], %5, %2\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   184
    " srl    %2, 0, %1\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   185
    " srlx   %2, 32, %0\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   186
    : "=r" (rv.words[0]), "=r" (rv.words[1])
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   187
    : "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
   188
    : "memory");
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   189
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   190
  return rv.long_value;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   191
#endif
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   192
}
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   193
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   194
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
   195
  intptr_t rv;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   196
#ifdef _LP64
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   197
  __asm__ volatile(
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   198
    " casx    [%2], %3, %0"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   199
    : "=r" (rv)
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   200
    : "0" (exchange_value), "r" (dest), "r" (compare_value)
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   201
    : "memory");
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   202
#else
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   203
  __asm__ volatile(
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   204
    " cas     [%2], %3, %0"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   205
    : "=r" (rv)
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   206
    : "0" (exchange_value), "r" (dest), "r" (compare_value)
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   207
    : "memory");
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   208
#endif // _LP64
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   209
  return rv;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   210
}
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   211
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   212
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
   213
  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
   214
}
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   215
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   216
#endif // OS_CPU_LINUX_SPARC_VM_ATOMIC_LINUX_SPARC_INLINE_HPP