src/hotspot/os_cpu/linux_arm/orderAccess_linux_arm.hpp
author coleenp
Wed, 06 Jun 2018 10:45:40 -0400
changeset 50429 83aec1d357d4
parent 49364 src/hotspot/os_cpu/linux_arm/orderAccess_linux_arm.inline.hpp@601146c66cad
child 51996 84743156e780
permissions -rw-r--r--
8204301: Make OrderAccess functions available to hpp rather than inline.hpp files Summary: move orderAccess.inline.hpp into orderAccess.hpp and remove os.hpp inclusion and conditional os::is_MP() for fence on x86 platforms Reviewed-by: dholmes, hseigel
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42664
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
     1
/*
49364
601146c66cad 8173070: Remove ValueObj class for allocation subclassing for runtime code
coleenp
parents: 47609
diff changeset
     2
 * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
42664
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
     4
 *
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
     7
 * published by the Free Software Foundation.
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
     8
 *
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    13
 * accompanied this code).
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    14
 *
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    18
 *
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    21
 * questions.
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    22
 *
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    23
 */
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    24
50429
83aec1d357d4 8204301: Make OrderAccess functions available to hpp rather than inline.hpp files
coleenp
parents: 49364
diff changeset
    25
#ifndef OS_CPU_LINUX_ARM_VM_ORDERACCESS_LINUX_ARM_HPP
83aec1d357d4 8204301: Make OrderAccess functions available to hpp rather than inline.hpp files
coleenp
parents: 49364
diff changeset
    26
#define OS_CPU_LINUX_ARM_VM_ORDERACCESS_LINUX_ARM_HPP
42664
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    27
50429
83aec1d357d4 8204301: Make OrderAccess functions available to hpp rather than inline.hpp files
coleenp
parents: 49364
diff changeset
    28
// Included in orderAccess.hpp header file.
83aec1d357d4 8204301: Make OrderAccess functions available to hpp rather than inline.hpp files
coleenp
parents: 49364
diff changeset
    29
42664
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    30
#include "runtime/os.hpp"
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    31
#include "vm_version_arm.hpp"
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    32
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    33
// Implementation of class OrderAccess.
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    34
// - we define the high level barriers below and use the general
50429
83aec1d357d4 8204301: Make OrderAccess functions available to hpp rather than inline.hpp files
coleenp
parents: 49364
diff changeset
    35
//   implementation in orderAccess.hpp, with customizations
42664
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    36
//   on AARCH64 via the specialized_* template functions
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    37
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    38
// Memory Ordering on ARM is weak.
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    39
//
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    40
// Implement all 4 memory ordering barriers by DMB, since it is a
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    41
// lighter version of DSB.
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    42
// dmb_sy implies full system shareability domain. RD/WR access type.
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    43
// dmb_st implies full system shareability domain. WR only access type.
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    44
//
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    45
// NOP on < ARMv6 (MP not supported)
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    46
//
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    47
// Non mcr instructions can be used if we build for armv7 or higher arch
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    48
//    __asm__ __volatile__ ("dmb" : : : "memory");
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    49
//    __asm__ __volatile__ ("dsb" : : : "memory");
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    50
//
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    51
// inline void _OrderAccess_dsb() {
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    52
//    volatile intptr_t dummy = 0;
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    53
//    if (os::is_MP()) {
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    54
//      __asm__ volatile (
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    55
//        "mcr p15, 0, %0, c7, c10, 4"
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    56
//        : : "r" (dummy) : "memory");
50429
83aec1d357d4 8204301: Make OrderAccess functions available to hpp rather than inline.hpp files
coleenp
parents: 49364
diff changeset
    57
