src/hotspot/os_cpu/solaris_x86/atomic_solaris_x86.hpp
author erikj
Fri, 05 Oct 2018 09:59:30 -0700
branchihse-runtestprebuilt-branch
changeset 56931 aff106ae3507
parent 50029 ea0a16ba6ac0
child 53244 9807daeb47c4
permissions -rw-r--r--
Fix CDS support. Change ParseKeywordVariable parameter name to enable JTREG_KEYWORDS parameter. Fix test list arg.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
50029
ea0a16ba6ac0 8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents: 48468
diff changeset
     2
 * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5542
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5542
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: 5542
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
40655
9f644073d3a0 8157907: Incorrect inclusion of atomic.hpp instead of atomic.inline.hpp
dholmes
parents: 39404
diff changeset
    25
#ifndef OS_CPU_SOLARIS_X86_VM_ATOMIC_SOLARIS_X86_HPP
9f644073d3a0 8157907: Incorrect inclusion of atomic.hpp instead of atomic.inline.hpp
dholmes
parents: 39404
diff changeset
    26
#define OS_CPU_SOLARIS_X86_VM_ATOMIC_SOLARIS_X86_HPP
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
46958
a13bd8c6b7a2 8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents: 46534
diff changeset
    28
// For Sun Studio - implementation is in solaris_x86_64.il.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
5542
be05c5ffe905 6951319: enable solaris builds using Sun Studio 12 update 1
jcoomes
parents: 3795
diff changeset
    30
