src/share/vm/oops/methodOop.cpp
Print this page
@@ -1098,12 +1098,19 @@
}
extern "C" {
static int method_compare(methodOop* a, methodOop* b) {
+ if (UseCompressedOops) {
+ methodOop m = (methodOop)oopDesc::load_decode_heap_oop((narrowOop*)a);
+ methodOop n = (methodOop)oopDesc::load_decode_heap_oop((narrowOop*)b);
+ return m->name()->fast_compare(n->name());
+ }
+ else {
return (*a)->name()->fast_compare((*b)->name());
}
+ }
// Prevent qsort from reordering a previous valid sort by
// considering the address of the methodOops if two methods
// would otherwise compare as equal. Required to preserve
// optimal access order in the shared archive. Slower than
@@ -1164,11 +1171,11 @@
}
}
// Use a simple bubble sort for small number of methods since
// qsort requires a functional pointer call for each comparison.
- if (UseCompressedOops || length < 8) {
+ if (length < 8) {
bool sorted = true;
for (int i=length-1; i>0; i--) {
for (int j=0; j<i; j++) {
methodOop m1 = (methodOop)methods->obj_at(j);
methodOop m2 = (methodOop)methods->obj_at(j+1);
@@ -1180,13 +1187,10 @@
}
if (sorted) break;
sorted = true;
}
} else {
- // XXX This doesn't work for UseCompressedOops because the compare fn
- // will have to decode the methodOop anyway making it not much faster
- // than above.
compareFn compare = (compareFn) (idempotent ? method_compare_idempotent : method_compare);
qsort(methods->base(), length, heapOopSize, compare);
}
// Sort annotations if necessary