src/share/vm/oops/instanceKlass.cpp

changeset 7714
d5b74c583ec1
parent 7325
3c87c13918fb
child 7717
41c3c456e326
     1.1 --- a/src/share/vm/oops/instanceKlass.cpp	Wed Nov 19 15:02:01 2014 -0800
     1.2 +++ b/src/share/vm/oops/instanceKlass.cpp	Mon Dec 01 13:06:20 2014 -0500
     1.3 @@ -1453,32 +1453,41 @@
     1.4  }
     1.5  
     1.6  Method* InstanceKlass::find_method_impl(Symbol* name, Symbol* signature, bool skipping_overpass) const {
     1.7 -  return InstanceKlass::find_method_impl(methods(), name, signature, skipping_overpass);
     1.8 +  return InstanceKlass::find_method_impl(methods(), name, signature, skipping_overpass, false);
     1.9  }
    1.10  
    1.11  // find_instance_method looks up the name/signature in the local methods array
    1.12  // and skips over static methods
    1.13  Method* InstanceKlass::find_instance_method(
    1.14      Array<Method*>* methods, Symbol* name, Symbol* signature) {
    1.15 -  Method* meth = InstanceKlass::find_method(methods, name, signature);
    1.16 -  if (meth != NULL && meth->is_static()) {
    1.17 -      meth = NULL;
    1.18 -  }
    1.19 +  Method* meth = InstanceKlass::find_method_impl(methods, name, signature, false, true);
    1.20    return meth;
    1.21  }
    1.22  
    1.23 +// find_instance_method looks up the name/signature in the local methods array
    1.24 +// and skips over static methods
    1.25 +Method* InstanceKlass::find_instance_method(Symbol* name, Symbol* signature) {
    1.26 +    return InstanceKlass::find_instance_method(methods(), name, signature);
    1.27 +}
    1.28 +
    1.29  // find_method looks up the name/signature in the local methods array
    1.30  Method* InstanceKlass::find_method(
    1.31      Array<Method*>* methods, Symbol* name, Symbol* signature) {
    1.32 -  return InstanceKlass::find_method_impl(methods, name, signature, false);
    1.33 +  return InstanceKlass::find_method_impl(methods, name, signature, false, false);
    1.34  }
    1.35  
    1.36  Method* InstanceKlass::find_method_impl(
    1.37 -    Array<Method*>* methods, Symbol* name, Symbol* signature, bool skipping_overpass) {
    1.38 -  int hit = find_method_index(methods, name, signature, skipping_overpass);
    1.39 +    Array<Method*>* methods, Symbol* name, Symbol* signature, bool skipping_overpass, bool skipping_static) {
    1.40 +  int hit = find_method_index(methods, name, signature, skipping_overpass, skipping_static);
    1.41    return hit >= 0 ? methods->at(hit): NULL;
    1.42  }
    1.43  
    1.44 +bool InstanceKlass::method_matches(Method* m, Symbol* signature, bool skipping_overpass, bool skipping_static) {
    1.45 +    return (m->signature() == signature) &&
    1.46 +            (!skipping_overpass || !m->is_overpass()) &&
    1.47 +            (!skipping_static || !m->is_static());
    1.48 +}
    1.49 +
    1.50  // Used directly for default_methods to find the index into the
    1.51  // default_vtable_indices, and indirectly by find_method
    1.52  // find_method_index looks in the local methods array to return the index
    1.53 @@ -1487,13 +1496,14 @@
    1.54  // is important during method resolution to prefer a static method, for example,
    1.55  // over an overpass method.
    1.56  int InstanceKlass::find_method_index(
    1.57 -    Array<Method*>* methods, Symbol* name, Symbol* signature, bool skipping_overpass) {
    1.58 +    Array<Method*>* methods, Symbol* name, Symbol* signature, bool skipping_overpass, bool skipping_static) {
    1.59    int hit = binary_search(methods, name);
    1.60    if (hit != -1) {
    1.61      Method* m = methods->at(hit);
    1.62 +
    1.63      // Do linear search to find matching signature.  First, quick check
    1.64      // for common case, ignoring overpasses if requested.
    1.65 -    if ((m->signature() == signature) && (!skipping_overpass || !m->is_overpass())) return hit;
    1.66 +    if (method_matches(m, signature, skipping_overpass, skipping_static)) return hit;
    1.67  
    1.68      // search downwards through overloaded methods
    1.69      int i;
    1.70 @@ -1501,18 +1511,18 @@
    1.71          Method* m = methods->at(i);
    1.72          assert(m->is_method(), "must be method");
    1.73          if (m->name() != name) break;
    1.74 -        if ((m->signature() == signature) && (!skipping_overpass || !m->is_overpass())) return i;
    1.75 +        if (method_matches(m, signature, skipping_overpass, skipping_static)) return i;
    1.76      }
    1.77      // search upwards
    1.78      for (i = hit + 1; i < methods->length(); ++i) {
    1.79          Method* m = methods->at(i);
    1.80          assert(m->is_method(), "must be method");
    1.81          if (m->name() != name) break;
    1.82 -        if ((m->signature() == signature) && (!skipping_overpass || !m->is_overpass())) return i;
    1.83 +        if (method_matches(m, signature, skipping_overpass, skipping_static)) return i;
    1.84      }
    1.85      // not found
    1.86  #ifdef ASSERT
    1.87 -    int index = skipping_overpass ? -1 : linear_search(methods, name, signature);
    1.88 +    int index = skipping_overpass || skipping_static ? -1 : linear_search(methods, name, signature);
    1.89      assert(index == -1, err_msg("binary search should have found entry %d", index));
    1.90  #endif
    1.91    }

mercurial