23 */
24
25 #ifndef SHARE_VM_OOPS_TYPEARRAYKLASS_HPP
26 #define SHARE_VM_OOPS_TYPEARRAYKLASS_HPP
27
28 #include "classfile/classLoaderData.hpp"
29 #include "oops/arrayKlass.hpp"
30
31 // A TypeArrayKlass is the klass of a typeArray
32 // It contains the type and size of the elements
33
34 class TypeArrayKlass : public ArrayKlass {
35 friend class VMStructs;
36 private:
37 jint _max_length; // maximum number of elements allowed in an array
38
39 // Constructor
40 TypeArrayKlass(BasicType type, Symbol* name);
41 static TypeArrayKlass* allocate(ClassLoaderData* loader_data, BasicType type, Symbol* name, TRAPS);
42 public:
43 TypeArrayKlass() {} // For dummy objects.
44
45 // instance variables
46 jint max_length() { return _max_length; }
47 void set_max_length(jint m) { _max_length = m; }
48
49 // testers
50 bool oop_is_typeArray_slow() const { return true; }
51
52 // klass allocation
53 static TypeArrayKlass* create_klass(BasicType type, const char* name_str,
54 TRAPS);
55 static inline Klass* create_klass(BasicType type, int scale, TRAPS) {
56 TypeArrayKlass* tak = create_klass(type, external_name(type), CHECK_NULL);
57 assert(scale == (1 << tak->log2_element_size()), "scale must check out");
58 return tak;
59 }
60
61 int oop_size(oop obj) const;
62
63 bool compute_is_subtype_of(Klass* k);
64
65 // Allocation
66 typeArrayOop allocate_common(int length, bool do_zero, TRAPS);
67 typeArrayOop allocate(int length, TRAPS) { return allocate_common(length, true, THREAD); }
68 oop multi_allocate(int rank, jint* sizes, TRAPS);
69
70 oop protection_domain() const { return NULL; }
71
72 // Copying
73 void copy_array(arrayOop s, int src_pos, arrayOop d, int dst_pos, int length, TRAPS);
74
75 // Iteration
76 int oop_oop_iterate(oop obj, ExtendedOopClosure* blk);
77 int oop_oop_iterate_m(oop obj, ExtendedOopClosure* blk, MemRegion mr);
78
79 // Garbage collection
80 void oop_follow_contents(oop obj);
81 int oop_adjust_pointers(oop obj);
82
83 // Parallel Scavenge and Parallel Old
84 PARALLEL_GC_DECLS
85
86 protected:
87 // Find n'th dimensional array
88 virtual Klass* array_klass_impl(bool or_null, int n, TRAPS);
89
90 // Returns the array class with this class as element type
91 virtual Klass* array_klass_impl(bool or_null, TRAPS);
92
93 public:
94 // Casting from Klass*
95 static TypeArrayKlass* cast(Klass* k) {
96 assert(k->oop_is_typeArray(), "cast to TypeArrayKlass");
97 return (TypeArrayKlass*) k;
|
23 */
24
25 #ifndef SHARE_VM_OOPS_TYPEARRAYKLASS_HPP
26 #define SHARE_VM_OOPS_TYPEARRAYKLASS_HPP
27
28 #include "classfile/classLoaderData.hpp"
29 #include "oops/arrayKlass.hpp"
30
31 // A TypeArrayKlass is the klass of a typeArray
32 // It contains the type and size of the elements
33
34 class TypeArrayKlass : public ArrayKlass {
35 friend class VMStructs;
36 private:
37 jint _max_length; // maximum number of elements allowed in an array
38
39 // Constructor
40 TypeArrayKlass(BasicType type, Symbol* name);
41 static TypeArrayKlass* allocate(ClassLoaderData* loader_data, BasicType type, Symbol* name, TRAPS);
42 public:
43 TypeArrayKlass() : ArrayKlass(_type_array) {} // For dummy objects.
44
45 // instance variables
46 jint max_length() { return _max_length; }
47 void set_max_length(jint m) { _max_length = m; }
48
49 // testers
50 bool oop_is_typeArray_slow() const { return true; }
51
52 // klass allocation
53 static TypeArrayKlass* create_klass(BasicType type, const char* name_str,
54 TRAPS);
55 static inline Klass* create_klass(BasicType type, int scale, TRAPS) {
56 TypeArrayKlass* tak = create_klass(type, external_name(type), CHECK_NULL);
57 assert(scale == (1 << tak->log2_element_size()), "scale must check out");
58 return tak;
59 }
60
61 int oop_size(oop obj) const;
62
63 bool compute_is_subtype_of(Klass* k);
64
65 // Allocation
66 typeArrayOop allocate_common(int length, bool do_zero, TRAPS);
67 typeArrayOop allocate(int length, TRAPS) { return allocate_common(length, true, THREAD); }
68 oop multi_allocate(int rank, jint* sizes, TRAPS);
69
70 oop protection_domain() const { return NULL; }
71
72 // Copying
73 void copy_array(arrayOop s, int src_pos, arrayOop d, int dst_pos, int length, TRAPS);
74
75 // Iteration
76 template <bool nv, typename OopClosureType>
77 int oop_oop_iterate(oop obj, OopClosureType* blk);
78
79 template <bool nv, typename OopClosureType>
80 int oop_oop_iterate_m(oop obj, OopClosureType* blk, MemRegion mr);
81
82 template <bool nv, typename OopClosureType>
83 int oop_oop_iterate_backwards(oop obj, OopClosureType* blk);
84
85 // Garbage collection
86 void oop_follow_contents(oop obj);
87 int oop_adjust_pointers(oop obj);
88
89 // Parallel Scavenge and Parallel Old
90 PARALLEL_GC_DECLS
91
92 protected:
93 // Find n'th dimensional array
94 virtual Klass* array_klass_impl(bool or_null, int n, TRAPS);
95
96 // Returns the array class with this class as element type
97 virtual Klass* array_klass_impl(bool or_null, TRAPS);
98
99 public:
100 // Casting from Klass*
101 static TypeArrayKlass* cast(Klass* k) {
102 assert(k->oop_is_typeArray(), "cast to TypeArrayKlass");
103 return (TypeArrayKlass*) k;
|