hotspot/src/os_cpu/aix_ppc/vm/atomic_aix_ppc.inline.hpp
author lana
Thu, 11 Aug 2016 17:02:00 +0000
changeset 40312 4c7bf578577e
parent 39404 d0ad5220e91c
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
     1
/*
25715
d5a8dbdc5150 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents: 24351
diff changeset
     2
 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
35594
cc13089c6327 8147937: Adapt SAP copyrights to new company name.
goetz
parents: 35063
diff changeset
     3
 * Copyright (c) 2012, 2014 SAP SE. All rights reserved.
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
     4
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
     5
 *
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
     6
 * This code is free software; you can redistribute it and/or modify it
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
     7
 * under the terms of the GNU General Public License version 2 only, as
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
     8
 * published by the Free Software Foundation.
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
     9
 *
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    14
 * accompanied this code).
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    15
 *
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    19
 *
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    22
 * questions.
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    23
 *
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    24
 */
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    25
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    26
#ifndef OS_CPU_AIX_OJDKPPC_VM_ATOMIC_AIX_PPC_INLINE_HPP
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    27
#define OS_CPU_AIX_OJDKPPC_VM_ATOMIC_AIX_PPC_INLINE_HPP
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    28
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    29
#include "runtime/atomic.hpp"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    30
#include "runtime/os.hpp"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    31
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    32
#ifndef _LP64
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    33
#error "Atomic currently only impleneted for PPC64"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    34
#endif
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    35
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    36
// Implementation of class atomic
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    37
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    38
inline void Atomic::store    (jbyte    store_value, jbyte*    dest) { *dest = store_value; }
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    39
inline void Atomic::store    (jshort   store_value, jshort*   dest) { *dest = store_value; }
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    40
inline void Atomic::store    (jint     store_value, jint*     dest) { *dest = store_value; }
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    41
inline void Atomic::store    (jlong    store_value, jlong*    dest) { *dest = store_value; }
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    42
inline void Atomic::store_ptr(intptr_t store_value, intptr_t* dest) { *dest = store_value; }
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    43
inline void Atomic::store_ptr(void*    store_value, void*     dest) { *(void**)dest = store_value; }
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    44
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    45
inline void Atomic::store    (jbyte    store_value, volatile jbyte*    dest) { *dest = store_value; }
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    46
inline void Atomic::store    (jshort   store_value, volatile jshort*   dest) { *dest = store_value; }
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    47
inline void Atomic::store    (jint     store_value, volatile jint*     dest) { *dest = store_value; }
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    48
inline void Atomic::store    (jlong    store_value, volatile jlong*    dest) { *dest = store_value; }
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    49
inline void Atomic::store_ptr(intptr_t store_value, volatile intptr_t* dest) { *dest = store_value; }
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    50
inline void Atomic::store_ptr(void*    store_value, volatile void*     dest) { *(void* volatile *)dest = store_value; }
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    51
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    52
inline jlong Atomic::load(volatile jlong* src) { return *src; }
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    53
22867
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
    54
//
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
    55
//   machine barrier instructions:
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
    56
//
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
    57
//   - ppc_sync            two-way memory barrier, aka fence
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
    58
//   - ppc_lwsync          orders  Store|Store,
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
    59
//                                  Load|Store,
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
    60
//                                  Load|Load,
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
    61
//                         but not Store|Load
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
    62
//   - ppc_eieio           orders memory accesses for device memory (only)
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
    63
//   - ppc_isync           invalidates speculatively executed instructions
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
    64
//                         From the POWER ISA 2.06 documentation:
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
    65
//                          "[...] an isync instruction prevents the execution of
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
    66
//                         instructions following the isync until instructions
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
    67
//                         preceding the isync have completed, [...]"
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
    68
//                         From IBM's AIX assembler reference:
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
    69
//                          "The isync [...] instructions causes the processor to
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
    70
//                         refetch any instructions that might have been fetched
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
    71
//                         prior to the isync instruction. The instruction isync
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
    72
//                         causes the processor to wait for all previous instructions
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
    73
