annotate src/share/vm/oops/objArrayKlass.cpp @ 113:ba764ed4b6f2

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