//    }
42664
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    58
// }
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    59
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    60
inline static void dmb_sy() {
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    61
   if (!os::is_MP()) {
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    62
     return;
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    63
   }
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    64
#ifdef AARCH64
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    65
   __asm__ __volatile__ ("dmb sy" : : : "memory");
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    66
#else
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    67
   if (VM_Version::arm_arch() >= 7) {
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    68
#ifdef __thumb__
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    69
     __asm__ volatile (
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    70
     "dmb sy": : : "memory");
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    71
#else
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    72
     __asm__ volatile (
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    73
     ".word 0xF57FF050 | 0xf" : : : "memory");
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    74
#endif
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    75
   } else {
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    76
     intptr_t zero = 0;
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    77
     __asm__ volatile (
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    78
       "mcr p15, 0, %0, c7, c10, 5"
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    79
       : : "r" (zero) : "memory");
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    80
   }
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    81
#endif
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    82
}
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    83
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    84
inline static void dmb_st() {
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    85
   if (!os::is_MP()) {
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    86
     return;
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    87
   }
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    88
#ifdef AARCH64
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    89
   __asm__ __volatile__ ("dmb st" : : : "memory");
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    90
#else
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    91
   if (VM_Version::arm_arch() >= 7) {
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    92
#ifdef __thumb__
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    93
     __asm__ volatile (
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    94
     "dmb st": : : "memory");
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    95
#else
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    96
     __asm__ volatile (
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    97
     ".word 0xF57FF050 | 0xe" : : : "memory");
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    98
#endif
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    99
   } else {
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   100
     intptr_t zero = 0;
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   101
     __asm__ volatile (
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   102
       "mcr p15, 0, %0, c7, c10, 5"
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   103
       : : "r" (zero) : "memory");
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   104
   }
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   105
#endif
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   106
}
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   107
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   108
// Load-Load/Store barrier
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   109
inline static void dmb_ld() {
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   110
#ifdef AARCH64
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   111
   if (!os::is_MP()) {
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   112
     return;
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   113
   }
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   114
   __asm__ __volatile__ ("dmb ld" : : : "memory");
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   115
#else
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   116
   dmb_sy();
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   117
#endif
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   118
}
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   119
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   120
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   121
inline void OrderAccess::loadload()   { dmb_ld(); }
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   122
inline void OrderAccess::loadstore()  { dmb_ld(); }
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   123
inline void OrderAccess::acquire()    { dmb_ld(); }
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   124
inline void OrderAccess::storestore() { dmb_st(); }
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   125
inline void OrderAccess::storeload()  { dmb_sy(); }
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   126
inline void OrderAccess::release()    { dmb_sy(); }
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   127
inline void OrderAccess::fence()      { dmb_sy(); }
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   128
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   129
// specializations for Aarch64
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   130
// TODO-AARCH64: evaluate effectiveness of ldar*/stlr* implementations compared to 32-bit ARM approach
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   131
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   132
#ifdef AARCH64
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   133
47609
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   134
template<>
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   135
struct OrderAccess::PlatformOrderedLoad<1, X_ACQUIRE>
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   136
{
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   137
  template <typename T>
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   138
  T operator()(const volatile T* p) const {
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   139
    volatile T result;
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   140
    __asm__ volatile(
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   141
      "ldarb %w[res], [%[ptr]]"
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   142
      : [res] "=&r" (result)
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   143
      : [ptr] "r" (p)
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   144
      : "memory");
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   145
    return result;
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   146
  }
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   147
};
42664
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   148
47609
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   149
template<>
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   150
struct OrderAccess::PlatformOrderedLoad<2, X_ACQUIRE>
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   151
{
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   152
  template <typename T>
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   153
  T operator()(const volatile T* p) const {
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   154
    volatile T result;
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   155
    __asm__ volatile(
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   156
      "ldarh %w[res], [%[ptr]]"
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   157
      : [res] "=&r" (result)
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   158
      : [ptr] "r" (p)
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   159
      : "memory");
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   160
    return result;
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   161
  }
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   162
};
42664
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   163
47609
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   164
template<>
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   165
struct OrderAccess::PlatformOrderedLoad<4, X_ACQUIRE>
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   166
{
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   167
  template <typename T>
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   168
  T operator()(const volatile T* p) const {
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   169
    volatile T result;
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   170
    __asm__ volatile(
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   171
      "ldar %w[res], [%[ptr]]"
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   172
      : [res] "=&r" (result)
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   173
      : [ptr] "r" (p)
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   174
      : "memory");
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   175
    return result;
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   176
  }
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   177
};
42664
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   178
47609
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   179
template<>
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   180
struct OrderAccess::PlatformOrderedLoad<8, X_ACQUIRE>
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   181
{
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   182
  template <typename T>
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   183
  T operator()(const volatile T* p) const {
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   184
    volatile T result;
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   185
    __asm__ volatile(
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   186
      "ldar %[res], [%[ptr]]"
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   187
      : [res] "=&r" (result)
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   188
      : [ptr] "r" (p)
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   189
      : "memory");
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   190
    return result;
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   191
  }
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   192
};
42664
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   193
47609
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   194
template<>
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   195
struct OrderAccess::PlatformOrderedStore<1, RELEASE_X_FENCE>
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   196
{
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   197
  template <typename T>
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   198
  void operator()(T v, volatile T* p) const {
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   199
    __asm__ volatile(
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   200
      "stlrb %w[val], [%[ptr]]"
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   201
      :
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   202
      : [ptr] "r" (p), [val] "r" (v)
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   203
      : "memory");
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   204
  }
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   205
};
42664
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   206
47609
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   207
template<>
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   208
struct OrderAccess::PlatformOrderedStore<2, RELEASE_X_FENCE>
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   209
{
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   210
  template <typename T>
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   211
  void operator()(T v, volatile T* p) const {
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   212
    __asm__ volatile(
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   213
      "stlrh %w[val], [%[ptr]]"
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   214
      :
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   215
      : [ptr] "r" (p), [val] "r" (v)
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   216
      : "memory");
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   217
  }
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   218
};
42664
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   219
47609
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   220
template<>
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   221
struct OrderAccess::PlatformOrderedStore<4, RELEASE_X_FENCE>
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   222
{
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   223
  template <typename T>
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   224
  void operator()(T v, volatile T* p) const {
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   225
    __asm__ volatile(
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   226
      "stlr %w[val], [%[ptr]]"
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   227
      :
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   228
      : [ptr] "r" (p), [val] "r" (v)
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   229
      : "memory");
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   230
  }
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   231
};
42664
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   232
47609
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   233
template<>
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   234
struct OrderAccess::PlatformOrderedStore<8, RELEASE_X_FENCE>
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   235
{
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   236
  template <typename T>
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   237
  void operator()(T v, volatile T* p) const {
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   238
    __asm__ volatile(
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   239
      "stlr %[val], [%[ptr]]"
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   240
      :
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   241
      : [ptr] "r" (p), [val] "r" (v)
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   242
      : "memory");
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   243
  }
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   244
};
a1f68e415b48 8188813: Generalize OrderAccess to use templates
eosterlund
parents: 47216
diff changeset
   245
42664
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   246
#endif // AARCH64
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   247
50429
83aec1d357d4 8204301: Make OrderAccess functions available to hpp rather than inline.hpp files
coleenp
parents: 49364
diff changeset
   248
#endif // OS_CPU_LINUX_ARM_VM_ORDERACCESS_LINUX_ARM_HPP