src/hotspot/share/oops/accessBackend.inline.hpp
author eosterlund
Mon, 20 Nov 2017 13:07:44 +0100
changeset 47998 fb0275c320a0
child 48628 69d65d9dcadb
permissions -rw-r--r--
8189871: Refactor GC barriers to use declarative semantics Reviewed-by: pliden, rkennke, coleenp, dholmes, kbarrett, stefank
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
/*
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
     2
 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
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<
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    35
  AccessInternal::MustConvertCompressedOop<idecorators>::value, T>::type
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<
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    47
  AccessInternal::MustConvertCompressedOop<idecorators>::value,
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) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   121
  return arraycopy(src, dst, length);
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
inline bool RawAccessBarrier<decorators>::oop_arraycopy(arrayOop src_obj, arrayOop dst_obj, HeapWord* src, HeapWord* dst, size_t length) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   126
  bool needs_oop_compress = HasDecorator<decorators, INTERNAL_CONVERT_COMPRESSED_OOP>::value &&
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   127
                            HasDecorator<decorators, INTERNAL_RT_USE_COMPRESSED_OOPS>::value;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   128
  if (needs_oop_compress) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   129
    return arraycopy(reinterpret_cast<narrowOop*>(src), reinterpret_cast<narrowOop*>(dst), length);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   130
  } else {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   131
    return arraycopy(reinterpret_cast<oop*>(src), reinterpret_cast<oop*>(dst), length);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   132
  }
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_SEQ_CST>::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
  if (support_IRIW_for_not_multiple_copy_atomic_cpu) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   141
    OrderAccess::fence();
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
  return OrderAccess::load_acquire(reinterpret_cast<const volatile T*>(addr));
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   144
}
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   145
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   146
template <DecoratorSet decorators>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   147
template <DecoratorSet ds, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   148
inline typename EnableIf<
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   149
  HasDecorator<ds, MO_ACQUIRE>::value, T>::type
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   150
RawAccessBarrier<decorators>::load_internal(void* addr) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   151
  return OrderAccess::load_acquire(reinterpret_cast<const volatile T*>(addr));
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   152
}
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   153
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   154
template <DecoratorSet decorators>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   155
template <DecoratorSet ds, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   156
inline typename EnableIf<
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   157
  HasDecorator<ds, MO_RELAXED>::value, T>::type
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   158
RawAccessBarrier<decorators>::load_internal(void* addr) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   159
  return Atomic::load(reinterpret_cast<const volatile T*>(addr));
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   160
}
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   161
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   162
template <DecoratorSet decorators>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   163
template <DecoratorSet ds, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   164
inline typename EnableIf<
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   165
  HasDecorator<ds, MO_SEQ_CST>::value>::type
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   166
RawAccessBarrier<decorators>::store_internal(void* addr, T value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   167
  OrderAccess::release_store_fence(reinterpret_cast<volatile T*>(addr), value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   168
}
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   169
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   170
template <DecoratorSet decorators>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   171
template <DecoratorSet ds, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   172
inline typename EnableIf<
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   173
  HasDecorator<ds, MO_RELEASE>::value>::type
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   174
RawAccessBarrier<decorators>::store_internal(void* addr, T value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   175
  OrderAccess::release_store(reinterpret_cast<volatile T*>(addr), value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   176
}
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   177
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   178
template <DecoratorSet decorators>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   179
template <DecoratorSet ds, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   180
inline typename EnableIf<
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   181
  HasDecorator<ds, MO_RELAXED>::value>::type
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   182
RawAccessBarrier<decorators>::store_internal(void* addr, T value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   183
  Atomic::store(value, reinterpret_cast<volatile T*>(addr));
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_RELAXED>::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_relaxed);
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_cmpxchg_internal(T new_value, void* addr, T compare_value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   202
  return Atomic::cmpxchg(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
                         compare_value,
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   205
                         memory_order_conservative);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   206
}
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   207
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   208
template <DecoratorSet decorators>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   209
template <DecoratorSet ds, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   210
inline typename EnableIf<
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   211
  HasDecorator<ds, MO_SEQ_CST>::value, T>::type
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   212
RawAccessBarrier<decorators>::atomic_xchg_internal(T new_value, void* addr) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   213
  return Atomic::xchg(new_value,
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   214
                      reinterpret_cast<volatile T*>(addr));
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   215
}
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   216
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   217
// For platforms that do not have native support for wide atomics,
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   218
// 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
   219
// whether that is necessary or not.
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   220
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   221
template <DecoratorSet ds>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   222
template <DecoratorSet decorators, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   223
inline typename EnableIf<
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   224
  AccessInternal::PossiblyLockedAccess<T>::value, T>::type
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   225
RawAccessBarrier<ds>::atomic_xchg_maybe_locked(T new_value, void* addr) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   226
  if (!AccessInternal::wide_atomic_needs_locking()) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   227
    return atomic_xchg_internal<ds>(new_value, addr);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   228
  } else {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   229
    AccessInternal::AccessLocker access_lock;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   230
    volatile T* p = reinterpret_cast<volatile T*>(addr);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   231
    T old_val = RawAccess<>::load(p);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   232
    RawAccess<>::store(p, new_value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   233
    return old_val;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   234
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   235
}
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   236
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   237
template <DecoratorSet ds>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   238
template <DecoratorSet decorators, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   239
inline typename EnableIf<
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   240
  AccessInternal::PossiblyLockedAccess<T>::value, T>::type
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   241
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
   242
  if (!AccessInternal::wide_atomic_needs_locking()) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   243
    return atomic_cmpxchg_internal<ds>(new_value, addr, compare_value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   244
  } else {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   245
    AccessInternal::AccessLocker access_lock;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   246
    volatile T* p = reinterpret_cast<volatile T*>(addr);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   247
    T old_val = RawAccess<>::load(p);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   248
    if (old_val == compare_value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   249
      RawAccess<>::store(p, new_value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   250
    }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   251
    return old_val;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   252
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   253
}
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   254
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   255
class RawAccessBarrierArrayCopy: public AllStatic {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   256
public:
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   257
  template <DecoratorSet decorators, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   258
  static inline typename EnableIf<
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   259
  HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value>::type
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   260
  arraycopy(T* src, T* dst, size_t length) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   261
    // 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
   262
    if (HasDecorator<decorators, ARRAYCOPY_ARRAYOF>::value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   263
      AccessInternal::arraycopy_arrayof_conjoint_oops(src, dst, length);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   264
    } else {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   265
      typedef typename HeapOopType<decorators>::type OopType;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   266
      AccessInternal::arraycopy_conjoint_oops(reinterpret_cast<OopType*>(src),
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   267
                                              reinterpret_cast<OopType*>(dst), length);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   268
    }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   269
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   270
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   271
  template <DecoratorSet decorators, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   272
  static inline typename EnableIf<
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   273
    !HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value>::type
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   274
  arraycopy(T* src, T* dst, size_t length) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   275
    if (HasDecorator<decorators, ARRAYCOPY_ARRAYOF>::value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   276
      AccessInternal::arraycopy_arrayof_conjoint(src, dst, length);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   277
    } else if (HasDecorator<decorators, ARRAYCOPY_DISJOINT>::value && sizeof(T) == HeapWordSize) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   278
      // There is only a disjoint optimization for word granularity copying
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   279
      if (HasDecorator<decorators, ARRAYCOPY_ATOMIC>::value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   280
        AccessInternal::arraycopy_disjoint_words_atomic(src, dst, length);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   281
      } else {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   282
        AccessInternal::arraycopy_disjoint_words(src, dst, length);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   283
      }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   284
    } else {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   285
      if (HasDecorator<decorators, ARRAYCOPY_ATOMIC>::value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   286
        AccessInternal::arraycopy_conjoint_atomic(src, dst, length);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   287
      } else {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   288
        AccessInternal::arraycopy_conjoint(src, dst, length);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   289
      }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   290
    }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   291
  }
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>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   296
inline bool RawAccessBarrier<decorators>::arraycopy(T* src, T* dst, size_t length) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   297
  RawAccessBarrierArrayCopy::arraycopy<decorators>(src, dst, length);
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