extern "C" {
48468
7cc7de9bf4a4 8186903: Remove j-types from Atomic
coleenp
parents: 47593
diff changeset
    31
  int32_t _Atomic_add(int32_t add_value, volatile int32_t* dest);
7cc7de9bf4a4 8186903: Remove j-types from Atomic
coleenp
parents: 47593
diff changeset
    32
  int64_t _Atomic_add_long(int64_t add_value, volatile int64_t* dest);
46993
dd0f91c85ffc 8186476: Generalize Atomic::add with templates
eosterlund
parents: 46958
diff changeset
    33
48468
7cc7de9bf4a4 8186903: Remove j-types from Atomic
coleenp
parents: 47593
diff changeset
    34
  int32_t _Atomic_xchg(int32_t exchange_value, volatile int32_t* dest);
7cc7de9bf4a4 8186903: Remove j-types from Atomic
coleenp
parents: 47593
diff changeset
    35
  int8_t  _Atomic_cmpxchg_byte(int8_t exchange_value, volatile int8_t* dest,
7cc7de9bf4a4 8186903: Remove j-types from Atomic
coleenp
parents: 47593
diff changeset
    36
                               int8_t compare_value);
7cc7de9bf4a4 8186903: Remove j-types from Atomic
coleenp
parents: 47593
diff changeset
    37
  int32_t _Atomic_cmpxchg(int32_t exchange_value, volatile int32_t* dest,
7cc7de9bf4a4 8186903: Remove j-types from Atomic
coleenp
parents: 47593
diff changeset
    38
                          int32_t compare_value);
7cc7de9bf4a4 8186903: Remove j-types from Atomic
coleenp
parents: 47593
diff changeset
    39
  int64_t _Atomic_cmpxchg_long(int64_t exchange_value, volatile int64_t* dest,
7cc7de9bf4a4 8186903: Remove j-types from Atomic
coleenp
parents: 47593
diff changeset
    40
                               int64_t compare_value);
5542
be05c5ffe905 6951319: enable solaris builds using Sun Studio 12 update 1
jcoomes
parents: 3795
diff changeset
    41
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
46993
dd0f91c85ffc 8186476: Generalize Atomic::add with templates
eosterlund
parents: 46958
diff changeset
    43
template<size_t byte_size>
dd0f91c85ffc 8186476: Generalize Atomic::add with templates
eosterlund
parents: 46958
diff changeset
    44
struct Atomic::PlatformAdd
dd0f91c85ffc 8186476: Generalize Atomic::add with templates
eosterlund
parents: 46958
diff changeset
    45
  : Atomic::AddAndFetch<Atomic::PlatformAdd<byte_size> >
dd0f91c85ffc 8186476: Generalize Atomic::add with templates
eosterlund
parents: 46958
diff changeset
    46
{
dd0f91c85ffc 8186476: Generalize Atomic::add with templates
eosterlund
parents: 46958
diff changeset
    47
  template<typename I, typename D>
50029
ea0a16ba6ac0 8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents: 48468
diff changeset
    48
  D add_and_fetch(I add_value, D volatile* dest, atomic_memory_order order) const;
46993
dd0f91c85ffc 8186476: Generalize Atomic::add with templates
eosterlund
parents: 46958
diff changeset
    49
};
dd0f91c85ffc 8186476: Generalize Atomic::add with templates
eosterlund
parents: 46958
diff changeset
    50
dd0f91c85ffc 8186476: Generalize Atomic::add with templates
eosterlund
parents: 46958
diff changeset
    51
// Not using add_using_helper; see comment for cmpxchg.
dd0f91c85ffc 8186476: Generalize Atomic::add with templates
eosterlund
parents: 46958
diff changeset
    52
template<>
dd0f91c85ffc 8186476: Generalize Atomic::add with templates
eosterlund
parents: 46958
diff changeset
    53
template<typename I, typename D>
50029
ea0a16ba6ac0 8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents: 48468
diff changeset
    54
inline D Atomic::PlatformAdd<4>::add_and_fetch(I add_value, D volatile* dest,
ea0a16ba6ac0 8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents: 48468
diff changeset
    55
                                               atomic_memory_order order) const {
46993
dd0f91c85ffc 8186476: Generalize Atomic::add with templates
eosterlund
parents: 46958
diff changeset
    56
  STATIC_ASSERT(4 == sizeof(I));
dd0f91c85ffc 8186476: Generalize Atomic::add with templates
eosterlund
parents: 46958
diff changeset
    57
  STATIC_ASSERT(4 == sizeof(D));
dd0f91c85ffc 8186476: Generalize Atomic::add with templates
eosterlund
parents: 46958
diff changeset
    58
  return PrimitiveConversions::cast<D>(
48468
7cc7de9bf4a4 8186903: Remove j-types from Atomic
coleenp
parents: 47593
diff changeset
    59
    _Atomic_add(PrimitiveConversions::cast<int32_t>(add_value),
7cc7de9bf4a4 8186903: Remove j-types from Atomic
coleenp
parents: 47593
diff changeset
    60
                reinterpret_cast<int32_t volatile*>(dest)));
46993
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
dd0f91c85ffc 8186476: Generalize Atomic::add with templates
eosterlund
parents: 46958
diff changeset
    63
// Not using add_using_helper; see comment for cmpxchg.
dd0f91c85ffc 8186476: Generalize Atomic::add with templates
eosterlund
parents: 46958
diff changeset
    64
template<>
dd0f91c85ffc 8186476: Generalize Atomic::add with templates
eosterlund
parents: 46958
diff changeset
    65
template<typename I, typename D>
50029
ea0a16ba6ac0 8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents: 48468
diff changeset
    66
inline D Atomic::PlatformAdd<8>::add_and_fetch(I add_value, D volatile* dest,
ea0a16ba6ac0 8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents: 48468
diff changeset
    67
                                               atomic_memory_order order) const {
46993
dd0f91c85ffc 8186476: Generalize Atomic::add with templates
eosterlund
parents: 46958
diff changeset
    68
  STATIC_ASSERT(8 == sizeof(I));
dd0f91c85ffc 8186476: Generalize Atomic::add with templates
eosterlund
parents: 46958
diff changeset
    69
  STATIC_ASSERT(8 == sizeof(D));
dd0f91c85ffc 8186476: Generalize Atomic::add with templates
eosterlund
parents: 46958
diff changeset
    70
  return PrimitiveConversions::cast<D>(
48468
7cc7de9bf4a4 8186903: Remove j-types from Atomic
coleenp
parents: 47593
diff changeset
    71
    _Atomic_add_long(PrimitiveConversions::cast<int64_t>(add_value),
7cc7de9bf4a4 8186903: Remove j-types from Atomic
coleenp
parents: 47593
diff changeset
    72
                     reinterpret_cast<int64_t volatile*>(dest)));
5542
be05c5ffe905 6951319: enable solaris builds using Sun Studio 12 update 1
jcoomes
parents: 3795
diff changeset
    73
}
be05c5ffe905 6951319: enable solaris builds using Sun Studio 12 update 1
jcoomes
parents: 3795
diff changeset
    74
47578
09c41c4913d9 8187977: Generalize Atomic::xchg to use templates
eosterlund
parents: 47552
diff changeset
    75
template<>
09c41c4913d9 8187977: Generalize Atomic::xchg to use templates
eosterlund
parents: 47552
diff changeset
    76
template<typename T>
09c41c4913d9 8187977: Generalize Atomic::xchg to use templates
eosterlund
parents: 47552
diff changeset
    77
inline T Atomic::PlatformXchg<4>::operator()(T exchange_value,
50029
ea0a16ba6ac0 8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents: 48468
diff changeset
    78
                                             T volatile* dest,
ea0a16ba6ac0 8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents: 48468
diff changeset
    79
                                             atomic_memory_order order) const {
47578
09c41c4913d9 8187977: Generalize Atomic::xchg to use templates
eosterlund
parents: 47552
diff changeset
    80
  STATIC_ASSERT(4 == sizeof(T));
09c41c4913d9 8187977: Generalize Atomic::xchg to use templates
eosterlund
parents: 47552
diff changeset
    81
  return PrimitiveConversions::cast<T>(
48468
7cc7de9bf4a4 8186903: Remove j-types from Atomic
coleenp
parents: 47593
diff changeset
    82
    _Atomic_xchg(PrimitiveConversions::cast<int32_t>(exchange_value),
7cc7de9bf4a4 8186903: Remove j-types from Atomic
coleenp
parents: 47593
diff changeset
    83
                 reinterpret_cast<int32_t volatile*>(dest)));
47578
09c41c4913d9 8187977: Generalize Atomic::xchg to use templates
eosterlund
parents: 47552
diff changeset
    84
}
09c41c4913d9 8187977: Generalize Atomic::xchg to use templates
eosterlund
parents: 47552
diff changeset
    85
48468
7cc7de9bf4a4 8186903: Remove j-types from Atomic
coleenp
parents: 47593
diff changeset
    86
extern "C" int64_t _Atomic_xchg_long(int64_t exchange_value, volatile int64_t* dest);
47578
09c41c4913d9 8187977: Generalize Atomic::xchg to use templates
eosterlund
parents: 47552
diff changeset
    87
09c41c4913d9 8187977: Generalize Atomic::xchg to use templates
eosterlund
parents: 47552
diff changeset
    88
template<>
09c41c4913d9 8187977: Generalize Atomic::xchg to use templates
eosterlund
parents: 47552
diff changeset
    89
template<typename T>
09c41c4913d9 8187977: Generalize Atomic::xchg to use templates
eosterlund
parents: 47552
diff changeset
    90
inline T Atomic::PlatformXchg<8>::operator()(T exchange_value,
50029
ea0a16ba6ac0 8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents: 48468
diff changeset
    91
                                             T volatile* dest,
ea0a16ba6ac0 8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents: 48468
diff changeset
    92
                                             atomic_memory_order order) const {
47578
09c41c4913d9 8187977: Generalize Atomic::xchg to use templates
eosterlund
parents: 47552
diff changeset
    93
  STATIC_ASSERT(8 == sizeof(T));
09c41c4913d9 8187977: Generalize Atomic::xchg to use templates
eosterlund
parents: 47552
diff changeset
    94
  return PrimitiveConversions::cast<T>(
48468
7cc7de9bf4a4 8186903: Remove j-types from Atomic
coleenp
parents: 47593
diff changeset
    95
    _Atomic_xchg_long(PrimitiveConversions::cast<int64_t>(exchange_value),
7cc7de9bf4a4 8186903: Remove j-types from Atomic
coleenp
parents: 47593
diff changeset
    96
                      reinterpret_cast<int64_t volatile*>(dest)));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
46958
a13bd8c6b7a2 8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents: 46534
diff changeset
    99
// Not using cmpxchg_using_helper here, because some configurations of
a13bd8c6b7a2 8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents: 46534
diff changeset
   100
// Solaris compiler don't deal well with passing a "defined in .il"
a13bd8c6b7a2 8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents: 46534
diff changeset
   101
// function as an argument.  We *should* switch to using gcc-style
a13bd8c6b7a2 8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents: 46534
diff changeset
   102
// inline assembly, but attempting to do so with Studio 12.4 ran into
a13bd8c6b7a2 8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents: 46534
diff changeset
   103
// segfaults.
a13bd8c6b7a2 8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents: 46534
diff changeset
   104
a13bd8c6b7a2 8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents: 46534
diff changeset
   105
template<>
a13bd8c6b7a2 8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents: 46534
diff changeset
   106
template<typename T>
a13bd8c6b7a2 8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents: 46534
diff changeset
   107
inline T Atomic::PlatformCmpxchg<1>::operator()(T exchange_value,
a13bd8c6b7a2 8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents: 46534
diff changeset
   108
                                                T volatile* dest,
a13bd8c6b7a2 8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents: 46534
diff changeset
   109
                                                T compare_value,
50029
ea0a16ba6ac0 8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents: 48468
diff changeset
   110
                                                atomic_memory_order order) const {
46958
a13bd8c6b7a2 8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents: 46534
diff changeset
   111
  STATIC_ASSERT(1 == sizeof(T));
a13bd8c6b7a2 8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents: 46534
diff changeset
   112
  return PrimitiveConversions::cast<T>(
48468
7cc7de9bf4a4 8186903: Remove j-types from Atomic
coleenp
parents: 47593
diff changeset
   113
    _Atomic_cmpxchg_byte(PrimitiveConversions::cast<int8_t>(exchange_value),
7cc7de9bf4a4 8186903: Remove j-types from Atomic
coleenp
parents: 47593
diff changeset
   114
                         reinterpret_cast<int8_t volatile*>(dest),
7cc7de9bf4a4 8186903: Remove j-types from Atomic
coleenp
parents: 47593
diff changeset
   115
                         PrimitiveConversions::cast<int8_t>(compare_value)));
27691
733f189ad1f7 8058255: Native jbyte Atomic::cmpxchg for supported x86 platforms
jwilhelm
parents: 25715
diff changeset
   116
}
733f189ad1f7 8058255: Native jbyte Atomic::cmpxchg for supported x86 platforms
jwilhelm
parents: 25715
diff changeset
   117
46958
a13bd8c6b7a2 8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents: 46534
diff changeset
   118
template<>
a13bd8c6b7a2 8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents: 46534
diff changeset
   119
template<typename T>
a13bd8c6b7a2 8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents: 46534
diff changeset
   120
inline T Atomic::PlatformCmpxchg<4>::operator()(T exchange_value,
a13bd8c6b7a2 8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents: 46534
diff changeset
   121
                                                T volatile* dest,
a13bd8c6b7a2 8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents: 46534
diff changeset
   122
                                                T compare_value,
50029
ea0a16ba6ac0 8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents: 48468
diff changeset
   123
                                                atomic_memory_order order) const {
46958
a13bd8c6b7a2 8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents: 46534
diff changeset
   124
  STATIC_ASSERT(4 == sizeof(T));
a13bd8c6b7a2 8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents: 46534
diff changeset
   125
  return PrimitiveConversions::cast<T>(
48468
7cc7de9bf4a4 8186903: Remove j-types from Atomic
coleenp
parents: 47593
diff changeset
   126
    _Atomic_cmpxchg(PrimitiveConversions::cast<int32_t>(exchange_value),
7cc7de9bf4a4 8186903: Remove j-types from Atomic
coleenp
parents: 47593
diff changeset
   127
                    reinterpret_cast<int32_t volatile*>(dest),
7cc7de9bf4a4 8186903: Remove j-types from Atomic
coleenp
parents: 47593
diff changeset
   128
                    PrimitiveConversions::cast<int32_t>(compare_value)));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
46958
a13bd8c6b7a2 8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents: 46534
diff changeset
   131
template<>
a13bd8c6b7a2 8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents: 46534
diff changeset
   132
template<typename T>
a13bd8c6b7a2 8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents: 46534
diff changeset
   133
inline T Atomic::PlatformCmpxchg<8>::operator()(T exchange_value,
a13bd8c6b7a2 8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents: 46534
diff changeset
   134
                                                T volatile* dest,
a13bd8c6b7a2 8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents: 46534
diff changeset
   135
                                                T compare_value,
50029
ea0a16ba6ac0 8202080: Introduce ordering semantics for Atomic::add and other RMW atomics
mdoerr
parents: 48468
diff changeset
   136
                                                atomic_memory_order order) const {
46958
a13bd8c6b7a2 8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents: 46534
diff changeset
   137
  STATIC_ASSERT(8 == sizeof(T));
a13bd8c6b7a2 8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents: 46534
diff changeset
   138
  return PrimitiveConversions::cast<T>(
48468
7cc7de9bf4a4 8186903: Remove j-types from Atomic
coleenp
parents: 47593
diff changeset
   139
    _Atomic_cmpxchg_long(PrimitiveConversions::cast<int64_t>(exchange_value),
7cc7de9bf4a4 8186903: Remove j-types from Atomic
coleenp
parents: 47593
diff changeset
   140
                         reinterpret_cast<int64_t volatile*>(dest),
7cc7de9bf4a4 8186903: Remove j-types from Atomic
coleenp
parents: 47593
diff changeset
   141
                         PrimitiveConversions::cast<int64_t>(compare_value)));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
40655
9f644073d3a0 8157907: Incorrect inclusion of atomic.hpp instead of atomic.inline.hpp
dholmes
parents: 39404
diff changeset
   144
#endif // OS_CPU_SOLARIS_X86_VM_ATOMIC_SOLARIS_X86_HPP