1 #ifdef USE_PRAGMA_IDENT_HDR 2 #pragma ident "@(#)objArrayKlass.hpp 1.87 07/05/29 09:44:23 JVM" 3 #endif 4 /* 5 * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved. 6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 7 * 8 * This code is free software; you can redistribute it and/or modify it 9 * under the terms of the GNU General Public License version 2 only, as 10 * published by the Free Software Foundation. 11 * 12 * This code is distributed in the hope that it will be useful, but WITHOUT 13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15 * version 2 for more details (a copy is included in the LICENSE file that 16 * accompanied this code). 17 * 18 * You should have received a copy of the GNU General Public License version 19 * 2 along with this work; if not, write to the Free Software Foundation, 20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 21 * 22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 23 * CA 95054 USA or visit www.sun.com if you need additional information or 24 * have any questions. 25 * 26 */ 27 28 // objArrayKlass is the klass for objArrays 29 30 class objArrayKlass : public arrayKlass { 31 friend class VMStructs; 32 private: 33 klassOop _element_klass; // The klass of the elements of this array type 34 klassOop _bottom_klass; // The one-dimensional type (instanceKlass or typeArrayKlass) 35 public: 36 // Instance variables 37 klassOop element_klass() const { return _element_klass; } 38 void set_element_klass(klassOop k) { oop_store_without_check((oop*) &_element_klass, (oop) k); } 39 oop* element_klass_addr() { return (oop*)&_element_klass; } 40 41 klassOop bottom_klass() const { return _bottom_klass; } 42 void set_bottom_klass(klassOop k) { oop_store_without_check((oop*) &_bottom_klass, (oop) k); } 43 oop* bottom_klass_addr() { return (oop*)&_bottom_klass; } 44 45 // Compiler/Interpreter offset 46 static int element_klass_offset_in_bytes() { return offset_of(objArrayKlass, _element_klass); } 47 48 // Dispatched operation 49 bool can_be_primary_super_slow() const; 50 objArrayOop compute_secondary_supers(int num_extra_slots, TRAPS); 51 bool compute_is_subtype_of(klassOop k); 52 bool oop_is_objArray_slow() const { return true; } 53 int oop_size(oop obj) const; 54 int klass_oop_size() const { return object_size(); } 55 56 // Allocation 57 DEFINE_ALLOCATE_PERMANENT(objArrayKlass); 58 objArrayOop allocate(int length, TRAPS); 59 oop multi_allocate(int rank, jint* sizes, TRAPS); 60 61 // Copying 62 void copy_array(arrayOop s, int src_pos, arrayOop d, int dst_pos, int length, TRAPS); 63 64 // Compute protection domain 65 oop protection_domain() { return Klass::cast(bottom_klass())->protection_domain(); } 66 // Compute class loader 67 oop class_loader() const { return Klass::cast(bottom_klass())->class_loader(); } 68 69 protected: 70 // Returns the objArrayKlass for n'th dimension. 71 virtual klassOop array_klass_impl(bool or_null, int n, TRAPS); 72 73 // Returns the array class with this class as element type. 74 virtual klassOop array_klass_impl(bool or_null, TRAPS); 75 76 public: 77 // Casting from klassOop 78 static objArrayKlass* cast(klassOop k) { 79 assert(k->klass_part()->oop_is_objArray_slow(), "cast to objArrayKlass"); 80 return (objArrayKlass*) k->klass_part(); 81 } 82 83 // Sizing 84 static int header_size() { return oopDesc::header_size() + sizeof(objArrayKlass)/HeapWordSize; } 85 int object_size() const { return arrayKlass::object_size(header_size()); } 86 87 // Initialization (virtual from Klass) 88 void initialize(TRAPS); 89 90 // Garbage collection 91 void oop_follow_contents(oop obj); 92 int oop_adjust_pointers(oop obj); 93 94 // Parallel Scavenge and Parallel Old 95 PARALLEL_GC_DECLS 96 97 // Iterators 98 int oop_oop_iterate(oop obj, OopClosure* blk) { 99 return oop_oop_iterate_v(obj, blk); 100 } 101 int oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr) { 102 return oop_oop_iterate_v_m(obj, blk, mr); 103 } 104 #define ObjArrayKlass_OOP_OOP_ITERATE_DECL(OopClosureType, nv_suffix) \ 105 int oop_oop_iterate##nv_suffix(oop obj, OopClosureType* blk); \ 106 int oop_oop_iterate##nv_suffix##_m(oop obj, OopClosureType* blk, \ 107 MemRegion mr); 108 109 ALL_OOP_OOP_ITERATE_CLOSURES_1(ObjArrayKlass_OOP_OOP_ITERATE_DECL) 110 ALL_OOP_OOP_ITERATE_CLOSURES_3(ObjArrayKlass_OOP_OOP_ITERATE_DECL) 111 112 // JVM support 113 jint compute_modifier_flags(TRAPS) const; 114 115 private: 116 static klassOop array_klass_impl (objArrayKlassHandle this_oop, bool or_null, int n, TRAPS); 117 118 #ifndef PRODUCT 119 public: 120 // Printing 121 void oop_print_on (oop obj, outputStream* st); 122 void oop_print_value_on(oop obj, outputStream* st); 123 #endif 124 125 public: 126 // Verification 127 const char* internal_name() const; 128 void oop_verify_on(oop obj, outputStream* st); 129 void oop_verify_old_oop(oop obj, oop* p, bool allow_dirty); 130 131 }; 132