< prev index next >
src/share/vm/gc/g1/g1CollectionSet.cpp
Print this page
rev 11942 : imported patch 8165313-sort-collection-set-at-end
rev 11943 : [mq]: 8165313-mikael-review1
@@ -30,10 +30,11 @@
#include "gc/g1/heapRegion.inline.hpp"
#include "gc/g1/heapRegionRemSet.hpp"
#include "gc/g1/heapRegionSet.hpp"
#include "logging/logStream.hpp"
#include "utilities/debug.hpp"
+#include "utilities/quickSort.hpp"
G1CollectorState* G1CollectionSet::collector_state() {
return _g1->collector_state();
}
@@ -394,16 +395,15 @@
phase_times()->record_young_cset_choice_time_ms((young_end_time_sec - young_start_time_sec) * 1000.0);
return time_remaining_ms;
}
-static int compare_region_idx(const void *a, const void*b) {
- uint const first = *(uint*)a;
- uint const second = *(uint*)b;
- assert(first != second, "Two regions with the same index %u in the collection set", first);
- if (first > second) {
+static int compare_region_idx(const uint a, const uint b) {
+ if (a > b) {
return 1;
+ } else if (a == b) {
+ return 0;
} else {
return -1;
}
}
@@ -503,11 +503,11 @@
old_region_length(), predicted_old_time_ms, time_remaining_ms);
double non_young_end_time_sec = os::elapsedTime();
phase_times()->record_non_young_cset_choice_time_ms((non_young_end_time_sec - non_young_start_time_sec) * 1000.0);
- qsort(_collection_set_regions, _collection_set_cur_length, sizeof(uint), compare_region_idx);
+ QuickSort::sort<uint>(_collection_set_regions, (int)_collection_set_cur_length, compare_region_idx, true);
}
#ifdef ASSERT
class G1VerifyYoungCSetIndicesClosure : public HeapRegionClosure {
private:
< prev index next >