annotate src/share/vm/oops/objArrayKlass.cpp @ 356:1ee8caae33af

Merge
author tonyp
date Thu, 21 Aug 2008 23:36:31 -0400
parents 37f87013dfd8 d1605aabd0a1
children 443791f333a2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
196
d1605aabd0a1 6719955: Update copyright year
xdono
parents: 113
diff changeset
2 * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 # include "incls/_precompiled.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
26 # include "incls/_objArrayKlass.cpp.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
27
a61af66fc99e Initial load
duke
parents:
diff changeset
28 int objArrayKlass::oop_size(oop obj) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
29 assert(obj->is_objArray(), "must be object array");
a61af66fc99e Initial load
duke
parents:
diff changeset
30 return objArrayOop(obj)->object_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
31 }
a61af66fc99e Initial load
duke
parents:
diff changeset
32
a61af66fc99e Initial load
duke
parents:
diff changeset
33 objArrayOop objArrayKlass::allocate(int length, TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
34 if (length >= 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
35 if (length <= arrayOopDesc::max_array_length(T_OBJECT)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
36 int size = objArrayOopDesc::object_size(length);
a61af66fc99e Initial load
duke
parents:
diff changeset
37 KlassHandle h_k(THREAD, as_klassOop());
a61af66fc99e Initial load
duke
parents:
diff changeset
38 objArrayOop a = (objArrayOop)CollectedHeap::array_allocate(h_k, size, length, CHECK_NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
39 assert(a->is_parsable(), "Can't publish unless parsable");
a61af66fc99e Initial load
duke
parents:
diff changeset
40 return a;
a61af66fc99e Initial load
duke
parents:
diff changeset
41 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
42 THROW_OOP_0(Universe::out_of_memory_error_array_size());
a61af66fc99e Initial load
duke
parents:
diff changeset
43 }
a61af66fc99e Initial load
duke
parents:
diff changeset
44 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
45 THROW_0(vmSymbols::java_lang_NegativeArraySizeException());
a61af66fc99e Initial load
duke
parents:
diff changeset
46 }
a61af66fc99e Initial load
duke
parents:
diff changeset
47 }
a61af66fc99e Initial load
duke
parents:
diff changeset
48
a61af66fc99e Initial load
duke
parents:
diff changeset
49 static int multi_alloc_counter = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
50
a61af66fc99e Initial load
duke
parents:
diff changeset
51 oop objArrayKlass::multi_allocate(int rank, jint* sizes, TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
52 int length = *sizes;
a61af66fc99e Initial load
duke
parents:
diff changeset
53 // Call to lower_dimension uses this pointer, so most be called before a
a61af66fc99e Initial load
duke
parents:
diff changeset
54 // possible GC
a61af66fc99e Initial load
duke
parents:
diff changeset
55 KlassHandle h_lower_dimension(THREAD, lower_dimension());
a61af66fc99e Initial load
duke
parents:
diff changeset
56 // If length < 0 allocate will throw an exception.
a61af66fc99e Initial load
duke
parents:
diff changeset
57 objArrayOop array = allocate(length, CHECK_NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
58 assert(array->is_parsable(), "Don't handlize unless parsable");
a61af66fc99e Initial load
duke
parents:
diff changeset
59 objArrayHandle h_array (THREAD, array);
a61af66fc99e Initial load
duke
parents:
diff changeset
60 if (rank > 1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
61 if (length != 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
62 for (int index = 0; index < length; index++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
63 arrayKlass* ak = arrayKlass::cast(h_lower_dimension());
a61af66fc99e Initial load
duke
parents:
diff changeset
64 oop sub_array = ak->multi_allocate(rank-1, &sizes[1], CHECK_NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
65 assert(sub_array->is_parsable(), "Don't publish until parsable");
a61af66fc99e Initial load
duke
parents:
diff changeset
66 h_array->obj_at_put(index, sub_array);
a61af66fc99e Initial load
duke
parents:
diff changeset
67 }
a61af66fc99e Initial load
duke
parents:
diff changeset
68 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
69 // Since this array dimension has zero length, nothing will be
a61af66fc99e Initial load
duke
parents:
diff changeset
70 // allocated, however the lower dimension values must be checked
a61af66fc99e Initial load
duke
parents:
diff changeset
71 // for illegal values.
a61af66fc99e Initial load
duke
parents:
diff changeset
72 for (int i = 0; i < rank - 1; ++i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
73 sizes += 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
74 if (*sizes < 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
75 THROW_0(vmSymbols::java_lang_NegativeArraySizeException());
a61af66fc99e Initial load
duke
parents:
diff changeset
76 }
a61af66fc99e Initial load
duke
parents:
diff changeset
77 }
a61af66fc99e Initial load
duke
parents:
diff changeset
78 }
a61af66fc99e Initial load
duke
parents:
diff changeset
79 }
a61af66fc99e Initial load
duke
parents:
diff changeset
80 return h_array();
a61af66fc99e Initial load
duke
parents:
diff changeset
81 }
a61af66fc99e Initial load
duke
parents:
diff changeset
82
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
83 // Either oop or narrowOop depending on UseCompressedOops.
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
84 template <class T> void objArrayKlass::do_copy(arrayOop s, T* src,
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
85 arrayOop d, T* dst, int length, TRAPS) {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
86
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
87 const size_t word_len = objArrayOopDesc::array_size(length);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
88
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
89 BarrierSet* bs = Universe::heap()->barrier_set();
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 113
diff changeset
90 // For performance reasons, we assume we are that the write barrier we
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 113
diff changeset
91 // are using has optimized modes for arrays of references. At least one
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 113
diff changeset
92 // of the asserts below will fail if this is not the case.
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
93 assert(bs->has_write_ref_array_opt(), "Barrier set must have ref array opt");
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 113
diff changeset
94 assert(bs->has_write_ref_array_pre_opt(), "For pre-barrier as well.");
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
95
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 113
diff changeset
96 MemRegion dst_mr = MemRegion((HeapWord*)dst, word_len);
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
97 if (s == d) {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
98 // since source and destination are equal we do not need conversion checks.
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
99 assert(length > 0, "sanity check");
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 113
diff changeset
100 bs->write_ref_array_pre(dst_mr);
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
101 Copy::conjoint_oops_atomic(src, dst, length);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
102 } else {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
103 // We have to make sure all elements conform to the destination array
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
104 klassOop bound = objArrayKlass::cast(d->klass())->element_klass();
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
105 klassOop stype = objArrayKlass::cast(s->klass())->element_klass();
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
106 if (stype == bound || Klass::cast(stype)->is_subtype_of(bound)) {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
107 // elements are guaranteed to be subtypes, so no check necessary
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 113
diff changeset
108 bs->write_ref_array_pre(dst_mr);
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
109 Copy::conjoint_oops_atomic(src, dst, length);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
110 } else {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
111 // slow case: need individual subtype checks
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
112 // note: don't use obj_at_put below because it includes a redundant store check
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
113 T* from = src;
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
114 T* end = from + length;
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
115 for (T* p = dst; from < end; from++, p++) {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
116 // XXX this is going to be slow.
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
117 T element = *from;
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 113
diff changeset
118 // even slower now
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 113
diff changeset
119 bool element_is_null = oopDesc::is_null(element);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 113
diff changeset
120 oop new_val = element_is_null ? oop(NULL)
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 113
diff changeset
121 : oopDesc::decode_heap_oop_not_null(element);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 113
diff changeset
122 if (element_is_null ||
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 113
diff changeset
123 Klass::cast((new_val->klass()))->is_subtype_of(bound)) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 113
diff changeset
124 bs->write_ref_field_pre(p, new_val);
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
125 *p = *from;
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
126 } else {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
127 // We must do a barrier to cover the partial copy.
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
128 const size_t pd = pointer_delta(p, dst, (size_t)heapOopSize);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
129 // pointer delta is scaled to number of elements (length field in
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
130 // objArrayOop) which we assume is 32 bit.
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
131 assert(pd == (size_t)(int)pd, "length field overflow");
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
132 const size_t done_word_len = objArrayOopDesc::array_size((int)pd);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
133 bs->write_ref_array(MemRegion((HeapWord*)dst, done_word_len));
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
134 THROW(vmSymbols::java_lang_ArrayStoreException());
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
135 return;
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
136 }
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
137 }
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
138 }
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
139 }
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
140 bs->write_ref_array(MemRegion((HeapWord*)dst, word_len));
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
141 }
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
142
0
a61af66fc99e Initial load
duke
parents:
diff changeset
143 void objArrayKlass::copy_array(arrayOop s, int src_pos, arrayOop d,
a61af66fc99e Initial load
duke
parents:
diff changeset
144 int dst_pos, int length, TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
145 assert(s->is_objArray(), "must be obj array");
a61af66fc99e Initial load
duke
parents:
diff changeset
146
a61af66fc99e Initial load
duke
parents:
diff changeset
147 if (!d->is_objArray()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
148 THROW(vmSymbols::java_lang_ArrayStoreException());
a61af66fc99e Initial load
duke
parents:
diff changeset
149 }
a61af66fc99e Initial load
duke
parents:
diff changeset
150
a61af66fc99e Initial load
duke
parents:
diff changeset
151 // Check is all offsets and lengths are non negative
a61af66fc99e Initial load
duke
parents:
diff changeset
152 if (src_pos < 0 || dst_pos < 0 || length < 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
153 THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException());
a61af66fc99e Initial load
duke
parents:
diff changeset
154 }
a61af66fc99e Initial load
duke
parents:
diff changeset
155 // Check if the ranges are valid
a61af66fc99e Initial load
duke
parents:
diff changeset
156 if ( (((unsigned int) length + (unsigned int) src_pos) > (unsigned int) s->length())
a61af66fc99e Initial load
duke
parents:
diff changeset
157 || (((unsigned int) length + (unsigned int) dst_pos) > (unsigned int) d->length()) ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
158 THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException());
a61af66fc99e Initial load
duke
parents:
diff changeset
159 }
a61af66fc99e Initial load
duke
parents:
diff changeset
160
a61af66fc99e Initial load
duke
parents:
diff changeset
161 // Special case. Boundary cases must be checked first
a61af66fc99e Initial load
duke
parents:
diff changeset
162 // This allows the following call: copy_array(s, s.length(), d.length(), 0).
a61af66fc99e Initial load
duke
parents:
diff changeset
163 // This is correct, since the position is supposed to be an 'in between point', i.e., s.length(),
a61af66fc99e Initial load
duke
parents:
diff changeset
164 // points to the right of the last element.
a61af66fc99e Initial load
duke
parents:
diff changeset
165 if (length==0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
166 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
167 }
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
168 if (UseCompressedOops) {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
169 narrowOop* const src = objArrayOop(s)->obj_at_addr<narrowOop>(src_pos);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
170 narrowOop* const dst = objArrayOop(d)->obj_at_addr<narrowOop>(dst_pos);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
171 do_copy<narrowOop>(s, src, d, dst, length, CHECK);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
172 } else {
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
173 oop* const src = objArrayOop(s)->obj_at_addr<oop>(src_pos);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
174 oop* const dst = objArrayOop(d)->obj_at_addr<oop>(dst_pos);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
175 do_copy<oop> (s, src, d, dst, length, CHECK);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
176 }
a61af66fc99e Initial load
duke
parents:
diff changeset
177 }
a61af66fc99e Initial load
duke
parents:
diff changeset
178
a61af66fc99e Initial load
duke
parents:
diff changeset
179
a61af66fc99e Initial load
duke
parents:
diff changeset
180 klassOop objArrayKlass::array_klass_impl(bool or_null, int n, TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
181 objArrayKlassHandle h_this(THREAD, as_klassOop());
a61af66fc99e Initial load
duke
parents:
diff changeset
182 return array_klass_impl(h_this, or_null, n, CHECK_NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
183 }
a61af66fc99e Initial load
duke
parents:
diff changeset
184
a61af66fc99e Initial load
duke
parents:
diff changeset
185
a61af66fc99e Initial load
duke
parents:
diff changeset
186 klassOop objArrayKlass::array_klass_impl(objArrayKlassHandle this_oop, bool or_null, int n, TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
187
a61af66fc99e Initial load
duke
parents:
diff changeset
188 assert(this_oop->dimension() <= n, "check order of chain");
a61af66fc99e Initial load
duke
parents:
diff changeset
189 int dimension = this_oop->dimension();
a61af66fc99e Initial load
duke
parents:
diff changeset
190 if (dimension == n)
a61af66fc99e Initial load
duke
parents:
diff changeset
191 return this_oop();
a61af66fc99e Initial load
duke
parents:
diff changeset
192
a61af66fc99e Initial load
duke
parents:
diff changeset
193 objArrayKlassHandle ak (THREAD, this_oop->higher_dimension());
a61af66fc99e Initial load
duke
parents:
diff changeset
194 if (ak.is_null()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
195 if (or_null) return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
196
a61af66fc99e Initial load
duke
parents:
diff changeset
197 ResourceMark rm;
a61af66fc99e Initial load
duke
parents:
diff changeset
198 JavaThread *jt = (JavaThread *)THREAD;
a61af66fc99e Initial load
duke
parents:
diff changeset
199 {
a61af66fc99e Initial load
duke
parents:
diff changeset
200 MutexLocker mc(Compile_lock, THREAD); // for vtables
a61af66fc99e Initial load
duke
parents:
diff changeset
201 // Ensure atomic creation of higher dimensions
a61af66fc99e Initial load
duke
parents:
diff changeset
202 MutexLocker mu(MultiArray_lock, THREAD);
a61af66fc99e Initial load
duke
parents:
diff changeset
203
a61af66fc99e Initial load
duke
parents:
diff changeset
204 // Check if another thread beat us
a61af66fc99e Initial load
duke
parents:
diff changeset
205 ak = objArrayKlassHandle(THREAD, this_oop->higher_dimension());
a61af66fc99e Initial load
duke
parents:
diff changeset
206 if( ak.is_null() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
207
a61af66fc99e Initial load
duke
parents:
diff changeset
208 // Create multi-dim klass object and link them together
a61af66fc99e Initial load
duke
parents:
diff changeset
209 klassOop new_klass =
a61af66fc99e Initial load
duke
parents:
diff changeset
210 objArrayKlassKlass::cast(Universe::objArrayKlassKlassObj())->
a61af66fc99e Initial load
duke
parents:
diff changeset
211 allocate_objArray_klass(dimension + 1, this_oop, CHECK_NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
212 ak = objArrayKlassHandle(THREAD, new_klass);
a61af66fc99e Initial load
duke
parents:
diff changeset
213 this_oop->set_higher_dimension(ak());
a61af66fc99e Initial load
duke
parents:
diff changeset
214 ak->set_lower_dimension(this_oop());
a61af66fc99e Initial load
duke
parents:
diff changeset
215 assert(ak->oop_is_objArray(), "incorrect initialization of objArrayKlass");
a61af66fc99e Initial load
duke
parents:
diff changeset
216 }
a61af66fc99e Initial load
duke
parents:
diff changeset
217 }
a61af66fc99e Initial load
duke
parents:
diff changeset
218 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
219 CHECK_UNHANDLED_OOPS_ONLY(Thread::current()->clear_unhandled_oops());
a61af66fc99e Initial load
duke
parents:
diff changeset
220 }
a61af66fc99e Initial load
duke
parents:
diff changeset
221
a61af66fc99e Initial load
duke
parents:
diff changeset
222 if (or_null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
223 return ak->array_klass_or_null(n);
a61af66fc99e Initial load
duke
parents:
diff changeset
224 }
a61af66fc99e Initial load
duke
parents:
diff changeset
225 return ak->array_klass(n, CHECK_NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
226 }
a61af66fc99e Initial load
duke
parents:
diff changeset
227
a61af66fc99e Initial load
duke
parents:
diff changeset
228 klassOop objArrayKlass::array_klass_impl(bool or_null, TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
229 return array_klass_impl(or_null, dimension() + 1, CHECK_NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
230 }
a61af66fc99e Initial load
duke
parents:
diff changeset
231
a61af66fc99e Initial load
duke
parents:
diff changeset
232 bool objArrayKlass::can_be_primary_super_slow() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
233 if (!bottom_klass()->klass_part()->can_be_primary_super())
a61af66fc99e Initial load
duke
parents:
diff changeset
234 // array of interfaces
a61af66fc99e Initial load
duke
parents:
diff changeset
235 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
236 else
a61af66fc99e Initial load
duke
parents:
diff changeset
237 return Klass::can_be_primary_super_slow();
a61af66fc99e Initial load
duke
parents:
diff changeset
238 }
a61af66fc99e Initial load
duke
parents:
diff changeset
239
a61af66fc99e Initial load
duke
parents:
diff changeset
240 objArrayOop objArrayKlass::compute_secondary_supers(int num_extra_slots, TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
241 // interfaces = { cloneable_klass, serializable_klass, elemSuper[], ... };
a61af66fc99e Initial load
duke
parents:
diff changeset
242 objArrayOop es = Klass::cast(element_klass())->secondary_supers();
a61af66fc99e Initial load
duke
parents:
diff changeset
243 objArrayHandle elem_supers (THREAD, es);
a61af66fc99e Initial load
duke
parents:
diff changeset
244 int num_elem_supers = elem_supers.is_null() ? 0 : elem_supers->length();
a61af66fc99e Initial load
duke
parents:
diff changeset
245 int num_secondaries = num_extra_slots + 2 + num_elem_supers;
a61af66fc99e Initial load
duke
parents:
diff changeset
246 if (num_secondaries == 2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
247 // Must share this for correct bootstrapping!
a61af66fc99e Initial load
duke
parents:
diff changeset
248 return Universe::the_array_interfaces_array();
a61af66fc99e Initial load
duke
parents:
diff changeset
249 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
250 objArrayOop sec_oop = oopFactory::new_system_objArray(num_secondaries, CHECK_NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
251 objArrayHandle secondaries(THREAD, sec_oop);
a61af66fc99e Initial load
duke
parents:
diff changeset
252 secondaries->obj_at_put(num_extra_slots+0, SystemDictionary::cloneable_klass());
a61af66fc99e Initial load
duke
parents:
diff changeset
253 secondaries->obj_at_put(num_extra_slots+1, SystemDictionary::serializable_klass());
a61af66fc99e Initial load
duke
parents:
diff changeset
254 for (int i = 0; i < num_elem_supers; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
255 klassOop elem_super = (klassOop) elem_supers->obj_at(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
256 klassOop array_super = elem_super->klass_part()->array_klass_or_null();
a61af66fc99e Initial load
duke
parents:
diff changeset
257 assert(array_super != NULL, "must already have been created");
a61af66fc99e Initial load
duke
parents:
diff changeset
258 secondaries->obj_at_put(num_extra_slots+2+i, array_super);
a61af66fc99e Initial load
duke
parents:
diff changeset
259 }
a61af66fc99e Initial load
duke
parents:
diff changeset
260 return secondaries();
a61af66fc99e Initial load
duke
parents:
diff changeset
261 }
a61af66fc99e Initial load
duke
parents:
diff changeset
262 }
a61af66fc99e Initial load
duke
parents:
diff changeset
263
a61af66fc99e Initial load
duke
parents:
diff changeset
264 bool objArrayKlass::compute_is_subtype_of(klassOop k) {
a61af66fc99e Initial load
duke
parents:
diff changeset
265 if (!k->klass_part()->oop_is_objArray())
a61af66fc99e Initial load
duke
parents:
diff changeset
266 return arrayKlass::compute_is_subtype_of(k);
a61af66fc99e Initial load
duke
parents:
diff changeset
267
a61af66fc99e Initial load
duke
parents:
diff changeset
268 objArrayKlass* oak = objArrayKlass::cast(k);
a61af66fc99e Initial load
duke
parents:
diff changeset
269 return element_klass()->klass_part()->is_subtype_of(oak->element_klass());
a61af66fc99e Initial load
duke
parents:
diff changeset
270 }
a61af66fc99e Initial load
duke
parents:
diff changeset
271
a61af66fc99e Initial load
duke
parents:
diff changeset
272 void objArrayKlass::initialize(TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
273 Klass::cast(bottom_klass())->initialize(THREAD); // dispatches to either instanceKlass or typeArrayKlass
a61af66fc99e Initial load
duke
parents:
diff changeset
274 }
a61af66fc99e Initial load
duke
parents:
diff changeset
275
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
276 #define ObjArrayKlass_SPECIALIZED_OOP_ITERATE(T, a, p, do_oop) \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
277 { \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
278 T* p = (T*)(a)->base(); \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
279 T* const end = p + (a)->length(); \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
280 while (p < end) { \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
281 do_oop; \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
282 p++; \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
283 } \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
284 }
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
285
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
286 #define ObjArrayKlass_SPECIALIZED_BOUNDED_OOP_ITERATE(T, a, p, low, high, do_oop) \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
287 { \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
288 T* const l = (T*)(low); \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
289 T* const h = (T*)(high); \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
290 T* p = (T*)(a)->base(); \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
291 T* end = p + (a)->length(); \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
292 if (p < l) p = l; \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
293 if (end > h) end = h; \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
294 while (p < end) { \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
295 do_oop; \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
296 ++p; \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
297 } \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
298 }
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
299
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
300 #define ObjArrayKlass_OOP_ITERATE(a, p, do_oop) \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
301 if (UseCompressedOops) { \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
302 ObjArrayKlass_SPECIALIZED_OOP_ITERATE(narrowOop, \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
303 a, p, do_oop) \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
304 } else { \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
305 ObjArrayKlass_SPECIALIZED_OOP_ITERATE(oop, \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
306 a, p, do_oop) \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
307 }
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
308
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
309 #define ObjArrayKlass_BOUNDED_OOP_ITERATE(a, p, low, high, do_oop) \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
310 if (UseCompressedOops) { \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
311 ObjArrayKlass_SPECIALIZED_BOUNDED_OOP_ITERATE(narrowOop, \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
312 a, p, low, high, do_oop) \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
313 } else { \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
314 ObjArrayKlass_SPECIALIZED_BOUNDED_OOP_ITERATE(oop, \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
315 a, p, low, high, do_oop) \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
316 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
317
a61af66fc99e Initial load
duke
parents:
diff changeset
318 void objArrayKlass::oop_follow_contents(oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
319 assert (obj->is_array(), "obj must be array");
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
320 objArrayOop a = objArrayOop(obj);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
321 a->follow_header();
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
322 ObjArrayKlass_OOP_ITERATE( \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
323 a, p, \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
324 /* we call mark_and_follow here to avoid excessive marking stack usage */ \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
325 MarkSweep::mark_and_follow(p))
0
a61af66fc99e Initial load
duke
parents:
diff changeset
326 }
a61af66fc99e Initial load
duke
parents:
diff changeset
327
a61af66fc99e Initial load
duke
parents:
diff changeset
328 #ifndef SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
329 void objArrayKlass::oop_follow_contents(ParCompactionManager* cm,
a61af66fc99e Initial load
duke
parents:
diff changeset
330 oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
331 assert (obj->is_array(), "obj must be array");
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
332 objArrayOop a = objArrayOop(obj);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
333 a->follow_header(cm);
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
334 ObjArrayKlass_OOP_ITERATE( \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
335 a, p, \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
336 /* we call mark_and_follow here to avoid excessive marking stack usage */ \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
337 PSParallelCompact::mark_and_follow(cm, p))
0
a61af66fc99e Initial load
duke
parents:
diff changeset
338 }
a61af66fc99e Initial load
duke
parents:
diff changeset
339 #endif // SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
340
a61af66fc99e Initial load
duke
parents:
diff changeset
341 #define ObjArrayKlass_OOP_OOP_ITERATE_DEFN(OopClosureType, nv_suffix) \
a61af66fc99e Initial load
duke
parents:
diff changeset
342 \
a61af66fc99e Initial load
duke
parents:
diff changeset
343 int objArrayKlass::oop_oop_iterate##nv_suffix(oop obj, \
a61af66fc99e Initial load
duke
parents:
diff changeset
344 OopClosureType* closure) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
345 SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::oa); \
a61af66fc99e Initial load
duke
parents:
diff changeset
346 assert (obj->is_array(), "obj must be array"); \
a61af66fc99e Initial load
duke
parents:
diff changeset
347 objArrayOop a = objArrayOop(obj); \
a61af66fc99e Initial load
duke
parents:
diff changeset
348 /* Get size before changing pointers. */ \
a61af66fc99e Initial load
duke
parents:
diff changeset
349 /* Don't call size() or oop_size() since that is a virtual call. */ \
a61af66fc99e Initial load
duke
parents:
diff changeset
350 int size = a->object_size(); \
a61af66fc99e Initial load
duke
parents:
diff changeset
351 if (closure->do_header()) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
352 a->oop_iterate_header(closure); \
a61af66fc99e Initial load
duke
parents:
diff changeset
353 } \
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
354 ObjArrayKlass_OOP_ITERATE(a, p, (closure)->do_oop##nv_suffix(p)) \
0
a61af66fc99e Initial load
duke
parents:
diff changeset
355 return size; \
a61af66fc99e Initial load
duke
parents:
diff changeset
356 }
a61af66fc99e Initial load
duke
parents:
diff changeset
357
a61af66fc99e Initial load
duke
parents:
diff changeset
358 #define ObjArrayKlass_OOP_OOP_ITERATE_DEFN_m(OopClosureType, nv_suffix) \
a61af66fc99e Initial load
duke
parents:
diff changeset
359 \
a61af66fc99e Initial load
duke
parents:
diff changeset
360 int objArrayKlass::oop_oop_iterate##nv_suffix##_m(oop obj, \
a61af66fc99e Initial load
duke
parents:
diff changeset
361 OopClosureType* closure, \
a61af66fc99e Initial load
duke
parents:
diff changeset
362 MemRegion mr) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
363 SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::oa); \
a61af66fc99e Initial load
duke
parents:
diff changeset
364 assert(obj->is_array(), "obj must be array"); \
a61af66fc99e Initial load
duke
parents:
diff changeset
365 objArrayOop a = objArrayOop(obj); \
a61af66fc99e Initial load
duke
parents:
diff changeset
366 /* Get size before changing pointers. */ \
a61af66fc99e Initial load
duke
parents:
diff changeset
367 /* Don't call size() or oop_size() since that is a virtual call */ \
a61af66fc99e Initial load
duke
parents:
diff changeset
368 int size = a->object_size(); \
a61af66fc99e Initial load
duke
parents:
diff changeset
369 if (closure->do_header()) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
370 a->oop_iterate_header(closure, mr); \
a61af66fc99e Initial load
duke
parents:
diff changeset
371 } \
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
372 ObjArrayKlass_BOUNDED_OOP_ITERATE( \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
373 a, p, mr.start(), mr.end(), (closure)->do_oop##nv_suffix(p)) \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
374 return size; \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
375 }
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
376
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
377 // Like oop_oop_iterate but only iterates over a specified range and only used
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
378 // for objArrayOops.
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
379 #define ObjArrayKlass_OOP_OOP_ITERATE_DEFN_r(OopClosureType, nv_suffix) \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
380 \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
381 int objArrayKlass::oop_oop_iterate_range##nv_suffix(oop obj, \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
382 OopClosureType* closure, \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
383 int start, int end) { \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
384 SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::oa); \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
385 assert(obj->is_array(), "obj must be array"); \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
386 objArrayOop a = objArrayOop(obj); \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
387 /* Get size before changing pointers. */ \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
388 /* Don't call size() or oop_size() since that is a virtual call */ \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
389 int size = a->object_size(); \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
390 if (UseCompressedOops) { \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
391 HeapWord* low = start == 0 ? (HeapWord*)a : (HeapWord*)a->obj_at_addr<narrowOop>(start);\
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
392 /* this might be wierd if end needs to be aligned on HeapWord boundary */ \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
393 HeapWord* high = (HeapWord*)((narrowOop*)a->base() + end); \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
394 MemRegion mr(low, high); \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
395 if (closure->do_header()) { \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
396 a->oop_iterate_header(closure, mr); \
0
a61af66fc99e Initial load
duke
parents:
diff changeset
397 } \
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
398 ObjArrayKlass_SPECIALIZED_BOUNDED_OOP_ITERATE(narrowOop, \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
399 a, p, low, high, (closure)->do_oop##nv_suffix(p)) \
0
a61af66fc99e Initial load
duke
parents:
diff changeset
400 } else { \
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
401 HeapWord* low = start == 0 ? (HeapWord*)a : (HeapWord*)a->obj_at_addr<oop>(start); \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
402 HeapWord* high = (HeapWord*)((oop*)a->base() + end); \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
403 MemRegion mr(low, high); \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
404 if (closure->do_header()) { \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
405 a->oop_iterate_header(closure, mr); \
0
a61af66fc99e Initial load
duke
parents:
diff changeset
406 } \
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
407 ObjArrayKlass_SPECIALIZED_BOUNDED_OOP_ITERATE(oop, \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
408 a, p, low, high, (closure)->do_oop##nv_suffix(p)) \
0
a61af66fc99e Initial load
duke
parents:
diff changeset
409 } \
a61af66fc99e Initial load
duke
parents:
diff changeset
410 return size; \
a61af66fc99e Initial load
duke
parents:
diff changeset
411 }
a61af66fc99e Initial load
duke
parents:
diff changeset
412
a61af66fc99e Initial load
duke
parents:
diff changeset
413 ALL_OOP_OOP_ITERATE_CLOSURES_1(ObjArrayKlass_OOP_OOP_ITERATE_DEFN)
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 113
diff changeset
414 ALL_OOP_OOP_ITERATE_CLOSURES_2(ObjArrayKlass_OOP_OOP_ITERATE_DEFN)
0
a61af66fc99e Initial load
duke
parents:
diff changeset
415 ALL_OOP_OOP_ITERATE_CLOSURES_1(ObjArrayKlass_OOP_OOP_ITERATE_DEFN_m)
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 113
diff changeset
416 ALL_OOP_OOP_ITERATE_CLOSURES_2(ObjArrayKlass_OOP_OOP_ITERATE_DEFN_m)
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
417 ALL_OOP_OOP_ITERATE_CLOSURES_1(ObjArrayKlass_OOP_OOP_ITERATE_DEFN_r)
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 113
diff changeset
418 ALL_OOP_OOP_ITERATE_CLOSURES_2(ObjArrayKlass_OOP_OOP_ITERATE_DEFN_r)
0
a61af66fc99e Initial load
duke
parents:
diff changeset
419
a61af66fc99e Initial load
duke
parents:
diff changeset
420 int objArrayKlass::oop_adjust_pointers(oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
421 assert(obj->is_objArray(), "obj must be obj array");
a61af66fc99e Initial load
duke
parents:
diff changeset
422 objArrayOop a = objArrayOop(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
423 // Get size before changing pointers.
a61af66fc99e Initial load
duke
parents:
diff changeset
424 // Don't call size() or oop_size() since that is a virtual call.
a61af66fc99e Initial load
duke
parents:
diff changeset
425 int size = a->object_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
426 a->adjust_header();
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
427 ObjArrayKlass_OOP_ITERATE(a, p, MarkSweep::adjust_pointer(p))
0
a61af66fc99e Initial load
duke
parents:
diff changeset
428 return size;
a61af66fc99e Initial load
duke
parents:
diff changeset
429 }
a61af66fc99e Initial load
duke
parents:
diff changeset
430
a61af66fc99e Initial load
duke
parents:
diff changeset
431 #ifndef SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
432 void objArrayKlass::oop_copy_contents(PSPromotionManager* pm, oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
433 assert(!pm->depth_first(), "invariant");
a61af66fc99e Initial load
duke
parents:
diff changeset
434 assert(obj->is_objArray(), "obj must be obj array");
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
435 ObjArrayKlass_OOP_ITERATE( \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
436 objArrayOop(obj), p, \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
437 if (PSScavenge::should_scavenge(p)) { \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
438 pm->claim_or_forward_breadth(p); \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
439 })
0
a61af66fc99e Initial load
duke
parents:
diff changeset
440 }
a61af66fc99e Initial load
duke
parents:
diff changeset
441
a61af66fc99e Initial load
duke
parents:
diff changeset
442 void objArrayKlass::oop_push_contents(PSPromotionManager* pm, oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
443 assert(pm->depth_first(), "invariant");
a61af66fc99e Initial load
duke
parents:
diff changeset
444 assert(obj->is_objArray(), "obj must be obj array");
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
445 ObjArrayKlass_OOP_ITERATE( \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
446 objArrayOop(obj), p, \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
447 if (PSScavenge::should_scavenge(p)) { \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
448 pm->claim_or_forward_depth(p); \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
449 })
0
a61af66fc99e Initial load
duke
parents:
diff changeset
450 }
a61af66fc99e Initial load
duke
parents:
diff changeset
451
a61af66fc99e Initial load
duke
parents:
diff changeset
452 int objArrayKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
453 assert (obj->is_objArray(), "obj must be obj array");
a61af66fc99e Initial load
duke
parents:
diff changeset
454 objArrayOop a = objArrayOop(obj);
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
455 ObjArrayKlass_OOP_ITERATE(a, p, PSParallelCompact::adjust_pointer(p))
0
a61af66fc99e Initial load
duke
parents:
diff changeset
456 return a->object_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
457 }
a61af66fc99e Initial load
duke
parents:
diff changeset
458
a61af66fc99e Initial load
duke
parents:
diff changeset
459 int objArrayKlass::oop_update_pointers(ParCompactionManager* cm, oop obj,
a61af66fc99e Initial load
duke
parents:
diff changeset
460 HeapWord* beg_addr, HeapWord* end_addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
461 assert (obj->is_objArray(), "obj must be obj array");
a61af66fc99e Initial load
duke
parents:
diff changeset
462 objArrayOop a = objArrayOop(obj);
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
463 ObjArrayKlass_BOUNDED_OOP_ITERATE( \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
464 a, p, beg_addr, end_addr, \
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
465 PSParallelCompact::adjust_pointer(p))
0
a61af66fc99e Initial load
duke
parents:
diff changeset
466 return a->object_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
467 }
a61af66fc99e Initial load
duke
parents:
diff changeset
468 #endif // SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
469
a61af66fc99e Initial load
duke
parents:
diff changeset
470 // JVM support
a61af66fc99e Initial load
duke
parents:
diff changeset
471
a61af66fc99e Initial load
duke
parents:
diff changeset
472 jint objArrayKlass::compute_modifier_flags(TRAPS) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
473 // The modifier for an objectArray is the same as its element
a61af66fc99e Initial load
duke
parents:
diff changeset
474 if (element_klass() == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
475 assert(Universe::is_bootstrapping(), "partial objArray only at startup");
a61af66fc99e Initial load
duke
parents:
diff changeset
476 return JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC;
a61af66fc99e Initial load
duke
parents:
diff changeset
477 }
a61af66fc99e Initial load
duke
parents:
diff changeset
478 // Recurse down the element list
a61af66fc99e Initial load
duke
parents:
diff changeset
479 jint element_flags = Klass::cast(element_klass())->compute_modifier_flags(CHECK_0);
a61af66fc99e Initial load
duke
parents:
diff changeset
480
a61af66fc99e Initial load
duke
parents:
diff changeset
481 return (element_flags & (JVM_ACC_PUBLIC | JVM_ACC_PRIVATE | JVM_ACC_PROTECTED))
a61af66fc99e Initial load
duke
parents:
diff changeset
482 | (JVM_ACC_ABSTRACT | JVM_ACC_FINAL);
a61af66fc99e Initial load
duke
parents:
diff changeset
483 }
a61af66fc99e Initial load
duke
parents:
diff changeset
484
a61af66fc99e Initial load
duke
parents:
diff changeset
485
a61af66fc99e Initial load
duke
parents:
diff changeset
486 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
487 // Printing
a61af66fc99e Initial load
duke
parents:
diff changeset
488
a61af66fc99e Initial load
duke
parents:
diff changeset
489 void objArrayKlass::oop_print_on(oop obj, outputStream* st) {
a61af66fc99e Initial load
duke
parents:
diff changeset
490 arrayKlass::oop_print_on(obj, st);
a61af66fc99e Initial load
duke
parents:
diff changeset
491 assert(obj->is_objArray(), "must be objArray");
a61af66fc99e Initial load
duke
parents:
diff changeset
492 objArrayOop oa = objArrayOop(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
493 int print_len = MIN2((intx) oa->length(), MaxElementPrintSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
494 for(int index = 0; index < print_len; index++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
495 st->print(" - %3d : ", index);
a61af66fc99e Initial load
duke
parents:
diff changeset
496 oa->obj_at(index)->print_value_on(st);
a61af66fc99e Initial load
duke
parents:
diff changeset
497 st->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
498 }
a61af66fc99e Initial load
duke
parents:
diff changeset
499 int remaining = oa->length() - print_len;
a61af66fc99e Initial load
duke
parents:
diff changeset
500 if (remaining > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
501 tty->print_cr(" - <%d more elements, increase MaxElementPrintSize to print>", remaining);
a61af66fc99e Initial load
duke
parents:
diff changeset
502 }
a61af66fc99e Initial load
duke
parents:
diff changeset
503 }
a61af66fc99e Initial load
duke
parents:
diff changeset
504
a61af66fc99e Initial load
duke
parents:
diff changeset
505
a61af66fc99e Initial load
duke
parents:
diff changeset
506 void objArrayKlass::oop_print_value_on(oop obj, outputStream* st) {
a61af66fc99e Initial load
duke
parents:
diff changeset
507 assert(obj->is_objArray(), "must be objArray");
a61af66fc99e Initial load
duke
parents:
diff changeset
508 element_klass()->print_value_on(st);
a61af66fc99e Initial load
duke
parents:
diff changeset
509 st->print("a [%d] ", objArrayOop(obj)->length());
a61af66fc99e Initial load
duke
parents:
diff changeset
510 as_klassOop()->klass()->print_value_on(st);
a61af66fc99e Initial load
duke
parents:
diff changeset
511 }
a61af66fc99e Initial load
duke
parents:
diff changeset
512
a61af66fc99e Initial load
duke
parents:
diff changeset
513 #endif // PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
514
a61af66fc99e Initial load
duke
parents:
diff changeset
515 const char* objArrayKlass::internal_name() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
516 return external_name();
a61af66fc99e Initial load
duke
parents:
diff changeset
517 }
a61af66fc99e Initial load
duke
parents:
diff changeset
518
a61af66fc99e Initial load
duke
parents:
diff changeset
519 // Verification
a61af66fc99e Initial load
duke
parents:
diff changeset
520
a61af66fc99e Initial load
duke
parents:
diff changeset
521 void objArrayKlass::oop_verify_on(oop obj, outputStream* st) {
a61af66fc99e Initial load
duke
parents:
diff changeset
522 arrayKlass::oop_verify_on(obj, st);
a61af66fc99e Initial load
duke
parents:
diff changeset
523 guarantee(obj->is_objArray(), "must be objArray");
a61af66fc99e Initial load
duke
parents:
diff changeset
524 objArrayOop oa = objArrayOop(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
525 for(int index = 0; index < oa->length(); index++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
526 guarantee(oa->obj_at(index)->is_oop_or_null(), "should be oop");
a61af66fc99e Initial load
duke
parents:
diff changeset
527 }
a61af66fc99e Initial load
duke
parents:
diff changeset
528 }
a61af66fc99e Initial load
duke
parents:
diff changeset
529
a61af66fc99e Initial load
duke
parents:
diff changeset
530 void objArrayKlass::oop_verify_old_oop(oop obj, oop* p, bool allow_dirty) {
a61af66fc99e Initial load
duke
parents:
diff changeset
531 /* $$$ move into remembered set verification?
a61af66fc99e Initial load
duke
parents:
diff changeset
532 RememberedSet::verify_old_oop(obj, p, allow_dirty, true);
a61af66fc99e Initial load
duke
parents:
diff changeset
533 */
a61af66fc99e Initial load
duke
parents:
diff changeset
534 }
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
535 void objArrayKlass::oop_verify_old_oop(oop obj, narrowOop* p, bool allow_dirty) {}