src/hotspot/share/oops/accessBackend.inline.hpp
author eosterlund
Fri, 16 Mar 2018 14:47:53 +0100
changeset 49454 689ebcfe04fd
parent 49383 bf2ff45e592f
child 49592 77fb0be7d19f
permissions -rw-r--r--
8199685: Access arraycopy build failure with GCC 7.3.1 Reviewed-by: rkennke, pliden
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
     1
/*
48628
69d65d9dcadb 8193063: Enabling narrowOop values for RawAccess accesses
eosterlund
parents: 47998
diff changeset
     2
 * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
     4
 *
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
     7
 * published by the Free Software Foundation.
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
     8
 *
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    13
 * accompanied this code).
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    14
 *
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    18
 *
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    21
 * questions.
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    22
 *
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    23
 */
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    24
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    25
#ifndef SHARE_VM_RUNTIME_ACCESSBACKEND_INLINE_HPP
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    26
#define SHARE_VM_RUNTIME_ACCESSBACKEND_INLINE_HPP
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    27
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    28
#include "oops/access.hpp"
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    29
#include "oops/accessBackend.hpp"
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    30
#include "oops/oop.inline.hpp"
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    31
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    32
template <DecoratorSet decorators>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    33
template <DecoratorSet idecorators, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    34
inline typename EnableIf<
48628
69d65d9dcadb 8193063: Enabling narrowOop values for RawAccess accesses
eosterlund
parents: 47998
diff changeset
    35
  AccessInternal::MustConvertCompressedOop<idecorators, T>::value, T>::type
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    36
RawAccessBarrier<decorators>::decode_internal(typename HeapOopType<idecorators>::type value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    37
  if (HasDecorator<decorators, OOP_NOT_NULL>::value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    38
    return oopDesc::decode_heap_oop_not_null(value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    39
  } else {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    40
    return oopDesc::decode_heap_oop(value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    41
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    42
}
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    43
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    44
template <DecoratorSet decorators>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    45
template <DecoratorSet idecorators, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    46
inline typename EnableIf<
48628
69d65d9dcadb 8193063: Enabling narrowOop values for RawAccess accesses
eosterlund
parents: 47998
diff changeset
    47
  AccessInternal::MustConvertCompressedOop<idecorators, T>::value,
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    48
  typename HeapOopType<idecorators>::type>::type
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    49
RawAccessBarrier<decorators>::encode_internal(T value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    50
  if (HasDecorator<decorators, OOP_NOT_NULL>::value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    51
    return oopDesc::encode_heap_oop_not_null(value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    52
  } else {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    53
    return oopDesc::encode_heap_oop(value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    54
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    55
}
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    56
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    57
template <DecoratorSet decorators>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    58
template <typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    59
inline void RawAccessBarrier<decorators>::oop_store(void* addr, T value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    60
  typedef typename AccessInternal::EncodedType<decorators, T>::type Encoded;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    61
  Encoded encoded = encode(value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    62
  store(reinterpret_cast<Encoded*>(addr), encoded);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    63
}
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    64
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    65
template <DecoratorSet decorators>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    66
template <typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    67
inline void RawAccessBarrier<decorators>::oop_store_at(oop base, ptrdiff_t offset, T value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    68
  oop_store(field_addr(base, offset), value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    69
}
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    70
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    71
template <DecoratorSet decorators>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    72
template <typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    73
inline T RawAccessBarrier<decorators>::oop_load(void* addr) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    74
  typedef typename AccessInternal::EncodedType<decorators, T>::type Encoded;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    75
  Encoded encoded = load<Encoded>(reinterpret_cast<Encoded*>(addr));
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    76
  return decode<T>(encoded);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    77
}
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    78
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    79
template <DecoratorSet decorators>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    80
template <typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    81
inline T RawAccessBarrier<decorators>::oop_load_at(oop base, ptrdiff_t offset) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    82
  return oop_load<T>(field_addr(base, offset));
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    83
}
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    84
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    85
template <DecoratorSet decorators>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    86
template <typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    87
inline T RawAccessBarrier<decorators>::oop_atomic_cmpxchg(T new_value, void* addr, T compare_value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    88
  typedef typename AccessInternal::EncodedType<decorators, T>::type Encoded;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    89
  Encoded encoded_new = encode(new_value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    90
  Encoded encoded_compare = encode(compare_value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    91
  Encoded encoded_result = atomic_cmpxchg(encoded_new,
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    92
                                          reinterpret_cast<Encoded*>(addr),
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    93
                                          encoded_compare);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    94
  return decode<T>(encoded_result);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    95
}
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    96
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    97
template <DecoratorSet decorators>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    98
template <typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    99
inline T RawAccessBarrier<decorators>::oop_atomic_cmpxchg_at(T new_value, oop base, ptrdiff_t offset, T compare_value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   100
  return oop_atomic_cmpxchg(new_value, field_addr(base, offset), compare_value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   101
}
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   102
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   103
template <DecoratorSet decorators>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   104
template <typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   105
inline T RawAccessBarrier<decorators>::oop_atomic_xchg(T new_value, void* addr) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   106
  typedef typename AccessInternal::EncodedType<decorators, T>::type Encoded;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   107
  Encoded encoded_new = encode(new_value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   108
  Encoded encoded_result = atomic_xchg(encoded_new, reinterpret_cast<Encoded*>(addr));
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   109
  return decode<T>(encoded_result);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   110
}
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   111
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   112
template <DecoratorSet decorators>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   113
template <typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   114
inline T RawAccessBarrier<decorators>::oop_atomic_xchg_at(T new_value, oop base, ptrdiff_t offset) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   115
  return oop_atomic_xchg(new_value, field_addr(base, offset));
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   116
}
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   117
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   118
template <DecoratorSet decorators>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   119
template <typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   120
inline bool RawAccessBarrier<decorators>::oop_arraycopy(arrayOop src_obj, arrayOop dst_obj, T* src, T* dst, size_t length) {
49383
bf2ff45e592f 8198445: Access API for primitive/native arraycopy
rkennke
parents: 48628
diff changeset
   121
  return arraycopy(src_obj, dst_obj, src, dst, length);
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   122
}
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   123
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   124
template <DecoratorSet decorators>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   125
template <DecoratorSet ds, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   126
inline typename EnableIf<
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   127
  HasDecorator<ds, MO_SEQ_CST>::value, T>::type
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   128
RawAccessBarrier<decorators>::load_internal(void* addr) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   129
  if (support_IRIW_for_not_multiple_copy_atomic_cpu) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   130
    OrderAccess::fence();
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   131
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   132
  return OrderAccess::load_acquire(reinterpret_cast<const volatile T*>(addr));
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   133
}
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   134
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   135
template <DecoratorSet decorators>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   136
template <DecoratorSet ds, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   137
inline typename EnableIf<
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   138
  HasDecorator<ds, MO_ACQUIRE>::value, T>::type
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   139
RawAccessBarrier<decorators>::load_internal(void* addr) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   140
  return OrderAccess::load_acquire(reinterpret_cast<const volatile T*>(addr));
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   141
}
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   142
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   143
template <DecoratorSet decorators>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   144
template <DecoratorSet ds, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   145
inline typename EnableIf<
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   146
  HasDecorator<ds, MO_RELAXED>::value, T>::type
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   147
RawAccessBarrier<decorators>::load_internal(void* addr) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   148
  return Atomic::load(reinterpret_cast<const volatile T*>(addr));
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   149
}
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   150
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   151
template <DecoratorSet decorators>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   152
template <DecoratorSet ds, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   153
inline typename EnableIf<
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   154
  HasDecorator<ds, MO_SEQ_CST>::value>::type
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   155
RawAccessBarrier<decorators>::store_internal(void* addr, T value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   156
  OrderAccess::release_store_fence(reinterpret_cast<volatile T*>(addr), value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   157
}
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   158
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   159
template <DecoratorSet decorators>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   160
template <DecoratorSet ds, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   161
inline typename EnableIf<
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   162
  HasDecorator<ds, MO_RELEASE>::value>::type
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   163
RawAccessBarrier<decorators>::store_internal(void* addr, T value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   164
  OrderAccess::release_store(reinterpret_cast<volatile T*>(addr), value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   165
}
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   166
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   167
template <DecoratorSet decorators>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   168
template <DecoratorSet ds, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   169
inline typename EnableIf<
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   170
  HasDecorator<ds, MO_RELAXED>::value>::type
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   171
RawAccessBarrier<decorators>::store_internal(void* addr, T value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   172
  Atomic::store(value, reinterpret_cast<volatile T*>(addr));
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   173
}
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   174
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   175
template <DecoratorSet decorators>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   176
template <DecoratorSet ds, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   177
inline typename EnableIf<
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   178
  HasDecorator<ds, MO_RELAXED>::value, T>::type
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   179
RawAccessBarrier<decorators>::atomic_cmpxchg_internal(T new_value, void* addr, T compare_value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   180
  return Atomic::cmpxchg(new_value,
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   181
                         reinterpret_cast<volatile T*>(addr),
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   182
                         compare_value,
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   183
                         memory_order_relaxed);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   184
}
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   185
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   186
template <DecoratorSet decorators>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   187
template <DecoratorSet ds, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   188
inline typename EnableIf<
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   189
  HasDecorator<ds, MO_SEQ_CST>::value, T>::type
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   190
RawAccessBarrier<decorators>::atomic_cmpxchg_internal(T new_value, void* addr, T compare_value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   191
  return Atomic::cmpxchg(new_value,
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   192
                         reinterpret_cast<volatile T*>(addr),
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   193
                         compare_value,
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   194
                         memory_order_conservative);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   195
}
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   196
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   197
template <DecoratorSet decorators>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   198
template <DecoratorSet ds, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   199
inline typename EnableIf<
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   200
  HasDecorator<ds, MO_SEQ_CST>::value, T>::type
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   201
RawAccessBarrier<decorators>::atomic_xchg_internal(T new_value, void* addr) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   202
  return Atomic::xchg(new_value,
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   203
                      reinterpret_cast<volatile T*>(addr));
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   204
}
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   205
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   206
// For platforms that do not have native support for wide atomics,
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   207
// we can emulate the atomicity using a lock. So here we check
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   208
// whether that is necessary or not.
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   209
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   210
template <DecoratorSet ds>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   211
template <DecoratorSet decorators, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   212
inline typename EnableIf<
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   213
  AccessInternal::PossiblyLockedAccess<T>::value, T>::type
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   214
RawAccessBarrier<ds>::atomic_xchg_maybe_locked(T new_value, void* addr) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   215
  if (!AccessInternal::wide_atomic_needs_locking()) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   216
    return atomic_xchg_internal<ds>(new_value, addr);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   217
  } else {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   218
    AccessInternal::AccessLocker access_lock;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   219
    volatile T* p = reinterpret_cast<volatile T*>(addr);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   220
    T old_val = RawAccess<>::load(p);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   221
    RawAccess<>::store(p, new_value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   222
    return old_val;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   223
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   224
}
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   225
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   226
template <DecoratorSet ds>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   227
template <DecoratorSet decorators, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   228
inline typename EnableIf<
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   229
  AccessInternal::PossiblyLockedAccess<T>::value, T>::type
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   230
RawAccessBarrier<ds>::atomic_cmpxchg_maybe_locked(T new_value, void* addr, T compare_value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   231
  if (!AccessInternal::wide_atomic_needs_locking()) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   232
    return atomic_cmpxchg_internal<ds>(new_value, addr, compare_value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   233
  } else {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   234
    AccessInternal::AccessLocker access_lock;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   235
    volatile T* p = reinterpret_cast<volatile T*>(addr);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   236
    T old_val = RawAccess<>::load(p);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   237
    if (old_val == compare_value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   238
      RawAccess<>::store(p, new_value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   239
    }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   240
    return old_val;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   241
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   242
}
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   243
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   244
class RawAccessBarrierArrayCopy: public AllStatic {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   245
public:
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   246
  template <DecoratorSet decorators, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   247
  static inline typename EnableIf<
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   248
  HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value>::type
49383
bf2ff45e592f 8198445: Access API for primitive/native arraycopy
rkennke
parents: 48628
diff changeset
   249
  arraycopy(arrayOop src_obj, arrayOop dst_obj, T* src, T* dst, size_t length) {
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   250
    // We do not check for ARRAYCOPY_ATOMIC for oops, because they are unconditionally always atomic.
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   251
    if (HasDecorator<decorators, ARRAYCOPY_ARRAYOF>::value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   252
      AccessInternal::arraycopy_arrayof_conjoint_oops(src, dst, length);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   253
    } else {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   254
      typedef typename HeapOopType<decorators>::type OopType;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   255
      AccessInternal::arraycopy_conjoint_oops(reinterpret_cast<OopType*>(src),
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   256
                                              reinterpret_cast<OopType*>(dst), length);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   257
    }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   258
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   259
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   260
  template <DecoratorSet decorators, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   261
  static inline typename EnableIf<
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   262
    !HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value>::type
49383
bf2ff45e592f 8198445: Access API for primitive/native arraycopy
rkennke
parents: 48628
diff changeset
   263
  arraycopy(arrayOop src_obj, arrayOop dst_obj, T* src, T* dst, size_t length) {
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   264
    if (HasDecorator<decorators, ARRAYCOPY_ARRAYOF>::value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   265
      AccessInternal::arraycopy_arrayof_conjoint(src, dst, length);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   266
    } else if (HasDecorator<decorators, ARRAYCOPY_DISJOINT>::value && sizeof(T) == HeapWordSize) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   267
      // There is only a disjoint optimization for word granularity copying
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   268
      if (HasDecorator<decorators, ARRAYCOPY_ATOMIC>::value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   269
        AccessInternal::arraycopy_disjoint_words_atomic(src, dst, length);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   270
      } else {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   271
        AccessInternal::arraycopy_disjoint_words(src, dst, length);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   272
      }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   273
    } else {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   274
      if (HasDecorator<decorators, ARRAYCOPY_ATOMIC>::value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   275
        AccessInternal::arraycopy_conjoint_atomic(src, dst, length);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   276
      } else {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   277
        AccessInternal::arraycopy_conjoint(src, dst, length);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   278
      }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   279
    }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   280
  }
49383
bf2ff45e592f 8198445: Access API for primitive/native arraycopy
rkennke
parents: 48628
diff changeset
   281
bf2ff45e592f 8198445: Access API for primitive/native arraycopy
rkennke
parents: 48628
diff changeset
   282
  template <DecoratorSet decorators>
bf2ff45e592f 8198445: Access API for primitive/native arraycopy
rkennke
parents: 48628
diff changeset
   283
  static inline typename EnableIf<
bf2ff45e592f 8198445: Access API for primitive/native arraycopy
rkennke
parents: 48628
diff changeset
   284
    !HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value>::type
bf2ff45e592f 8198445: Access API for primitive/native arraycopy
rkennke
parents: 48628
diff changeset
   285
  arraycopy(arrayOop src_obj, arrayOop dst_obj, void* src, void* dst, size_t length) {
bf2ff45e592f 8198445: Access API for primitive/native arraycopy
rkennke
parents: 48628
diff changeset
   286
    if (HasDecorator<decorators, ARRAYCOPY_ATOMIC>::value) {
bf2ff45e592f 8198445: Access API for primitive/native arraycopy
rkennke
parents: 48628
diff changeset
   287
      AccessInternal::arraycopy_conjoint_atomic(src, dst, length);
bf2ff45e592f 8198445: Access API for primitive/native arraycopy
rkennke
parents: 48628
diff changeset
   288
    } else {
bf2ff45e592f 8198445: Access API for primitive/native arraycopy
rkennke
parents: 48628
diff changeset
   289
      AccessInternal::arraycopy_conjoint(src, dst, length);
bf2ff45e592f 8198445: Access API for primitive/native arraycopy
rkennke
parents: 48628
diff changeset
   290
    }
bf2ff45e592f 8198445: Access API for primitive/native arraycopy
rkennke
parents: 48628
diff changeset
   291
  }
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   292
};
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   293
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   294
template <DecoratorSet decorators>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   295
template <typename T>
49383
bf2ff45e592f 8198445: Access API for primitive/native arraycopy
rkennke
parents: 48628
diff changeset
   296
inline bool RawAccessBarrier<decorators>::arraycopy(arrayOop src_obj, arrayOop dst_obj, T* src, T* dst, size_t length) {
bf2ff45e592f 8198445: Access API for primitive/native arraycopy
rkennke
parents: 48628
diff changeset
   297
  RawAccessBarrierArrayCopy::arraycopy<decorators>(src_obj, dst_obj, src, dst, length);
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   298
  return true;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   299
}
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   300
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   301
template <DecoratorSet decorators>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   302
inline void RawAccessBarrier<decorators>::clone(oop src, oop dst, size_t size) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   303
  // 4839641 (4840070): We must do an oop-atomic copy, because if another thread
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   304
  // is modifying a reference field in the clonee, a non-oop-atomic copy might
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   305
  // be suspended in the middle of copying the pointer and end up with parts
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   306
  // of two different pointers in the field.  Subsequent dereferences will crash.
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   307
  // 4846409: an oop-copy of objects with long or double fields or arrays of same
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   308
  // won't copy the longs/doubles atomically in 32-bit vm's, so we copy jlongs instead
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   309
  // of oops.  We know objects are aligned on a minimum of an jlong boundary.
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   310
  // The same is true of StubRoutines::object_copy and the various oop_copy
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   311
  // variants, and of the code generated by the inline_native_clone intrinsic.
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   312
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   313
  assert(MinObjAlignmentInBytes >= BytesPerLong, "objects misaligned");
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   314
  AccessInternal::arraycopy_conjoint_atomic(reinterpret_cast<jlong*>((oopDesc*)src),
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   315
                                            reinterpret_cast<jlong*>((oopDesc*)dst),
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   316
                                            align_object_size(size) / HeapWordsPerLong);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   317
  // Clear the header
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   318
  dst->init_mark();
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   319
}
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   320
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   321
#endif // SHARE_VM_RUNTIME_ACCESSBACKEND_INLINE_HPP