8234735: InstanceKlass:find_method_index regression after JDK-8231610
Reviewed-by: iklam, coleenp
This commit is contained in:
parent
22e26b2a81
commit
3cccc62e56
src/hotspot/share/oops
@ -1595,27 +1595,34 @@ static int linear_search(const Array<Method*>* methods,
|
||||
|
||||
bool InstanceKlass::_disable_method_binary_search = false;
|
||||
|
||||
int InstanceKlass::quick_search(const Array<Method*>* methods, const Symbol* name) {
|
||||
NOINLINE int linear_search(const Array<Method*>* methods, const Symbol* name) {
|
||||
int len = methods->length();
|
||||
int l = 0;
|
||||
int h = len - 1;
|
||||
while (l <= h) {
|
||||
Method* m = methods->at(l);
|
||||
if (m->name() == name) {
|
||||
return l;
|
||||
}
|
||||
l++;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
inline int InstanceKlass::quick_search(const Array<Method*>* methods, const Symbol* name) {
|
||||
if (_disable_method_binary_search) {
|
||||
assert(DynamicDumpSharedSpaces, "must be");
|
||||
// At the final stage of dynamic dumping, the methods array may not be sorted
|
||||
// by ascending addresses of their names, so we can't use binary search anymore.
|
||||
// However, methods with the same name are still laid out consecutively inside the
|
||||
// methods array, so let's look for the first one that matches.
|
||||
assert(DynamicDumpSharedSpaces, "must be");
|
||||
while (l <= h) {
|
||||
Method* m = methods->at(l);
|
||||
if (m->name() == name) {
|
||||
return l;
|
||||
}
|
||||
l ++;
|
||||
}
|
||||
return -1;
|
||||
return linear_search(methods, name);
|
||||
}
|
||||
|
||||
int len = methods->length();
|
||||
int l = 0;
|
||||
int h = len - 1;
|
||||
|
||||
// methods are sorted by ascending addresses of their names, so do binary search
|
||||
while (l <= h) {
|
||||
int mid = (l + h) >> 1;
|
||||
|
@ -579,7 +579,7 @@ public:
|
||||
bool find_field_from_offset(int offset, bool is_static, fieldDescriptor* fd) const;
|
||||
|
||||
private:
|
||||
static int quick_search(const Array<Method*>* methods, const Symbol* name);
|
||||
inline static int quick_search(const Array<Method*>* methods, const Symbol* name);
|
||||
|
||||
public:
|
||||
static void disable_method_binary_search() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user