//                         to complete. Then any instructions already fetched are
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
    74
//                         discarded and instruction processing continues in the
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
    75
//                         environment established by the previous instructions."
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
    76
//
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
    77
//   semantic barrier instructions:
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
    78
//   (as defined in orderAccess.hpp)
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
    79
//
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
    80
//   - ppc_release         orders Store|Store,       (maps to ppc_lwsync)
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
    81
//                                 Load|Store
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
    82
//   - ppc_acquire         orders  Load|Store,       (maps to ppc_lwsync)
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
    83
//                                 Load|Load
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
    84
//   - ppc_fence           orders Store|Store,       (maps to ppc_sync)
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
    85
//                                 Load|Store,
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
    86
//                                 Load|Load,
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
    87
//                                Store|Load
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
    88
//
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    89
22867
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
    90
#define strasm_sync                       "\n  sync    \n"
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
    91
#define strasm_lwsync                     "\n  lwsync  \n"
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
    92
#define strasm_isync                      "\n  isync   \n"
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
    93
#define strasm_release                    strasm_lwsync
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
    94
#define strasm_acquire                    strasm_lwsync
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
    95
#define strasm_fence                      strasm_sync
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
    96
#define strasm_nobarrier                  ""
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
    97
#define strasm_nobarrier_clobber_memory   ""
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    98
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    99
inline jint     Atomic::add    (jint     add_value, volatile jint*     dest) {
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   100
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   101
  unsigned int result;
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   102
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   103
  __asm__ __volatile__ (
22867
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
   104
    strasm_lwsync
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   105
    "1: lwarx   %0,  0, %2    \n"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   106
    "   add     %0, %0, %1    \n"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   107
    "   stwcx.  %0,  0, %2    \n"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   108
    "   bne-    1b            \n"
22867
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
   109
    strasm_isync
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   110
    : /*%0*/"=&r" (result)
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   111
    : /*%1*/"r" (add_value), /*%2*/"r" (dest)
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   112
    : "cc", "memory" );
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   113
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   114
  return (jint) result;
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   115
}
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   116
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   117
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   118
inline intptr_t Atomic::add_ptr(intptr_t add_value, volatile intptr_t* dest) {
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   119
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   120
  long result;
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   121
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   122
  __asm__ __volatile__ (
22867
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
   123
    strasm_lwsync
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   124
    "1: ldarx   %0,  0, %2    \n"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   125
    "   add     %0, %0, %1    \n"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   126
    "   stdcx.  %0,  0, %2    \n"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   127
    "   bne-    1b            \n"
22867
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
   128
    strasm_isync
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   129
    : /*%0*/"=&r" (result)
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   130
    : /*%1*/"r" (add_value), /*%2*/"r" (dest)
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   131
    : "cc", "memory" );
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   132
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   133
  return (intptr_t) result;
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   134
}
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   135
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   136
inline void*    Atomic::add_ptr(intptr_t add_value, volatile void*     dest) {
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   137
  return (void*)add_ptr(add_value, (volatile intptr_t*)dest);
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   138
}
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   139
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   140
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   141
inline void Atomic::inc    (volatile jint*     dest) {
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   142
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   143
  unsigned int temp;
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   144
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   145
  __asm__ __volatile__ (
22867
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
   146
    strasm_nobarrier
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   147
    "1: lwarx   %0,  0, %2    \n"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   148
    "   addic   %0, %0,  1    \n"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   149
    "   stwcx.  %0,  0, %2    \n"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   150
    "   bne-    1b            \n"
22867
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
   151
    strasm_nobarrier
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   152
    : /*%0*/"=&r" (temp), "=m" (*dest)
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   153
    : /*%2*/"r" (dest), "m" (*dest)
22867
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
   154
    : "cc" strasm_nobarrier_clobber_memory);
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   155
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   156
}
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   157
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   158
inline void Atomic::inc_ptr(volatile intptr_t* dest) {
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   159
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   160
  long temp;
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   161
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   162
  __asm__ __volatile__ (
22867
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
   163
    strasm_nobarrier
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   164
    "1: ldarx   %0,  0, %2    \n"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   165
    "   addic   %0, %0,  1    \n"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   166
    "   stdcx.  %0,  0, %2    \n"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   167
    "   bne-    1b            \n"
22867
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
   168
    strasm_nobarrier
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   169
    : /*%0*/"=&r" (temp), "=m" (*dest)
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   170
    : /*%2*/"r" (dest), "m" (*dest)
22867
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
   171
    : "cc" strasm_nobarrier_clobber_memory);
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   172
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   173
}
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   174
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   175
inline void Atomic::inc_ptr(volatile void*     dest) {
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   176
  inc_ptr((volatile intptr_t*)dest);
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   177
}
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   178
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   179
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   180
inline void Atomic::dec    (volatile jint*     dest) {
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   181
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   182
  unsigned int temp;
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   183
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   184
  __asm__ __volatile__ (
22867
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
   185
    strasm_nobarrier
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   186
    "1: lwarx   %0,  0, %2    \n"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   187
    "   addic   %0, %0, -1    \n"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   188
    "   stwcx.  %0,  0, %2    \n"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   189
    "   bne-    1b            \n"
22867
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
   190
    strasm_nobarrier
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   191
    : /*%0*/"=&r" (temp), "=m" (*dest)
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   192
    : /*%2*/"r" (dest), "m" (*dest)
22867
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
   193
    : "cc" strasm_nobarrier_clobber_memory);
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   194
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   195
}
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   196
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   197
inline void Atomic::dec_ptr(volatile intptr_t* dest) {
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   198
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   199
  long temp;
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   200
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   201
  __asm__ __volatile__ (
22867
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
   202
    strasm_nobarrier
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   203
    "1: ldarx   %0,  0, %2    \n"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   204
    "   addic   %0, %0, -1    \n"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   205
    "   stdcx.  %0,  0, %2    \n"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   206
    "   bne-    1b            \n"
22867
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
   207
    strasm_nobarrier
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   208
    : /*%0*/"=&r" (temp), "=m" (*dest)
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   209
    : /*%2*/"r" (dest), "m" (*dest)
22867
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
   210
    : "cc" strasm_nobarrier_clobber_memory);
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   211
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   212
}
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   213
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   214
inline void Atomic::dec_ptr(volatile void*     dest) {
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   215
  dec_ptr((volatile intptr_t*)dest);
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   216
}
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   217
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   218
inline jint Atomic::xchg(jint exchange_value, volatile jint* dest) {
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   219
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   220
  // Note that xchg_ptr doesn't necessarily do an acquire
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   221
  // (see synchronizer.cpp).
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   222
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   223
  unsigned int old_value;
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   224
  const uint64_t zero = 0;
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   225
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   226
  __asm__ __volatile__ (
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   227
    /* lwsync */
22867
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
   228
    strasm_lwsync
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   229
    /* atomic loop */
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   230
    "1:                                                 \n"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   231
    "   lwarx   %[old_value], %[dest], %[zero]          \n"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   232
    "   stwcx.  %[exchange_value], %[dest], %[zero]     \n"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   233
    "   bne-    1b                                      \n"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   234
    /* isync */
22867
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
   235
    strasm_sync
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   236
    /* exit */
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   237
    "2:                                                 \n"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   238
    /* out */
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   239
    : [old_value]       "=&r"   (old_value),
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   240
                        "=m"    (*dest)
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   241
    /* in */
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   242
    : [dest]            "b"     (dest),
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   243
      [zero]            "r"     (zero),
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   244
      [exchange_value]  "r"     (exchange_value),
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   245
                        "m"     (*dest)
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   246
    /* clobber */
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   247
    : "cc",
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   248
      "memory"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   249
    );
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   250
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   251
  return (jint) old_value;
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   252
}
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   253
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   254
inline intptr_t Atomic::xchg_ptr(intptr_t exchange_value, volatile intptr_t* dest) {
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   255
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   256
  // Note that xchg_ptr doesn't necessarily do an acquire
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   257
  // (see synchronizer.cpp).
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   258
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   259
  long old_value;
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   260
  const uint64_t zero = 0;
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   261
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   262
  __asm__ __volatile__ (
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   263
    /* lwsync */
22867
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
   264
    strasm_lwsync
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   265
    /* atomic loop */
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   266
    "1:                                                 \n"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   267
    "   ldarx   %[old_value], %[dest], %[zero]          \n"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   268
    "   stdcx.  %[exchange_value], %[dest], %[zero]     \n"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   269
    "   bne-    1b                                      \n"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   270
    /* isync */
22867
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
   271
    strasm_sync
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   272
    /* exit */
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   273
    "2:                                                 \n"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   274
    /* out */
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   275
    : [old_value]       "=&r"   (old_value),
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   276
                        "=m"    (*dest)
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   277
    /* in */
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   278
    : [dest]            "b"     (dest),
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   279
      [zero]            "r"     (zero),
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   280
      [exchange_value]  "r"     (exchange_value),
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   281
                        "m"     (*dest)
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   282
    /* clobber */
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   283
    : "cc",
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   284
      "memory"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   285
    );
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   286
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   287
  return (intptr_t) old_value;
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   288
}
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   289
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   290
inline void* Atomic::xchg_ptr(void* exchange_value, volatile void* dest) {
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   291
  return (void*)xchg_ptr((intptr_t)exchange_value, (volatile intptr_t*)dest);
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   292
}
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   293
39404
d0ad5220e91c 8155949: Support relaxed semantics in cmpxchg
mdoerr
parents: 35594
diff changeset
   294
