--- a/hotspot/src/share/vm/oops/instanceKlass.cpp Tue Jan 27 05:51:00 2015 -0800
+++ b/hotspot/src/share/vm/oops/instanceKlass.cpp Tue Jan 27 20:02:35 2015 -0800
@@ -1434,6 +1434,12 @@
return meth;
}
+// find_instance_method looks up the name/signature in the local methods array
+// and skips over static methods
+Method* InstanceKlass::find_instance_method(Symbol* name, Symbol* signature) {
+ return InstanceKlass::find_instance_method(methods(), name, signature);
+}
+
// find_method looks up the name/signature in the local methods array
Method* InstanceKlass::find_method(
Array<Method*>* methods, Symbol* name, Symbol* signature) {
@@ -1446,6 +1452,12 @@
return hit >= 0 ? methods->at(hit): NULL;
}
+bool InstanceKlass::method_matches(Method* m, Symbol* signature, bool skipping_overpass, bool skipping_static) {
+ return (m->signature() == signature) &&
+ (!skipping_overpass || !m->is_overpass()) &&
+ (!skipping_static || !m->is_static());
+}
+
// Used directly for default_methods to find the index into the
// default_vtable_indices, and indirectly by find_method
// find_method_index looks in the local methods array to return the index
@@ -1460,13 +1472,10 @@
int hit = binary_search(methods, name);
if (hit != -1) {
Method* m = methods->at(hit);
+
// Do linear search to find matching signature. First, quick check
// for common case, ignoring overpasses if requested.
- if ((m->signature() == signature) &&
- (!skipping_overpass || !m->is_overpass()) &&
- (!skipping_static || !m->is_static())) {
- return hit;
- }
+ if (method_matches(m, signature, skipping_overpass, skipping_static)) return hit;
// search downwards through overloaded methods
int i;
@@ -1474,22 +1483,14 @@
Method* m = methods->at(i);
assert(m->is_method(), "must be method");
if (m->name() != name) break;
- if ((m->signature() == signature) &&
- (!skipping_overpass || !m->is_overpass()) &&
- (!skipping_static || !m->is_static())) {
- return i;
- }
+ if (method_matches(m, signature, skipping_overpass, skipping_static)) return i;
}
// search upwards
for (i = hit + 1; i < methods->length(); ++i) {
Method* m = methods->at(i);
assert(m->is_method(), "must be method");
if (m->name() != name) break;
- if ((m->signature() == signature) &&
- (!skipping_overpass || !m->is_overpass()) &&
- (!skipping_static || !m->is_static())) {
- return i;
- }
+ if (method_matches(m, signature, skipping_overpass, skipping_static)) return i;
}
// not found
#ifdef ASSERT