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_TYPEARRAYKLASS_HPP stefank@2314: #define SHARE_VM_OOPS_TYPEARRAYKLASS_HPP stefank@2314: coleenp@4037: #include "classfile/classLoaderData.hpp" stefank@2314: #include "oops/arrayKlass.hpp" stefank@2314: coleenp@4142: // A TypeArrayKlass is the klass of a typeArray duke@435: // It contains the type and size of the elements duke@435: coleenp@4142: class TypeArrayKlass : public ArrayKlass { duke@435: friend class VMStructs; duke@435: private: duke@435: jint _max_length; // maximum number of elements allowed in an array coleenp@4037: coleenp@4037: // Constructor coleenp@4142: TypeArrayKlass(BasicType type, Symbol* name); coleenp@4142: static TypeArrayKlass* allocate(ClassLoaderData* loader_data, BasicType type, Symbol* name, TRAPS); duke@435: public: coleenp@4142: TypeArrayKlass() {} // For dummy objects. coleenp@4037: duke@435: // instance variables duke@435: jint max_length() { return _max_length; } duke@435: void set_max_length(jint m) { _max_length = m; } duke@435: duke@435: // testers duke@435: bool oop_is_typeArray_slow() const { return true; } duke@435: duke@435: // klass allocation coleenp@4142: static TypeArrayKlass* create_klass(BasicType type, const char* name_str, jcoomes@916: TRAPS); coleenp@4037: static inline Klass* create_klass(BasicType type, int scale, TRAPS) { coleenp@4142: TypeArrayKlass* tak = create_klass(type, external_name(type), CHECK_NULL); coleenp@4037: assert(scale == (1 << tak->log2_element_size()), "scale must check out"); coleenp@4037: return tak; jcoomes@916: } duke@435: duke@435: int oop_size(oop obj) const; duke@435: coleenp@4037: bool compute_is_subtype_of(Klass* k); duke@435: duke@435: // Allocation kvn@3157: typeArrayOop allocate_common(int length, bool do_zero, TRAPS); kvn@3157: typeArrayOop allocate(int length, TRAPS) { return allocate_common(length, true, THREAD); } 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: // Iteration coleenp@4037: int oop_oop_iterate(oop obj, ExtendedOopClosure* blk); coleenp@4037: int oop_oop_iterate_m(oop obj, ExtendedOopClosure* blk, MemRegion mr); 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: protected: duke@435: // Find n'th dimensional array 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 TypeArrayKlass* cast(Klass* k) { coleenp@4142: assert(k->oop_is_typeArray(), "cast to TypeArrayKlass"); coleenp@4142: return (TypeArrayKlass*) k; duke@435: } duke@435: duke@435: // Naming duke@435: static const char* external_name(BasicType type); duke@435: duke@435: // Sizing coleenp@4142: static int header_size() { return sizeof(TypeArrayKlass)/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: public: duke@435: // Printing coleenp@4037: #ifndef PRODUCT duke@435: void oop_print_on(oop obj, outputStream* st); duke@435: #endif coleenp@4037: coleenp@4037: void print_on(outputStream* st) const; coleenp@4037: void print_value_on(outputStream* st) const; coleenp@4037: duke@435: public: duke@435: const char* internal_name() const; duke@435: }; stefank@2314: stefank@2314: #endif // SHARE_VM_OOPS_TYPEARRAYKLASS_HPP