inline void cmpxchg_pre_membar(cmpxchg_memory_order order) {
d0ad5220e91c 8155949: Support relaxed semantics in cmpxchg
mdoerr
parents: 35594
diff changeset
   295
  if (order != memory_order_relaxed) {
d0ad5220e91c 8155949: Support relaxed semantics in cmpxchg
mdoerr
parents: 35594
diff changeset
   296
    __asm__ __volatile__ (
d0ad5220e91c 8155949: Support relaxed semantics in cmpxchg
mdoerr
parents: 35594
diff changeset
   297
      /* fence */
d0ad5220e91c 8155949: Support relaxed semantics in cmpxchg
mdoerr
parents: 35594
diff changeset
   298
      strasm_sync
d0ad5220e91c 8155949: Support relaxed semantics in cmpxchg
mdoerr
parents: 35594
diff changeset
   299
      );
d0ad5220e91c 8155949: Support relaxed semantics in cmpxchg
mdoerr
parents: 35594
diff changeset
   300
  }
d0ad5220e91c 8155949: Support relaxed semantics in cmpxchg
mdoerr
parents: 35594
diff changeset
   301
}
d0ad5220e91c 8155949: Support relaxed semantics in cmpxchg
mdoerr
parents: 35594
diff changeset
   302
d0ad5220e91c 8155949: Support relaxed semantics in cmpxchg
mdoerr
parents: 35594
diff changeset
   303
