hotspot/src/share/vm/oops/objArrayKlass.cpp
changeset 14488 ab48109f7d1b
parent 13961 aeaa21c167d1
child 14588 8ec26d2d9339
equal deleted inserted replaced
14486:7d079e0eedef 14488:ab48109f7d1b
    79       // Also, see if the element has secondary supertypes.
    79       // Also, see if the element has secondary supertypes.
    80       // We need an array type for each.
    80       // We need an array type for each.
    81       Array<Klass*>* element_supers = element_klass->secondary_supers();
    81       Array<Klass*>* element_supers = element_klass->secondary_supers();
    82       for( int i = element_supers->length()-1; i >= 0; i-- ) {
    82       for( int i = element_supers->length()-1; i >= 0; i-- ) {
    83         Klass* elem_super = element_supers->at(i);
    83         Klass* elem_super = element_supers->at(i);
    84         if (Klass::cast(elem_super)->array_klass_or_null() == NULL) {
    84         if (elem_super->array_klass_or_null() == NULL) {
    85           supers_exist = false;
    85           supers_exist = false;
    86           break;
    86           break;
    87         }
    87         }
    88       }
    88       }
    89       if (!supers_exist) {
    89       if (!supers_exist) {
   170   if (element_klass->oop_is_objArray()) {
   170   if (element_klass->oop_is_objArray()) {
   171     bk = ObjArrayKlass::cast(element_klass())->bottom_klass();
   171     bk = ObjArrayKlass::cast(element_klass())->bottom_klass();
   172   } else {
   172   } else {
   173     bk = element_klass();
   173     bk = element_klass();
   174   }
   174   }
   175   assert(bk != NULL && (Klass::cast(bk)->oop_is_instance() || Klass::cast(bk)->oop_is_typeArray()), "invalid bottom klass");
   175   assert(bk != NULL && (bk->oop_is_instance() || bk->oop_is_typeArray()), "invalid bottom klass");
   176   this->set_bottom_klass(bk);
   176   this->set_bottom_klass(bk);
   177   this->set_class_loader_data(bk->class_loader_data());
   177   this->set_class_loader_data(bk->class_loader_data());
   178 
   178 
   179   this->set_layout_helper(array_layout_helper(T_OBJECT));
   179   this->set_layout_helper(array_layout_helper(T_OBJECT));
   180   assert(this->oop_is_array(), "sanity");
   180   assert(this->oop_is_array(), "sanity");
   252     Copy::conjoint_oops_atomic(src, dst, length);
   252     Copy::conjoint_oops_atomic(src, dst, length);
   253   } else {
   253   } else {
   254     // We have to make sure all elements conform to the destination array
   254     // We have to make sure all elements conform to the destination array
   255     Klass* bound = ObjArrayKlass::cast(d->klass())->element_klass();
   255     Klass* bound = ObjArrayKlass::cast(d->klass())->element_klass();
   256     Klass* stype = ObjArrayKlass::cast(s->klass())->element_klass();
   256     Klass* stype = ObjArrayKlass::cast(s->klass())->element_klass();
   257     if (stype == bound || Klass::cast(stype)->is_subtype_of(bound)) {
   257     if (stype == bound || stype->is_subtype_of(bound)) {
   258       // elements are guaranteed to be subtypes, so no check necessary
   258       // elements are guaranteed to be subtypes, so no check necessary
   259       bs->write_ref_array_pre(dst, length);
   259       bs->write_ref_array_pre(dst, length);
   260       Copy::conjoint_oops_atomic(src, dst, length);
   260       Copy::conjoint_oops_atomic(src, dst, length);
   261     } else {
   261     } else {
   262       // slow case: need individual subtype checks
   262       // slow case: need individual subtype checks
   269         // even slower now
   269         // even slower now
   270         bool element_is_null = oopDesc::is_null(element);
   270         bool element_is_null = oopDesc::is_null(element);
   271         oop new_val = element_is_null ? oop(NULL)
   271         oop new_val = element_is_null ? oop(NULL)
   272                                       : oopDesc::decode_heap_oop_not_null(element);
   272                                       : oopDesc::decode_heap_oop_not_null(element);
   273         if (element_is_null ||
   273         if (element_is_null ||
   274             Klass::cast((new_val->klass()))->is_subtype_of(bound)) {
   274             (new_val->klass())->is_subtype_of(bound)) {
   275           bs->write_ref_field_pre(p, new_val);
   275           bs->write_ref_field_pre(p, new_val);
   276           *p = *from;
   276           *p = *from;
   277         } else {
   277         } else {
   278           // We must do a barrier to cover the partial copy.
   278           // We must do a barrier to cover the partial copy.
   279           const size_t pd = pointer_delta(p, dst, (size_t)heapOopSize);
   279           const size_t pd = pointer_delta(p, dst, (size_t)heapOopSize);
   379     return Klass::can_be_primary_super_slow();
   379     return Klass::can_be_primary_super_slow();
   380 }
   380 }
   381 
   381 
   382 GrowableArray<Klass*>* ObjArrayKlass::compute_secondary_supers(int num_extra_slots) {
   382 GrowableArray<Klass*>* ObjArrayKlass::compute_secondary_supers(int num_extra_slots) {
   383   // interfaces = { cloneable_klass, serializable_klass, elemSuper[], ... };
   383   // interfaces = { cloneable_klass, serializable_klass, elemSuper[], ... };
   384   Array<Klass*>* elem_supers = Klass::cast(element_klass())->secondary_supers();
   384   Array<Klass*>* elem_supers = element_klass()->secondary_supers();
   385   int num_elem_supers = elem_supers == NULL ? 0 : elem_supers->length();
   385   int num_elem_supers = elem_supers == NULL ? 0 : elem_supers->length();
   386   int num_secondaries = num_extra_slots + 2 + num_elem_supers;
   386   int num_secondaries = num_extra_slots + 2 + num_elem_supers;
   387   if (num_secondaries == 2) {
   387   if (num_secondaries == 2) {
   388     // Must share this for correct bootstrapping!
   388     // Must share this for correct bootstrapping!
   389     set_secondary_supers(Universe::the_array_interfaces_array());
   389     set_secondary_supers(Universe::the_array_interfaces_array());
   409   ObjArrayKlass* oak = ObjArrayKlass::cast(k);
   409   ObjArrayKlass* oak = ObjArrayKlass::cast(k);
   410   return element_klass()->is_subtype_of(oak->element_klass());
   410   return element_klass()->is_subtype_of(oak->element_klass());
   411 }
   411 }
   412 
   412 
   413 void ObjArrayKlass::initialize(TRAPS) {
   413 void ObjArrayKlass::initialize(TRAPS) {
   414   Klass::cast(bottom_klass())->initialize(THREAD);  // dispatches to either InstanceKlass or TypeArrayKlass
   414   bottom_klass()->initialize(THREAD);  // dispatches to either InstanceKlass or TypeArrayKlass
   415 }
   415 }
   416 
   416 
   417 #define ObjArrayKlass_SPECIALIZED_OOP_ITERATE(T, a, p, do_oop) \
   417 #define ObjArrayKlass_SPECIALIZED_OOP_ITERATE(T, a, p, do_oop) \
   418 {                                   \
   418 {                                   \
   419   T* p         = (T*)(a)->base();   \
   419   T* p         = (T*)(a)->base();   \
   605   if (element_klass() == NULL) {
   605   if (element_klass() == NULL) {
   606     assert(Universe::is_bootstrapping(), "partial objArray only at startup");
   606     assert(Universe::is_bootstrapping(), "partial objArray only at startup");
   607     return JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC;
   607     return JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC;
   608   }
   608   }
   609   // Return the flags of the bottom element type.
   609   // Return the flags of the bottom element type.
   610   jint element_flags = Klass::cast(bottom_klass())->compute_modifier_flags(CHECK_0);
   610   jint element_flags = bottom_klass()->compute_modifier_flags(CHECK_0);
   611 
   611 
   612   return (element_flags & (JVM_ACC_PUBLIC | JVM_ACC_PRIVATE | JVM_ACC_PROTECTED))
   612   return (element_flags & (JVM_ACC_PUBLIC | JVM_ACC_PRIVATE | JVM_ACC_PROTECTED))
   613                         | (JVM_ACC_ABSTRACT | JVM_ACC_FINAL);
   613                         | (JVM_ACC_ABSTRACT | JVM_ACC_FINAL);
   614 }
   614 }
   615 
   615 
   684   ArrayKlass::verify_on(st);
   684   ArrayKlass::verify_on(st);
   685   guarantee(element_klass()->is_metadata(), "should be in metaspace");
   685   guarantee(element_klass()->is_metadata(), "should be in metaspace");
   686   guarantee(element_klass()->is_klass(), "should be klass");
   686   guarantee(element_klass()->is_klass(), "should be klass");
   687   guarantee(bottom_klass()->is_metadata(), "should be in metaspace");
   687   guarantee(bottom_klass()->is_metadata(), "should be in metaspace");
   688   guarantee(bottom_klass()->is_klass(), "should be klass");
   688   guarantee(bottom_klass()->is_klass(), "should be klass");
   689   Klass* bk = Klass::cast(bottom_klass());
   689   Klass* bk = bottom_klass();
   690   guarantee(bk->oop_is_instance() || bk->oop_is_typeArray(),  "invalid bottom klass");
   690   guarantee(bk->oop_is_instance() || bk->oop_is_typeArray(),  "invalid bottom klass");
   691 }
   691 }
   692 
   692 
   693 void ObjArrayKlass::oop_verify_on(oop obj, outputStream* st) {
   693 void ObjArrayKlass::oop_verify_on(oop obj, outputStream* st) {
   694   ArrayKlass::oop_verify_on(obj, st);
   694   ArrayKlass::oop_verify_on(obj, st);