Mercurial > hg > graal-jvmci-8
diff src/share/vm/oops/methodOop.cpp @ 1498:77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
Summary: Add comparison functions for compressed oops to use bubblesort.
Reviewed-by: never, coleenp
Contributed-by: volker.simonis@gmail.com
author | coleenp |
---|---|
date | Tue, 04 May 2010 15:12:08 -0400 |
parents | cef333a48af6 |
children | ef1a1d051971 |
line wrap: on
line diff
--- a/src/share/vm/oops/methodOop.cpp Mon Apr 19 18:58:31 2010 -0400 +++ b/src/share/vm/oops/methodOop.cpp Tue May 04 15:12:08 2010 -0400 @@ -1114,6 +1114,20 @@ return ( a < b ? -1 : (a == b ? 0 : 1)); } + // We implement special compare versions for narrow oops to avoid + // testing for UseCompressedOops on every comparison. + static int method_compare_narrow(narrowOop* a, narrowOop* b) { + methodOop m = (methodOop)oopDesc::load_decode_heap_oop(a); + methodOop n = (methodOop)oopDesc::load_decode_heap_oop(b); + return m->name()->fast_compare(n->name()); + } + + static int method_compare_narrow_idempotent(narrowOop* a, narrowOop* b) { + int i = method_compare_narrow(a, b); + if (i != 0) return i; + return ( a < b ? -1 : (a == b ? 0 : 1)); + } + typedef int (*compareFn)(const void*, const void*); } @@ -1166,7 +1180,7 @@ // 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++) { @@ -1182,10 +1196,10 @@ 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); + compareFn compare = + (UseCompressedOops ? + (compareFn) (idempotent ? method_compare_narrow_idempotent : method_compare_narrow): + (compareFn) (idempotent ? method_compare_idempotent : method_compare)); qsort(methods->base(), length, heapOopSize, compare); }