inline void cmpxchg_post_membar(cmpxchg_memory_order order) {
d0ad5220e91c 8155949: Support relaxed semantics in cmpxchg
mdoerr
parents: 35594
diff changeset
   304
  if (order != memory_order_relaxed) {
d0ad5220e91c 8155949: Support relaxed semantics in cmpxchg
mdoerr
parents: 35594
diff changeset
   305
    __asm__ __volatile__ (
d0ad5220e91c 8155949: Support relaxed semantics in cmpxchg
mdoerr
parents: 35594
diff changeset
   306
      /* fence */
d0ad5220e91c 8155949: Support relaxed semantics in cmpxchg
mdoerr
parents: 35594
diff changeset
   307
      strasm_sync
d0ad5220e91c 8155949: Support relaxed semantics in cmpxchg
mdoerr
parents: 35594
diff changeset
   308
      );
d0ad5220e91c 8155949: Support relaxed semantics in cmpxchg
mdoerr
parents: 35594
diff changeset
   309
  }
d0ad5220e91c 8155949: Support relaxed semantics in cmpxchg
mdoerr
parents: 35594
diff changeset
   310
}
d0ad5220e91c 8155949: Support relaxed semantics in cmpxchg
mdoerr
parents: 35594
diff changeset
   311
35063
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   312
#define VM_HAS_SPECIALIZED_CMPXCHG_BYTE
39404
d0ad5220e91c 8155949: Support relaxed semantics in cmpxchg
mdoerr
parents: 35594
diff changeset
   313
