26 #define SHARE_OOPS_ARRAYKLASS_HPP
27
28 #include "oops/klass.hpp"
29
30 class fieldDescriptor;
31 class klassVtable;
32 class ObjArrayKlass;
33
34 // ArrayKlass is the abstract baseclass for all array classes
35
36 class ArrayKlass: public Klass {
37 friend class VMStructs;
38 private:
39 // If you add a new field that points to any metaspace object, you
40 // must add this field to ArrayKlass::metaspace_pointers_do().
41 int _dimension; // This is n'th-dimensional array.
42 ObjArrayKlass* volatile _higher_dimension; // Refers the (n+1)'th-dimensional array (if present).
43 ArrayKlass* volatile _lower_dimension; // Refers the (n-1)'th-dimensional array (if present).
44
45 protected:
46 // Constructors
47 // The constructor with the Symbol argument does the real array
48 // initialization, the other is a dummy
49 ArrayKlass(Symbol* name, KlassKind kind);
50 ArrayKlass();
51
52 public:
53 // Testing operation
54 DEBUG_ONLY(bool is_array_klass_slow() const { return true; })
55
56 // Returns the ObjArrayKlass for n'th dimension.
57 ArrayKlass* array_klass(int n, TRAPS);
58 ArrayKlass* array_klass_or_null(int n);
59
60 // Returns the array class with this class as element type.
61 ArrayKlass* array_klass(TRAPS);
62 ArrayKlass* array_klass_or_null();
63
64 // Instance variables
65 int dimension() const { return _dimension; }
66 void set_dimension(int dimension) { _dimension = dimension; }
67
68 ObjArrayKlass* higher_dimension() const { return _higher_dimension; }
69 inline ObjArrayKlass* higher_dimension_acquire() const; // load with acquire semantics
70 void set_higher_dimension(ObjArrayKlass* k) { _higher_dimension = k; }
71 inline void release_set_higher_dimension(ObjArrayKlass* k); // store with release semantics
72
91 Klass* find_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const;
92
93 // Lookup operations
94 Method* uncached_lookup_method(const Symbol* name,
95 const Symbol* signature,
96 OverpassLookupMode overpass_mode,
97 PrivateLookupMode private_mode = PrivateLookupMode::find) const;
98
99 static ArrayKlass* cast(Klass* k) {
100 return const_cast<ArrayKlass*>(cast(const_cast<const Klass*>(k)));
101 }
102
103 static const ArrayKlass* cast(const Klass* k) {
104 assert(k->is_array_klass(), "cast to ArrayKlass");
105 return static_cast<const ArrayKlass*>(k);
106 }
107
108 GrowableArray<Klass*>* compute_secondary_supers(int num_extra_slots,
109 Array<InstanceKlass*>* transitive_interfaces);
110
111 // Sizing
112 static int static_size(int header_size);
113
114 virtual void metaspace_pointers_do(MetaspaceClosure* iter);
115
116 // Return a handle.
117 static void complete_create_array_klass(ArrayKlass* k, Klass* super_klass, ModuleEntry* module, TRAPS);
118
119
120 // jvm support
121 jint compute_modifier_flags() const;
122
123 // JVMTI support
124 jint jvmti_class_status() const;
125
126 #if INCLUDE_CDS
127 // CDS support - remove and restore oops from metadata. Oops are not shared.
128 virtual void remove_unshareable_info();
129 virtual void remove_java_mirror();
130 void restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, TRAPS);
|
26 #define SHARE_OOPS_ARRAYKLASS_HPP
27
28 #include "oops/klass.hpp"
29
30 class fieldDescriptor;
31 class klassVtable;
32 class ObjArrayKlass;
33
34 // ArrayKlass is the abstract baseclass for all array classes
35
36 class ArrayKlass: public Klass {
37 friend class VMStructs;
38 private:
39 // If you add a new field that points to any metaspace object, you
40 // must add this field to ArrayKlass::metaspace_pointers_do().
41 int _dimension; // This is n'th-dimensional array.
42 ObjArrayKlass* volatile _higher_dimension; // Refers the (n+1)'th-dimensional array (if present).
43 ArrayKlass* volatile _lower_dimension; // Refers the (n-1)'th-dimensional array (if present).
44
45 protected:
46 Klass* _element_klass; // The klass of the elements of this array type
47 // The element type must be registered for both object arrays
48 // (incl. object arrays with value type elements) and value type
49 // arrays containing flat value types. However, the element
50 // type must not be registered for arrays of primitive types.
51 // TODO: Update the class hierarchy so that element klass appears
52 // only in array that contain non-primitive types.
53 // Constructors
54 // The constructor with the Symbol argument does the real array
55 // initialization, the other is a dummy
56 ArrayKlass(Symbol* name, KlassKind kind);
57 ArrayKlass();
58
59 // Create array_name for element klass
60 static Symbol* create_element_klass_array_name(Klass* element_klass, TRAPS);
61
62 public:
63 // Instance variables
64 virtual Klass* element_klass() const { return _element_klass; }
65 virtual void set_element_klass(Klass* k) { _element_klass = k; }
66
67 // Compiler/Interpreter offset
68 static ByteSize element_klass_offset() { return in_ByteSize(offset_of(ArrayKlass, _element_klass)); }
69
70 // Are loads and stores to this concrete array type atomic?
71 // Note that Object[] is naturally atomic, but its subtypes may not be.
72 virtual bool element_access_is_atomic() { return true; }
73
74 // Testing operation
75 DEBUG_ONLY(bool is_array_klass_slow() const { return true; })
76
77 // Returns the ObjArrayKlass for n'th dimension.
78 ArrayKlass* array_klass(int n, TRAPS);
79 ArrayKlass* array_klass_or_null(int n);
80
81 // Returns the array class with this class as element type.
82 ArrayKlass* array_klass(TRAPS);
83 ArrayKlass* array_klass_or_null();
84
85 // Instance variables
86 int dimension() const { return _dimension; }
87 void set_dimension(int dimension) { _dimension = dimension; }
88
89 ObjArrayKlass* higher_dimension() const { return _higher_dimension; }
90 inline ObjArrayKlass* higher_dimension_acquire() const; // load with acquire semantics
91 void set_higher_dimension(ObjArrayKlass* k) { _higher_dimension = k; }
92 inline void release_set_higher_dimension(ObjArrayKlass* k); // store with release semantics
93
112 Klass* find_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const;
113
114 // Lookup operations
115 Method* uncached_lookup_method(const Symbol* name,
116 const Symbol* signature,
117 OverpassLookupMode overpass_mode,
118 PrivateLookupMode private_mode = PrivateLookupMode::find) const;
119
120 static ArrayKlass* cast(Klass* k) {
121 return const_cast<ArrayKlass*>(cast(const_cast<const Klass*>(k)));
122 }
123
124 static const ArrayKlass* cast(const Klass* k) {
125 assert(k->is_array_klass(), "cast to ArrayKlass");
126 return static_cast<const ArrayKlass*>(k);
127 }
128
129 GrowableArray<Klass*>* compute_secondary_supers(int num_extra_slots,
130 Array<InstanceKlass*>* transitive_interfaces);
131
132 oop component_mirror() const;
133
134 // Sizing
135 static int static_size(int header_size);
136
137 virtual void metaspace_pointers_do(MetaspaceClosure* iter);
138
139 // Return a handle.
140 static void complete_create_array_klass(ArrayKlass* k, Klass* super_klass, ModuleEntry* module, TRAPS);
141
142
143 // jvm support
144 jint compute_modifier_flags() const;
145
146 // JVMTI support
147 jint jvmti_class_status() const;
148
149 #if INCLUDE_CDS
150 // CDS support - remove and restore oops from metadata. Oops are not shared.
151 virtual void remove_unshareable_info();
152 virtual void remove_java_mirror();
153 void restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, TRAPS);
|