duke@435: /* xdono@631: * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved. duke@435: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: * duke@435: * This code is free software; you can redistribute it and/or modify it duke@435: * under the terms of the GNU General Public License version 2 only, as duke@435: * published by the Free Software Foundation. duke@435: * duke@435: * This code is distributed in the hope that it will be useful, but WITHOUT duke@435: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: * version 2 for more details (a copy is included in the LICENSE file that duke@435: * accompanied this code). duke@435: * duke@435: * You should have received a copy of the GNU General Public License version duke@435: * 2 along with this work; if not, write to the Free Software Foundation, duke@435: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: * duke@435: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, duke@435: * CA 95054 USA or visit www.sun.com if you need additional information or duke@435: * have any questions. duke@435: * duke@435: */ duke@435: duke@435: // objArrayKlass is the klass for objArrays duke@435: duke@435: class objArrayKlass : public arrayKlass { duke@435: friend class VMStructs; duke@435: private: duke@435: klassOop _element_klass; // The klass of the elements of this array type duke@435: klassOop _bottom_klass; // The one-dimensional type (instanceKlass or typeArrayKlass) duke@435: public: duke@435: // Instance variables duke@435: klassOop element_klass() const { return _element_klass; } duke@435: void set_element_klass(klassOop k) { oop_store_without_check((oop*) &_element_klass, (oop) k); } duke@435: oop* element_klass_addr() { return (oop*)&_element_klass; } duke@435: duke@435: klassOop bottom_klass() const { return _bottom_klass; } duke@435: void set_bottom_klass(klassOop k) { oop_store_without_check((oop*) &_bottom_klass, (oop) k); } duke@435: oop* bottom_klass_addr() { return (oop*)&_bottom_klass; } duke@435: duke@435: // Compiler/Interpreter offset duke@435: static int element_klass_offset_in_bytes() { return offset_of(objArrayKlass, _element_klass); } duke@435: duke@435: // Dispatched operation duke@435: bool can_be_primary_super_slow() const; duke@435: objArrayOop compute_secondary_supers(int num_extra_slots, TRAPS); duke@435: bool compute_is_subtype_of(klassOop k); duke@435: bool oop_is_objArray_slow() const { return true; } duke@435: int oop_size(oop obj) const; duke@435: int klass_oop_size() const { return object_size(); } duke@435: duke@435: // Allocation duke@435: DEFINE_ALLOCATE_PERMANENT(objArrayKlass); duke@435: objArrayOop allocate(int length, TRAPS); duke@435: oop multi_allocate(int rank, jint* sizes, TRAPS); duke@435: duke@435: // Copying duke@435: void copy_array(arrayOop s, int src_pos, arrayOop d, int dst_pos, int length, TRAPS); duke@435: duke@435: // Compute protection domain duke@435: oop protection_domain() { return Klass::cast(bottom_klass())->protection_domain(); } duke@435: // Compute class loader duke@435: oop class_loader() const { return Klass::cast(bottom_klass())->class_loader(); } duke@435: coleenp@548: private: coleenp@548: // Either oop or narrowOop depending on UseCompressedOops. coleenp@548: // must be called from within objArrayKlass.cpp coleenp@548: template void do_copy(arrayOop s, T* src, arrayOop d, coleenp@548: T* dst, int length, TRAPS); duke@435: protected: duke@435: // Returns the objArrayKlass for n'th dimension. duke@435: virtual klassOop array_klass_impl(bool or_null, int n, TRAPS); duke@435: duke@435: // Returns the array class with this class as element type. duke@435: virtual klassOop array_klass_impl(bool or_null, TRAPS); duke@435: duke@435: public: duke@435: // Casting from klassOop duke@435: static objArrayKlass* cast(klassOop k) { duke@435: assert(k->klass_part()->oop_is_objArray_slow(), "cast to objArrayKlass"); duke@435: return (objArrayKlass*) k->klass_part(); duke@435: } duke@435: duke@435: // Sizing duke@435: static int header_size() { return oopDesc::header_size() + sizeof(objArrayKlass)/HeapWordSize; } duke@435: int object_size() const { return arrayKlass::object_size(header_size()); } duke@435: duke@435: // Initialization (virtual from Klass) duke@435: void initialize(TRAPS); duke@435: duke@435: // Garbage collection duke@435: void oop_follow_contents(oop obj); duke@435: int oop_adjust_pointers(oop obj); duke@435: duke@435: // Parallel Scavenge and Parallel Old duke@435: PARALLEL_GC_DECLS duke@435: duke@435: // Iterators duke@435: int oop_oop_iterate(oop obj, OopClosure* blk) { duke@435: return oop_oop_iterate_v(obj, blk); duke@435: } duke@435: int oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr) { duke@435: return oop_oop_iterate_v_m(obj, blk, mr); duke@435: } duke@435: #define ObjArrayKlass_OOP_OOP_ITERATE_DECL(OopClosureType, nv_suffix) \ duke@435: int oop_oop_iterate##nv_suffix(oop obj, OopClosureType* blk); \ duke@435: int oop_oop_iterate##nv_suffix##_m(oop obj, OopClosureType* blk, \ coleenp@548: MemRegion mr); \ coleenp@548: int oop_oop_iterate_range##nv_suffix(oop obj, OopClosureType* blk, \ coleenp@548: int start, int end); duke@435: duke@435: ALL_OOP_OOP_ITERATE_CLOSURES_1(ObjArrayKlass_OOP_OOP_ITERATE_DECL) ysr@777: ALL_OOP_OOP_ITERATE_CLOSURES_2(ObjArrayKlass_OOP_OOP_ITERATE_DECL) duke@435: duke@435: // JVM support duke@435: jint compute_modifier_flags(TRAPS) const; duke@435: duke@435: private: duke@435: static klassOop array_klass_impl (objArrayKlassHandle this_oop, bool or_null, int n, TRAPS); duke@435: duke@435: #ifndef PRODUCT duke@435: public: duke@435: // Printing duke@435: void oop_print_on (oop obj, outputStream* st); duke@435: void oop_print_value_on(oop obj, outputStream* st); duke@435: #endif duke@435: duke@435: public: duke@435: // Verification duke@435: const char* internal_name() const; duke@435: void oop_verify_on(oop obj, outputStream* st); duke@435: void oop_verify_old_oop(oop obj, oop* p, bool allow_dirty); coleenp@548: void oop_verify_old_oop(oop obj, narrowOop* p, bool allow_dirty); duke@435: duke@435: };