inline jbyte Atomic::cmpxchg(jbyte exchange_value, volatile jbyte* dest, jbyte compare_value, cmpxchg_memory_order order) {
35063
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   314
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   315
  // Note that cmpxchg guarantees a two-way memory barrier across
39404
d0ad5220e91c 8155949: Support relaxed semantics in cmpxchg
mdoerr
parents: 35594
diff changeset
   316
  // the cmpxchg, so it's really a a 'fence_cmpxchg_fence' if not
d0ad5220e91c 8155949: Support relaxed semantics in cmpxchg
mdoerr
parents: 35594
diff changeset
   317
  // specified otherwise (see atomic.hpp).
35063
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   318
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   319
  // Using 32 bit internally.
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   320
  volatile int *dest_base = (volatile int*)((uintptr_t)dest & ~3);
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   321
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   322
#ifdef VM_LITTLE_ENDIAN
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   323
  const unsigned int shift_amount        = ((uintptr_t)dest & 3) * 8;
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   324
#else
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   325
  const unsigned int shift_amount        = ((~(uintptr_t)dest) & 3) * 8;
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   326
#endif
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   327
  const unsigned int masked_compare_val  = ((unsigned int)(unsigned char)compare_value),
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   328
                     masked_exchange_val = ((unsigned int)(unsigned char)exchange_value),
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   329
                     xor_value           = (masked_compare_val ^ masked_exchange_val) << shift_amount;
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   330
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   331
  unsigned int old_value, value32;
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   332
39404
d0ad5220e91c 8155949: Support relaxed semantics in cmpxchg
mdoerr
parents: 35594
diff changeset
   333
  cmpxchg_pre_membar(order);
d0ad5220e91c 8155949: Support relaxed semantics in cmpxchg
mdoerr
parents: 35594
diff changeset
   334
35063
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   335
  __asm__ __volatile__ (
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   336
    /* simple guard */
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   337
    "   lbz     %[old_value], 0(%[dest])                  \n"
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   338
    "   cmpw    %[masked_compare_val], %[old_value]       \n"
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   339
    "   bne-    2f                                        \n"
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   340
    /* atomic loop */
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   341
    "1:                                                   \n"
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   342
    "   lwarx   %[value32], 0, %[dest_base]               \n"
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   343
    /* extract byte and compare */
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   344
    "   srd     %[old_value], %[value32], %[shift_amount] \n"
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   345
    "   clrldi  %[old_value], %[old_value], 56            \n"
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   346
    "   cmpw    %[masked_compare_val], %[old_value]       \n"
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   347
    "   bne-    2f                                        \n"
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   348
    /* replace byte and try to store */
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   349
    "   xor     %[value32], %[xor_value], %[value32]      \n"
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   350
    "   stwcx.  %[value32], 0, %[dest_base]               \n"
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   351
    "   bne-    1b                                        \n"
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   352
    /* exit */
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   353
    "2:                                                   \n"
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   354
    /* out */
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   355
    : [old_value]           "=&r"   (old_value),
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   356
      [value32]             "=&r"   (value32),
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   357
                            "=m"    (*dest),
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   358
                            "=m"    (*dest_base)
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   359
    /* in */
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   360
    : [dest]                "b"     (dest),
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   361
      [dest_base]           "b"     (dest_base),
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   362
      [shift_amount]        "r"     (shift_amount),
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   363
      [masked_compare_val]  "r"     (masked_compare_val),
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   364
      [xor_value]           "r"     (xor_value),
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   365
                            "m"     (*dest),
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   366
                            "m"     (*dest_base)
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   367
    /* clobber */
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   368
    : "cc",
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   369
      "memory"
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   370
    );
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   371
39404
d0ad5220e91c 8155949: Support relaxed semantics in cmpxchg
mdoerr
parents: 35594
diff changeset
   372
  cmpxchg_post_membar(order);
d0ad5220e91c 8155949: Support relaxed semantics in cmpxchg
mdoerr
parents: 35594
diff changeset
   373
35063
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   374
  return (jbyte)(unsigned char)old_value;
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   375
}
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 25715
diff changeset
   376
