--- a/hotspot/src/share/vm/memory/freeList.hpp Fri Oct 19 11:26:17 2012 -0700
+++ b/hotspot/src/share/vm/memory/freeList.hpp Tue Sep 18 23:35:42 2012 -0700
@@ -40,23 +40,19 @@
// for that implementation.
class Mutex;
-template <class Chunk> class TreeList;
-template <class Chunk> class PrintTreeCensusClosure;
-template <class Chunk>
+template <class Chunk_t>
class FreeList VALUE_OBJ_CLASS_SPEC {
friend class CompactibleFreeListSpace;
friend class VMStructs;
- friend class PrintTreeCensusClosure<Chunk>;
private:
- Chunk* _head; // Head of list of free chunks
- Chunk* _tail; // Tail of list of free chunks
+ Chunk_t* _head; // Head of list of free chunks
+ Chunk_t* _tail; // Tail of list of free chunks
size_t _size; // Size in Heap words of each chunk
ssize_t _count; // Number of entries in list
- size_t _hint; // next larger size list with a positive surplus
- AllocationStats _allocation_stats; // allocation-related statistics
+ protected:
#ifdef ASSERT
Mutex* _protecting_lock;
@@ -71,10 +67,6 @@
#endif
}
- // Initialize the allocation statistics.
- protected:
- void init_statistics(bool split_birth = false);
- void set_count(ssize_t v) { _count = v;}
void increment_count() {
_count++;
}
@@ -89,52 +81,48 @@
// Construct a list without any entries.
FreeList();
// Construct a list with "fc" as the first (and lone) entry in the list.
- FreeList(Chunk* fc);
+ FreeList(Chunk_t* fc);
- // Reset the head, tail, hint, and count of a free list.
- void reset(size_t hint);
+ // Do initialization
+ void initialize();
+
+ // Reset the head, tail, and count of a free list.
+ void reset();
// Declare the current free list to be protected by the given lock.
#ifdef ASSERT
- void set_protecting_lock(Mutex* protecting_lock) {
- _protecting_lock = protecting_lock;
+ Mutex* protecting_lock() const { return _protecting_lock; }
+ void set_protecting_lock(Mutex* v) {
+ _protecting_lock = v;
}
#endif
// Accessors.
- Chunk* head() const {
+ Chunk_t* head() const {
assert_proper_lock_protection();
return _head;
}
- void set_head(Chunk* v) {
+ void set_head(Chunk_t* v) {
assert_proper_lock_protection();
_head = v;
assert(!_head || _head->size() == _size, "bad chunk size");
}
// Set the head of the list and set the prev field of non-null
// values to NULL.
- void link_head(Chunk* v) {
- assert_proper_lock_protection();
- set_head(v);
- // If this method is not used (just set the head instead),
- // this check can be avoided.
- if (v != NULL) {
- v->link_prev(NULL);
- }
- }
+ void link_head(Chunk_t* v);
- Chunk* tail() const {
+ Chunk_t* tail() const {
assert_proper_lock_protection();
return _tail;
}
- void set_tail(Chunk* v) {
+ void set_tail(Chunk_t* v) {
assert_proper_lock_protection();
_tail = v;
assert(!_tail || _tail->size() == _size, "bad chunk size");
}
// Set the tail of the list and set the next field of non-null
// values to NULL.
- void link_tail(Chunk* v) {
+ void link_tail(Chunk_t* v) {
assert_proper_lock_protection();
set_tail(v);
if (v != NULL) {
@@ -152,174 +140,45 @@
assert_proper_lock_protection();
_size = v;
}
- ssize_t count() const {
- return _count;
- }
- size_t hint() const {
- return _hint;
- }
- void set_hint(size_t v) {
- assert_proper_lock_protection();
- assert(v == 0 || _size < v, "Bad hint"); _hint = v;
- }
-
- // Accessors for statistics
- AllocationStats* allocation_stats() {
- assert_proper_lock_protection();
- return &_allocation_stats;
- }
-
- ssize_t desired() const {
- return _allocation_stats.desired();
- }
- void set_desired(ssize_t v) {
- assert_proper_lock_protection();
- _allocation_stats.set_desired(v);
- }
- void compute_desired(float inter_sweep_current,
- float inter_sweep_estimate,
- float intra_sweep_estimate) {
- assert_proper_lock_protection();
- _allocation_stats.compute_desired(_count,
- inter_sweep_current,
- inter_sweep_estimate,
- intra_sweep_estimate);
- }
- ssize_t coal_desired() const {
- return _allocation_stats.coal_desired();
- }
- void set_coal_desired(ssize_t v) {
- assert_proper_lock_protection();
- _allocation_stats.set_coal_desired(v);
- }
-
- ssize_t surplus() const {
- return _allocation_stats.surplus();
- }
- void set_surplus(ssize_t v) {
- assert_proper_lock_protection();
- _allocation_stats.set_surplus(v);
- }
- void increment_surplus() {
- assert_proper_lock_protection();
- _allocation_stats.increment_surplus();
- }
- void decrement_surplus() {
- assert_proper_lock_protection();
- _allocation_stats.decrement_surplus();
- }
+ ssize_t count() const { return _count; }
+ void set_count(ssize_t v) { _count = v;}
- ssize_t bfr_surp() const {
- return _allocation_stats.bfr_surp();
- }
- void set_bfr_surp(ssize_t v) {
- assert_proper_lock_protection();
- _allocation_stats.set_bfr_surp(v);
- }
- ssize_t prev_sweep() const {
- return _allocation_stats.prev_sweep();
- }
- void set_prev_sweep(ssize_t v) {
- assert_proper_lock_protection();
- _allocation_stats.set_prev_sweep(v);
- }
- ssize_t before_sweep() const {
- return _allocation_stats.before_sweep();
- }
- void set_before_sweep(ssize_t v) {
- assert_proper_lock_protection();
- _allocation_stats.set_before_sweep(v);
- }
-
- ssize_t coal_births() const {
- return _allocation_stats.coal_births();
- }
- void set_coal_births(ssize_t v) {
- assert_proper_lock_protection();
- _allocation_stats.set_coal_births(v);
- }
- void increment_coal_births() {
- assert_proper_lock_protection();
- _allocation_stats.increment_coal_births();
- }
+ size_t get_better_size() { return size(); }
- ssize_t coal_deaths() const {
- return _allocation_stats.coal_deaths();
- }
- void set_coal_deaths(ssize_t v) {
- assert_proper_lock_protection();
- _allocation_stats.set_coal_deaths(v);
- }
- void increment_coal_deaths() {
- assert_proper_lock_protection();
- _allocation_stats.increment_coal_deaths();
- }
-
- ssize_t split_births() const {
- return _allocation_stats.split_births();
- }
- void set_split_births(ssize_t v) {
- assert_proper_lock_protection();
- _allocation_stats.set_split_births(v);
- }
- void increment_split_births() {
- assert_proper_lock_protection();
- _allocation_stats.increment_split_births();
- }
-
- ssize_t split_deaths() const {
- return _allocation_stats.split_deaths();
- }
- void set_split_deaths(ssize_t v) {
- assert_proper_lock_protection();
- _allocation_stats.set_split_deaths(v);
- }
- void increment_split_deaths() {
- assert_proper_lock_protection();
- _allocation_stats.increment_split_deaths();
- }
-
- NOT_PRODUCT(
- // For debugging. The "_returned_bytes" in all the lists are summed
- // and compared with the total number of bytes swept during a
- // collection.
- size_t returned_bytes() const { return _allocation_stats.returned_bytes(); }
- void set_returned_bytes(size_t v) { _allocation_stats.set_returned_bytes(v); }
- void increment_returned_bytes_by(size_t v) {
- _allocation_stats.set_returned_bytes(_allocation_stats.returned_bytes() + v);
- }
- )
+ size_t returned_bytes() const { ShouldNotReachHere(); return 0; }
+ void set_returned_bytes(size_t v) {}
+ void increment_returned_bytes_by(size_t v) {}
// Unlink head of list and return it. Returns NULL if
// the list is empty.
- Chunk* get_chunk_at_head();
+ Chunk_t* get_chunk_at_head();
// Remove the first "n" or "count", whichever is smaller, chunks from the
// list, setting "fl", which is required to be empty, to point to them.
- void getFirstNChunksFromList(size_t n, FreeList<Chunk>* fl);
+ void getFirstNChunksFromList(size_t n, FreeList<Chunk_t>* fl);
// Unlink this chunk from it's free list
- void remove_chunk(Chunk* fc);
+ void remove_chunk(Chunk_t* fc);
// Add this chunk to this free list.
- void return_chunk_at_head(Chunk* fc);
- void return_chunk_at_tail(Chunk* fc);
+ void return_chunk_at_head(Chunk_t* fc);
+ void return_chunk_at_tail(Chunk_t* fc);
// Similar to returnChunk* but also records some diagnostic
// information.
- void return_chunk_at_head(Chunk* fc, bool record_return);
- void return_chunk_at_tail(Chunk* fc, bool record_return);
+ void return_chunk_at_head(Chunk_t* fc, bool record_return);
+ void return_chunk_at_tail(Chunk_t* fc, bool record_return);
// Prepend "fl" (whose size is required to be the same as that of "this")
// to the front of "this" list.
- void prepend(FreeList<Chunk>* fl);
+ void prepend(FreeList<Chunk_t>* fl);
// Verify that the chunk is in the list.
// found. Return NULL if "fc" is not found.
- bool verify_chunk_in_free_list(Chunk* fc) const;
+ bool verify_chunk_in_free_list(Chunk_t* fc) const;
// Stats verification
- void verify_stats() const PRODUCT_RETURN;
+// void verify_stats() const { ShouldNotReachHere(); };
// Printing support
static void print_labels_on(outputStream* st, const char* c);