hotspot/src/share/vm/oops/klassVtable.cpp
changeset 30615 4713e7c7b96f
parent 29871 77e7fe063568
child 30768 66b53dcce510
equal deleted inserted replaced
30606:9dae6b41c617 30615:4713e7c7b96f
  1052   return true;
  1052   return true;
  1053 }
  1053 }
  1054 
  1054 
  1055 int klassItable::assign_itable_indices_for_interface(Klass* klass) {
  1055 int klassItable::assign_itable_indices_for_interface(Klass* klass) {
  1056   // an interface does not have an itable, but its methods need to be numbered
  1056   // an interface does not have an itable, but its methods need to be numbered
  1057   if (TraceItables) tty->print_cr("%3d: Initializing itable for interface %s", ++initialize_count,
  1057   if (TraceItables) tty->print_cr("%3d: Initializing itable indices for interface %s", ++initialize_count,
  1058                                   klass->name()->as_C_string());
  1058                                   klass->name()->as_C_string());
  1059   Array<Method*>* methods = InstanceKlass::cast(klass)->methods();
  1059   Array<Method*>* methods = InstanceKlass::cast(klass)->methods();
  1060   int nof_methods = methods->length();
  1060   int nof_methods = methods->length();
  1061   int ime_num = 0;
  1061   int ime_num = 0;
  1062   for (int i = 0; i < nof_methods; i++) {
  1062   for (int i = 0; i < nof_methods; i++) {
  1066       // If m is already assigned a vtable index, do not disturb it.
  1066       // If m is already assigned a vtable index, do not disturb it.
  1067       if (TraceItables && Verbose) {
  1067       if (TraceItables && Verbose) {
  1068         ResourceMark rm;
  1068         ResourceMark rm;
  1069         const char* sig = (m != NULL) ? m->name_and_sig_as_C_string() : "<NULL>";
  1069         const char* sig = (m != NULL) ? m->name_and_sig_as_C_string() : "<NULL>";
  1070         if (m->has_vtable_index()) {
  1070         if (m->has_vtable_index()) {
  1071           tty->print("itable index %d for method: %s, flags: ", m->vtable_index(), sig);
  1071           tty->print("vtable index %d for method: %s, flags: ", m->vtable_index(), sig);
  1072         } else {
  1072         } else {
  1073           tty->print("itable index %d for method: %s, flags: ", ime_num, sig);
  1073           tty->print("itable index %d for method: %s, flags: ", ime_num, sig);
  1074         }
  1074         }
  1075         if (m != NULL) {
  1075         if (m != NULL) {
  1076           m->access_flags().print_on(tty);
  1076           m->access_flags().print_on(tty);
  1098 int klassItable::method_count_for_interface(Klass* interf) {
  1098 int klassItable::method_count_for_interface(Klass* interf) {
  1099   assert(interf->oop_is_instance(), "must be");
  1099   assert(interf->oop_is_instance(), "must be");
  1100   assert(interf->is_interface(), "must be");
  1100   assert(interf->is_interface(), "must be");
  1101   Array<Method*>* methods = InstanceKlass::cast(interf)->methods();
  1101   Array<Method*>* methods = InstanceKlass::cast(interf)->methods();
  1102   int nof_methods = methods->length();
  1102   int nof_methods = methods->length();
       
  1103   int length = 0;
  1103   while (nof_methods > 0) {
  1104   while (nof_methods > 0) {
  1104     Method* m = methods->at(nof_methods-1);
  1105     Method* m = methods->at(nof_methods-1);
  1105     if (m->has_itable_index()) {
  1106     if (m->has_itable_index()) {
  1106       int length = m->itable_index() + 1;
  1107       length = m->itable_index() + 1;
       
  1108       break;
       
  1109     }
       
  1110     nof_methods -= 1;
       
  1111   }
  1107 #ifdef ASSERT
  1112 #ifdef ASSERT
  1108       while (nof_methods = 0) {
  1113   int nof_methods_copy = nof_methods;
  1109         m = methods->at(--nof_methods);
  1114   while (nof_methods_copy > 0) {
  1110         assert(!m->has_itable_index() || m->itable_index() < length, "");
  1115     Method* mm = methods->at(--nof_methods_copy);
  1111       }
  1116     assert(!mm->has_itable_index() || mm->itable_index() < length, "");
       
  1117   }
  1112 #endif //ASSERT
  1118 #endif //ASSERT
  1113       return length;  // return the rightmost itable index, plus one
  1119   // return the rightmost itable index, plus one; or 0 if no methods have
  1114     }
  1120   // itable indices
  1115     nof_methods -= 1;
  1121   return length;
  1116   }
       
  1117   // no methods have itable indices
       
  1118   return 0;
       
  1119 }
  1122 }
  1120 
  1123 
  1121 
  1124 
  1122 void klassItable::initialize_itable_for_interface(int method_table_offset, KlassHandle interf_h, bool checkconstraints, TRAPS) {
  1125 void klassItable::initialize_itable_for_interface(int method_table_offset, KlassHandle interf_h, bool checkconstraints, TRAPS) {
  1123   Array<Method*>* methods = InstanceKlass::cast(interf_h())->methods();
  1126   Array<Method*>* methods = InstanceKlass::cast(interf_h())->methods();