1
|
1 |
/*
|
|
2 |
* Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved.
|
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation.
|
|
8 |
*
|
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
13 |
* accompanied this code).
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License version
|
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18 |
*
|
|
19 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
20 |
* CA 95054 USA or visit www.sun.com if you need additional information or
|
|
21 |
* have any questions.
|
|
22 |
*
|
|
23 |
*/
|
|
24 |
|
|
25 |
// A typeArrayKlass is the klass of a typeArray
|
|
26 |
// It contains the type and size of the elements
|
|
27 |
|
|
28 |
class typeArrayKlass : public arrayKlass {
|
|
29 |
friend class VMStructs;
|
|
30 |
private:
|
|
31 |
jint _max_length; // maximum number of elements allowed in an array
|
|
32 |
public:
|
|
33 |
// instance variables
|
|
34 |
jint max_length() { return _max_length; }
|
|
35 |
void set_max_length(jint m) { _max_length = m; }
|
|
36 |
|
|
37 |
// testers
|
|
38 |
bool oop_is_typeArray_slow() const { return true; }
|
|
39 |
|
|
40 |
// klass allocation
|
|
41 |
DEFINE_ALLOCATE_PERMANENT(typeArrayKlass);
|
|
42 |
static klassOop create_klass(BasicType type, int scale, TRAPS);
|
|
43 |
|
|
44 |
int oop_size(oop obj) const;
|
|
45 |
int klass_oop_size() const { return object_size(); }
|
|
46 |
|
|
47 |
bool compute_is_subtype_of(klassOop k);
|
|
48 |
|
|
49 |
// Allocation
|
|
50 |
typeArrayOop allocate(int length, TRAPS);
|
|
51 |
typeArrayOop allocate_permanent(int length, TRAPS); // used for class file structures
|
|
52 |
oop multi_allocate(int rank, jint* sizes, TRAPS);
|
|
53 |
|
|
54 |
// Copying
|
|
55 |
void copy_array(arrayOop s, int src_pos, arrayOop d, int dst_pos, int length, TRAPS);
|
|
56 |
|
|
57 |
// Iteration
|
|
58 |
int oop_oop_iterate(oop obj, OopClosure* blk);
|
|
59 |
int oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr);
|
|
60 |
|
|
61 |
// Garbage collection
|
|
62 |
void oop_follow_contents(oop obj);
|
|
63 |
int oop_adjust_pointers(oop obj);
|
|
64 |
|
|
65 |
// Parallel Scavenge and Parallel Old
|
|
66 |
PARALLEL_GC_DECLS
|
|
67 |
|
|
68 |
protected:
|
|
69 |
// Find n'th dimensional array
|
|
70 |
virtual klassOop array_klass_impl(bool or_null, int n, TRAPS);
|
|
71 |
|
|
72 |
// Returns the array class with this class as element type
|
|
73 |
virtual klassOop array_klass_impl(bool or_null, TRAPS);
|
|
74 |
|
|
75 |
public:
|
|
76 |
// Casting from klassOop
|
|
77 |
static typeArrayKlass* cast(klassOop k) {
|
|
78 |
assert(k->klass_part()->oop_is_typeArray_slow(), "cast to typeArrayKlass");
|
|
79 |
return (typeArrayKlass*) k->klass_part();
|
|
80 |
}
|
|
81 |
|
|
82 |
// Naming
|
|
83 |
static const char* external_name(BasicType type);
|
|
84 |
|
|
85 |
// Sizing
|
|
86 |
static int header_size() { return oopDesc::header_size() + sizeof(typeArrayKlass)/HeapWordSize; }
|
|
87 |
int object_size() const { return arrayKlass::object_size(header_size()); }
|
|
88 |
|
|
89 |
// Initialization (virtual from Klass)
|
|
90 |
void initialize(TRAPS);
|
|
91 |
|
|
92 |
private:
|
|
93 |
// Helpers
|
|
94 |
static klassOop array_klass_impl(typeArrayKlassHandle h_this, bool or_null, int n, TRAPS);
|
|
95 |
|
|
96 |
#ifndef PRODUCT
|
|
97 |
public:
|
|
98 |
// Printing
|
|
99 |
void oop_print_on(oop obj, outputStream* st);
|
|
100 |
#endif
|
|
101 |
public:
|
|
102 |
const char* internal_name() const;
|
|
103 |
};
|