139 ObjArrayKlass::ObjArrayKlass(int n, Klass* element_klass, Symbol* name) : ArrayKlass(name, Kind) {
140 set_dimension(n);
141 set_element_klass(element_klass);
142
143 Klass* bk;
144 if (element_klass->is_objArray_klass()) {
145 bk = ObjArrayKlass::cast(element_klass)->bottom_klass();
146 } else {
147 bk = element_klass;
148 }
149 assert(bk != nullptr && (bk->is_instance_klass() || bk->is_typeArray_klass()), "invalid bottom klass");
150 set_bottom_klass(bk);
151 set_class_loader_data(bk->class_loader_data());
152
153 set_layout_helper(array_layout_helper(T_OBJECT));
154 assert(is_array_klass(), "sanity");
155 assert(is_objArray_klass(), "sanity");
156 }
157
158 size_t ObjArrayKlass::oop_size(oop obj) const {
159 assert(obj->is_objArray(), "must be object array");
160 return objArrayOop(obj)->object_size();
161 }
162
163 objArrayOop ObjArrayKlass::allocate(int length, TRAPS) {
164 check_array_allocation_length(length, arrayOopDesc::max_array_length(T_OBJECT), CHECK_NULL);
165 size_t size = objArrayOopDesc::object_size(length);
166 return (objArrayOop)Universe::heap()->array_allocate(this, size, length,
167 /* do_zero */ true, THREAD);
168 }
169
170 oop ObjArrayKlass::multi_allocate(int rank, jint* sizes, TRAPS) {
171 int length = *sizes;
172 // Call to lower_dimension uses this pointer, so most be called before a
173 // possible GC
174 Klass* ld_klass = lower_dimension();
175 // If length < 0 allocate will throw an exception.
176 objArrayOop array = allocate(length, CHECK_NULL);
177 objArrayHandle h_array (THREAD, array);
178 if (rank > 1) {
179 if (length != 0) {
|
139 ObjArrayKlass::ObjArrayKlass(int n, Klass* element_klass, Symbol* name) : ArrayKlass(name, Kind) {
140 set_dimension(n);
141 set_element_klass(element_klass);
142
143 Klass* bk;
144 if (element_klass->is_objArray_klass()) {
145 bk = ObjArrayKlass::cast(element_klass)->bottom_klass();
146 } else {
147 bk = element_klass;
148 }
149 assert(bk != nullptr && (bk->is_instance_klass() || bk->is_typeArray_klass()), "invalid bottom klass");
150 set_bottom_klass(bk);
151 set_class_loader_data(bk->class_loader_data());
152
153 set_layout_helper(array_layout_helper(T_OBJECT));
154 assert(is_array_klass(), "sanity");
155 assert(is_objArray_klass(), "sanity");
156 }
157
158 size_t ObjArrayKlass::oop_size(oop obj) const {
159 // In this assert, we cannot safely access the Klass* with compact headers.
160 assert(UseCompactObjectHeaders || obj->is_objArray(), "must be object array");
161 return objArrayOop(obj)->object_size();
162 }
163
164 objArrayOop ObjArrayKlass::allocate(int length, TRAPS) {
165 check_array_allocation_length(length, arrayOopDesc::max_array_length(T_OBJECT), CHECK_NULL);
166 size_t size = objArrayOopDesc::object_size(length);
167 return (objArrayOop)Universe::heap()->array_allocate(this, size, length,
168 /* do_zero */ true, THREAD);
169 }
170
171 oop ObjArrayKlass::multi_allocate(int rank, jint* sizes, TRAPS) {
172 int length = *sizes;
173 // Call to lower_dimension uses this pointer, so most be called before a
174 // possible GC
175 Klass* ld_klass = lower_dimension();
176 // If length < 0 allocate will throw an exception.
177 objArrayOop array = allocate(length, CHECK_NULL);
178 objArrayHandle h_array (THREAD, array);
179 if (rank > 1) {
180 if (length != 0) {
|