39404
d0ad5220e91c 8155949: Support relaxed semantics in cmpxchg
mdoerr
parents: 35594
diff changeset
   377
inline jint Atomic::cmpxchg(jint exchange_value, volatile jint* dest, jint compare_value, cmpxchg_memory_order order) {
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   378
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   379
  // Note that cmpxchg guarantees a two-way memory barrier across
39404
d0ad5220e91c 8155949: Support relaxed semantics in cmpxchg
mdoerr
parents: 35594
diff changeset
   380
  // the cmpxchg, so it's really a a 'fence_cmpxchg_fence' if not
d0ad5220e91c 8155949: Support relaxed semantics in cmpxchg
mdoerr
parents: 35594
diff changeset
   381
  // specified otherwise (see atomic.hpp).
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   382
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   383
  unsigned int old_value;
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   384
  const uint64_t zero = 0;
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   385
39404
d0ad5220e91c 8155949: Support relaxed semantics in cmpxchg
mdoerr
parents: 35594
diff changeset
   386
  cmpxchg_pre_membar(order);
d0ad5220e91c 8155949: Support relaxed semantics in cmpxchg
mdoerr
parents: 35594
diff changeset
   387
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   388
  __asm__ __volatile__ (
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   389
    /* simple guard */
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   390
    "   lwz     %[old_value], 0(%[dest])                \n"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   391
    "   cmpw    %[compare_value], %[old_value]          \n"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   392
    "   bne-    2f                                      \n"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   393
    /* atomic loop */
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   394
    "1:                                                 \n"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   395
    "   lwarx   %[old_value], %[dest], %[zero]          \n"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   396
    "   cmpw    %[compare_value], %[old_value]          \n"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   397
    "   bne-    2f                                      \n"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   398
    "   stwcx.  %[exchange_value], %[dest], %[zero]     \n"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   399
    "   bne-    1b                                      \n"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   400
    /* exit */
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   401
    "2:                                                 \n"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   402
    /* out */
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   403
    : [old_value]       "=&r"   (old_value),
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   404
                        "=m"    (*dest)
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   405
    /* in */
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   406
    : [dest]            "b"     (dest),
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   407
      [zero]            "r"     (zero),
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   408
      [compare_value]   "r"     (compare_value),
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   409
      [exchange_value]  "r"     (exchange_value),
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   410
                        "m"     (*dest)
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   411
    /* clobber */
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   412
    : "cc",
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   413
      "memory"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   414
    );
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   415
39404
d0ad5220e91c 8155949: Support relaxed semantics in cmpxchg
mdoerr
parents: 35594
diff changeset
   416
  cmpxchg_post_membar(order);
d0ad5220e91c 8155949: Support relaxed semantics in cmpxchg
mdoerr
parents: 35594
diff changeset
   417
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   418
  return (jint) old_value;
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   419
}
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   420
39404
d0ad5220e91c 8155949: Support relaxed semantics in cmpxchg
mdoerr
parents: 35594
diff changeset
   421
