< prev index next >
src/hotspot/share/oops/instanceKlass.cpp
Print this page
*** 1568,1582 ****
}
return -1;
}
#endif
! static int binary_search(const Array<Method*>* methods, const Symbol* name) {
int len = methods->length();
- // methods are sorted, so do binary search
int l = 0;
int h = len - 1;
while (l <= h) {
int mid = (l + h) >> 1;
Method* m = methods->at(mid);
assert(m->is_method(), "must be method");
int res = m->name()->fast_compare(name);
--- 1568,1600 ----
}
return -1;
}
#endif
! bool InstanceKlass::_disable_method_binary_search = false;
!
! int InstanceKlass::quick_search(const Array<Method*>* methods, const Symbol* name) {
int len = methods->length();
int l = 0;
int h = len - 1;
+
+ if (_disable_method_binary_search) {
+ // During portions of dynamic dumping, the methods array may not be sorted by ascending
+ // addresses of their names. However, methods with the same name are still laid out
+ // consecutively inside the methods array.
+ assert(DynamicDumpSharedSpaces, "must be");
+ while (l <= h) {
+ Method* m = methods->at(l);
+ if (m->name() == name) {
+ return l;
+ }
+ l ++;
+ }
+ return -1;
+ }
+
+ // methods are sorted, so do binary search
while (l <= h) {
int mid = (l + h) >> 1;
Method* m = methods->at(mid);
assert(m->is_method(), "must be method");
int res = m->name()->fast_compare(name);
*** 1724,1734 ****
StaticLookupMode static_mode,
PrivateLookupMode private_mode) {
const bool skipping_overpass = (overpass_mode == skip_overpass);
const bool skipping_static = (static_mode == skip_static);
const bool skipping_private = (private_mode == skip_private);
! const int hit = binary_search(methods, name);
if (hit != -1) {
const Method* const m = methods->at(hit);
// Do linear search to find matching signature. First, quick check
// for common case, ignoring overpasses if requested.
--- 1742,1752 ----
StaticLookupMode static_mode,
PrivateLookupMode private_mode) {
const bool skipping_overpass = (overpass_mode == skip_overpass);
const bool skipping_static = (static_mode == skip_static);
const bool skipping_private = (private_mode == skip_private);
! const int hit = quick_search(methods, name);
if (hit != -1) {
const Method* const m = methods->at(hit);
// Do linear search to find matching signature. First, quick check
// for common case, ignoring overpasses if requested.
*** 1775,1785 ****
int InstanceKlass::find_method_by_name(const Array<Method*>* methods,
const Symbol* name,
int* end_ptr) {
assert(end_ptr != NULL, "just checking");
! int start = binary_search(methods, name);
int end = start + 1;
if (start != -1) {
while (start - 1 >= 0 && (methods->at(start - 1))->name() == name) --start;
while (end < methods->length() && (methods->at(end))->name() == name) ++end;
*end_ptr = end;
--- 1793,1803 ----
int InstanceKlass::find_method_by_name(const Array<Method*>* methods,
const Symbol* name,
int* end_ptr) {
assert(end_ptr != NULL, "just checking");
! int start = quick_search(methods, name);
int end = start + 1;
if (start != -1) {
while (start - 1 >= 0 && (methods->at(start - 1))->name() == name) --start;
while (end < methods->length() && (methods->at(end))->name() == name) ++end;
*end_ptr = end;
*** 2356,2373 ****
--- 2374,2394 ----
_osr_nmethods_head = NULL;
#if INCLUDE_JVMTI
_breakpoints = NULL;
_previous_versions = NULL;
_cached_class_file = NULL;
+ _jvmti_cached_class_field_map = NULL;
#endif
_init_thread = NULL;
_methods_jmethod_ids = NULL;
_jni_ids = NULL;
_oop_map_cache = NULL;
// clear _nest_host to ensure re-load at runtime
_nest_host = NULL;
+ _package_entry = NULL;
+ _dep_context_last_cleaned = 0;
}
void InstanceKlass::remove_java_mirror() {
Klass::remove_java_mirror();
< prev index next >