139 ObjArrayKlass::ObjArrayKlass(int n, Klass* element_klass, Symbol* name) : ArrayKlass(name, ID) {
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 != NULL && (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 int 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 int size = objArrayOopDesc::object_size(length);
166 return (objArrayOop)Universe::heap()->array_allocate(this, size, length,
167 /* do_zero */ true, THREAD);
168 }
169
170 static int multi_alloc_counter = 0;
171
172 oop ObjArrayKlass::multi_allocate(int rank, jint* sizes, TRAPS) {
173 int length = *sizes;
174 // Call to lower_dimension uses this pointer, so most be called before a
175 // possible GC
176 Klass* ld_klass = lower_dimension();
177 // If length < 0 allocate will throw an exception.
178 objArrayOop array = allocate(length, CHECK_NULL);
179 objArrayHandle h_array (THREAD, array);
|
139 ObjArrayKlass::ObjArrayKlass(int n, Klass* element_klass, Symbol* name) : ArrayKlass(name, ID) {
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 != NULL && (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 int ObjArrayKlass::oop_size(oop obj) const {
159 assert(UseCompactObjectHeaders || 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 int size = objArrayOopDesc::object_size(length);
166 return (objArrayOop)Universe::heap()->array_allocate(this, size, length,
167 /* do_zero */ true, THREAD);
168 }
169
170 static int multi_alloc_counter = 0;
171
172 oop ObjArrayKlass::multi_allocate(int rank, jint* sizes, TRAPS) {
173 int length = *sizes;
174 // Call to lower_dimension uses this pointer, so most be called before a
175 // possible GC
176 Klass* ld_klass = lower_dimension();
177 // If length < 0 allocate will throw an exception.
178 objArrayOop array = allocate(length, CHECK_NULL);
179 objArrayHandle h_array (THREAD, array);
|