duke@435: /* brutisso@3711: * Copyright (c) 1997, 2012, Oracle and/or its affiliates. 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: * trims@1907: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA trims@1907: * or visit www.oracle.com if you need additional information or have any trims@1907: * questions. duke@435: * duke@435: */ duke@435: stefank@2314: #ifndef SHARE_VM_OOPS_OBJARRAYKLASS_HPP stefank@2314: #define SHARE_VM_OOPS_OBJARRAYKLASS_HPP stefank@2314: coleenp@4037: #include "classfile/classLoaderData.hpp" stefank@2314: #include "memory/specialized_oop_closures.hpp" stefank@2314: #include "oops/arrayKlass.hpp" jprovino@4542: #include "utilities/macros.hpp" stefank@2314: coleenp@4142: // ObjArrayKlass is the klass for objArrays duke@435: coleenp@4142: class ObjArrayKlass : public ArrayKlass { duke@435: friend class VMStructs; duke@435: private: coleenp@4037: Klass* _element_klass; // The klass of the elements of this array type coleenp@4142: Klass* _bottom_klass; // The one-dimensional type (InstanceKlass or TypeArrayKlass) coleenp@4037: coleenp@4037: // Constructor coleenp@4142: ObjArrayKlass(int n, KlassHandle element_klass, Symbol* name); coleenp@4142: static ObjArrayKlass* allocate(ClassLoaderData* loader_data, int n, KlassHandle klass_handle, Symbol* name, TRAPS); duke@435: public: coleenp@4037: // For dummy objects coleenp@4142: ObjArrayKlass() {} coleenp@4037: duke@435: // Instance variables coleenp@4037: Klass* element_klass() const { return _element_klass; } coleenp@4037: void set_element_klass(Klass* k) { _element_klass = k; } coleenp@4037: Klass** element_klass_addr() { return &_element_klass; } duke@435: coleenp@4037: Klass* bottom_klass() const { return _bottom_klass; } coleenp@4037: void set_bottom_klass(Klass* k) { _bottom_klass = k; } coleenp@4037: Klass** bottom_klass_addr() { return &_bottom_klass; } duke@435: duke@435: // Compiler/Interpreter offset coleenp@4142: static ByteSize element_klass_offset() { return in_ByteSize(offset_of(ObjArrayKlass, _element_klass)); } duke@435: duke@435: // Dispatched operation duke@435: bool can_be_primary_super_slow() const; coleenp@4037: GrowableArray* compute_secondary_supers(int num_extra_slots); coleenp@4037: bool compute_is_subtype_of(Klass* k); duke@435: bool oop_is_objArray_slow() const { return true; } duke@435: int oop_size(oop obj) const; duke@435: duke@435: // Allocation coleenp@4037: static Klass* allocate_objArray_klass(ClassLoaderData* loader_data, coleenp@4037: int n, KlassHandle element_klass, TRAPS); coleenp@4037: 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 coleenp@5176: oop protection_domain() const { return bottom_klass()->protection_domain(); } duke@435: coleenp@548: private: coleenp@548: // Either oop or narrowOop depending on UseCompressedOops. coleenp@4142: // 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: coleenp@4142: // Returns the ObjArrayKlass for n'th dimension. coleenp@4037: virtual Klass* array_klass_impl(bool or_null, int n, TRAPS); duke@435: duke@435: // Returns the array class with this class as element type. coleenp@4037: virtual Klass* array_klass_impl(bool or_null, TRAPS); duke@435: duke@435: public: coleenp@4037: // Casting from Klass* coleenp@4142: static ObjArrayKlass* cast(Klass* k) { coleenp@4142: assert(k->oop_is_objArray(), "cast to ObjArrayKlass"); coleenp@4142: return (ObjArrayKlass*) k; duke@435: } duke@435: duke@435: // Sizing coleenp@4142: static int header_size() { return sizeof(ObjArrayKlass)/HeapWordSize; } coleenp@4142: int size() const { return ArrayKlass::static_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); jcoomes@1746: inline void oop_follow_contents(oop obj, int index); jcoomes@1746: template inline void objarray_follow_contents(oop obj, int index); jcoomes@1746: duke@435: int oop_adjust_pointers(oop obj); duke@435: duke@435: // Parallel Scavenge and Parallel Old duke@435: PARALLEL_GC_DECLS jprovino@4542: #if INCLUDE_ALL_GCS jcoomes@1746: inline void oop_follow_contents(ParCompactionManager* cm, oop obj, int index); jcoomes@1746: template inline void jcoomes@1746: objarray_follow_contents(ParCompactionManager* cm, oop obj, int index); jprovino@4542: #endif // INCLUDE_ALL_GCS duke@435: duke@435: // Iterators coleenp@4037: int oop_oop_iterate(oop obj, ExtendedOopClosure* blk) { duke@435: return oop_oop_iterate_v(obj, blk); duke@435: } coleenp@4037: int oop_oop_iterate_m(oop obj, ExtendedOopClosure* 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: public: duke@435: // Printing coleenp@4037: void print_on(outputStream* st) const; coleenp@4037: void print_value_on(outputStream* st) const; coleenp@4037: jrose@1590: void oop_print_value_on(oop obj, outputStream* st); jrose@1590: #ifndef PRODUCT duke@435: void oop_print_on (oop obj, outputStream* st); jrose@1590: #endif //PRODUCT duke@435: coleenp@4037: const char* internal_name() const; coleenp@4037: duke@435: // Verification coleenp@4037: void verify_on(outputStream* st); coleenp@4037: duke@435: void oop_verify_on(oop obj, outputStream* st); duke@435: }; stefank@2314: stefank@2314: #endif // SHARE_VM_OOPS_OBJARRAYKLASS_HPP