author | rkennke |
Mon, 04 Jun 2018 23:01:48 +0200 | |
changeset 50389 | 7e8c0409a747 |
parent 49722 | a47d1e21b3f1 |
child 50470 | f3aac763a315 |
permissions | -rw-r--r-- |
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" |
49592
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
49454
diff
changeset
|
30 |
#include "oops/compressedOops.inline.hpp" |
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
49454
diff
changeset
|
31 |
#include "oops/oopsHierarchy.hpp" |
47998
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
32 |
|
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
33 |
template <DecoratorSet decorators> |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
34 |
template <DecoratorSet idecorators, typename T> |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
35 |
inline typename EnableIf< |
48628
69d65d9dcadb
8193063: Enabling narrowOop values for RawAccess accesses
eosterlund
parents:
47998
diff
changeset
|
36 |
AccessInternal::MustConvertCompressedOop<idecorators, T>::value, T>::type |
47998
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
37 |
RawAccessBarrier<decorators>::decode_internal(typename HeapOopType<idecorators>::type value) { |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
38 |
if (HasDecorator<decorators, OOP_NOT_NULL>::value) { |
49592
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
49454
diff
changeset
|
39 |
return CompressedOops::decode_not_null(value); |
47998
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
40 |
} else { |
49592
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
49454
diff
changeset
|
41 |
return CompressedOops::decode(value); |
47998
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 |
|
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
45 |
template <DecoratorSet decorators> |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
46 |
template <DecoratorSet idecorators, typename T> |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
47 |
inline typename EnableIf< |
48628
69d65d9dcadb
8193063: Enabling narrowOop values for RawAccess accesses
eosterlund
parents:
47998
diff
changeset
|
48 |
AccessInternal::MustConvertCompressedOop<idecorators, T>::value, |
47998
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
49 |
typename HeapOopType<idecorators>::type>::type |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
50 |
RawAccessBarrier<decorators>::encode_internal(T value) { |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
51 |
if (HasDecorator<decorators, OOP_NOT_NULL>::value) { |
49592
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
49454
diff
changeset
|
52 |
return CompressedOops::encode_not_null(value); |
47998
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
53 |
} else { |
49592
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
49454
diff
changeset
|
54 |
return CompressedOops::encode(value); |
47998
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 |
|
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
58 |
template <DecoratorSet decorators> |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
59 |
template <typename T> |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
60 |
inline void RawAccessBarrier<decorators>::oop_store(void* addr, T value) { |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
61 |
typedef typename AccessInternal::EncodedType<decorators, T>::type Encoded; |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
62 |
Encoded encoded = encode(value); |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
63 |
store(reinterpret_cast<Encoded*>(addr), encoded); |
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 |
|
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
66 |
template <DecoratorSet decorators> |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
67 |
template <typename T> |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
68 |
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
|
69 |
oop_store(field_addr(base, offset), value); |
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 |
|
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
72 |
template <DecoratorSet decorators> |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
73 |
template <typename T> |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
74 |
inline T RawAccessBarrier<decorators>::oop_load(void* addr) { |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
75 |
typedef typename AccessInternal::EncodedType<decorators, T>::type Encoded; |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
76 |
Encoded encoded = load<Encoded>(reinterpret_cast<Encoded*>(addr)); |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
77 |
return decode<T>(encoded); |
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 |
|
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
80 |
template <DecoratorSet decorators> |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
81 |
template <typename T> |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
82 |
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
|
83 |
return oop_load<T>(field_addr(base, offset)); |
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 |
|
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
86 |
template <DecoratorSet decorators> |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
87 |
template <typename T> |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
88 |
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
|
89 |
typedef typename AccessInternal::EncodedType<decorators, T>::type Encoded; |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
90 |
Encoded encoded_new = encode(new_value); |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
91 |
Encoded encoded_compare = encode(compare_value); |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
92 |
Encoded encoded_result = atomic_cmpxchg(encoded_new, |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
93 |
reinterpret_cast<Encoded*>(addr), |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
94 |
encoded_compare); |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
95 |
return decode<T>(encoded_result); |
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 |
|
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
98 |
template <DecoratorSet decorators> |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
99 |
template <typename T> |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
100 |
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
|
101 |
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
|
102 |
} |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
103 |
|
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
104 |
template <DecoratorSet decorators> |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
105 |
template <typename T> |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
106 |
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
|
107 |
typedef typename AccessInternal::EncodedType<decorators, T>::type Encoded; |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
108 |
Encoded encoded_new = encode(new_value); |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
109 |
Encoded encoded_result = atomic_xchg(encoded_new, reinterpret_cast<Encoded*>(addr)); |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
110 |
return decode<T>(encoded_result); |
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 |
|
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
113 |
template <DecoratorSet decorators> |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
114 |
template <typename T> |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
115 |
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
|
116 |
return oop_atomic_xchg(new_value, field_addr(base, offset)); |
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 |
|
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
119 |
template <DecoratorSet decorators> |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
120 |
template <typename T> |
50389
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
49722
diff
changeset
|
121 |
inline bool RawAccessBarrier<decorators>::oop_arraycopy(arrayOop src_obj, size_t src_offset_in_bytes, T* src_raw, |
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
49722
diff
changeset
|
122 |
arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw, |
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
49722
diff
changeset
|
123 |
size_t length) { |
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
49722
diff
changeset
|
124 |
return arraycopy(src_obj, src_offset_in_bytes, src_raw, |
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
49722
diff
changeset
|
125 |
dst_obj, dst_offset_in_bytes, dst_raw, |
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
49722
diff
changeset
|
126 |
length); |
47998
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
127 |
} |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
128 |
|
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
129 |
template <DecoratorSet decorators> |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
130 |
template <DecoratorSet ds, typename T> |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
131 |
inline typename EnableIf< |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
132 |
HasDecorator<ds, MO_SEQ_CST>::value, T>::type |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
133 |
RawAccessBarrier<decorators>::load_internal(void* addr) { |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
134 |
if (support_IRIW_for_not_multiple_copy_atomic_cpu) { |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
135 |
OrderAccess::fence(); |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
136 |
} |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
137 |
return OrderAccess::load_acquire(reinterpret_cast<const volatile T*>(addr)); |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
138 |
} |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
139 |
|
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
140 |
template <DecoratorSet decorators> |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
141 |
template <DecoratorSet ds, typename T> |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
142 |
inline typename EnableIf< |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
143 |
HasDecorator<ds, MO_ACQUIRE>::value, T>::type |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
144 |
RawAccessBarrier<decorators>::load_internal(void* addr) { |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
145 |
return OrderAccess::load_acquire(reinterpret_cast<const volatile T*>(addr)); |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
146 |
} |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
147 |
|
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
148 |
template <DecoratorSet decorators> |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
149 |
template <DecoratorSet ds, typename T> |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
150 |
inline typename EnableIf< |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
151 |
HasDecorator<ds, MO_RELAXED>::value, T>::type |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
152 |
RawAccessBarrier<decorators>::load_internal(void* addr) { |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
153 |
return Atomic::load(reinterpret_cast<const volatile T*>(addr)); |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
154 |
} |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
155 |
|
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
156 |
template <DecoratorSet decorators> |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
157 |
template <DecoratorSet ds, typename T> |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
158 |
inline typename EnableIf< |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
159 |
HasDecorator<ds, MO_SEQ_CST>::value>::type |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
160 |
RawAccessBarrier<decorators>::store_internal(void* addr, T value) { |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
161 |
OrderAccess::release_store_fence(reinterpret_cast<volatile T*>(addr), value); |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
162 |
} |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
163 |
|
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
164 |
template <DecoratorSet decorators> |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
165 |
template <DecoratorSet ds, typename T> |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
166 |
inline typename EnableIf< |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
167 |
HasDecorator<ds, MO_RELEASE>::value>::type |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
168 |
RawAccessBarrier<decorators>::store_internal(void* addr, T value) { |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
169 |
OrderAccess::release_store(reinterpret_cast<volatile T*>(addr), value); |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
170 |
} |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
171 |
|
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
172 |
template <DecoratorSet decorators> |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
173 |
template <DecoratorSet ds, typename T> |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
174 |
inline typename EnableIf< |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
175 |
HasDecorator<ds, MO_RELAXED>::value>::type |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
176 |
RawAccessBarrier<decorators>::store_internal(void* addr, T value) { |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
177 |
Atomic::store(value, reinterpret_cast<volatile T*>(addr)); |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
178 |
} |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
179 |
|
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
180 |
template <DecoratorSet decorators> |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
181 |
template <DecoratorSet ds, typename T> |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
182 |
inline typename EnableIf< |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
183 |
HasDecorator<ds, MO_RELAXED>::value, T>::type |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
184 |
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
|
185 |
return Atomic::cmpxchg(new_value, |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
186 |
reinterpret_cast<volatile T*>(addr), |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
187 |
compare_value, |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
188 |
memory_order_relaxed); |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
189 |
} |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
190 |
|
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
191 |
template <DecoratorSet decorators> |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
192 |
template <DecoratorSet ds, typename T> |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
193 |
inline typename EnableIf< |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
194 |
HasDecorator<ds, MO_SEQ_CST>::value, T>::type |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
195 |
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
|
196 |
return Atomic::cmpxchg(new_value, |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
197 |
reinterpret_cast<volatile T*>(addr), |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
198 |
compare_value, |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
199 |
memory_order_conservative); |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
200 |
} |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
201 |
|
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
202 |
template <DecoratorSet decorators> |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
203 |
template <DecoratorSet ds, typename T> |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
204 |
inline typename EnableIf< |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
205 |
HasDecorator<ds, MO_SEQ_CST>::value, T>::type |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
206 |
RawAccessBarrier<decorators>::atomic_xchg_internal(T new_value, void* addr) { |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
207 |
return Atomic::xchg(new_value, |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
208 |
reinterpret_cast<volatile T*>(addr)); |
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 |
|
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
211 |
// For platforms that do not have native support for wide atomics, |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
212 |
// 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
|
213 |
// whether that is necessary or not. |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
214 |
|
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
215 |
template <DecoratorSet ds> |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
216 |
template <DecoratorSet decorators, typename T> |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
217 |
inline typename EnableIf< |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
218 |
AccessInternal::PossiblyLockedAccess<T>::value, T>::type |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
219 |
RawAccessBarrier<ds>::atomic_xchg_maybe_locked(T new_value, void* addr) { |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
220 |
if (!AccessInternal::wide_atomic_needs_locking()) { |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
221 |
return atomic_xchg_internal<ds>(new_value, addr); |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
222 |
} else { |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
223 |
AccessInternal::AccessLocker access_lock; |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
224 |
volatile T* p = reinterpret_cast<volatile T*>(addr); |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
225 |
T old_val = RawAccess<>::load(p); |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
226 |
RawAccess<>::store(p, new_value); |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
227 |
return old_val; |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
228 |
} |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
229 |
} |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
230 |
|
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
231 |
template <DecoratorSet ds> |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
232 |
template <DecoratorSet decorators, typename T> |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
233 |
inline typename EnableIf< |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
234 |
AccessInternal::PossiblyLockedAccess<T>::value, T>::type |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
235 |
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
|
236 |
if (!AccessInternal::wide_atomic_needs_locking()) { |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
237 |
return atomic_cmpxchg_internal<ds>(new_value, addr, compare_value); |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
238 |
} else { |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
239 |
AccessInternal::AccessLocker access_lock; |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
240 |
volatile T* p = reinterpret_cast<volatile T*>(addr); |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
241 |
T old_val = RawAccess<>::load(p); |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
242 |
if (old_val == compare_value) { |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
243 |
RawAccess<>::store(p, new_value); |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
244 |
} |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
245 |
return old_val; |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
246 |
} |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
247 |
} |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
248 |
|
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
249 |
class RawAccessBarrierArrayCopy: public AllStatic { |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
250 |
public: |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
251 |
template <DecoratorSet decorators, typename T> |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
252 |
static inline typename EnableIf< |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
253 |
HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value>::type |
50389
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
49722
diff
changeset
|
254 |
arraycopy(arrayOop src_obj, size_t src_offset_in_bytes, T* src_raw, |
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
49722
diff
changeset
|
255 |
arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw, |
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
49722
diff
changeset
|
256 |
size_t length) { |
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
49722
diff
changeset
|
257 |
|
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
49722
diff
changeset
|
258 |
src_raw = arrayOopDesc::obj_offset_to_raw(src_obj, src_offset_in_bytes, src_raw); |
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
49722
diff
changeset
|
259 |
dst_raw = arrayOopDesc::obj_offset_to_raw(dst_obj, dst_offset_in_bytes, dst_raw); |
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
49722
diff
changeset
|
260 |
|
47998
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) { |
50389
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
49722
diff
changeset
|
263 |
AccessInternal::arraycopy_arrayof_conjoint_oops(src_raw, dst_raw, length); |
47998
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; |
50389
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
49722
diff
changeset
|
266 |
AccessInternal::arraycopy_conjoint_oops(reinterpret_cast<OopType*>(src_raw), |
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
49722
diff
changeset
|
267 |
reinterpret_cast<OopType*>(dst_raw), length); |
47998
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 |
50389
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
49722
diff
changeset
|
274 |
arraycopy(arrayOop src_obj, size_t src_offset_in_bytes, const T* src_raw, arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw, size_t length) { |
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
49722
diff
changeset
|
275 |
|
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
49722
diff
changeset
|
276 |
src_raw = arrayOopDesc::obj_offset_to_raw(src_obj, src_offset_in_bytes, src_raw); |
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
49722
diff
changeset
|
277 |
dst_raw = arrayOopDesc::obj_offset_to_raw(dst_obj, dst_offset_in_bytes, dst_raw); |
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
49722
diff
changeset
|
278 |
|
47998
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
279 |
if (HasDecorator<decorators, ARRAYCOPY_ARRAYOF>::value) { |
50389
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
49722
diff
changeset
|
280 |
AccessInternal::arraycopy_arrayof_conjoint(const_cast<T*>(src_raw), dst_raw, length); |
47998
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
281 |
} else if (HasDecorator<decorators, ARRAYCOPY_DISJOINT>::value && sizeof(T) == HeapWordSize) { |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
282 |
// There is only a disjoint optimization for word granularity copying |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
283 |
if (HasDecorator<decorators, ARRAYCOPY_ATOMIC>::value) { |
50389
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
49722
diff
changeset
|
284 |
AccessInternal::arraycopy_disjoint_words_atomic(const_cast<T*>(src_raw), dst_raw, length); |
47998
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
285 |
} else { |
50389
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
49722
diff
changeset
|
286 |
AccessInternal::arraycopy_disjoint_words(const_cast<T*>(src_raw), dst_raw, length); |
47998
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
287 |
} |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
288 |
} else { |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
289 |
if (HasDecorator<decorators, ARRAYCOPY_ATOMIC>::value) { |
50389
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
49722
diff
changeset
|
290 |
AccessInternal::arraycopy_conjoint_atomic(const_cast<T*>(src_raw), dst_raw, length); |
47998
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
291 |
} else { |
50389
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
49722
diff
changeset
|
292 |
AccessInternal::arraycopy_conjoint(const_cast<T*>(src_raw), dst_raw, length); |
47998
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 |
} |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
295 |
} |
49383
bf2ff45e592f
8198445: Access API for primitive/native arraycopy
rkennke
parents:
48628
diff
changeset
|
296 |
|
bf2ff45e592f
8198445: Access API for primitive/native arraycopy
rkennke
parents:
48628
diff
changeset
|
297 |
template <DecoratorSet decorators> |
bf2ff45e592f
8198445: Access API for primitive/native arraycopy
rkennke
parents:
48628
diff
changeset
|
298 |
static inline typename EnableIf< |
bf2ff45e592f
8198445: Access API for primitive/native arraycopy
rkennke
parents:
48628
diff
changeset
|
299 |
!HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value>::type |
50389
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
49722
diff
changeset
|
300 |
arraycopy(arrayOop src_obj, size_t src_offset_in_bytes, const void* src_raw, |
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
49722
diff
changeset
|
301 |
arrayOop dst_obj, size_t dst_offset_in_bytes, void* dst_raw, |
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
49722
diff
changeset
|
302 |
size_t length) { |
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
49722
diff
changeset
|
303 |
|
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
49722
diff
changeset
|
304 |
src_raw = arrayOopDesc::obj_offset_to_raw(src_obj, src_offset_in_bytes, src_raw); |
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
49722
diff
changeset
|
305 |
dst_raw = arrayOopDesc::obj_offset_to_raw(dst_obj, dst_offset_in_bytes, dst_raw); |
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
49722
diff
changeset
|
306 |
|
49383
bf2ff45e592f
8198445: Access API for primitive/native arraycopy
rkennke
parents:
48628
diff
changeset
|
307 |
if (HasDecorator<decorators, ARRAYCOPY_ATOMIC>::value) { |
50389
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
49722
diff
changeset
|
308 |
AccessInternal::arraycopy_conjoint_atomic(const_cast<void*>(src_raw), dst_raw, length); |
49383
bf2ff45e592f
8198445: Access API for primitive/native arraycopy
rkennke
parents:
48628
diff
changeset
|
309 |
} else { |
50389
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
49722
diff
changeset
|
310 |
AccessInternal::arraycopy_conjoint(const_cast<void*>(src_raw), dst_raw, length); |
49383
bf2ff45e592f
8198445: Access API for primitive/native arraycopy
rkennke
parents:
48628
diff
changeset
|
311 |
} |
bf2ff45e592f
8198445: Access API for primitive/native arraycopy
rkennke
parents:
48628
diff
changeset
|
312 |
} |
47998
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
313 |
}; |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
314 |
|
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
315 |
template <DecoratorSet decorators> |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
316 |
template <typename T> |
50389
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
49722
diff
changeset
|
317 |
inline bool RawAccessBarrier<decorators>::arraycopy(arrayOop src_obj, size_t src_offset_in_bytes, T* src_raw, |
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
49722
diff
changeset
|
318 |
arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw, |
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
49722
diff
changeset
|
319 |
size_t length) { |
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
49722
diff
changeset
|
320 |
RawAccessBarrierArrayCopy::arraycopy<decorators>(src_obj, src_offset_in_bytes, src_raw, |
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
49722
diff
changeset
|
321 |
dst_obj, dst_offset_in_bytes, dst_raw, |
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
49722
diff
changeset
|
322 |
length); |
47998
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
323 |
return true; |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
324 |
} |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
325 |
|
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
326 |
template <DecoratorSet decorators> |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
327 |
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
|
328 |
// 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
|
329 |
// 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
|
330 |
// 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
|
331 |
// of two different pointers in the field. Subsequent dereferences will crash. |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
332 |
// 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
|
333 |
// 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
|
334 |
// 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
|
335 |
// 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
|
336 |
// 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
|
337 |
|
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
338 |
assert(MinObjAlignmentInBytes >= BytesPerLong, "objects misaligned"); |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
339 |
AccessInternal::arraycopy_conjoint_atomic(reinterpret_cast<jlong*>((oopDesc*)src), |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
340 |
reinterpret_cast<jlong*>((oopDesc*)dst), |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
341 |
align_object_size(size) / HeapWordsPerLong); |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
342 |
// Clear the header |
49722
a47d1e21b3f1
8199735: Mark word updates need to use Access API
rkennke
parents:
49592
diff
changeset
|
343 |
dst->init_mark_raw(); |
47998
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
344 |
} |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
345 |
|
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff
changeset
|
346 |
#endif // SHARE_VM_RUNTIME_ACCESSBACKEND_INLINE_HPP |