1 #ifdef USE_PRAGMA_IDENT_HDR 2 #pragma ident "@(#)typeArrayKlass.hpp 1.69 07/05/29 09:44:25 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 // A typeArrayKlass is the klass of a typeArray 29 // It contains the type and size of the elements 30 31 class typeArrayKlass : public arrayKlass { 32 friend class VMStructs; 33 private: 34 jint _max_length; // maximum number of elements allowed in an array 35 public: 36 // instance variables 37 jint max_length() { return _max_length; } 38 void set_max_length(jint m) { _max_length = m; } 39 40 // testers 41 bool oop_is_typeArray_slow() const { return true; } 42 43 // klass allocation 44 DEFINE_ALLOCATE_PERMANENT(typeArrayKlass); 45 static klassOop create_klass(BasicType type, int scale, const char* name_str, 46 TRAPS); 47 static inline klassOop create_klass(BasicType type, int scale, TRAPS) { 48 return create_klass(type, scale, external_name(type), CHECK_NULL); 49 } 50 51 int oop_size(oop obj) const; 52 int klass_oop_size() const { return object_size(); } 53 54 bool compute_is_subtype_of(klassOop k); 55 56 // Allocation 57 typeArrayOop allocate(int length, TRAPS); 58 typeArrayOop allocate_permanent(int length, TRAPS); // used for class file structures 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 // Iteration 65 int oop_oop_iterate(oop obj, OopClosure* blk); 66 int oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr); 67 68 // Garbage collection 69 void oop_follow_contents(oop obj); 70 int oop_adjust_pointers(oop obj); 71 72 // Parallel Scavenge and Parallel Old 73 PARALLEL_GC_DECLS 74 75 protected: 76 // Find n'th dimensional array 77 virtual klassOop array_klass_impl(bool or_null, int n, TRAPS); 78 79 // Returns the array class with this class as element type 80 virtual klassOop array_klass_impl(bool or_null, TRAPS); 81 82 public: 83 // Casting from klassOop 84 static typeArrayKlass* cast(klassOop k) { 85 assert(k->klass_part()->oop_is_typeArray_slow(), "cast to typeArrayKlass"); 86 return (typeArrayKlass*) k->klass_part(); 87 } 88 89 // Naming 90 static const char* external_name(BasicType type); 91 92 // Sizing 93 static int header_size() { return oopDesc::header_size() + sizeof(typeArrayKlass)/HeapWordSize; } 94 int object_size() const { return arrayKlass::object_size(header_size()); } 95 96 // Initialization (virtual from Klass) 97 void initialize(TRAPS); 98 99 private: 100 // Helpers 101 static klassOop array_klass_impl(typeArrayKlassHandle h_this, bool or_null, int n, TRAPS); 102 103 #ifndef PRODUCT 104 public: 105 // Printing 106 void oop_print_on(oop obj, outputStream* st); 107 #endif 108 public: 109 const char* internal_name() const; 110 };