47 }
48
49 template <class Chunk>
50 AdaptiveFreeList<Chunk>::AdaptiveFreeList() : FreeList<Chunk>(), _hint(0) {
51 init_statistics();
52 }
53
54 template <class Chunk>
55 void AdaptiveFreeList<Chunk>::initialize() {
56 FreeList<Chunk>::initialize();
57 set_hint(0);
58 init_statistics(true /* split_birth */);
59 }
60
61 template <class Chunk>
62 void AdaptiveFreeList<Chunk>::reset(size_t hint) {
63 FreeList<Chunk>::reset();
64 set_hint(hint);
65 }
66
67 #ifndef PRODUCT
68 template <class Chunk>
69 void AdaptiveFreeList<Chunk>::assert_proper_lock_protection_work() const {
70 assert(protecting_lock() != NULL, "Don't call this directly");
71 assert(ParallelGCThreads > 0, "Don't call this directly");
72 Thread* thr = Thread::current();
73 if (thr->is_VM_thread() || thr->is_ConcurrentGC_thread()) {
74 // assert that we are holding the freelist lock
75 } else if (thr->is_GC_task_thread()) {
76 assert(protecting_lock()->owned_by_self(), "FreeList RACE DETECTED");
77 } else if (thr->is_Java_thread()) {
78 assert(!SafepointSynchronize::is_at_safepoint(), "Should not be executing");
79 } else {
80 ShouldNotReachHere(); // unaccounted thread type?
81 }
82 }
83 #endif
84 template <class Chunk>
85 void AdaptiveFreeList<Chunk>::init_statistics(bool split_birth) {
86 _allocation_stats.initialize(split_birth);
87 }
88
89 template <class Chunk>
90 size_t AdaptiveFreeList<Chunk>::get_better_size() {
91
92 // A candidate chunk has been found. If it is already under
93 // populated and there is a hinT, REturn the hint(). Else
94 // return the size of this chunk.
95 if (surplus() <= 0) {
96 if (hint() != 0) {
97 return hint();
98 } else {
99 return size();
100 }
101 } else {
102 // This list has a surplus so use it.
103 return size();
|
47 }
48
49 template <class Chunk>
50 AdaptiveFreeList<Chunk>::AdaptiveFreeList() : FreeList<Chunk>(), _hint(0) {
51 init_statistics();
52 }
53
54 template <class Chunk>
55 void AdaptiveFreeList<Chunk>::initialize() {
56 FreeList<Chunk>::initialize();
57 set_hint(0);
58 init_statistics(true /* split_birth */);
59 }
60
61 template <class Chunk>
62 void AdaptiveFreeList<Chunk>::reset(size_t hint) {
63 FreeList<Chunk>::reset();
64 set_hint(hint);
65 }
66
67 template <class Chunk>
68 void AdaptiveFreeList<Chunk>::init_statistics(bool split_birth) {
69 _allocation_stats.initialize(split_birth);
70 }
71
72 template <class Chunk>
73 size_t AdaptiveFreeList<Chunk>::get_better_size() {
74
75 // A candidate chunk has been found. If it is already under
76 // populated and there is a hinT, REturn the hint(). Else
77 // return the size of this chunk.
78 if (surplus() <= 0) {
79 if (hint() != 0) {
80 return hint();
81 } else {
82 return size();
83 }
84 } else {
85 // This list has a surplus so use it.
86 return size();
|