mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8234735: InstanceKlass:find_method_index regression after JDK-8231610
Reviewed-by: iklam, coleenp
This commit is contained in:
parent
22e26b2a81
commit
3cccc62e56
2 changed files with 18 additions and 11 deletions
|
@ -1595,27 +1595,34 @@ static int linear_search(const Array<Method*>* methods,
|
||||||
|
|
||||||
bool InstanceKlass::_disable_method_binary_search = false;
|
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 len = methods->length();
|
||||||
int l = 0;
|
int l = 0;
|
||||||
int h = len - 1;
|
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) {
|
if (_disable_method_binary_search) {
|
||||||
|
assert(DynamicDumpSharedSpaces, "must be");
|
||||||
// At the final stage of dynamic dumping, the methods array may not be sorted
|
// 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.
|
// 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
|
// 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.
|
// methods array, so let's look for the first one that matches.
|
||||||
assert(DynamicDumpSharedSpaces, "must be");
|
return linear_search(methods, name);
|
||||||
while (l <= h) {
|
|
||||||
Method* m = methods->at(l);
|
|
||||||
if (m->name() == name) {
|
|
||||||
return l;
|
|
||||||
}
|
|
||||||
l ++;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int len = methods->length();
|
||||||
|
int l = 0;
|
||||||
|
int h = len - 1;
|
||||||
|
|
||||||
// methods are sorted by ascending addresses of their names, so do binary search
|
// methods are sorted by ascending addresses of their names, so do binary search
|
||||||
while (l <= h) {
|
while (l <= h) {
|
||||||
int mid = (l + h) >> 1;
|
int mid = (l + h) >> 1;
|
||||||
|
|
|
@ -579,7 +579,7 @@ public:
|
||||||
bool find_field_from_offset(int offset, bool is_static, fieldDescriptor* fd) const;
|
bool find_field_from_offset(int offset, bool is_static, fieldDescriptor* fd) const;
|
||||||
|
|
||||||
private:
|
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:
|
public:
|
||||||
static void disable_method_binary_search() {
|
static void disable_method_binary_search() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue