25 #ifndef SHARE_OOPS_ARRAY_HPP |
25 #ifndef SHARE_OOPS_ARRAY_HPP |
26 #define SHARE_OOPS_ARRAY_HPP |
26 #define SHARE_OOPS_ARRAY_HPP |
27 |
27 |
28 #include "memory/allocation.hpp" |
28 #include "memory/allocation.hpp" |
29 #include "memory/metaspace.hpp" |
29 #include "memory/metaspace.hpp" |
30 #include "runtime/orderAccess.hpp" |
30 #include "runtime/atomic.hpp" |
31 #include "utilities/align.hpp" |
31 #include "utilities/align.hpp" |
32 |
32 |
33 // Array for metadata allocation |
33 // Array for metadata allocation |
34 |
34 |
35 template <typename T> |
35 template <typename T> |
120 T at(int i) const { assert(i >= 0 && i< _length, "oob: 0 <= %d < %d", i, _length); return _data[i]; } |
120 T at(int i) const { assert(i >= 0 && i< _length, "oob: 0 <= %d < %d", i, _length); return _data[i]; } |
121 void at_put(const int i, const T& x) { assert(i >= 0 && i< _length, "oob: 0 <= %d < %d", i, _length); _data[i] = x; } |
121 void at_put(const int i, const T& x) { assert(i >= 0 && i< _length, "oob: 0 <= %d < %d", i, _length); _data[i] = x; } |
122 T* adr_at(const int i) { assert(i >= 0 && i< _length, "oob: 0 <= %d < %d", i, _length); return &_data[i]; } |
122 T* adr_at(const int i) { assert(i >= 0 && i< _length, "oob: 0 <= %d < %d", i, _length); return &_data[i]; } |
123 int find(const T& x) { return index_of(x); } |
123 int find(const T& x) { return index_of(x); } |
124 |
124 |
125 T at_acquire(const int i) { return OrderAccess::load_acquire(adr_at(i)); } |
125 T at_acquire(const int i) { return Atomic::load_acquire(adr_at(i)); } |
126 void release_at_put(int i, T x) { OrderAccess::release_store(adr_at(i), x); } |
126 void release_at_put(int i, T x) { Atomic::release_store(adr_at(i), x); } |
127 |
127 |
128 static int size(int length) { |
128 static int size(int length) { |
129 size_t bytes = align_up(byte_sizeof(length), BytesPerWord); |
129 size_t bytes = align_up(byte_sizeof(length), BytesPerWord); |
130 size_t words = bytes / BytesPerWord; |
130 size_t words = bytes / BytesPerWord; |
131 |
131 |