changeset 59224:7fbe6a42ffe9

8234735: InstanceKlass:find_method_index regression after JDK-8231610 Reviewed-by: iklam, coleenp
author redestad
date Mon, 09 Dec 2019 16:46:29 +0100
parents 9cb141c7329f
children 8df91a722672
files src/hotspot/share/oops/instanceKlass.cpp src/hotspot/share/oops/instanceKlass.hpp
diffstat 2 files changed, 19 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/share/oops/instanceKlass.cpp	Mon Dec 09 14:25:37 2019 +0000
+++ b/src/hotspot/share/oops/instanceKlass.cpp	Mon Dec 09 16:46:29 2019 +0100
@@ -1595,27 +1595,34 @@
 
 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;
--- a/src/hotspot/share/oops/instanceKlass.hpp	Mon Dec 09 14:25:37 2019 +0000
+++ b/src/hotspot/share/oops/instanceKlass.hpp	Mon Dec 09 16:46:29 2019 +0100
@@ -579,7 +579,7 @@
   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() {