duke@435: /* coleenp@4037: * 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_ARRAYKLASS_HPP stefank@2314: #define SHARE_VM_OOPS_ARRAYKLASS_HPP stefank@2314: stefank@2314: #include "memory/universe.hpp" stefank@2314: #include "oops/klass.hpp" coleenp@4037: coleenp@4037: class klassVtable; stefank@2314: coleenp@4142: // ArrayKlass is the abstract baseclass for all array classes duke@435: coleenp@4142: class ArrayKlass: public Klass { duke@435: friend class VMStructs; duke@435: private: duke@435: int _dimension; // This is n'th-dimensional array. coleenp@4037: Klass* volatile _higher_dimension; // Refers the (n+1)'th-dimensional array (if present). coleenp@4037: Klass* volatile _lower_dimension; // Refers the (n-1)'th-dimensional array (if present). duke@435: int _vtable_len; // size of vtable for this klass duke@435: juint _alloc_size; // allocation profiling support duke@435: oop _component_mirror; // component type, as a java/lang/Class duke@435: coleenp@4037: protected: coleenp@4037: // Constructors coleenp@4037: // The constructor with the Symbol argument does the real array coleenp@4037: // initialization, the other is a dummy coleenp@4142: ArrayKlass(Symbol* name); coleenp@4142: ArrayKlass() { assert(DumpSharedSpaces || UseSharedSpaces, "only for cds"); } coleenp@4037: duke@435: public: duke@435: // Testing operation coleenp@4037: bool oop_is_array_slow() const { return true; } duke@435: duke@435: // Instance variables duke@435: int dimension() const { return _dimension; } duke@435: void set_dimension(int dimension) { _dimension = dimension; } duke@435: coleenp@4037: Klass* higher_dimension() const { return _higher_dimension; } coleenp@4037: void set_higher_dimension(Klass* k) { _higher_dimension = k; } coleenp@4037: Klass** adr_higher_dimension() { return (Klass**)&this->_higher_dimension;} duke@435: coleenp@4037: Klass* lower_dimension() const { return _lower_dimension; } coleenp@4037: void set_lower_dimension(Klass* k) { _lower_dimension = k; } coleenp@4037: Klass** adr_lower_dimension() { return (Klass**)&this->_lower_dimension;} duke@435: duke@435: // Allocation profiling support duke@435: juint alloc_size() const { return _alloc_size; } duke@435: void set_alloc_size(juint n) { _alloc_size = n; } duke@435: duke@435: // offset of first element, including any padding for the sake of alignment duke@435: int array_header_in_bytes() const { return layout_helper_header_size(layout_helper()); } duke@435: int log2_element_size() const { return layout_helper_log2_element_size(layout_helper()); } duke@435: // type of elements (T_OBJECT for both oop arrays and array-arrays) duke@435: BasicType element_type() const { return layout_helper_element_type(layout_helper()); } duke@435: duke@435: oop component_mirror() const { return _component_mirror; } coleenp@4037: void set_component_mirror(oop m) { klass_oop_store(&_component_mirror, m); } duke@435: oop* adr_component_mirror() { return (oop*)&this->_component_mirror;} duke@435: duke@435: // Compiler/Interpreter offset coleenp@4142: static ByteSize component_mirror_offset() { return in_ByteSize(offset_of(ArrayKlass, _component_mirror)); } duke@435: coleenp@4037: virtual Klass* java_super() const;//{ return SystemDictionary::Object_klass(); } duke@435: duke@435: // Allocation duke@435: // Sizes points to the first dimension of the array, subsequent dimensions duke@435: // are always in higher memory. The callers of these set that up. duke@435: virtual oop multi_allocate(int rank, jint* sizes, TRAPS); duke@435: objArrayOop allocate_arrayArray(int n, int length, TRAPS); duke@435: duke@435: // Lookup operations coleenp@4037: Method* uncached_lookup_method(Symbol* name, Symbol* signature) const; duke@435: coleenp@4037: // Casting from Klass* coleenp@4142: static ArrayKlass* cast(Klass* k) { coleenp@4142: assert(k->oop_is_array(), "cast to ArrayKlass"); coleenp@4142: return (ArrayKlass*) k; duke@435: } duke@435: coleenp@4037: GrowableArray* compute_secondary_supers(int num_extra_slots); coleenp@4037: bool compute_is_subtype_of(Klass* k); duke@435: duke@435: // Sizing coleenp@4142: static int header_size() { return sizeof(ArrayKlass)/HeapWordSize; } coleenp@4037: static int static_size(int header_size); duke@435: duke@435: // Java vtable duke@435: klassVtable* vtable() const; // return new klassVtable duke@435: int vtable_length() const { return _vtable_len; } duke@435: static int base_vtable_length() { return Universe::base_vtable_size(); } duke@435: void set_vtable_length(int len) { assert(len == base_vtable_length(), "bad length"); _vtable_len = len; } duke@435: protected: duke@435: inline intptr_t* start_of_vtable() const; duke@435: duke@435: public: duke@435: // Iterators coleenp@4037: void array_klasses_do(void f(Klass* k)); coleenp@4037: void array_klasses_do(void f(Klass* k, TRAPS), TRAPS); coleenp@4037: void with_array_klasses_do(void f(Klass* k)); duke@435: coleenp@4037: // GC support coleenp@4037: virtual void oops_do(OopClosure* cl); coleenp@4037: duke@435: // Return a handle. coleenp@4142: static void complete_create_array_klass(ArrayKlass* k, KlassHandle super_klass, TRAPS); coleenp@4037: duke@435: bobv@2036: // jvm support bobv@2036: jint compute_modifier_flags(TRAPS) const; duke@435: bobv@2036: // JVMTI support bobv@2036: jint jvmti_class_status() const; duke@435: coleenp@4037: // CDS support - remove and restore oops from metadata. Oops are not shared. coleenp@4037: virtual void remove_unshareable_info(); coleenp@4037: virtual void restore_unshareable_info(TRAPS); coleenp@4037: duke@435: // Printing coleenp@4037: void print_on(outputStream* st) const; coleenp@4037: void print_value_on(outputStream* st) const; coleenp@4037: duke@435: void oop_print_on(oop obj, outputStream* st); bobv@2036: 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_ARRAYKLASS_HPP