inline jlong Atomic::cmpxchg(jlong exchange_value, volatile jlong* dest, jlong compare_value, cmpxchg_memory_order order) {
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   422
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   423
  // Note that cmpxchg guarantees a two-way memory barrier across
39404
d0ad5220e91c 8155949: Support relaxed semantics in cmpxchg
mdoerr
parents: 35594
diff changeset
   424
  // the cmpxchg, so it's really a a 'fence_cmpxchg_fence' if not
d0ad5220e91c 8155949: Support relaxed semantics in cmpxchg
mdoerr
parents: 35594
diff changeset
   425
  // specified otherwise (see atomic.hpp).
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   426
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   427
  long old_value;
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   428
  const uint64_t zero = 0;
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   429
39404
d0ad5220e91c 8155949: Support relaxed semantics in cmpxchg
mdoerr
parents: 35594
diff changeset
   430
  cmpxchg_pre_membar(order);
d0ad5220e91c 8155949: Support relaxed semantics in cmpxchg
mdoerr
parents: 35594
diff changeset
   431
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   432
  __asm__ __volatile__ (
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   433
    /* simple guard */
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   434
    "   ld      %[old_value], 0(%[dest])                \n"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   435
    "   cmpd    %[compare_value], %[old_value]          \n"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   436
    "   bne-    2f                                      \n"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   437
    /* atomic loop */
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   438
    "1:                                                 \n"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   439
    "   ldarx   %[old_value], %[dest], %[zero]          \n"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   440
    "   cmpd    %[compare_value], %[old_value]          \n"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   441
    "   bne-    2f                                      \n"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   442
    "   stdcx.  %[exchange_value], %[dest], %[zero]     \n"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   443
    "   bne-    1b                                      \n"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   444
    /* exit */
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   445
    "2:                                                 \n"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   446
    /* out */
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   447
    : [old_value]       "=&r"   (old_value),
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   448
                        "=m"    (*dest)
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   449
    /* in */
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   450
    : [dest]            "b"     (dest),
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   451
      [zero]            "r"     (zero),
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   452
      [compare_value]   "r"     (compare_value),
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   453
      [exchange_value]  "r"     (exchange_value),
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   454
                        "m"     (*dest)
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   455
    /* clobber */
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   456
    : "cc",
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   457
      "memory"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   458
    );
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   459
39404
d0ad5220e91c 8155949: Support relaxed semantics in cmpxchg
mdoerr
parents: 35594
diff changeset
   460
  cmpxchg_post_membar(order);
d0ad5220e91c 8155949: Support relaxed semantics in cmpxchg
mdoerr
parents: 35594
diff changeset
   461
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   462
  return (jlong) old_value;
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   463
}
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   464
39404
d0ad5220e91c 8155949: Support relaxed semantics in cmpxchg
mdoerr
parents: 35594
diff changeset
   465
inline intptr_t Atomic::cmpxchg_ptr(intptr_t exchange_value, volatile intptr_t* dest, intptr_t compare_value, cmpxchg_memory_order order) {
d0ad5220e91c 8155949: Support relaxed semantics in cmpxchg
mdoerr
parents: 35594
diff changeset
   466
  return (intptr_t)cmpxchg((jlong)exchange_value, (volatile jlong*)dest, (jlong)compare_value, order);
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   467
}
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   468
39404
d0ad5220e91c 8155949: Support relaxed semantics in cmpxchg
mdoerr
parents: 35594
diff changeset
   469
inline void* Atomic::cmpxchg_ptr(void* exchange_value, volatile void* dest, void* compare_value, cmpxchg_memory_order order) {
d0ad5220e91c 8155949: Support relaxed semantics in cmpxchg
mdoerr
parents: 35594
diff changeset
   470
  return (void*)cmpxchg((jlong)exchange_value, (volatile jlong*)dest, (jlong)compare_value, order);
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   471
}
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   472
22867
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
   473
#undef strasm_sync
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
   474
#undef strasm_lwsync
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
   475
#undef strasm_isync
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
   476
#undef strasm_release
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
   477
#undef strasm_acquire
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
   478
#undef strasm_fence
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
   479
#undef strasm_nobarrier
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22831
diff changeset
   480
#undef strasm_nobarrier_clobber_memory
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   481
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   482
#endif // OS_CPU_AIX_OJDKPPC_VM_ATOMIC_AIX_PPC_INLINE_HPP