8062116: JVMTI GetClassMethods is Slow

Allocate enough space for all jmethodids; make adding a jmethodid O(1)

Reviewed-by: coleenp, rasbold, sspitsyn
This commit is contained in:
Jeremy Manson 2014-11-05 16:47:37 -08:00
parent 75778598e2
commit 54e9fee4d2
5 changed files with 166 additions and 44 deletions

View file

@ -1730,6 +1730,25 @@ jmethodID InstanceKlass::get_jmethod_id(instanceKlassHandle ik_h, methodHandle m
return id;
}
// Figure out how many jmethodIDs haven't been allocated, and make
// sure space for them is pre-allocated. This makes getting all
// method ids much, much faster with classes with more than 8
// methods, and has a *substantial* effect on performance with jvmti
// code that loads all jmethodIDs for all classes.
void InstanceKlass::ensure_space_for_methodids(int start_offset) {
int new_jmeths = 0;
int length = methods()->length();
for (int index = start_offset; index < length; index++) {
Method* m = methods()->at(index);
jmethodID id = m->find_jmethod_id_or_null();
if (id == NULL) {
new_jmeths++;
}
}
if (new_jmeths != 0) {
Method::ensure_jmethod_ids(class_loader_data(), new_jmeths);
}
}
// Common code to fetch the jmethodID from the cache or update the
// cache with the new jmethodID. This function should never do anything