< prev index next >

src/hotspot/share/oops/objArrayKlass.cpp

Print this page

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 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, 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 size_t ObjArrayKlass::oop_size(oop obj) const {

159   return objArrayOop(obj)->object_size();
160 }
161 
162 objArrayOop ObjArrayKlass::allocate(int length, TRAPS) {
163   check_array_allocation_length(length, arrayOopDesc::max_array_length(T_OBJECT), CHECK_NULL);
164   size_t size = objArrayOopDesc::object_size(length);
165   return (objArrayOop)Universe::heap()->array_allocate(this, size, length,
166                                                        /* do_zero */ true, THREAD);
167 }
168 
169 oop ObjArrayKlass::multi_allocate(int rank, jint* sizes, TRAPS) {
170   int length = *sizes;
171   // Call to lower_dimension uses this pointer, so most be called before a
172   // possible GC
173   Klass* ld_klass = lower_dimension();
174   // If length < 0 allocate will throw an exception.
175   objArrayOop array = allocate(length, CHECK_NULL);
176   objArrayHandle h_array (THREAD, array);
177   if (rank > 1) {
178     if (length != 0) {
< prev index next >