hotspot/src/share/vm/oops/methodOop.cpp
changeset 10537 23539f11e110
parent 10500 0f9de4fc106e
child 11637 030466036615
equal deleted inserted replaced
10536:28111f5acd64 10537:23539f11e110
  1266   }
  1266   }
  1267 }
  1267 }
  1268 
  1268 
  1269 // Comparer for sorting an object array containing
  1269 // Comparer for sorting an object array containing
  1270 // methodOops.
  1270 // methodOops.
  1271 template <class T>
  1271 // Used non-template method_comparator methods since
  1272 static int method_comparator(T a, T b) {
  1272 // Visual Studio 2003 compiler generates incorrect
       
  1273 // optimized code for it.
       
  1274 static int method_comparator_narrowOop(narrowOop a, narrowOop b) {
  1273   methodOop m = (methodOop)oopDesc::decode_heap_oop_not_null(a);
  1275   methodOop m = (methodOop)oopDesc::decode_heap_oop_not_null(a);
  1274   methodOop n = (methodOop)oopDesc::decode_heap_oop_not_null(b);
  1276   methodOop n = (methodOop)oopDesc::decode_heap_oop_not_null(b);
       
  1277   return m->name()->fast_compare(n->name());
       
  1278 }
       
  1279 static int method_comparator_oop(oop a, oop b) {
       
  1280   methodOop m = (methodOop)a;
       
  1281   methodOop n = (methodOop)b;
  1275   return m->name()->fast_compare(n->name());
  1282   return m->name()->fast_compare(n->name());
  1276 }
  1283 }
  1277 
  1284 
  1278 // This is only done during class loading, so it is OK to assume method_idnum matches the methods() array
  1285 // This is only done during class loading, so it is OK to assume method_idnum matches the methods() array
  1279 void methodOopDesc::sort_methods(objArrayOop methods,
  1286 void methodOopDesc::sort_methods(objArrayOop methods,
  1297       }
  1304       }
  1298     }
  1305     }
  1299     {
  1306     {
  1300       No_Safepoint_Verifier nsv;
  1307       No_Safepoint_Verifier nsv;
  1301       if (UseCompressedOops) {
  1308       if (UseCompressedOops) {
  1302         QuickSort::sort<narrowOop>((narrowOop*)(methods->base()), length, method_comparator<narrowOop>, idempotent);
  1309         QuickSort::sort<narrowOop>((narrowOop*)(methods->base()), length, method_comparator_narrowOop, idempotent);
  1303       } else {
  1310       } else {
  1304         QuickSort::sort<oop>((oop*)(methods->base()), length, method_comparator<oop>, idempotent);
  1311         QuickSort::sort<oop>((oop*)(methods->base()), length, method_comparator_oop, idempotent);
  1305       }
  1312       }
  1306       if (UseConcMarkSweepGC) {
  1313       if (UseConcMarkSweepGC) {
  1307         // For CMS we need to dirty the cards for the array
  1314         // For CMS we need to dirty the cards for the array
  1308         BarrierSet* bs = Universe::heap()->barrier_set();
  1315         BarrierSet* bs = Universe::heap()->barrier_set();
  1309         assert(bs->has_write_ref_array_opt(), "Barrier set must have ref array opt");
  1316         assert(bs->has_write_ref_array_opt(), "Barrier set must have ref array opt");