< prev index next >

src/hotspot/share/oops/objArrayKlass.cpp

Print this page

126   Klass* bk;
127   if (element_klass->is_objArray_klass()) {
128     bk = ObjArrayKlass::cast(element_klass)->bottom_klass();
129   } else {
130     bk = element_klass;
131   }
132   assert(bk != nullptr && (bk->is_instance_klass() || bk->is_typeArray_klass()), "invalid bottom klass");
133   set_bottom_klass(bk);
134   set_class_loader_data(bk->class_loader_data());
135 
136   if (element_klass->is_array_klass()) {
137     set_lower_dimension(ArrayKlass::cast(element_klass));
138   }
139 
140   set_layout_helper(array_layout_helper(T_OBJECT));
141   assert(is_array_klass(), "sanity");
142   assert(is_objArray_klass(), "sanity");
143 }
144 
145 size_t ObjArrayKlass::oop_size(oop obj) const {
146   assert(obj->is_objArray(), "must be object array");

147   return objArrayOop(obj)->object_size();
148 }
149 
150 objArrayOop ObjArrayKlass::allocate(int length, TRAPS) {
151   check_array_allocation_length(length, arrayOopDesc::max_array_length(T_OBJECT), CHECK_NULL);
152   size_t size = objArrayOopDesc::object_size(length);
153   return (objArrayOop)Universe::heap()->array_allocate(this, size, length,
154                                                        /* do_zero */ true, THREAD);
155 }
156 
157 oop ObjArrayKlass::multi_allocate(int rank, jint* sizes, TRAPS) {
158   int length = *sizes;
159   ArrayKlass* ld_klass = lower_dimension();
160   // If length < 0 allocate will throw an exception.
161   objArrayOop array = allocate(length, CHECK_NULL);
162   objArrayHandle h_array (THREAD, array);
163   if (rank > 1) {
164     if (length != 0) {
165       for (int index = 0; index < length; index++) {
166         oop sub_array = ld_klass->multi_allocate(rank - 1, &sizes[1], CHECK_NULL);

126   Klass* bk;
127   if (element_klass->is_objArray_klass()) {
128     bk = ObjArrayKlass::cast(element_klass)->bottom_klass();
129   } else {
130     bk = element_klass;
131   }
132   assert(bk != nullptr && (bk->is_instance_klass() || bk->is_typeArray_klass()), "invalid bottom klass");
133   set_bottom_klass(bk);
134   set_class_loader_data(bk->class_loader_data());
135 
136   if (element_klass->is_array_klass()) {
137     set_lower_dimension(ArrayKlass::cast(element_klass));
138   }
139 
140   set_layout_helper(array_layout_helper(T_OBJECT));
141   assert(is_array_klass(), "sanity");
142   assert(is_objArray_klass(), "sanity");
143 }
144 
145 size_t ObjArrayKlass::oop_size(oop obj) const {
146   // In this assert, we cannot safely access the Klass* with compact headers.
147   assert(UseCompactObjectHeaders || obj->is_objArray(), "must be object array");
148   return objArrayOop(obj)->object_size();
149 }
150 
151 objArrayOop ObjArrayKlass::allocate(int length, TRAPS) {
152   check_array_allocation_length(length, arrayOopDesc::max_array_length(T_OBJECT), CHECK_NULL);
153   size_t size = objArrayOopDesc::object_size(length);
154   return (objArrayOop)Universe::heap()->array_allocate(this, size, length,
155                                                        /* do_zero */ true, THREAD);
156 }
157 
158 oop ObjArrayKlass::multi_allocate(int rank, jint* sizes, TRAPS) {
159   int length = *sizes;
160   ArrayKlass* ld_klass = lower_dimension();
161   // If length < 0 allocate will throw an exception.
162   objArrayOop array = allocate(length, CHECK_NULL);
163   objArrayHandle h_array (THREAD, array);
164   if (rank > 1) {
165     if (length != 0) {
166       for (int index = 0; index < length; index++) {
167         oop sub_array = ld_klass->multi_allocate(rank - 1, &sizes[1], CHECK_NULL);
< prev index next >