8030680: 292 cleanup from default method code assessment

Fri, 08 May 2015 14:00:24 -0400

author
acorn
date
Fri, 08 May 2015 14:00:24 -0400
changeset 9898
e6a26331730f
parent 9897
cf634627cdd0
child 9899
bc53a86f5357

8030680: 292 cleanup from default method code assessment
Summary: small code improvements for increased robustness
Reviewed-by: acorn, coleenp
Contributed-by: michael.haupt@oracle.com

src/share/vm/oops/klassVtable.cpp file | annotate | diff | comparison | revisions
src/share/vm/prims/methodHandles.cpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/oops/klassVtable.cpp	Tue Mar 03 13:22:39 2020 +0000
     1.2 +++ b/src/share/vm/oops/klassVtable.cpp	Fri May 08 14:00:24 2015 -0400
     1.3 @@ -1154,7 +1154,7 @@
     1.4  
     1.5  int klassItable::assign_itable_indices_for_interface(Klass* klass) {
     1.6    // an interface does not have an itable, but its methods need to be numbered
     1.7 -  if (TraceItables) tty->print_cr("%3d: Initializing itable for interface %s", ++initialize_count,
     1.8 +  if (TraceItables) tty->print_cr("%3d: Initializing itable indices for interface %s", ++initialize_count,
     1.9                                    klass->name()->as_C_string());
    1.10    Array<Method*>* methods = InstanceKlass::cast(klass)->methods();
    1.11    int nof_methods = methods->length();
    1.12 @@ -1168,7 +1168,7 @@
    1.13          ResourceMark rm;
    1.14          const char* sig = (m != NULL) ? m->name_and_sig_as_C_string() : "<NULL>";
    1.15          if (m->has_vtable_index()) {
    1.16 -          tty->print("itable index %d for method: %s, flags: ", m->vtable_index(), sig);
    1.17 +          tty->print("vtable index %d for method: %s, flags: ", m->vtable_index(), sig);
    1.18          } else {
    1.19            tty->print("itable index %d for method: %s, flags: ", ime_num, sig);
    1.20          }
    1.21 @@ -1204,22 +1204,25 @@
    1.22    assert(interf->is_interface(), "must be");
    1.23    Array<Method*>* methods = InstanceKlass::cast(interf)->methods();
    1.24    int nof_methods = methods->length();
    1.25 +  int length = 0;
    1.26    while (nof_methods > 0) {
    1.27      Method* m = methods->at(nof_methods-1);
    1.28      if (m->has_itable_index()) {
    1.29 -      int length = m->itable_index() + 1;
    1.30 -#ifdef ASSERT
    1.31 -      while (nof_methods = 0) {
    1.32 -        m = methods->at(--nof_methods);
    1.33 -        assert(!m->has_itable_index() || m->itable_index() < length, "");
    1.34 -      }
    1.35 -#endif //ASSERT
    1.36 -      return length;  // return the rightmost itable index, plus one
    1.37 +      length = m->itable_index() + 1;
    1.38 +      break;
    1.39      }
    1.40      nof_methods -= 1;
    1.41    }
    1.42 -  // no methods have itable indices
    1.43 -  return 0;
    1.44 +#ifdef ASSERT
    1.45 +  int nof_methods_copy = nof_methods;
    1.46 +  while (nof_methods_copy > 0) {
    1.47 +    Method* mm = methods->at(--nof_methods_copy);
    1.48 +    assert(!mm->has_itable_index() || mm->itable_index() < length, "");
    1.49 +  }
    1.50 +#endif //ASSERT
    1.51 +  // return the rightmost itable index, plus one; or 0 if no methods have
    1.52 +  // itable indices
    1.53 +  return length;
    1.54  }
    1.55  
    1.56  
     2.1 --- a/src/share/vm/prims/methodHandles.cpp	Tue Mar 03 13:22:39 2020 +0000
     2.2 +++ b/src/share/vm/prims/methodHandles.cpp	Fri May 08 14:00:24 2015 -0400
     2.3 @@ -176,7 +176,9 @@
     2.4  oop MethodHandles::init_method_MemberName(Handle mname, CallInfo& info, bool intern) {
     2.5    assert(info.resolved_appendix().is_null(), "only normal methods here");
     2.6    methodHandle m = info.resolved_method();
     2.7 +  assert(m.not_null(), "null method handle");
     2.8    KlassHandle m_klass = m->method_holder();
     2.9 +  assert(m.not_null(), "null holder for method handle");
    2.10    int flags = (jushort)( m->access_flags().as_short() & JVM_RECOGNIZED_METHOD_MODIFIERS );
    2.11    int vmindex = Method::invalid_vtable_index;
    2.12  

mercurial