annotate src/share/vm/oops/objArrayKlass.cpp @ 0:a61af66fc99e jdk7-b24

Initial load
author duke
date Sat, 01 Dec 2007 00:00:00 +0000
parents
children ba764ed4b6f2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
2 * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved.
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
a61af66fc99e Initial load
duke
parents:
diff changeset
83 void objArrayKlass::copy_array(arrayOop s, int src_pos, arrayOop d,
a61af66fc99e Initial load
duke
parents:
diff changeset
84 int dst_pos, int length, TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
85 assert(s->is_objArray(), "must be obj array");
a61af66fc99e Initial load
duke
parents:
diff changeset
86
a61af66fc99e Initial load
duke
parents:
diff changeset
87 if (!d->is_objArray()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
88 THROW(vmSymbols::java_lang_ArrayStoreException());
a61af66fc99e Initial load
duke
parents:
diff changeset
89 }
a61af66fc99e Initial load
duke
parents:
diff changeset
90
a61af66fc99e Initial load
duke
parents:
diff changeset
91 // Check is all offsets and lengths are non negative
a61af66fc99e Initial load
duke
parents:
diff changeset
92 if (src_pos < 0 || dst_pos < 0 || length < 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
93 THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException());
a61af66fc99e Initial load
duke
parents:
diff changeset
94 }
a61af66fc99e Initial load
duke
parents:
diff changeset
95 // Check if the ranges are valid
a61af66fc99e Initial load
duke
parents:
diff changeset
96 if ( (((unsigned int) length + (unsigned int) src_pos) > (unsigned int) s->length())
a61af66fc99e Initial load
duke
parents:
diff changeset
97 || (((unsigned int) length + (unsigned int) dst_pos) > (unsigned int) d->length()) ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
98 THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException());
a61af66fc99e Initial load
duke
parents:
diff changeset
99 }
a61af66fc99e Initial load
duke
parents:
diff changeset
100
a61af66fc99e Initial load
duke
parents:
diff changeset
101 // Special case. Boundary cases must be checked first
a61af66fc99e Initial load
duke
parents:
diff changeset
102 // This allows the following call: copy_array(s, s.length(), d.length(), 0).
a61af66fc99e Initial load
duke
parents:
diff changeset
103 // 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
104 // points to the right of the last element.
a61af66fc99e Initial load
duke
parents:
diff changeset
105 if (length==0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
106 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
107 }
a61af66fc99e Initial load
duke
parents:
diff changeset
108
a61af66fc99e Initial load
duke
parents:
diff changeset
109 oop* const src = objArrayOop(s)->obj_at_addr(src_pos);
a61af66fc99e Initial load
duke
parents:
diff changeset
110 oop* const dst = objArrayOop(d)->obj_at_addr(dst_pos);
a61af66fc99e Initial load
duke
parents:
diff changeset
111 const size_t word_len = length * HeapWordsPerOop;
a61af66fc99e Initial load
duke
parents:
diff changeset
112
a61af66fc99e Initial load
duke
parents:
diff changeset
113 // For performance reasons, we assume we are using a card marking write
a61af66fc99e Initial load
duke
parents:
diff changeset
114 // barrier. The assert will fail if this is not the case.
a61af66fc99e Initial load
duke
parents:
diff changeset
115 BarrierSet* bs = Universe::heap()->barrier_set();
a61af66fc99e Initial load
duke
parents:
diff changeset
116 assert(bs->has_write_ref_array_opt(), "Barrier set must have ref array opt");
a61af66fc99e Initial load
duke
parents:
diff changeset
117
a61af66fc99e Initial load
duke
parents:
diff changeset
118 if (s == d) {
a61af66fc99e Initial load
duke
parents:
diff changeset
119 // since source and destination are equal we do not need conversion checks.
a61af66fc99e Initial load
duke
parents:
diff changeset
120 assert(length > 0, "sanity check");
a61af66fc99e Initial load
duke
parents:
diff changeset
121 Copy::conjoint_oops_atomic(src, dst, length);
a61af66fc99e Initial load
duke
parents:
diff changeset
122 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
123 // We have to make sure all elements conform to the destination array
a61af66fc99e Initial load
duke
parents:
diff changeset
124 klassOop bound = objArrayKlass::cast(d->klass())->element_klass();
a61af66fc99e Initial load
duke
parents:
diff changeset
125 klassOop stype = objArrayKlass::cast(s->klass())->element_klass();
a61af66fc99e Initial load
duke
parents:
diff changeset
126 if (stype == bound || Klass::cast(stype)->is_subtype_of(bound)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
127 // elements are guaranteed to be subtypes, so no check necessary
a61af66fc99e Initial load
duke
parents:
diff changeset
128 Copy::conjoint_oops_atomic(src, dst, length);
a61af66fc99e Initial load
duke
parents:
diff changeset
129 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
130 // slow case: need individual subtype checks
a61af66fc99e Initial load
duke
parents:
diff changeset
131 // note: don't use obj_at_put below because it includes a redundant store check
a61af66fc99e Initial load
duke
parents:
diff changeset
132 oop* from = src;
a61af66fc99e Initial load
duke
parents:
diff changeset
133 oop* end = from + length;
a61af66fc99e Initial load
duke
parents:
diff changeset
134 for (oop* p = dst; from < end; from++, p++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
135 oop element = *from;
a61af66fc99e Initial load
duke
parents:
diff changeset
136 if (element == NULL || Klass::cast(element->klass())->is_subtype_of(bound)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
137 *p = element;
a61af66fc99e Initial load
duke
parents:
diff changeset
138 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
139 // We must do a barrier to cover the partial copy.
a61af66fc99e Initial load
duke
parents:
diff changeset
140 const size_t done_word_len = pointer_delta(p, dst, oopSize) *
a61af66fc99e Initial load
duke
parents:
diff changeset
141 HeapWordsPerOop;
a61af66fc99e Initial load
duke
parents:
diff changeset
142 bs->write_ref_array(MemRegion((HeapWord*)dst, done_word_len));
a61af66fc99e Initial load
duke
parents:
diff changeset
143 THROW(vmSymbols::java_lang_ArrayStoreException());
a61af66fc99e Initial load
duke
parents:
diff changeset
144 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
145 }
a61af66fc99e Initial load
duke
parents:
diff changeset
146 }
a61af66fc99e Initial load
duke
parents:
diff changeset
147 }
a61af66fc99e Initial load
duke
parents:
diff changeset
148 }
a61af66fc99e Initial load
duke
parents:
diff changeset
149 bs->write_ref_array(MemRegion((HeapWord*)dst, word_len));
a61af66fc99e Initial load
duke
parents:
diff changeset
150 }
a61af66fc99e Initial load
duke
parents:
diff changeset
151
a61af66fc99e Initial load
duke
parents:
diff changeset
152
a61af66fc99e Initial load
duke
parents:
diff changeset
153 klassOop objArrayKlass::array_klass_impl(bool or_null, int n, TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
154 objArrayKlassHandle h_this(THREAD, as_klassOop());
a61af66fc99e Initial load
duke
parents:
diff changeset
155 return array_klass_impl(h_this, or_null, n, CHECK_NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
156 }
a61af66fc99e Initial load
duke
parents:
diff changeset
157
a61af66fc99e Initial load
duke
parents:
diff changeset
158
a61af66fc99e Initial load
duke
parents:
diff changeset
159 klassOop objArrayKlass::array_klass_impl(objArrayKlassHandle this_oop, bool or_null, int n, TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
160
a61af66fc99e Initial load
duke
parents:
diff changeset
161 assert(this_oop->dimension() <= n, "check order of chain");
a61af66fc99e Initial load
duke
parents:
diff changeset
162 int dimension = this_oop->dimension();
a61af66fc99e Initial load
duke
parents:
diff changeset
163 if (dimension == n)
a61af66fc99e Initial load
duke
parents:
diff changeset
164 return this_oop();
a61af66fc99e Initial load
duke
parents:
diff changeset
165
a61af66fc99e Initial load
duke
parents:
diff changeset
166 objArrayKlassHandle ak (THREAD, this_oop->higher_dimension());
a61af66fc99e Initial load
duke
parents:
diff changeset
167 if (ak.is_null()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
168 if (or_null) return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
169
a61af66fc99e Initial load
duke
parents:
diff changeset
170 ResourceMark rm;
a61af66fc99e Initial load
duke
parents:
diff changeset
171 JavaThread *jt = (JavaThread *)THREAD;
a61af66fc99e Initial load
duke
parents:
diff changeset
172 {
a61af66fc99e Initial load
duke
parents:
diff changeset
173 MutexLocker mc(Compile_lock, THREAD); // for vtables
a61af66fc99e Initial load
duke
parents:
diff changeset
174 // Ensure atomic creation of higher dimensions
a61af66fc99e Initial load
duke
parents:
diff changeset
175 MutexLocker mu(MultiArray_lock, THREAD);
a61af66fc99e Initial load
duke
parents:
diff changeset
176
a61af66fc99e Initial load
duke
parents:
diff changeset
177 // Check if another thread beat us
a61af66fc99e Initial load
duke
parents:
diff changeset
178 ak = objArrayKlassHandle(THREAD, this_oop->higher_dimension());
a61af66fc99e Initial load
duke
parents:
diff changeset
179 if( ak.is_null() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
180
a61af66fc99e Initial load
duke
parents:
diff changeset
181 // Create multi-dim klass object and link them together
a61af66fc99e Initial load
duke
parents:
diff changeset
182 klassOop new_klass =
a61af66fc99e Initial load
duke
parents:
diff changeset
183 objArrayKlassKlass::cast(Universe::objArrayKlassKlassObj())->
a61af66fc99e Initial load
duke
parents:
diff changeset
184 allocate_objArray_klass(dimension + 1, this_oop, CHECK_NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
185 ak = objArrayKlassHandle(THREAD, new_klass);
a61af66fc99e Initial load
duke
parents:
diff changeset
186 this_oop->set_higher_dimension(ak());
a61af66fc99e Initial load
duke
parents:
diff changeset
187 ak->set_lower_dimension(this_oop());
a61af66fc99e Initial load
duke
parents:
diff changeset
188 assert(ak->oop_is_objArray(), "incorrect initialization of objArrayKlass");
a61af66fc99e Initial load
duke
parents:
diff changeset
189 }
a61af66fc99e Initial load
duke
parents:
diff changeset
190 }
a61af66fc99e Initial load
duke
parents:
diff changeset
191 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
192 CHECK_UNHANDLED_OOPS_ONLY(Thread::current()->clear_unhandled_oops());
a61af66fc99e Initial load
duke
parents:
diff changeset
193 }
a61af66fc99e Initial load
duke
parents:
diff changeset
194
a61af66fc99e Initial load
duke
parents:
diff changeset
195 if (or_null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
196 return ak->array_klass_or_null(n);
a61af66fc99e Initial load
duke
parents:
diff changeset
197 }
a61af66fc99e Initial load
duke
parents:
diff changeset
198 return ak->array_klass(n, CHECK_NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
199 }
a61af66fc99e Initial load
duke
parents:
diff changeset
200
a61af66fc99e Initial load
duke
parents:
diff changeset
201 klassOop objArrayKlass::array_klass_impl(bool or_null, TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
202 return array_klass_impl(or_null, dimension() + 1, CHECK_NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
203 }
a61af66fc99e Initial load
duke
parents:
diff changeset
204
a61af66fc99e Initial load
duke
parents:
diff changeset
205 bool objArrayKlass::can_be_primary_super_slow() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
206 if (!bottom_klass()->klass_part()->can_be_primary_super())
a61af66fc99e Initial load
duke
parents:
diff changeset
207 // array of interfaces
a61af66fc99e Initial load
duke
parents:
diff changeset
208 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
209 else
a61af66fc99e Initial load
duke
parents:
diff changeset
210 return Klass::can_be_primary_super_slow();
a61af66fc99e Initial load
duke
parents:
diff changeset
211 }
a61af66fc99e Initial load
duke
parents:
diff changeset
212
a61af66fc99e Initial load
duke
parents:
diff changeset
213 objArrayOop objArrayKlass::compute_secondary_supers(int num_extra_slots, TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
214 // interfaces = { cloneable_klass, serializable_klass, elemSuper[], ... };
a61af66fc99e Initial load
duke
parents:
diff changeset
215 objArrayOop es = Klass::cast(element_klass())->secondary_supers();
a61af66fc99e Initial load
duke
parents:
diff changeset
216 objArrayHandle elem_supers (THREAD, es);
a61af66fc99e Initial load
duke
parents:
diff changeset
217 int num_elem_supers = elem_supers.is_null() ? 0 : elem_supers->length();
a61af66fc99e Initial load
duke
parents:
diff changeset
218 int num_secondaries = num_extra_slots + 2 + num_elem_supers;
a61af66fc99e Initial load
duke
parents:
diff changeset
219 if (num_secondaries == 2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
220 // Must share this for correct bootstrapping!
a61af66fc99e Initial load
duke
parents:
diff changeset
221 return Universe::the_array_interfaces_array();
a61af66fc99e Initial load
duke
parents:
diff changeset
222 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
223 objArrayOop sec_oop = oopFactory::new_system_objArray(num_secondaries, CHECK_NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
224 objArrayHandle secondaries(THREAD, sec_oop);
a61af66fc99e Initial load
duke
parents:
diff changeset
225 secondaries->obj_at_put(num_extra_slots+0, SystemDictionary::cloneable_klass());
a61af66fc99e Initial load
duke
parents:
diff changeset
226 secondaries->obj_at_put(num_extra_slots+1, SystemDictionary::serializable_klass());
a61af66fc99e Initial load
duke
parents:
diff changeset
227 for (int i = 0; i < num_elem_supers; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
228 klassOop elem_super = (klassOop) elem_supers->obj_at(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
229 klassOop array_super = elem_super->klass_part()->array_klass_or_null();
a61af66fc99e Initial load
duke
parents:
diff changeset
230 assert(array_super != NULL, "must already have been created");
a61af66fc99e Initial load
duke
parents:
diff changeset
231 secondaries->obj_at_put(num_extra_slots+2+i, array_super);
a61af66fc99e Initial load
duke
parents:
diff changeset
232 }
a61af66fc99e Initial load
duke
parents:
diff changeset
233 return secondaries();
a61af66fc99e Initial load
duke
parents:
diff changeset
234 }
a61af66fc99e Initial load
duke
parents:
diff changeset
235 }
a61af66fc99e Initial load
duke
parents:
diff changeset
236
a61af66fc99e Initial load
duke
parents:
diff changeset
237 bool objArrayKlass::compute_is_subtype_of(klassOop k) {
a61af66fc99e Initial load
duke
parents:
diff changeset
238 if (!k->klass_part()->oop_is_objArray())
a61af66fc99e Initial load
duke
parents:
diff changeset
239 return arrayKlass::compute_is_subtype_of(k);
a61af66fc99e Initial load
duke
parents:
diff changeset
240
a61af66fc99e Initial load
duke
parents:
diff changeset
241 objArrayKlass* oak = objArrayKlass::cast(k);
a61af66fc99e Initial load
duke
parents:
diff changeset
242 return element_klass()->klass_part()->is_subtype_of(oak->element_klass());
a61af66fc99e Initial load
duke
parents:
diff changeset
243 }
a61af66fc99e Initial load
duke
parents:
diff changeset
244
a61af66fc99e Initial load
duke
parents:
diff changeset
245
a61af66fc99e Initial load
duke
parents:
diff changeset
246 void objArrayKlass::initialize(TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
247 Klass::cast(bottom_klass())->initialize(THREAD); // dispatches to either instanceKlass or typeArrayKlass
a61af66fc99e Initial load
duke
parents:
diff changeset
248 }
a61af66fc99e Initial load
duke
parents:
diff changeset
249
a61af66fc99e Initial load
duke
parents:
diff changeset
250
a61af66fc99e Initial load
duke
parents:
diff changeset
251 void objArrayKlass::oop_follow_contents(oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
252 assert (obj->is_array(), "obj must be array");
a61af66fc99e Initial load
duke
parents:
diff changeset
253 arrayOop a = arrayOop(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
254 a->follow_header();
a61af66fc99e Initial load
duke
parents:
diff changeset
255 oop* base = (oop*)a->base(T_OBJECT);
a61af66fc99e Initial load
duke
parents:
diff changeset
256 oop* const end = base + a->length();
a61af66fc99e Initial load
duke
parents:
diff changeset
257 while (base < end) {
a61af66fc99e Initial load
duke
parents:
diff changeset
258 if (*base != NULL)
a61af66fc99e Initial load
duke
parents:
diff changeset
259 // we call mark_and_follow here to avoid excessive marking stack usage
a61af66fc99e Initial load
duke
parents:
diff changeset
260 MarkSweep::mark_and_follow(base);
a61af66fc99e Initial load
duke
parents:
diff changeset
261 base++;
a61af66fc99e Initial load
duke
parents:
diff changeset
262 }
a61af66fc99e Initial load
duke
parents:
diff changeset
263 }
a61af66fc99e Initial load
duke
parents:
diff changeset
264
a61af66fc99e Initial load
duke
parents:
diff changeset
265 #ifndef SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
266 void objArrayKlass::oop_follow_contents(ParCompactionManager* cm,
a61af66fc99e Initial load
duke
parents:
diff changeset
267 oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
268 assert (obj->is_array(), "obj must be array");
a61af66fc99e Initial load
duke
parents:
diff changeset
269 arrayOop a = arrayOop(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
270 a->follow_header(cm);
a61af66fc99e Initial load
duke
parents:
diff changeset
271 oop* base = (oop*)a->base(T_OBJECT);
a61af66fc99e Initial load
duke
parents:
diff changeset
272 oop* const end = base + a->length();
a61af66fc99e Initial load
duke
parents:
diff changeset
273 while (base < end) {
a61af66fc99e Initial load
duke
parents:
diff changeset
274 if (*base != NULL)
a61af66fc99e Initial load
duke
parents:
diff changeset
275 // we call mark_and_follow here to avoid excessive marking stack usage
a61af66fc99e Initial load
duke
parents:
diff changeset
276 PSParallelCompact::mark_and_follow(cm, base);
a61af66fc99e Initial load
duke
parents:
diff changeset
277 base++;
a61af66fc99e Initial load
duke
parents:
diff changeset
278 }
a61af66fc99e Initial load
duke
parents:
diff changeset
279 }
a61af66fc99e Initial load
duke
parents:
diff changeset
280 #endif // SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
281
a61af66fc99e Initial load
duke
parents:
diff changeset
282 #define invoke_closure_on(base, closure, nv_suffix) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
283 if (*(base) != NULL) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
284 (closure)->do_oop##nv_suffix(base); \
a61af66fc99e Initial load
duke
parents:
diff changeset
285 } \
a61af66fc99e Initial load
duke
parents:
diff changeset
286 }
a61af66fc99e Initial load
duke
parents:
diff changeset
287
a61af66fc99e Initial load
duke
parents:
diff changeset
288 #define ObjArrayKlass_OOP_OOP_ITERATE_DEFN(OopClosureType, nv_suffix) \
a61af66fc99e Initial load
duke
parents:
diff changeset
289 \
a61af66fc99e Initial load
duke
parents:
diff changeset
290 int objArrayKlass::oop_oop_iterate##nv_suffix(oop obj, \
a61af66fc99e Initial load
duke
parents:
diff changeset
291 OopClosureType* closure) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
292 SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::oa); \
a61af66fc99e Initial load
duke
parents:
diff changeset
293 assert (obj->is_array(), "obj must be array"); \
a61af66fc99e Initial load
duke
parents:
diff changeset
294 objArrayOop a = objArrayOop(obj); \
a61af66fc99e Initial load
duke
parents:
diff changeset
295 /* Get size before changing pointers. */ \
a61af66fc99e Initial load
duke
parents:
diff changeset
296 /* Don't call size() or oop_size() since that is a virtual call. */ \
a61af66fc99e Initial load
duke
parents:
diff changeset
297 int size = a->object_size(); \
a61af66fc99e Initial load
duke
parents:
diff changeset
298 if (closure->do_header()) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
299 a->oop_iterate_header(closure); \
a61af66fc99e Initial load
duke
parents:
diff changeset
300 } \
a61af66fc99e Initial load
duke
parents:
diff changeset
301 oop* base = a->base(); \
a61af66fc99e Initial load
duke
parents:
diff changeset
302 oop* const end = base + a->length(); \
a61af66fc99e Initial load
duke
parents:
diff changeset
303 const intx field_offset = PrefetchFieldsAhead; \
a61af66fc99e Initial load
duke
parents:
diff changeset
304 if (field_offset > 0) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
305 while (base < end) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
306 prefetch_beyond(base, end, field_offset, closure->prefetch_style()); \
a61af66fc99e Initial load
duke
parents:
diff changeset
307 invoke_closure_on(base, closure, nv_suffix); \
a61af66fc99e Initial load
duke
parents:
diff changeset
308 base++; \
a61af66fc99e Initial load
duke
parents:
diff changeset
309 } \
a61af66fc99e Initial load
duke
parents:
diff changeset
310 } else { \
a61af66fc99e Initial load
duke
parents:
diff changeset
311 while (base < end) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
312 invoke_closure_on(base, closure, nv_suffix); \
a61af66fc99e Initial load
duke
parents:
diff changeset
313 base++; \
a61af66fc99e Initial load
duke
parents:
diff changeset
314 } \
a61af66fc99e Initial load
duke
parents:
diff changeset
315 } \
a61af66fc99e Initial load
duke
parents:
diff changeset
316 return size; \
a61af66fc99e Initial load
duke
parents:
diff changeset
317 }
a61af66fc99e Initial load
duke
parents:
diff changeset
318
a61af66fc99e Initial load
duke
parents:
diff changeset
319 #define ObjArrayKlass_OOP_OOP_ITERATE_DEFN_m(OopClosureType, nv_suffix) \
a61af66fc99e Initial load
duke
parents:
diff changeset
320 \
a61af66fc99e Initial load
duke
parents:
diff changeset
321 int objArrayKlass::oop_oop_iterate##nv_suffix##_m(oop obj, \
a61af66fc99e Initial load
duke
parents:
diff changeset
322 OopClosureType* closure, \
a61af66fc99e Initial load
duke
parents:
diff changeset
323 MemRegion mr) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
324 SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::oa); \
a61af66fc99e Initial load
duke
parents:
diff changeset
325 assert(obj->is_array(), "obj must be array"); \
a61af66fc99e Initial load
duke
parents:
diff changeset
326 objArrayOop a = objArrayOop(obj); \
a61af66fc99e Initial load
duke
parents:
diff changeset
327 /* Get size before changing pointers. */ \
a61af66fc99e Initial load
duke
parents:
diff changeset
328 /* Don't call size() or oop_size() since that is a virtual call */ \
a61af66fc99e Initial load
duke
parents:
diff changeset
329 int size = a->object_size(); \
a61af66fc99e Initial load
duke
parents:
diff changeset
330 if (closure->do_header()) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
331 a->oop_iterate_header(closure, mr); \
a61af66fc99e Initial load
duke
parents:
diff changeset
332 } \
a61af66fc99e Initial load
duke
parents:
diff changeset
333 oop* bottom = (oop*)mr.start(); \
a61af66fc99e Initial load
duke
parents:
diff changeset
334 oop* top = (oop*)mr.end(); \
a61af66fc99e Initial load
duke
parents:
diff changeset
335 oop* base = a->base(); \
a61af66fc99e Initial load
duke
parents:
diff changeset
336 oop* end = base + a->length(); \
a61af66fc99e Initial load
duke
parents:
diff changeset
337 if (base < bottom) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
338 base = bottom; \
a61af66fc99e Initial load
duke
parents:
diff changeset
339 } \
a61af66fc99e Initial load
duke
parents:
diff changeset
340 if (end > top) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
341 end = top; \
a61af66fc99e Initial load
duke
parents:
diff changeset
342 } \
a61af66fc99e Initial load
duke
parents:
diff changeset
343 const intx field_offset = PrefetchFieldsAhead; \
a61af66fc99e Initial load
duke
parents:
diff changeset
344 if (field_offset > 0) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
345 while (base < end) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
346 prefetch_beyond(base, end, field_offset, closure->prefetch_style()); \
a61af66fc99e Initial load
duke
parents:
diff changeset
347 invoke_closure_on(base, closure, nv_suffix); \
a61af66fc99e Initial load
duke
parents:
diff changeset
348 base++; \
a61af66fc99e Initial load
duke
parents:
diff changeset
349 } \
a61af66fc99e Initial load
duke
parents:
diff changeset
350 } else { \
a61af66fc99e Initial load
duke
parents:
diff changeset
351 while (base < end) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
352 invoke_closure_on(base, closure, nv_suffix); \
a61af66fc99e Initial load
duke
parents:
diff changeset
353 base++; \
a61af66fc99e Initial load
duke
parents:
diff changeset
354 } \
a61af66fc99e Initial load
duke
parents:
diff changeset
355 } \
a61af66fc99e Initial load
duke
parents:
diff changeset
356 return size; \
a61af66fc99e Initial load
duke
parents:
diff changeset
357 }
a61af66fc99e Initial load
duke
parents:
diff changeset
358
a61af66fc99e Initial load
duke
parents:
diff changeset
359 ALL_OOP_OOP_ITERATE_CLOSURES_1(ObjArrayKlass_OOP_OOP_ITERATE_DEFN)
a61af66fc99e Initial load
duke
parents:
diff changeset
360 ALL_OOP_OOP_ITERATE_CLOSURES_3(ObjArrayKlass_OOP_OOP_ITERATE_DEFN)
a61af66fc99e Initial load
duke
parents:
diff changeset
361 ALL_OOP_OOP_ITERATE_CLOSURES_1(ObjArrayKlass_OOP_OOP_ITERATE_DEFN_m)
a61af66fc99e Initial load
duke
parents:
diff changeset
362 ALL_OOP_OOP_ITERATE_CLOSURES_3(ObjArrayKlass_OOP_OOP_ITERATE_DEFN_m)
a61af66fc99e Initial load
duke
parents:
diff changeset
363
a61af66fc99e Initial load
duke
parents:
diff changeset
364 int objArrayKlass::oop_adjust_pointers(oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
365 assert(obj->is_objArray(), "obj must be obj array");
a61af66fc99e Initial load
duke
parents:
diff changeset
366 objArrayOop a = objArrayOop(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
367 // Get size before changing pointers.
a61af66fc99e Initial load
duke
parents:
diff changeset
368 // Don't call size() or oop_size() since that is a virtual call.
a61af66fc99e Initial load
duke
parents:
diff changeset
369 int size = a->object_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
370 a->adjust_header();
a61af66fc99e Initial load
duke
parents:
diff changeset
371 oop* base = a->base();
a61af66fc99e Initial load
duke
parents:
diff changeset
372 oop* const end = base + a->length();
a61af66fc99e Initial load
duke
parents:
diff changeset
373 while (base < end) {
a61af66fc99e Initial load
duke
parents:
diff changeset
374 MarkSweep::adjust_pointer(base);
a61af66fc99e Initial load
duke
parents:
diff changeset
375 base++;
a61af66fc99e Initial load
duke
parents:
diff changeset
376 }
a61af66fc99e Initial load
duke
parents:
diff changeset
377 return size;
a61af66fc99e Initial load
duke
parents:
diff changeset
378 }
a61af66fc99e Initial load
duke
parents:
diff changeset
379
a61af66fc99e Initial load
duke
parents:
diff changeset
380 #ifndef SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
381 void objArrayKlass::oop_copy_contents(PSPromotionManager* pm, oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
382 assert(!pm->depth_first(), "invariant");
a61af66fc99e Initial load
duke
parents:
diff changeset
383 assert(obj->is_objArray(), "obj must be obj array");
a61af66fc99e Initial load
duke
parents:
diff changeset
384 // Compute oop range
a61af66fc99e Initial load
duke
parents:
diff changeset
385 oop* curr = objArrayOop(obj)->base();
a61af66fc99e Initial load
duke
parents:
diff changeset
386 oop* end = curr + objArrayOop(obj)->length();
a61af66fc99e Initial load
duke
parents:
diff changeset
387 // assert(align_object_size(end - (oop*)obj) == oop_size(obj), "checking size");
a61af66fc99e Initial load
duke
parents:
diff changeset
388 assert(align_object_size(pointer_delta(end, obj, sizeof(oop*)))
a61af66fc99e Initial load
duke
parents:
diff changeset
389 == oop_size(obj), "checking size");
a61af66fc99e Initial load
duke
parents:
diff changeset
390
a61af66fc99e Initial load
duke
parents:
diff changeset
391 // Iterate over oops
a61af66fc99e Initial load
duke
parents:
diff changeset
392 while (curr < end) {
a61af66fc99e Initial load
duke
parents:
diff changeset
393 if (PSScavenge::should_scavenge(*curr)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
394 pm->claim_or_forward_breadth(curr);
a61af66fc99e Initial load
duke
parents:
diff changeset
395 }
a61af66fc99e Initial load
duke
parents:
diff changeset
396 ++curr;
a61af66fc99e Initial load
duke
parents:
diff changeset
397 }
a61af66fc99e Initial load
duke
parents:
diff changeset
398 }
a61af66fc99e Initial load
duke
parents:
diff changeset
399
a61af66fc99e Initial load
duke
parents:
diff changeset
400 void objArrayKlass::oop_push_contents(PSPromotionManager* pm, oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
401 assert(pm->depth_first(), "invariant");
a61af66fc99e Initial load
duke
parents:
diff changeset
402 assert(obj->is_objArray(), "obj must be obj array");
a61af66fc99e Initial load
duke
parents:
diff changeset
403 // Compute oop range
a61af66fc99e Initial load
duke
parents:
diff changeset
404 oop* curr = objArrayOop(obj)->base();
a61af66fc99e Initial load
duke
parents:
diff changeset
405 oop* end = curr + objArrayOop(obj)->length();
a61af66fc99e Initial load
duke
parents:
diff changeset
406 // assert(align_object_size(end - (oop*)obj) == oop_size(obj), "checking size");
a61af66fc99e Initial load
duke
parents:
diff changeset
407 assert(align_object_size(pointer_delta(end, obj, sizeof(oop*)))
a61af66fc99e Initial load
duke
parents:
diff changeset
408 == oop_size(obj), "checking size");
a61af66fc99e Initial load
duke
parents:
diff changeset
409
a61af66fc99e Initial load
duke
parents:
diff changeset
410 // Iterate over oops
a61af66fc99e Initial load
duke
parents:
diff changeset
411 while (curr < end) {
a61af66fc99e Initial load
duke
parents:
diff changeset
412 if (PSScavenge::should_scavenge(*curr)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
413 pm->claim_or_forward_depth(curr);
a61af66fc99e Initial load
duke
parents:
diff changeset
414 }
a61af66fc99e Initial load
duke
parents:
diff changeset
415 ++curr;
a61af66fc99e Initial load
duke
parents:
diff changeset
416 }
a61af66fc99e Initial load
duke
parents:
diff changeset
417 }
a61af66fc99e Initial load
duke
parents:
diff changeset
418
a61af66fc99e Initial load
duke
parents:
diff changeset
419 int objArrayKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
420 assert (obj->is_objArray(), "obj must be obj array");
a61af66fc99e Initial load
duke
parents:
diff changeset
421 objArrayOop a = objArrayOop(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
422
a61af66fc99e Initial load
duke
parents:
diff changeset
423 oop* const base = a->base();
a61af66fc99e Initial load
duke
parents:
diff changeset
424 oop* const beg_oop = base;
a61af66fc99e Initial load
duke
parents:
diff changeset
425 oop* const end_oop = base + a->length();
a61af66fc99e Initial load
duke
parents:
diff changeset
426 for (oop* cur_oop = beg_oop; cur_oop < end_oop; ++cur_oop) {
a61af66fc99e Initial load
duke
parents:
diff changeset
427 PSParallelCompact::adjust_pointer(cur_oop);
a61af66fc99e Initial load
duke
parents:
diff changeset
428 }
a61af66fc99e Initial load
duke
parents:
diff changeset
429 return a->object_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
430 }
a61af66fc99e Initial load
duke
parents:
diff changeset
431
a61af66fc99e Initial load
duke
parents:
diff changeset
432 int objArrayKlass::oop_update_pointers(ParCompactionManager* cm, oop obj,
a61af66fc99e Initial load
duke
parents:
diff changeset
433 HeapWord* beg_addr, HeapWord* end_addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
434 assert (obj->is_objArray(), "obj must be obj array");
a61af66fc99e Initial load
duke
parents:
diff changeset
435 objArrayOop a = objArrayOop(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
436
a61af66fc99e Initial load
duke
parents:
diff changeset
437 oop* const base = a->base();
a61af66fc99e Initial load
duke
parents:
diff changeset
438 oop* const beg_oop = MAX2((oop*)beg_addr, base);
a61af66fc99e Initial load
duke
parents:
diff changeset
439 oop* const end_oop = MIN2((oop*)end_addr, base + a->length());
a61af66fc99e Initial load
duke
parents:
diff changeset
440 for (oop* cur_oop = beg_oop; cur_oop < end_oop; ++cur_oop) {
a61af66fc99e Initial load
duke
parents:
diff changeset
441 PSParallelCompact::adjust_pointer(cur_oop);
a61af66fc99e Initial load
duke
parents:
diff changeset
442 }
a61af66fc99e Initial load
duke
parents:
diff changeset
443 return a->object_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
444 }
a61af66fc99e Initial load
duke
parents:
diff changeset
445 #endif // SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
446
a61af66fc99e Initial load
duke
parents:
diff changeset
447 // JVM support
a61af66fc99e Initial load
duke
parents:
diff changeset
448
a61af66fc99e Initial load
duke
parents:
diff changeset
449 jint objArrayKlass::compute_modifier_flags(TRAPS) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
450 // The modifier for an objectArray is the same as its element
a61af66fc99e Initial load
duke
parents:
diff changeset
451 if (element_klass() == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
452 assert(Universe::is_bootstrapping(), "partial objArray only at startup");
a61af66fc99e Initial load
duke
parents:
diff changeset
453 return JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC;
a61af66fc99e Initial load
duke
parents:
diff changeset
454 }
a61af66fc99e Initial load
duke
parents:
diff changeset
455 // Recurse down the element list
a61af66fc99e Initial load
duke
parents:
diff changeset
456 jint element_flags = Klass::cast(element_klass())->compute_modifier_flags(CHECK_0);
a61af66fc99e Initial load
duke
parents:
diff changeset
457
a61af66fc99e Initial load
duke
parents:
diff changeset
458 return (element_flags & (JVM_ACC_PUBLIC | JVM_ACC_PRIVATE | JVM_ACC_PROTECTED))
a61af66fc99e Initial load
duke
parents:
diff changeset
459 | (JVM_ACC_ABSTRACT | JVM_ACC_FINAL);
a61af66fc99e Initial load
duke
parents:
diff changeset
460 }
a61af66fc99e Initial load
duke
parents:
diff changeset
461
a61af66fc99e Initial load
duke
parents:
diff changeset
462
a61af66fc99e Initial load
duke
parents:
diff changeset
463 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
464 // Printing
a61af66fc99e Initial load
duke
parents:
diff changeset
465
a61af66fc99e Initial load
duke
parents:
diff changeset
466 void objArrayKlass::oop_print_on(oop obj, outputStream* st) {
a61af66fc99e Initial load
duke
parents:
diff changeset
467 arrayKlass::oop_print_on(obj, st);
a61af66fc99e Initial load
duke
parents:
diff changeset
468 assert(obj->is_objArray(), "must be objArray");
a61af66fc99e Initial load
duke
parents:
diff changeset
469 objArrayOop oa = objArrayOop(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
470 int print_len = MIN2((intx) oa->length(), MaxElementPrintSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
471 for(int index = 0; index < print_len; index++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
472 st->print(" - %3d : ", index);
a61af66fc99e Initial load
duke
parents:
diff changeset
473 oa->obj_at(index)->print_value_on(st);
a61af66fc99e Initial load
duke
parents:
diff changeset
474 st->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
475 }
a61af66fc99e Initial load
duke
parents:
diff changeset
476 int remaining = oa->length() - print_len;
a61af66fc99e Initial load
duke
parents:
diff changeset
477 if (remaining > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
478 tty->print_cr(" - <%d more elements, increase MaxElementPrintSize to print>", remaining);
a61af66fc99e Initial load
duke
parents:
diff changeset
479 }
a61af66fc99e Initial load
duke
parents:
diff changeset
480 }
a61af66fc99e Initial load
duke
parents:
diff changeset
481
a61af66fc99e Initial load
duke
parents:
diff changeset
482
a61af66fc99e Initial load
duke
parents:
diff changeset
483 void objArrayKlass::oop_print_value_on(oop obj, outputStream* st) {
a61af66fc99e Initial load
duke
parents:
diff changeset
484 assert(obj->is_objArray(), "must be objArray");
a61af66fc99e Initial load
duke
parents:
diff changeset
485 element_klass()->print_value_on(st);
a61af66fc99e Initial load
duke
parents:
diff changeset
486 st->print("a [%d] ", objArrayOop(obj)->length());
a61af66fc99e Initial load
duke
parents:
diff changeset
487 as_klassOop()->klass()->print_value_on(st);
a61af66fc99e Initial load
duke
parents:
diff changeset
488 }
a61af66fc99e Initial load
duke
parents:
diff changeset
489
a61af66fc99e Initial load
duke
parents:
diff changeset
490 #endif // PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
491
a61af66fc99e Initial load
duke
parents:
diff changeset
492 const char* objArrayKlass::internal_name() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
493 return external_name();
a61af66fc99e Initial load
duke
parents:
diff changeset
494 }
a61af66fc99e Initial load
duke
parents:
diff changeset
495
a61af66fc99e Initial load
duke
parents:
diff changeset
496 // Verification
a61af66fc99e Initial load
duke
parents:
diff changeset
497
a61af66fc99e Initial load
duke
parents:
diff changeset
498 void objArrayKlass::oop_verify_on(oop obj, outputStream* st) {
a61af66fc99e Initial load
duke
parents:
diff changeset
499 arrayKlass::oop_verify_on(obj, st);
a61af66fc99e Initial load
duke
parents:
diff changeset
500 guarantee(obj->is_objArray(), "must be objArray");
a61af66fc99e Initial load
duke
parents:
diff changeset
501 objArrayOop oa = objArrayOop(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
502 for(int index = 0; index < oa->length(); index++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
503 guarantee(oa->obj_at(index)->is_oop_or_null(), "should be oop");
a61af66fc99e Initial load
duke
parents:
diff changeset
504 }
a61af66fc99e Initial load
duke
parents:
diff changeset
505 }
a61af66fc99e Initial load
duke
parents:
diff changeset
506
a61af66fc99e Initial load
duke
parents:
diff changeset
507 void objArrayKlass::oop_verify_old_oop(oop obj, oop* p, bool allow_dirty) {
a61af66fc99e Initial load
duke
parents:
diff changeset
508 /* $$$ move into remembered set verification?
a61af66fc99e Initial load
duke
parents:
diff changeset
509 RememberedSet::verify_old_oop(obj, p, allow_dirty, true);
a61af66fc99e Initial load
duke
parents:
diff changeset
510 */
a61af66fc99e Initial load
duke
parents:
diff changeset
511 }