hotspot/src/os_cpu/linux_sparc/vm/atomic_linux_sparc.hpp
author glaubitz
Tue, 29 Aug 2017 18:34:32 +0200
changeset 47091 4cc46bb5057b
parent 46993 dd0f91c85ffc
permissions -rw-r--r--
8186855: Multiple platforms broken after 8186476: Generalize Atomic::add with templates Reviewed-by: stuefe, coleenp
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
380
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
     1
/*
46523
cbcc0ebaa044 8166651: OrderAccess::load_acquire &etc should have const parameters
kbarrett
parents: 46381
diff changeset
     2
 * Copyright (c) 1999, 2017, 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
380
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    28
// Implementation of class atomic
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    29
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    30
inline void Atomic::store    (jbyte    store_value, jbyte*    dest) { *dest = store_value; }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    31
inline void Atomic::store    (jshort   store_value, jshort*   dest) { *dest = store_value; }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    32
inline void Atomic::store    (jint     store_value, jint*     dest) { *dest = store_value; }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    33
inline void Atomic::store    (jlong    store_value, jlong*    dest) { *dest = store_value; }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    34
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
    35
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
    36
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    37
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
    38
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
    39
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
    40
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
    41
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
    42
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
    43
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    44
inline void Atomic::inc    (volatile jint*     dest) { (void)add    (1, dest); }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    45
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
    46
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
    47
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    48
inline void Atomic::dec    (volatile jint*     dest) { (void)add    (-1, dest); }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    49
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
    50
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
    51
46523
cbcc0ebaa044 8166651: OrderAccess::load_acquire &etc should have const parameters
kbarrett
parents: 46381
diff changeset
    52
inline jlong Atomic::load(const volatile jlong* src) { return *src; }
7885
c02b05ba16a1 7009756: volatile variables could be broken throw reflection API
kvn
parents: 7397
diff changeset
    53
46993
dd0f91c85ffc 8186476: Generalize Atomic::add with templates
eosterlund
parents: 46958
diff changeset
    54
template<size_t byte_size>
dd0f91c85ffc 8186476: Generalize Atomic::add with templates
eosterlund
parents: 46958
diff changeset
    55
struct Atomic::PlatformAdd
dd0f91c85ffc 8186476: Generalize Atomic::add with templates
eosterlund
parents: 46958
diff changeset
    56
  : Atomic::AddAndFetch<Atomic::PlatformAdd<byte_size> >
dd0f91c85ffc 8186476: Generalize Atomic::add with templates
eosterlund
parents: 46958
diff changeset
    57
{
dd0f91c85ffc 8186476: Generalize Atomic::add with templates
eosterlund
parents: 46958
diff changeset
    58
  template<typename I, typename D>
dd0f91c85ffc 8186476: Generalize Atomic::add with templates
eosterlund
parents: 46958
diff changeset
    59
  D add_and_fetch(I add_value, D volatile* dest) const;
dd0f91c85ffc 8186476: Generalize Atomic::add with templates
eosterlund
parents: 46958
diff changeset
    60
};
dd0f91c85ffc 8186476: Generalize Atomic::add with templates
eosterlund
parents: 46958
diff changeset
    61
dd0f91c85ffc 8186476: Generalize Atomic::add with templates
eosterlund
parents: 46958
diff changeset
    62
template<>
dd0f91c85ffc 8186476: Generalize Atomic::add with templates
eosterlund
parents: 46958
diff changeset
    63
template<typename I, typename D>
dd0f91c85ffc 8186476: Generalize Atomic::add with templates
eosterlund
parents: 46958
diff changeset
    64
inline D Atomic::PlatformAdd<4>::add_and_fetch(I add_value, D volatile* dest) const {
47091
4cc46bb5057b 8186855: Multiple platforms broken after 8186476: Generalize Atomic::add with templates
glaubitz
parents: 46993
diff changeset
    65
  STATIC_ASSERT(4 == sizeof(I));
4cc46bb5057b 8186855: Multiple platforms broken after 8186476: Generalize Atomic::add with templates
glaubitz
parents: 46993
diff changeset
    66
  STATIC_ASSERT(4 == sizeof(D));
46993
dd0f91c85ffc 8186476: Generalize Atomic::add with templates
eosterlund
parents: 46958
diff changeset
    67
dd0f91c85ffc 8186476: Generalize Atomic::add with templates
eosterlund
parents: 46958
diff changeset
    68
  D rv;
380
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
    " ld     [%2], %%o2\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    72
    " add    %1, %%o2, %%o3\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    73
    " cas    [%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    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    %1, %%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
  return rv;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    82
}
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    83
47091
4cc46bb5057b 8186855: Multiple platforms broken after 8186476: Generalize Atomic::add with templates
glaubitz
parents: 46993
diff changeset
    84
template<>
46993
dd0f91c85ffc 8186476: Generalize Atomic::add with templates
eosterlund
parents: 46958
diff changeset
    85
template<typename I, typename D>
dd0f91c85ffc 8186476: Generalize Atomic::add with templates
eosterlund
parents: 46958
diff changeset
    86
inline D Atomic::PlatformAdd<8>::add_and_fetch(I add_value, D volatile* dest) const {
47091
4cc46bb5057b 8186855: Multiple platforms broken after 8186476: Generalize Atomic::add with templates
glaubitz
parents: 46993
diff changeset
    87
  STATIC_ASSERT(8 == sizeof(I));
4cc46bb5057b 8186855: Multiple platforms broken after 8186476: Generalize Atomic::add with templates
glaubitz
parents: 46993
diff changeset
    88
  STATIC_ASSERT(8 == sizeof(D));
46993
dd0f91c85ffc 8186476: Generalize Atomic::add with templates
eosterlund
parents: 46958
diff changeset
    89
dd0f91c85ffc 8186476: Generalize Atomic::add with templates
eosterlund
parents: 46958
diff changeset
    90
  D rv;
380
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
    " ldx    [%2], %%o2\n\t"
24327
d8d91481f76e 8042059: Various fixes to linux/sparc
mikael
parents: 18097
diff changeset
    94
    " add    %1, %%o2, %%o3\n\t"
380
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    95
    " casx   [%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    %%xcc, 1b\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    98
    "  nop\n\t"
24327
d8d91481f76e 8042059: Various fixes to linux/sparc
mikael
parents: 18097
diff changeset
    99
    " add    %1, %%o2, %0\n\t"
380
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
  return rv;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   104
}
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 jint     Atomic::xchg    (jint     exchange_value, volatile jint*     dest) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   108
  intptr_t rv = exchange_value;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   109
  __asm__ volatile(
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   110
    " swap   [%2],%1\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   111
    : "=r" (rv)
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   112
    : "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
   113
    : "memory");
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   114
  return rv;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   115
}
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   116
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   117
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
   118
  intptr_t rv = exchange_value;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   119
  __asm__ volatile(
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   120
    "1:\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   121
    " mov    %1, %%o3\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   122
    " ldx    [%2], %%o2\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   123
    " casx   [%2], %%o2, %%o3\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   124
    " cmp    %%o2, %%o3\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   125
    " bne    %%xcc, 1b\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   126
    "  nop\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   127
    " mov    %%o2, %0\n\t"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   128
    : "=r" (rv)
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   129
    : "r" (exchange_value), "r" (dest)
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   130
    : "memory", "o2", "o3");
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   131
  return rv;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   132
}
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   133
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   134
inline void*    Atomic::xchg_ptr(void*    exchange_value, volatile void*     dest) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   135
  return (void*)xchg_ptr((intptr_t)exchange_value, (volatile intptr_t*)dest);
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
46958
a13bd8c6b7a2 8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents: 46668
diff changeset
   138
// No direct support for cmpxchg of bytes; emulate using int.
a13bd8c6b7a2 8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents: 46668
diff changeset
   139
template<>
a13bd8c6b7a2 8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents: 46668
diff changeset
   140
struct Atomic::PlatformCmpxchg<1> : Atomic::CmpxchgByteUsingInt {};
380
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   141
46958
a13bd8c6b7a2 8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents: 46668
diff changeset
   142
template<>
a13bd8c6b7a2 8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents: 46668
diff changeset
   143
template<typename T>
a13bd8c6b7a2 8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents: 46668
diff changeset
   144
inline T Atomic::PlatformCmpxchg<4>::operator()(T exchange_value,
a13bd8c6b7a2 8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents: 46668
diff changeset
   145
                                                T volatile* dest,
a13bd8c6b7a2 8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents: 46668
diff changeset
   146
                                                T compare_value,
a13bd8c6b7a2 8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents: 46668
diff changeset
   147
                                                cmpxchg_memory_order order) const {
a13bd8c6b7a2 8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents: 46668
diff changeset
   148
  STATIC_ASSERT(4 == sizeof(T));
a13bd8c6b7a2 8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents: 46668
diff changeset
   149
  T rv;
380
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   150
  __asm__ volatile(
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   151
    " cas    [%2], %3, %0"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   152
    : "=r" (rv)
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   153
    : "0" (exchange_value), "r" (dest), "r" (compare_value)
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   154
    : "memory");
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   155
  return rv;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   156
}
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   157
46958
a13bd8c6b7a2 8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents: 46668
diff changeset
   158
template<>
a13bd8c6b7a2 8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents: 46668
diff changeset
   159
template<typename T>
a13bd8c6b7a2 8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents: 46668
diff changeset
   160
inline T Atomic::PlatformCmpxchg<8>::operator()(T exchange_value,
a13bd8c6b7a2 8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents: 46668
diff changeset
   161
                                                T volatile* dest,
a13bd8c6b7a2 8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents: 46668
diff changeset
   162
                                                T compare_value,
a13bd8c6b7a2 8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents: 46668
diff changeset
   163
                                                cmpxchg_memory_order order) const {
a13bd8c6b7a2 8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents: 46668
diff changeset
   164
  STATIC_ASSERT(8 == sizeof(T));
a13bd8c6b7a2 8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents: 46668
diff changeset
   165
  T rv;
380
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   166
  __asm__ volatile(
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   167
    " casx   [%2], %3, %0"
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   168
    : "=r" (rv)
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   169
    : "0" (exchange_value), "r" (dest), "r" (compare_value)
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   170
    : "memory");
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   171
  return rv;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   172
}
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   173
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   174
#endif // OS_CPU_LINUX_SPARC_VM_ATOMIC_LINUX_SPARC_INLINE_HPP