Mercurial > hg > truffle
annotate src/share/vm/utilities/array.hpp @ 15844:d1822a8fe26f
minor cleanups
author | Tom Rodriguez <tom.rodriguez@oracle.com> |
---|---|
date | Wed, 21 May 2014 22:44:46 -0700 |
parents | 4ca6dc0799b6 |
children | 52b4284cb496 |
rev | line source |
---|---|
0 | 1 /* |
14909 | 2 * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
470
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
470
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
470
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #ifndef SHARE_VM_UTILITIES_ARRAY_HPP |
26 #define SHARE_VM_UTILITIES_ARRAY_HPP | |
27 | |
28 #include "memory/allocation.hpp" | |
29 #include "memory/allocation.inline.hpp" | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
30 #include "memory/metaspace.hpp" |
1972 | 31 |
0 | 32 // correct linkage required to compile w/o warnings |
33 // (must be on file level - cannot be local) | |
34 extern "C" { typedef int (*ftype)(const void*, const void*); } | |
35 | |
36 | |
37 class ResourceArray: public ResourceObj { | |
38 protected: | |
39 int _length; // the number of array elements | |
40 void* _data; // the array memory | |
41 #ifdef ASSERT | |
42 int _nesting; // the resource area nesting level | |
43 #endif | |
44 | |
45 // creation | |
46 ResourceArray() { | |
47 _length = 0; | |
48 _data = NULL; | |
49 DEBUG_ONLY(init_nesting();) | |
432 | 50 // client may call initialize, at most once |
0 | 51 } |
52 | |
53 | |
54 ResourceArray(size_t esize, int length) { | |
432 | 55 DEBUG_ONLY(_data = NULL); |
56 initialize(esize, length); | |
57 } | |
58 | |
59 void initialize(size_t esize, int length) { | |
0 | 60 assert(length >= 0, "illegal length"); |
14909 | 61 assert(_data == NULL, "must be new object"); |
0 | 62 _length = length; |
63 _data = resource_allocate_bytes(esize * length); | |
64 DEBUG_ONLY(init_nesting();) | |
65 } | |
66 | |
67 #ifdef ASSERT | |
68 void init_nesting(); | |
69 #endif | |
70 | |
71 // helper functions | |
72 void sort (size_t esize, ftype f); // sort the array | |
73 void expand (size_t esize, int i, int& size);// expand the array to include slot i | |
74 void remove_at(size_t esize, int i); // remove the element in slot i | |
75 | |
76 public: | |
77 // standard operations | |
78 int length() const { return _length; } | |
79 bool is_empty() const { return length() == 0; } | |
80 }; | |
81 | |
82 | |
6197 | 83 template <MEMFLAGS F>class CHeapArray: public CHeapObj<F> { |
0 | 84 protected: |
85 int _length; // the number of array elements | |
86 void* _data; // the array memory | |
87 | |
88 // creation | |
89 CHeapArray() { | |
90 _length = 0; | |
91 _data = NULL; | |
92 } | |
93 | |
94 | |
95 CHeapArray(size_t esize, int length) { | |
96 assert(length >= 0, "illegal length"); | |
97 _length = length; | |
6197 | 98 _data = (void*) NEW_C_HEAP_ARRAY(char *, esize * length, F); |
0 | 99 } |
100 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
101 void initialize(size_t esize, int length) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
102 // In debug set array to 0? |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
103 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
104 |
0 | 105 #ifdef ASSERT |
106 void init_nesting(); | |
107 #endif | |
108 | |
109 // helper functions | |
110 void sort (size_t esize, ftype f); // sort the array | |
111 void expand (size_t esize, int i, int& size);// expand the array to include slot i | |
112 void remove_at(size_t esize, int i); // remove the element in slot i | |
113 | |
114 public: | |
115 // standard operations | |
116 int length() const { return _length; } | |
117 bool is_empty() const { return length() == 0; } | |
118 }; | |
119 | |
120 #define define_generic_array(array_name,element_type, base_class) \ | |
121 class array_name: public base_class { \ | |
122 protected: \ | |
123 typedef element_type etype; \ | |
124 enum { esize = sizeof(etype) }; \ | |
125 \ | |
126 void base_remove_at(size_t size, int i) { base_class::remove_at(size, i); } \ | |
127 \ | |
128 public: \ | |
129 /* creation */ \ | |
130 array_name() : base_class() {} \ | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
131 explicit array_name(const int length) : base_class(esize, length) {} \ |
432 | 132 array_name(const int length, const etype fx) { initialize(length, fx); } \ |
133 void initialize(const int length) { base_class::initialize(esize, length); } \ | |
134 void initialize(const int length, const etype fx) { \ | |
135 initialize(length); \ | |
0 | 136 for (int i = 0; i < length; i++) ((etype*)_data)[i] = fx; \ |
137 } \ | |
138 \ | |
139 /* standard operations */ \ | |
140 etype& operator [] (const int i) const { \ | |
141 assert(0 <= i && i < length(), "index out of bounds"); \ | |
142 return ((etype*)_data)[i]; \ | |
143 } \ | |
144 \ | |
145 int index_of(const etype x) const { \ | |
146 int i = length(); \ | |
147 while (i-- > 0 && ((etype*)_data)[i] != x) ; \ | |
148 /* i < 0 || ((etype*)_data)_data[i] == x */ \ | |
149 return i; \ | |
150 } \ | |
151 \ | |
152 void sort(int f(etype*, etype*)) { base_class::sort(esize, (ftype)f); } \ | |
153 bool contains(const etype x) const { return index_of(x) >= 0; } \ | |
154 \ | |
155 /* deprecated operations - for compatibility with GrowableArray only */ \ | |
156 etype at(const int i) const { return (*this)[i]; } \ | |
157 void at_put(const int i, const etype x) { (*this)[i] = x; } \ | |
158 etype* adr_at(const int i) { return &(*this)[i]; } \ | |
159 int find(const etype x) { return index_of(x); } \ | |
160 }; \ | |
161 | |
162 | |
163 #define define_array(array_name,element_type) \ | |
164 define_generic_array(array_name, element_type, ResourceArray) | |
165 | |
166 | |
167 #define define_stack(stack_name,array_name) \ | |
168 class stack_name: public array_name { \ | |
169 protected: \ | |
170 int _size; \ | |
171 \ | |
172 void grow(const int i, const etype fx) { \ | |
173 assert(i >= length(), "index too small"); \ | |
174 if (i >= size()) expand(esize, i, _size); \ | |
175 for (int j = length(); j <= i; j++) ((etype*)_data)[j] = fx; \ | |
176 _length = i+1; \ | |
177 } \ | |
178 \ | |
179 public: \ | |
180 /* creation */ \ | |
432 | 181 stack_name() : array_name() { _size = 0; } \ |
182 stack_name(const int size) { initialize(size); } \ | |
183 stack_name(const int size, const etype fx) { initialize(size, fx); } \ | |
184 void initialize(const int size, const etype fx) { \ | |
185 _size = size; \ | |
186 array_name::initialize(size, fx); \ | |
187 /* _length == size, allocation and size are the same */ \ | |
188 } \ | |
189 void initialize(const int size) { \ | |
190 _size = size; \ | |
191 array_name::initialize(size); \ | |
192 _length = 0; /* reset length to zero; _size records the allocation */ \ | |
193 } \ | |
0 | 194 \ |
195 /* standard operations */ \ | |
196 int size() const { return _size; } \ | |
197 \ | |
432 | 198 int push(const etype x) { \ |
199 int len = length(); \ | |
200 if (len >= size()) expand(esize, len, _size); \ | |
201 ((etype*)_data)[len] = x; \ | |
202 _length = len+1; \ | |
203 return len; \ | |
0 | 204 } \ |
205 \ | |
206 etype pop() { \ | |
207 assert(!is_empty(), "stack is empty"); \ | |
208 return ((etype*)_data)[--_length]; \ | |
209 } \ | |
210 \ | |
211 etype top() const { \ | |
212 assert(!is_empty(), "stack is empty"); \ | |
213 return ((etype*)_data)[length() - 1]; \ | |
214 } \ | |
215 \ | |
216 void push_all(const stack_name* stack) { \ | |
217 const int l = stack->length(); \ | |
218 for (int i = 0; i < l; i++) push(((etype*)(stack->_data))[i]); \ | |
219 } \ | |
220 \ | |
221 etype at_grow(const int i, const etype fx) { \ | |
222 if (i >= length()) grow(i, fx); \ | |
223 return ((etype*)_data)[i]; \ | |
224 } \ | |
225 \ | |
226 void at_put_grow(const int i, const etype x, const etype fx) { \ | |
227 if (i >= length()) grow(i, fx); \ | |
228 ((etype*)_data)[i] = x; \ | |
229 } \ | |
230 \ | |
231 void truncate(const int length) { \ | |
232 assert(0 <= length && length <= this->length(), "illegal length"); \ | |
233 _length = length; \ | |
234 } \ | |
235 \ | |
236 void remove_at(int i) { base_remove_at(esize, i); } \ | |
237 void remove(etype x) { remove_at(index_of(x)); } \ | |
238 \ | |
239 /* inserts the given element before the element at index i */ \ | |
240 void insert_before(const int i, const etype el) { \ | |
241 int len = length(); \ | |
242 int new_length = len + 1; \ | |
243 if (new_length >= size()) expand(esize, new_length, _size); \ | |
244 for (int j = len - 1; j >= i; j--) { \ | |
245 ((etype*)_data)[j + 1] = ((etype*)_data)[j]; \ | |
246 } \ | |
247 _length = new_length; \ | |
248 at_put(i, el); \ | |
249 } \ | |
250 \ | |
251 /* inserts contents of the given stack before the element at index i */ \ | |
252 void insert_before(const int i, const stack_name *st) { \ | |
253 if (st->length() == 0) return; \ | |
254 int len = length(); \ | |
255 int st_len = st->length(); \ | |
256 int new_length = len + st_len; \ | |
257 if (new_length >= size()) expand(esize, new_length, _size); \ | |
258 int j; \ | |
259 for (j = len - 1; j >= i; j--) { \ | |
260 ((etype*)_data)[j + st_len] = ((etype*)_data)[j]; \ | |
261 } \ | |
262 for (j = 0; j < st_len; j++) { \ | |
263 ((etype*)_data)[i + j] = ((etype*)st->_data)[j]; \ | |
264 } \ | |
265 _length = new_length; \ | |
266 } \ | |
267 \ | |
268 /* deprecated operations - for compatibility with GrowableArray only */ \ | |
269 int capacity() const { return size(); } \ | |
270 void clear() { truncate(0); } \ | |
271 void trunc_to(const int length) { truncate(length); } \ | |
432 | 272 int append(const etype x) { return push(x); } \ |
0 | 273 void appendAll(const stack_name* stack) { push_all(stack); } \ |
274 etype last() const { return top(); } \ | |
275 }; \ | |
276 | |
277 | |
278 #define define_resource_list(element_type) \ | |
279 define_generic_array(element_type##Array, element_type, ResourceArray) \ | |
280 define_stack(element_type##List, element_type##Array) | |
281 | |
282 #define define_resource_pointer_list(element_type) \ | |
283 define_generic_array(element_type##Array, element_type *, ResourceArray) \ | |
284 define_stack(element_type##List, element_type##Array) | |
285 | |
286 #define define_c_heap_list(element_type) \ | |
287 define_generic_array(element_type##Array, element_type, CHeapArray) \ | |
288 define_stack(element_type##List, element_type##Array) | |
289 | |
290 #define define_c_heap_pointer_list(element_type) \ | |
291 define_generic_array(element_type##Array, element_type *, CHeapArray) \ | |
292 define_stack(element_type##List, element_type##Array) | |
293 | |
294 | |
295 // Arrays for basic types | |
296 | |
297 define_array(boolArray, bool) define_stack(boolStack, boolArray) | |
298 define_array(intArray , int ) define_stack(intStack , intArray ) | |
1972 | 299 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
300 // Array for metadata allocation |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
301 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
302 template <typename T> |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
303 class Array: public MetaspaceObj { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
304 friend class MetadataFactory; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
305 friend class VMStructs; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
306 friend class MethodHandleCompiler; // special case |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
307 protected: |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
308 int _length; // the number of array elements |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
309 T _data[1]; // the array memory |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
310 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
311 void initialize(int length) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
312 _length = length; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
313 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
314 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
315 private: |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
316 // Turn off copy constructor and assignment operator. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
317 Array(const Array<T>&); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
318 void operator=(const Array<T>&); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
319 |
12146
9758d9f36299
8021954: VM SIGSEGV during classloading on MacOS; hs_err_pid file produced
coleenp
parents:
10376
diff
changeset
|
320 void* operator new(size_t size, ClassLoaderData* loader_data, int length, bool read_only, TRAPS) throw() { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
321 size_t word_size = Array::size(length); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
322 return (void*) Metaspace::allocate(loader_data, word_size, read_only, |
10376
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
6972
diff
changeset
|
323 MetaspaceObj::array_type(sizeof(T)), CHECK_NULL); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
324 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
325 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
326 static size_t byte_sizeof(int length) { return sizeof(Array<T>) + MAX2(length - 1, 0) * sizeof(T); } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
327 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
328 explicit Array(int length) : _length(length) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
329 assert(length >= 0, "illegal length"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
330 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
331 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
332 Array(int length, T init) : _length(length) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
333 assert(length >= 0, "illegal length"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
334 for (int i = 0; i < length; i++) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
335 _data[i] = init; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
336 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
337 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
338 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
339 public: |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
340 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
341 // standard operations |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
342 int length() const { return _length; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
343 T* data() { return _data; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
344 bool is_empty() const { return length() == 0; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
345 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
346 int index_of(const T& x) const { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
347 int i = length(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
348 while (i-- > 0 && _data[i] != x) ; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
349 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
350 return i; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
351 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
352 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
353 // sort the array. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
354 bool contains(const T& x) const { return index_of(x) >= 0; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
355 |
12319
de059a14e159
8022187: Missing ResourceMark crash when assertion using FormatBufferResource fails
zgu
parents:
12146
diff
changeset
|
356 T at(int i) const { assert(i >= 0 && i< _length, err_msg("oob: 0 <= %d < %d", i, _length)); return _data[i]; } |
de059a14e159
8022187: Missing ResourceMark crash when assertion using FormatBufferResource fails
zgu
parents:
12146
diff
changeset
|
357 void at_put(const int i, const T& x) { assert(i >= 0 && i< _length, err_msg("oob: 0 <= %d < %d", i, _length)); _data[i] = x; } |
de059a14e159
8022187: Missing ResourceMark crash when assertion using FormatBufferResource fails
zgu
parents:
12146
diff
changeset
|
358 T* adr_at(const int i) { assert(i >= 0 && i< _length, err_msg("oob: 0 <= %d < %d", i, _length)); return &_data[i]; } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
359 int find(const T& x) { return index_of(x); } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
360 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
361 T at_acquire(const int which) { return OrderAccess::load_acquire(adr_at(which)); } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
362 void release_at_put(int which, T contents) { OrderAccess::release_store(adr_at(which), contents); } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
363 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
364 static int size(int length) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
365 return align_size_up(byte_sizeof(length), BytesPerWord) / BytesPerWord; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
366 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
367 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
368 int size() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
369 return size(_length); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
370 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
371 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
372 static int length_offset_in_bytes() { return (int) (offset_of(Array<T>, _length)); } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
373 // Note, this offset don't have to be wordSize aligned. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
374 static int base_offset_in_bytes() { return (int) (offset_of(Array<T>, _data)); }; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
375 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
376 // FIXME: How to handle this? |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
377 void print_value_on(outputStream* st) const { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
378 st->print("Array<T>(" INTPTR_FORMAT ")", this); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
379 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
380 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
381 #ifndef PRODUCT |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
382 void print(outputStream* st) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
383 for (int i = 0; i< _length; i++) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
384 st->print_cr("%d: " INTPTR_FORMAT, i, (intptr_t)at(i)); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
385 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
386 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
387 void print() { print(tty); } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
388 #endif // PRODUCT |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
389 }; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
390 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
391 |
1972 | 392 #endif // SHARE_VM_UTILITIES_ARRAY_HPP |