author | stefank |
Wed, 09 Apr 2014 13:54:32 +0200 | |
changeset 24092 | e274d864545a |
parent 22884 | 5cadaf2c3f32 |
child 24335 | 77c15794239b |
permissions | -rw-r--r-- |
1 | 1 |
/* |
19974
0d2f09f4643c
8024256: Minimal VM build is broken with PCH disabled
dholmes
parents:
15484
diff
changeset
|
2 |
* Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. |
1 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5402
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5402
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5402
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
15482
470d0b0c09f1
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
15086
diff
changeset
|
26 |
#include "utilities/macros.hpp" |
7397 | 27 |
#include "gc_implementation/shared/allocationStats.hpp" |
12507 | 28 |
#include "memory/binaryTreeDictionary.hpp" |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
29 |
#include "memory/freeList.hpp" |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
30 |
#include "memory/freeBlockDictionary.hpp" |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
31 |
#include "memory/metachunk.hpp" |
7397 | 32 |
#include "runtime/globals.hpp" |
33 |
#include "utilities/ostream.hpp" |
|
15482
470d0b0c09f1
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
15086
diff
changeset
|
34 |
#include "utilities/macros.hpp" |
19974
0d2f09f4643c
8024256: Minimal VM build is broken with PCH disabled
dholmes
parents:
15484
diff
changeset
|
35 |
#include "gc_implementation/shared/spaceDecorator.hpp" |
15482
470d0b0c09f1
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
15086
diff
changeset
|
36 |
#if INCLUDE_ALL_GCS |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
37 |
#include "gc_implementation/concurrentMarkSweep/adaptiveFreeList.hpp" |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
38 |
#include "gc_implementation/concurrentMarkSweep/freeChunk.hpp" |
12507 | 39 |
#include "gc_implementation/concurrentMarkSweep/freeChunk.hpp" |
15482
470d0b0c09f1
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
15086
diff
changeset
|
40 |
#endif // INCLUDE_ALL_GCS |
1 | 41 |
|
42 |
//////////////////////////////////////////////////////////////////////////////// |
|
43 |
// A binary tree based search structure for free blocks. |
|
44 |
// This is currently used in the Concurrent Mark&Sweep implementation. |
|
45 |
//////////////////////////////////////////////////////////////////////////////// |
|
46 |
||
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
47 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
48 |
size_t TreeChunk<Chunk_t, FreeList_t>::_min_tree_chunk_size = sizeof(TreeChunk<Chunk_t, FreeList_t>)/HeapWordSize; |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
49 |
|
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
50 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
51 |
TreeChunk<Chunk_t, FreeList_t>* TreeChunk<Chunk_t, FreeList_t>::as_TreeChunk(Chunk_t* fc) { |
1 | 52 |
// Do some assertion checking here. |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
53 |
return (TreeChunk<Chunk_t, FreeList_t>*) fc; |
1 | 54 |
} |
55 |
||
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
56 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
57 |
void TreeChunk<Chunk_t, FreeList_t>::verify_tree_chunk_list() const { |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
58 |
TreeChunk<Chunk_t, FreeList_t>* nextTC = (TreeChunk<Chunk_t, FreeList_t>*)next(); |
22551 | 59 |
if (prev() != NULL) { // interior list node shouldn't have tree fields |
1 | 60 |
guarantee(embedded_list()->parent() == NULL && embedded_list()->left() == NULL && |
61 |
embedded_list()->right() == NULL, "should be clear"); |
|
62 |
} |
|
63 |
if (nextTC != NULL) { |
|
64 |
guarantee(as_TreeChunk(nextTC->prev()) == this, "broken chain"); |
|
65 |
guarantee(nextTC->size() == size(), "wrong size"); |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
66 |
nextTC->verify_tree_chunk_list(); |
1 | 67 |
} |
68 |
} |
|
69 |
||
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
70 |
template <class Chunk_t, class FreeList_t> |
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14581
diff
changeset
|
71 |
TreeList<Chunk_t, FreeList_t>::TreeList() : _parent(NULL), |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14581
diff
changeset
|
72 |
_left(NULL), _right(NULL) {} |
1 | 73 |
|
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
74 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
75 |
TreeList<Chunk_t, FreeList_t>* |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
76 |
TreeList<Chunk_t, FreeList_t>::as_TreeList(TreeChunk<Chunk_t,FreeList_t>* tc) { |
1 | 77 |
// This first free chunk in the list will be the tree list. |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
78 |
assert((tc->size() >= (TreeChunk<Chunk_t, FreeList_t>::min_size())), |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
79 |
"Chunk is too small for a TreeChunk"); |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
80 |
TreeList<Chunk_t, FreeList_t>* tl = tc->embedded_list(); |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
81 |
tl->initialize(); |
1 | 82 |
tc->set_list(tl); |
83 |
tl->set_size(tc->size()); |
|
84 |
tl->link_head(tc); |
|
85 |
tl->link_tail(tc); |
|
86 |
tl->set_count(1); |
|
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14581
diff
changeset
|
87 |
assert(tl->parent() == NULL, "Should be clear"); |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
88 |
return tl; |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
89 |
} |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
90 |
|
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
91 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
92 |
TreeList<Chunk_t, FreeList_t>* |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
93 |
TreeList<Chunk_t, FreeList_t>::as_TreeList(HeapWord* addr, size_t size) { |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
94 |
TreeChunk<Chunk_t, FreeList_t>* tc = (TreeChunk<Chunk_t, FreeList_t>*) addr; |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
95 |
assert((size >= TreeChunk<Chunk_t, FreeList_t>::min_size()), |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
96 |
"Chunk is too small for a TreeChunk"); |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
97 |
// The space will have been mangled initially but |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
98 |
// is not remangled when a Chunk_t is returned to the free list |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
99 |
// (since it is used to maintain the chunk on the free list). |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
100 |
tc->assert_is_mangled(); |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
101 |
tc->set_size(size); |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
102 |
tc->link_prev(NULL); |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
103 |
tc->link_next(NULL); |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
104 |
TreeList<Chunk_t, FreeList_t>* tl = TreeList<Chunk_t, FreeList_t>::as_TreeList(tc); |
1 | 105 |
return tl; |
106 |
} |
|
4574
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
107 |
|
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
108 |
|
15482
470d0b0c09f1
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
15086
diff
changeset
|
109 |
#if INCLUDE_ALL_GCS |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
110 |
// Specialize for AdaptiveFreeList which tries to avoid |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
111 |
// splitting a chunk of a size that is under populated in favor of |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
112 |
// an over populated size. The general get_better_list() just returns |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
113 |
// the current list. |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
114 |
template <> |
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
115 |
TreeList<FreeChunk, AdaptiveFreeList<FreeChunk> >* |
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
116 |
TreeList<FreeChunk, AdaptiveFreeList<FreeChunk> >::get_better_list( |
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
117 |
BinaryTreeDictionary<FreeChunk, ::AdaptiveFreeList<FreeChunk> >* dictionary) { |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
118 |
// A candidate chunk has been found. If it is already under |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
119 |
// populated, get a chunk associated with the hint for this |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
120 |
// chunk. |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
121 |
|
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
122 |
TreeList<FreeChunk, ::AdaptiveFreeList<FreeChunk> >* curTL = this; |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
123 |
if (surplus() <= 0) { |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
124 |
/* Use the hint to find a size with a surplus, and reset the hint. */ |
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
125 |
TreeList<FreeChunk, ::AdaptiveFreeList<FreeChunk> >* hintTL = this; |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
126 |
while (hintTL->hint() != 0) { |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
127 |
assert(hintTL->hint() > hintTL->size(), |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
128 |
"hint points in the wrong direction"); |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
129 |
hintTL = dictionary->find_list(hintTL->hint()); |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
130 |
assert(curTL != hintTL, "Infinite loop"); |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
131 |
if (hintTL == NULL || |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
132 |
hintTL == curTL /* Should not happen but protect against it */ ) { |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
133 |
// No useful hint. Set the hint to NULL and go on. |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
134 |
curTL->set_hint(0); |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
135 |
break; |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
136 |
} |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
137 |
assert(hintTL->size() > curTL->size(), "hint is inconsistent"); |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
138 |
if (hintTL->surplus() > 0) { |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
139 |
// The hint led to a list that has a surplus. Use it. |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
140 |
// Set the hint for the candidate to an overpopulated |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
141 |
// size. |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
142 |
curTL->set_hint(hintTL->size()); |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
143 |
// Change the candidate. |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
144 |
curTL = hintTL; |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
145 |
break; |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
146 |
} |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
147 |
} |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
148 |
} |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
149 |
return curTL; |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
150 |
} |
15482
470d0b0c09f1
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
15086
diff
changeset
|
151 |
#endif // INCLUDE_ALL_GCS |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
152 |
|
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
153 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
154 |
TreeList<Chunk_t, FreeList_t>* |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
155 |
TreeList<Chunk_t, FreeList_t>::get_better_list( |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
156 |
BinaryTreeDictionary<Chunk_t, FreeList_t>* dictionary) { |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
157 |
return this; |
1 | 158 |
} |
159 |
||
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
160 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
161 |
TreeList<Chunk_t, FreeList_t>* TreeList<Chunk_t, FreeList_t>::remove_chunk_replace_if_needed(TreeChunk<Chunk_t, FreeList_t>* tc) { |
1 | 162 |
|
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
163 |
TreeList<Chunk_t, FreeList_t>* retTL = this; |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
164 |
Chunk_t* list = head(); |
1 | 165 |
assert(!list || list != list->next(), "Chunk on list twice"); |
166 |
assert(tc != NULL, "Chunk being removed is NULL"); |
|
167 |
assert(parent() == NULL || this == parent()->left() || |
|
168 |
this == parent()->right(), "list is inconsistent"); |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
169 |
assert(tc->is_free(), "Header is not marked correctly"); |
1 | 170 |
assert(head() == NULL || head()->prev() == NULL, "list invariant"); |
171 |
assert(tail() == NULL || tail()->next() == NULL, "list invariant"); |
|
172 |
||
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
173 |
Chunk_t* prevFC = tc->prev(); |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
174 |
TreeChunk<Chunk_t, FreeList_t>* nextTC = TreeChunk<Chunk_t, FreeList_t>::as_TreeChunk(tc->next()); |
1 | 175 |
assert(list != NULL, "should have at least the target chunk"); |
176 |
||
177 |
// Is this the first item on the list? |
|
178 |
if (tc == list) { |
|
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
179 |
// The "getChunk..." functions for a TreeList<Chunk_t, FreeList_t> will not return the |
1 | 180 |
// first chunk in the list unless it is the last chunk in the list |
181 |
// because the first chunk is also acting as the tree node. |
|
182 |
// When coalescing happens, however, the first chunk in the a tree |
|
183 |
// list can be the start of a free range. Free ranges are removed |
|
184 |
// from the free lists so that they are not available to be |
|
185 |
// allocated when the sweeper yields (giving up the free list lock) |
|
186 |
// to allow mutator activity. If this chunk is the first in the |
|
187 |
// list and is not the last in the list, do the work to copy the |
|
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
188 |
// TreeList<Chunk_t, FreeList_t> from the first chunk to the next chunk and update all |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
189 |
// the TreeList<Chunk_t, FreeList_t> pointers in the chunks in the list. |
1 | 190 |
if (nextTC == NULL) { |
5402
c51fd0c1d005
6888953: some calls to function-like macros are missing semicolons
jcoomes
parents:
4574
diff
changeset
|
191 |
assert(prevFC == NULL, "Not last chunk in the list"); |
1 | 192 |
set_tail(NULL); |
193 |
set_head(NULL); |
|
194 |
} else { |
|
195 |
// copy embedded list. |
|
196 |
nextTC->set_embedded_list(tc->embedded_list()); |
|
197 |
retTL = nextTC->embedded_list(); |
|
198 |
// Fix the pointer to the list in each chunk in the list. |
|
199 |
// This can be slow for a long list. Consider having |
|
200 |
// an option that does not allow the first chunk on the |
|
201 |
// list to be coalesced. |
|
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
202 |
for (TreeChunk<Chunk_t, FreeList_t>* curTC = nextTC; curTC != NULL; |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
203 |
curTC = TreeChunk<Chunk_t, FreeList_t>::as_TreeChunk(curTC->next())) { |
1 | 204 |
curTC->set_list(retTL); |
205 |
} |
|
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
206 |
// Fix the parent to point to the new TreeList<Chunk_t, FreeList_t>. |
1 | 207 |
if (retTL->parent() != NULL) { |
208 |
if (this == retTL->parent()->left()) { |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
209 |
retTL->parent()->set_left(retTL); |
1 | 210 |
} else { |
211 |
assert(this == retTL->parent()->right(), "Parent is incorrect"); |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
212 |
retTL->parent()->set_right(retTL); |
1 | 213 |
} |
214 |
} |
|
215 |
// Fix the children's parent pointers to point to the |
|
216 |
// new list. |
|
217 |
assert(right() == retTL->right(), "Should have been copied"); |
|
218 |
if (retTL->right() != NULL) { |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
219 |
retTL->right()->set_parent(retTL); |
1 | 220 |
} |
221 |
assert(left() == retTL->left(), "Should have been copied"); |
|
222 |
if (retTL->left() != NULL) { |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
223 |
retTL->left()->set_parent(retTL); |
1 | 224 |
} |
225 |
retTL->link_head(nextTC); |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
226 |
assert(nextTC->is_free(), "Should be a free chunk"); |
1 | 227 |
} |
228 |
} else { |
|
229 |
if (nextTC == NULL) { |
|
230 |
// Removing chunk at tail of list |
|
14475
4c094dfbbb99
8003259: NPG: Build with gcc 4.7.2 broken by 7045397
coleenp
parents:
14123
diff
changeset
|
231 |
this->link_tail(prevFC); |
1 | 232 |
} |
233 |
// Chunk is interior to the list |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
234 |
prevFC->link_after(nextTC); |
1 | 235 |
} |
236 |
||
22551 | 237 |
// Below this point the embedded TreeList<Chunk_t, FreeList_t> being used for the |
1 | 238 |
// tree node may have changed. Don't use "this" |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
239 |
// TreeList<Chunk_t, FreeList_t>*. |
1 | 240 |
// chunk should still be a free chunk (bit set in _prev) |
241 |
assert(!retTL->head() || retTL->size() == retTL->head()->size(), |
|
242 |
"Wrong sized chunk in list"); |
|
243 |
debug_only( |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
244 |
tc->link_prev(NULL); |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
245 |
tc->link_next(NULL); |
1 | 246 |
tc->set_list(NULL); |
247 |
bool prev_found = false; |
|
248 |
bool next_found = false; |
|
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
249 |
for (Chunk_t* curFC = retTL->head(); |
1 | 250 |
curFC != NULL; curFC = curFC->next()) { |
251 |
assert(curFC != tc, "Chunk is still in list"); |
|
252 |
if (curFC == prevFC) { |
|
253 |
prev_found = true; |
|
254 |
} |
|
255 |
if (curFC == nextTC) { |
|
256 |
next_found = true; |
|
257 |
} |
|
258 |
} |
|
259 |
assert(prevFC == NULL || prev_found, "Chunk was lost from list"); |
|
260 |
assert(nextTC == NULL || next_found, "Chunk was lost from list"); |
|
261 |
assert(retTL->parent() == NULL || |
|
262 |
retTL == retTL->parent()->left() || |
|
263 |
retTL == retTL->parent()->right(), |
|
264 |
"list is inconsistent"); |
|
265 |
) |
|
266 |
retTL->decrement_count(); |
|
267 |
||
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
268 |
assert(tc->is_free(), "Should still be a free chunk"); |
1 | 269 |
assert(retTL->head() == NULL || retTL->head()->prev() == NULL, |
270 |
"list invariant"); |
|
271 |
assert(retTL->tail() == NULL || retTL->tail()->next() == NULL, |
|
272 |
"list invariant"); |
|
273 |
return retTL; |
|
274 |
} |
|
12507 | 275 |
|
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
276 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
277 |
void TreeList<Chunk_t, FreeList_t>::return_chunk_at_tail(TreeChunk<Chunk_t, FreeList_t>* chunk) { |
1 | 278 |
assert(chunk != NULL, "returning NULL chunk"); |
279 |
assert(chunk->list() == this, "list should be set for chunk"); |
|
280 |
assert(tail() != NULL, "The tree list is embedded in the first chunk"); |
|
281 |
// which means that the list can never be empty. |
|
14581 | 282 |
assert(!this->verify_chunk_in_free_list(chunk), "Double entry"); |
1 | 283 |
assert(head() == NULL || head()->prev() == NULL, "list invariant"); |
284 |
assert(tail() == NULL || tail()->next() == NULL, "list invariant"); |
|
285 |
||
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
286 |
Chunk_t* fc = tail(); |
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
287 |
fc->link_after(chunk); |
14475
4c094dfbbb99
8003259: NPG: Build with gcc 4.7.2 broken by 7045397
coleenp
parents:
14123
diff
changeset
|
288 |
this->link_tail(chunk); |
1 | 289 |
|
290 |
assert(!tail() || size() == tail()->size(), "Wrong sized chunk in list"); |
|
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
291 |
FreeList_t::increment_count(); |
14581 | 292 |
debug_only(this->increment_returned_bytes_by(chunk->size()*sizeof(HeapWord));) |
1 | 293 |
assert(head() == NULL || head()->prev() == NULL, "list invariant"); |
294 |
assert(tail() == NULL || tail()->next() == NULL, "list invariant"); |
|
295 |
} |
|
296 |
||
297 |
// Add this chunk at the head of the list. "At the head of the list" |
|
298 |
// is defined to be after the chunk pointer to by head(). This is |
|
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
299 |
// because the TreeList<Chunk_t, FreeList_t> is embedded in the first TreeChunk<Chunk_t, FreeList_t> in the |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
300 |
// list. See the definition of TreeChunk<Chunk_t, FreeList_t>. |
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
301 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
302 |
void TreeList<Chunk_t, FreeList_t>::return_chunk_at_head(TreeChunk<Chunk_t, FreeList_t>* chunk) { |
1 | 303 |
assert(chunk->list() == this, "list should be set for chunk"); |
304 |
assert(head() != NULL, "The tree list is embedded in the first chunk"); |
|
305 |
assert(chunk != NULL, "returning NULL chunk"); |
|
14581 | 306 |
assert(!this->verify_chunk_in_free_list(chunk), "Double entry"); |
1 | 307 |
assert(head() == NULL || head()->prev() == NULL, "list invariant"); |
308 |
assert(tail() == NULL || tail()->next() == NULL, "list invariant"); |
|
309 |
||
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
310 |
Chunk_t* fc = head()->next(); |
1 | 311 |
if (fc != NULL) { |
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
312 |
chunk->link_after(fc); |
1 | 313 |
} else { |
314 |
assert(tail() == NULL, "List is inconsistent"); |
|
14475
4c094dfbbb99
8003259: NPG: Build with gcc 4.7.2 broken by 7045397
coleenp
parents:
14123
diff
changeset
|
315 |
this->link_tail(chunk); |
1 | 316 |
} |
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
317 |
head()->link_after(chunk); |
1 | 318 |
assert(!head() || size() == head()->size(), "Wrong sized chunk in list"); |
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
319 |
FreeList_t::increment_count(); |
14581 | 320 |
debug_only(this->increment_returned_bytes_by(chunk->size()*sizeof(HeapWord));) |
1 | 321 |
assert(head() == NULL || head()->prev() == NULL, "list invariant"); |
322 |
assert(tail() == NULL || tail()->next() == NULL, "list invariant"); |
|
323 |
} |
|
324 |
||
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
325 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
326 |
void TreeChunk<Chunk_t, FreeList_t>::assert_is_mangled() const { |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
327 |
assert((ZapUnusedHeapArea && |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
328 |
SpaceMangler::is_mangled((HeapWord*) Chunk_t::size_addr()) && |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
329 |
SpaceMangler::is_mangled((HeapWord*) Chunk_t::prev_addr()) && |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
330 |
SpaceMangler::is_mangled((HeapWord*) Chunk_t::next_addr())) || |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
331 |
(size() == 0 && prev() == NULL && next() == NULL), |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
332 |
"Space should be clear or mangled"); |
1 | 333 |
} |
334 |
||
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
335 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
336 |
TreeChunk<Chunk_t, FreeList_t>* TreeList<Chunk_t, FreeList_t>::head_as_TreeChunk() { |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
337 |
assert(head() == NULL || (TreeChunk<Chunk_t, FreeList_t>::as_TreeChunk(head())->list() == this), |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
338 |
"Wrong type of chunk?"); |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
339 |
return TreeChunk<Chunk_t, FreeList_t>::as_TreeChunk(head()); |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
340 |
} |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
341 |
|
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
342 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
343 |
TreeChunk<Chunk_t, FreeList_t>* TreeList<Chunk_t, FreeList_t>::first_available() { |
6447
32cc5cad7fa6
6983930: CMS: Various small cleanups ca September 2010
ysr
parents:
5547
diff
changeset
|
344 |
assert(head() != NULL, "The head of the list cannot be NULL"); |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
345 |
Chunk_t* fc = head()->next(); |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
346 |
TreeChunk<Chunk_t, FreeList_t>* retTC; |
1 | 347 |
if (fc == NULL) { |
348 |
retTC = head_as_TreeChunk(); |
|
349 |
} else { |
|
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
350 |
retTC = TreeChunk<Chunk_t, FreeList_t>::as_TreeChunk(fc); |
1 | 351 |
} |
352 |
assert(retTC->list() == this, "Wrong type of chunk."); |
|
353 |
return retTC; |
|
354 |
} |
|
355 |
||
4574
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
356 |
// Returns the block with the largest heap address amongst |
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
357 |
// those in the list for this size; potentially slow and expensive, |
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
358 |
// use with caution! |
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
359 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
360 |
TreeChunk<Chunk_t, FreeList_t>* TreeList<Chunk_t, FreeList_t>::largest_address() { |
6447
32cc5cad7fa6
6983930: CMS: Various small cleanups ca September 2010
ysr
parents:
5547
diff
changeset
|
361 |
assert(head() != NULL, "The head of the list cannot be NULL"); |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
362 |
Chunk_t* fc = head()->next(); |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
363 |
TreeChunk<Chunk_t, FreeList_t>* retTC; |
4574
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
364 |
if (fc == NULL) { |
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
365 |
retTC = head_as_TreeChunk(); |
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
366 |
} else { |
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
367 |
// walk down the list and return the one with the highest |
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
368 |
// heap address among chunks of this size. |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
369 |
Chunk_t* last = fc; |
4574
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
370 |
while (fc->next() != NULL) { |
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
371 |
if ((HeapWord*)last < (HeapWord*)fc) { |
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
372 |
last = fc; |
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
373 |
} |
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
374 |
fc = fc->next(); |
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
375 |
} |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
376 |
retTC = TreeChunk<Chunk_t, FreeList_t>::as_TreeChunk(last); |
4574
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
377 |
} |
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
378 |
assert(retTC->list() == this, "Wrong type of chunk."); |
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
379 |
return retTC; |
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
380 |
} |
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
381 |
|
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
382 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
383 |
BinaryTreeDictionary<Chunk_t, FreeList_t>::BinaryTreeDictionary(MemRegion mr) { |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
384 |
assert((mr.byte_size() > min_size()), "minimum chunk size"); |
1 | 385 |
|
386 |
reset(mr); |
|
387 |
assert(root()->left() == NULL, "reset check failed"); |
|
388 |
assert(root()->right() == NULL, "reset check failed"); |
|
389 |
assert(root()->head()->next() == NULL, "reset check failed"); |
|
390 |
assert(root()->head()->prev() == NULL, "reset check failed"); |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
391 |
assert(total_size() == root()->size(), "reset check failed"); |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
392 |
assert(total_free_blocks() == 1, "reset check failed"); |
1 | 393 |
} |
394 |
||
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
395 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
396 |
void BinaryTreeDictionary<Chunk_t, FreeList_t>::inc_total_size(size_t inc) { |
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
397 |
_total_size = _total_size + inc; |
1 | 398 |
} |
399 |
||
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
400 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
401 |
void BinaryTreeDictionary<Chunk_t, FreeList_t>::dec_total_size(size_t dec) { |
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
402 |
_total_size = _total_size - dec; |
1 | 403 |
} |
404 |
||
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
405 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
406 |
void BinaryTreeDictionary<Chunk_t, FreeList_t>::reset(MemRegion mr) { |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
407 |
assert((mr.byte_size() > min_size()), "minimum chunk size"); |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
408 |
set_root(TreeList<Chunk_t, FreeList_t>::as_TreeList(mr.start(), mr.word_size())); |
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
409 |
set_total_size(mr.word_size()); |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
410 |
set_total_free_blocks(1); |
1 | 411 |
} |
412 |
||
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
413 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
414 |
void BinaryTreeDictionary<Chunk_t, FreeList_t>::reset(HeapWord* addr, size_t byte_size) { |
1 | 415 |
MemRegion mr(addr, heap_word_size(byte_size)); |
416 |
reset(mr); |
|
417 |
} |
|
418 |
||
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
419 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
420 |
void BinaryTreeDictionary<Chunk_t, FreeList_t>::reset() { |
1 | 421 |
set_root(NULL); |
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
422 |
set_total_size(0); |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
423 |
set_total_free_blocks(0); |
1 | 424 |
} |
425 |
||
426 |
// Get a free block of size at least size from tree, or NULL. |
|
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
427 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
428 |
TreeChunk<Chunk_t, FreeList_t>* |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
429 |
BinaryTreeDictionary<Chunk_t, FreeList_t>::get_chunk_from_tree( |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
430 |
size_t size, |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
431 |
enum FreeBlockDictionary<Chunk_t>::Dither dither) |
1 | 432 |
{ |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
433 |
TreeList<Chunk_t, FreeList_t> *curTL, *prevTL; |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
434 |
TreeChunk<Chunk_t, FreeList_t>* retTC = NULL; |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
435 |
|
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
436 |
assert((size >= min_size()), "minimum chunk size"); |
1 | 437 |
if (FLSVerifyDictionary) { |
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
438 |
verify_tree(); |
1 | 439 |
} |
440 |
// starting at the root, work downwards trying to find match. |
|
441 |
// Remember the last node of size too great or too small. |
|
442 |
for (prevTL = curTL = root(); curTL != NULL;) { |
|
443 |
if (curTL->size() == size) { // exact match |
|
444 |
break; |
|
445 |
} |
|
446 |
prevTL = curTL; |
|
447 |
if (curTL->size() < size) { // proceed to right sub-tree |
|
448 |
curTL = curTL->right(); |
|
449 |
} else { // proceed to left sub-tree |
|
450 |
assert(curTL->size() > size, "size inconsistency"); |
|
451 |
curTL = curTL->left(); |
|
452 |
} |
|
453 |
} |
|
454 |
if (curTL == NULL) { // couldn't find exact match |
|
12507 | 455 |
|
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
456 |
if (dither == FreeBlockDictionary<Chunk_t>::exactly) return NULL; |
12507 | 457 |
|
1 | 458 |
// try and find the next larger size by walking back up the search path |
459 |
for (curTL = prevTL; curTL != NULL;) { |
|
460 |
if (curTL->size() >= size) break; |
|
461 |
else curTL = curTL->parent(); |
|
462 |
} |
|
463 |
assert(curTL == NULL || curTL->count() > 0, |
|
464 |
"An empty list should not be in the tree"); |
|
465 |
} |
|
466 |
if (curTL != NULL) { |
|
467 |
assert(curTL->size() >= size, "size inconsistency"); |
|
468 |
||
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
469 |
curTL = curTL->get_better_list(this); |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
470 |
|
1 | 471 |
retTC = curTL->first_available(); |
472 |
assert((retTC != NULL) && (curTL->count() > 0), |
|
473 |
"A list in the binary tree should not be NULL"); |
|
474 |
assert(retTC->size() >= size, |
|
475 |
"A chunk of the wrong size was found"); |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
476 |
remove_chunk_from_tree(retTC); |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
477 |
assert(retTC->is_free(), "Header is not marked correctly"); |
1 | 478 |
} |
479 |
||
480 |
if (FLSVerifyDictionary) { |
|
481 |
verify(); |
|
482 |
} |
|
483 |
return retTC; |
|
484 |
} |
|
485 |
||
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
486 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
487 |
TreeList<Chunk_t, FreeList_t>* BinaryTreeDictionary<Chunk_t, FreeList_t>::find_list(size_t size) const { |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
488 |
TreeList<Chunk_t, FreeList_t>* curTL; |
1 | 489 |
for (curTL = root(); curTL != NULL;) { |
490 |
if (curTL->size() == size) { // exact match |
|
491 |
break; |
|
492 |
} |
|
493 |
||
494 |
if (curTL->size() < size) { // proceed to right sub-tree |
|
495 |
curTL = curTL->right(); |
|
496 |
} else { // proceed to left sub-tree |
|
497 |
assert(curTL->size() > size, "size inconsistency"); |
|
498 |
curTL = curTL->left(); |
|
499 |
} |
|
500 |
} |
|
501 |
return curTL; |
|
502 |
} |
|
503 |
||
504 |
||
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
505 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
506 |
bool BinaryTreeDictionary<Chunk_t, FreeList_t>::verify_chunk_in_free_list(Chunk_t* tc) const { |
1 | 507 |
size_t size = tc->size(); |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
508 |
TreeList<Chunk_t, FreeList_t>* tl = find_list(size); |
1 | 509 |
if (tl == NULL) { |
510 |
return false; |
|
511 |
} else { |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
512 |
return tl->verify_chunk_in_free_list(tc); |
1 | 513 |
} |
514 |
} |
|
515 |
||
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
516 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
517 |
Chunk_t* BinaryTreeDictionary<Chunk_t, FreeList_t>::find_largest_dict() const { |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
518 |
TreeList<Chunk_t, FreeList_t> *curTL = root(); |
1 | 519 |
if (curTL != NULL) { |
520 |
while(curTL->right() != NULL) curTL = curTL->right(); |
|
4574
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
521 |
return curTL->largest_address(); |
1 | 522 |
} else { |
523 |
return NULL; |
|
524 |
} |
|
525 |
} |
|
526 |
||
527 |
// Remove the current chunk from the tree. If it is not the last |
|
528 |
// chunk in a list on a tree node, just unlink it. |
|
529 |
// If it is the last chunk in the list (the next link is NULL), |
|
530 |
// remove the node and repair the tree. |
|
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
531 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
532 |
TreeChunk<Chunk_t, FreeList_t>* |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
533 |
BinaryTreeDictionary<Chunk_t, FreeList_t>::remove_chunk_from_tree(TreeChunk<Chunk_t, FreeList_t>* tc) { |
1 | 534 |
assert(tc != NULL, "Should not call with a NULL chunk"); |
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
535 |
assert(tc->is_free(), "Header is not marked correctly"); |
1 | 536 |
|
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
537 |
TreeList<Chunk_t, FreeList_t> *newTL, *parentTL; |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
538 |
TreeChunk<Chunk_t, FreeList_t>* retTC; |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
539 |
TreeList<Chunk_t, FreeList_t>* tl = tc->list(); |
1 | 540 |
debug_only( |
541 |
bool removing_only_chunk = false; |
|
542 |
if (tl == _root) { |
|
543 |
if ((_root->left() == NULL) && (_root->right() == NULL)) { |
|
544 |
if (_root->count() == 1) { |
|
545 |
assert(_root->head() == tc, "Should only be this one chunk"); |
|
546 |
removing_only_chunk = true; |
|
547 |
} |
|
548 |
} |
|
549 |
} |
|
550 |
) |
|
551 |
assert(tl != NULL, "List should be set"); |
|
552 |
assert(tl->parent() == NULL || tl == tl->parent()->left() || |
|
553 |
tl == tl->parent()->right(), "list is inconsistent"); |
|
554 |
||
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
555 |
bool complicated_splice = false; |
1 | 556 |
|
557 |
retTC = tc; |
|
558 |
// Removing this chunk can have the side effect of changing the node |
|
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
559 |
// (TreeList<Chunk_t, FreeList_t>*) in the tree. If the node is the root, update it. |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
560 |
TreeList<Chunk_t, FreeList_t>* replacementTL = tl->remove_chunk_replace_if_needed(tc); |
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
561 |
assert(tc->is_free(), "Chunk should still be free"); |
1 | 562 |
assert(replacementTL->parent() == NULL || |
563 |
replacementTL == replacementTL->parent()->left() || |
|
564 |
replacementTL == replacementTL->parent()->right(), |
|
565 |
"list is inconsistent"); |
|
566 |
if (tl == root()) { |
|
567 |
assert(replacementTL->parent() == NULL, "Incorrectly replacing root"); |
|
568 |
set_root(replacementTL); |
|
569 |
} |
|
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
570 |
#ifdef ASSERT |
1 | 571 |
if (tl != replacementTL) { |
572 |
assert(replacementTL->head() != NULL, |
|
573 |
"If the tree list was replaced, it should not be a NULL list"); |
|
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
574 |
TreeList<Chunk_t, FreeList_t>* rhl = replacementTL->head_as_TreeChunk()->list(); |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
575 |
TreeList<Chunk_t, FreeList_t>* rtl = |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
576 |
TreeChunk<Chunk_t, FreeList_t>::as_TreeChunk(replacementTL->tail())->list(); |
1 | 577 |
assert(rhl == replacementTL, "Broken head"); |
578 |
assert(rtl == replacementTL, "Broken tail"); |
|
579 |
assert(replacementTL->size() == tc->size(), "Broken size"); |
|
580 |
} |
|
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
581 |
#endif |
1 | 582 |
|
583 |
// Does the tree need to be repaired? |
|
584 |
if (replacementTL->count() == 0) { |
|
585 |
assert(replacementTL->head() == NULL && |
|
586 |
replacementTL->tail() == NULL, "list count is incorrect"); |
|
587 |
// Find the replacement node for the (soon to be empty) node being removed. |
|
588 |
// if we have a single (or no) child, splice child in our stead |
|
589 |
if (replacementTL->left() == NULL) { |
|
590 |
// left is NULL so pick right. right may also be NULL. |
|
591 |
newTL = replacementTL->right(); |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
592 |
debug_only(replacementTL->clear_right();) |
1 | 593 |
} else if (replacementTL->right() == NULL) { |
594 |
// right is NULL |
|
595 |
newTL = replacementTL->left(); |
|
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
596 |
debug_only(replacementTL->clear_left();) |
1 | 597 |
} else { // we have both children, so, by patriarchal convention, |
598 |
// my replacement is least node in right sub-tree |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
599 |
complicated_splice = true; |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
600 |
newTL = remove_tree_minimum(replacementTL->right()); |
1 | 601 |
assert(newTL != NULL && newTL->left() == NULL && |
602 |
newTL->right() == NULL, "sub-tree minimum exists"); |
|
603 |
} |
|
604 |
// newTL is the replacement for the (soon to be empty) node. |
|
605 |
// newTL may be NULL. |
|
606 |
// should verify; we just cleanly excised our replacement |
|
607 |
if (FLSVerifyDictionary) { |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
608 |
verify_tree(); |
1 | 609 |
} |
610 |
// first make newTL my parent's child |
|
611 |
if ((parentTL = replacementTL->parent()) == NULL) { |
|
612 |
// newTL should be root |
|
613 |
assert(tl == root(), "Incorrectly replacing root"); |
|
614 |
set_root(newTL); |
|
615 |
if (newTL != NULL) { |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
616 |
newTL->clear_parent(); |
1 | 617 |
} |
618 |
} else if (parentTL->right() == replacementTL) { |
|
619 |
// replacementTL is a right child |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
620 |
parentTL->set_right(newTL); |
1 | 621 |
} else { // replacementTL is a left child |
622 |
assert(parentTL->left() == replacementTL, "should be left child"); |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
623 |
parentTL->set_left(newTL); |
1 | 624 |
} |
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
625 |
debug_only(replacementTL->clear_parent();) |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
626 |
if (complicated_splice) { // we need newTL to get replacementTL's |
1 | 627 |
// two children |
628 |
assert(newTL != NULL && |
|
629 |
newTL->left() == NULL && newTL->right() == NULL, |
|
630 |
"newTL should not have encumbrances from the past"); |
|
631 |
// we'd like to assert as below: |
|
632 |
// assert(replacementTL->left() != NULL && replacementTL->right() != NULL, |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
633 |
// "else !complicated_splice"); |
1 | 634 |
// ... however, the above assertion is too strong because we aren't |
635 |
// guaranteed that replacementTL->right() is still NULL. |
|
636 |
// Recall that we removed |
|
637 |
// the right sub-tree minimum from replacementTL. |
|
638 |
// That may well have been its right |
|
639 |
// child! So we'll just assert half of the above: |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
640 |
assert(replacementTL->left() != NULL, "else !complicated_splice"); |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
641 |
newTL->set_left(replacementTL->left()); |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
642 |
newTL->set_right(replacementTL->right()); |
1 | 643 |
debug_only( |
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
644 |
replacementTL->clear_right(); |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
645 |
replacementTL->clear_left(); |
1 | 646 |
) |
647 |
} |
|
648 |
assert(replacementTL->right() == NULL && |
|
649 |
replacementTL->left() == NULL && |
|
650 |
replacementTL->parent() == NULL, |
|
651 |
"delete without encumbrances"); |
|
652 |
} |
|
653 |
||
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
654 |
assert(total_size() >= retTC->size(), "Incorrect total size"); |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
655 |
dec_total_size(retTC->size()); // size book-keeping |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
656 |
assert(total_free_blocks() > 0, "Incorrect total count"); |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
657 |
set_total_free_blocks(total_free_blocks() - 1); |
1 | 658 |
|
659 |
assert(retTC != NULL, "null chunk?"); |
|
660 |
assert(retTC->prev() == NULL && retTC->next() == NULL, |
|
661 |
"should return without encumbrances"); |
|
662 |
if (FLSVerifyDictionary) { |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
663 |
verify_tree(); |
1 | 664 |
} |
665 |
assert(!removing_only_chunk || _root == NULL, "root should be NULL"); |
|
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
666 |
return TreeChunk<Chunk_t, FreeList_t>::as_TreeChunk(retTC); |
1 | 667 |
} |
668 |
||
669 |
// Remove the leftmost node (lm) in the tree and return it. |
|
670 |
// If lm has a right child, link it to the left node of |
|
671 |
// the parent of lm. |
|
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
672 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
673 |
TreeList<Chunk_t, FreeList_t>* BinaryTreeDictionary<Chunk_t, FreeList_t>::remove_tree_minimum(TreeList<Chunk_t, FreeList_t>* tl) { |
1 | 674 |
assert(tl != NULL && tl->parent() != NULL, "really need a proper sub-tree"); |
675 |
// locate the subtree minimum by walking down left branches |
|
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
676 |
TreeList<Chunk_t, FreeList_t>* curTL = tl; |
1 | 677 |
for (; curTL->left() != NULL; curTL = curTL->left()); |
678 |
// obviously curTL now has at most one child, a right child |
|
679 |
if (curTL != root()) { // Should this test just be removed? |
|
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
680 |
TreeList<Chunk_t, FreeList_t>* parentTL = curTL->parent(); |
1 | 681 |
if (parentTL->left() == curTL) { // curTL is a left child |
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
682 |
parentTL->set_left(curTL->right()); |
1 | 683 |
} else { |
684 |
// If the list tl has no left child, then curTL may be |
|
685 |
// the right child of parentTL. |
|
686 |
assert(parentTL->right() == curTL, "should be a right child"); |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
687 |
parentTL->set_right(curTL->right()); |
1 | 688 |
} |
689 |
} else { |
|
690 |
// The only use of this method would not pass the root of the |
|
691 |
// tree (as indicated by the assertion above that the tree list |
|
692 |
// has a parent) but the specification does not explicitly exclude the |
|
22551 | 693 |
// passing of the root so accommodate it. |
1 | 694 |
set_root(NULL); |
695 |
} |
|
696 |
debug_only( |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
697 |
curTL->clear_parent(); // Test if this needs to be cleared |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
698 |
curTL->clear_right(); // recall, above, left child is already null |
1 | 699 |
) |
700 |
// we just excised a (non-root) node, we should still verify all tree invariants |
|
701 |
if (FLSVerifyDictionary) { |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
702 |
verify_tree(); |
1 | 703 |
} |
704 |
return curTL; |
|
705 |
} |
|
706 |
||
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
707 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
708 |
void BinaryTreeDictionary<Chunk_t, FreeList_t>::insert_chunk_in_tree(Chunk_t* fc) { |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
709 |
TreeList<Chunk_t, FreeList_t> *curTL, *prevTL; |
1 | 710 |
size_t size = fc->size(); |
711 |
||
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
712 |
assert((size >= min_size()), |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
713 |
err_msg(SIZE_FORMAT " is too small to be a TreeChunk<Chunk_t, FreeList_t> " SIZE_FORMAT, |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
714 |
size, min_size())); |
1 | 715 |
if (FLSVerifyDictionary) { |
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
716 |
verify_tree(); |
1 | 717 |
} |
718 |
||
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
719 |
fc->clear_next(); |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
720 |
fc->link_prev(NULL); |
1 | 721 |
|
722 |
// work down from the _root, looking for insertion point |
|
723 |
for (prevTL = curTL = root(); curTL != NULL;) { |
|
724 |
if (curTL->size() == size) // exact match |
|
725 |
break; |
|
726 |
prevTL = curTL; |
|
727 |
if (curTL->size() > size) { // follow left branch |
|
728 |
curTL = curTL->left(); |
|
729 |
} else { // follow right branch |
|
730 |
assert(curTL->size() < size, "size inconsistency"); |
|
731 |
curTL = curTL->right(); |
|
732 |
} |
|
733 |
} |
|
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
734 |
TreeChunk<Chunk_t, FreeList_t>* tc = TreeChunk<Chunk_t, FreeList_t>::as_TreeChunk(fc); |
4574
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
735 |
// This chunk is being returned to the binary tree. Its embedded |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
736 |
// TreeList<Chunk_t, FreeList_t> should be unused at this point. |
1 | 737 |
tc->initialize(); |
738 |
if (curTL != NULL) { // exact match |
|
739 |
tc->set_list(curTL); |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
740 |
curTL->return_chunk_at_tail(tc); |
1 | 741 |
} else { // need a new node in tree |
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
742 |
tc->clear_next(); |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
743 |
tc->link_prev(NULL); |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
744 |
TreeList<Chunk_t, FreeList_t>* newTL = TreeList<Chunk_t, FreeList_t>::as_TreeList(tc); |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
745 |
assert(((TreeChunk<Chunk_t, FreeList_t>*)tc)->list() == newTL, |
1 | 746 |
"List was not initialized correctly"); |
747 |
if (prevTL == NULL) { // we are the only tree node |
|
748 |
assert(root() == NULL, "control point invariant"); |
|
749 |
set_root(newTL); |
|
750 |
} else { // insert under prevTL ... |
|
751 |
if (prevTL->size() < size) { // am right child |
|
752 |
assert(prevTL->right() == NULL, "control point invariant"); |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
753 |
prevTL->set_right(newTL); |
1 | 754 |
} else { // am left child |
755 |
assert(prevTL->size() > size && prevTL->left() == NULL, "cpt pt inv"); |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
756 |
prevTL->set_left(newTL); |
1 | 757 |
} |
758 |
} |
|
759 |
} |
|
760 |
assert(tc->list() != NULL, "Tree list should be set"); |
|
761 |
||
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
762 |
inc_total_size(size); |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
763 |
// Method 'total_size_in_tree' walks through the every block in the |
1 | 764 |
// tree, so it can cause significant performance loss if there are |
765 |
// many blocks in the tree |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
766 |
assert(!FLSVerifyDictionary || total_size_in_tree(root()) == total_size(), "_total_size inconsistency"); |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
767 |
set_total_free_blocks(total_free_blocks() + 1); |
1 | 768 |
if (FLSVerifyDictionary) { |
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
769 |
verify_tree(); |
1 | 770 |
} |
771 |
} |
|
772 |
||
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
773 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
774 |
size_t BinaryTreeDictionary<Chunk_t, FreeList_t>::max_chunk_size() const { |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
775 |
FreeBlockDictionary<Chunk_t>::verify_par_locked(); |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
776 |
TreeList<Chunk_t, FreeList_t>* tc = root(); |
1 | 777 |
if (tc == NULL) return 0; |
778 |
for (; tc->right() != NULL; tc = tc->right()); |
|
779 |
return tc->size(); |
|
780 |
} |
|
781 |
||
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
782 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
783 |
size_t BinaryTreeDictionary<Chunk_t, FreeList_t>::total_list_length(TreeList<Chunk_t, FreeList_t>* tl) const { |
1 | 784 |
size_t res; |
785 |
res = tl->count(); |
|
786 |
#ifdef ASSERT |
|
787 |
size_t cnt; |
|
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
788 |
Chunk_t* tc = tl->head(); |
1 | 789 |
for (cnt = 0; tc != NULL; tc = tc->next(), cnt++); |
790 |
assert(res == cnt, "The count is not being maintained correctly"); |
|
791 |
#endif |
|
792 |
return res; |
|
793 |
} |
|
794 |
||
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
795 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
796 |
size_t BinaryTreeDictionary<Chunk_t, FreeList_t>::total_size_in_tree(TreeList<Chunk_t, FreeList_t>* tl) const { |
1 | 797 |
if (tl == NULL) |
798 |
return 0; |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
799 |
return (tl->size() * total_list_length(tl)) + |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
800 |
total_size_in_tree(tl->left()) + |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
801 |
total_size_in_tree(tl->right()); |
1 | 802 |
} |
803 |
||
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
804 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
805 |
double BinaryTreeDictionary<Chunk_t, FreeList_t>::sum_of_squared_block_sizes(TreeList<Chunk_t, FreeList_t>* const tl) const { |
1 | 806 |
if (tl == NULL) { |
807 |
return 0.0; |
|
808 |
} |
|
809 |
double size = (double)(tl->size()); |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
810 |
double curr = size * size * total_list_length(tl); |
1 | 811 |
curr += sum_of_squared_block_sizes(tl->left()); |
812 |
curr += sum_of_squared_block_sizes(tl->right()); |
|
813 |
return curr; |
|
814 |
} |
|
815 |
||
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
816 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
817 |
size_t BinaryTreeDictionary<Chunk_t, FreeList_t>::total_free_blocks_in_tree(TreeList<Chunk_t, FreeList_t>* tl) const { |
1 | 818 |
if (tl == NULL) |
819 |
return 0; |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
820 |
return total_list_length(tl) + |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
821 |
total_free_blocks_in_tree(tl->left()) + |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
822 |
total_free_blocks_in_tree(tl->right()); |
1 | 823 |
} |
824 |
||
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
825 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
826 |
size_t BinaryTreeDictionary<Chunk_t, FreeList_t>::num_free_blocks() const { |
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
827 |
assert(total_free_blocks_in_tree(root()) == total_free_blocks(), |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
828 |
"_total_free_blocks inconsistency"); |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
829 |
return total_free_blocks(); |
1 | 830 |
} |
831 |
||
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
832 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
833 |
size_t BinaryTreeDictionary<Chunk_t, FreeList_t>::tree_height_helper(TreeList<Chunk_t, FreeList_t>* tl) const { |
1 | 834 |
if (tl == NULL) |
835 |
return 0; |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
836 |
return 1 + MAX2(tree_height_helper(tl->left()), |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
837 |
tree_height_helper(tl->right())); |
1 | 838 |
} |
839 |
||
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
840 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
841 |
size_t BinaryTreeDictionary<Chunk_t, FreeList_t>::tree_height() const { |
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
842 |
return tree_height_helper(root()); |
1 | 843 |
} |
844 |
||
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
845 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
846 |
size_t BinaryTreeDictionary<Chunk_t, FreeList_t>::total_nodes_helper(TreeList<Chunk_t, FreeList_t>* tl) const { |
1 | 847 |
if (tl == NULL) { |
848 |
return 0; |
|
849 |
} |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
850 |
return 1 + total_nodes_helper(tl->left()) + |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
851 |
total_nodes_helper(tl->right()); |
1 | 852 |
} |
853 |
||
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
854 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
855 |
size_t BinaryTreeDictionary<Chunk_t, FreeList_t>::total_nodes_in_tree(TreeList<Chunk_t, FreeList_t>* tl) const { |
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
856 |
return total_nodes_helper(root()); |
1 | 857 |
} |
858 |
||
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
859 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
860 |
void BinaryTreeDictionary<Chunk_t, FreeList_t>::dict_census_update(size_t size, bool split, bool birth){} |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
861 |
|
15482
470d0b0c09f1
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
15086
diff
changeset
|
862 |
#if INCLUDE_ALL_GCS |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
863 |
template <> |
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
864 |
void AFLBinaryTreeDictionary::dict_census_update(size_t size, bool split, bool birth) { |
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
865 |
TreeList<FreeChunk, AdaptiveFreeList<FreeChunk> >* nd = find_list(size); |
1 | 866 |
if (nd) { |
867 |
if (split) { |
|
868 |
if (birth) { |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
869 |
nd->increment_split_births(); |
1 | 870 |
nd->increment_surplus(); |
871 |
} else { |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
872 |
nd->increment_split_deaths(); |
1 | 873 |
nd->decrement_surplus(); |
874 |
} |
|
875 |
} else { |
|
876 |
if (birth) { |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
877 |
nd->increment_coal_births(); |
1 | 878 |
nd->increment_surplus(); |
879 |
} else { |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
880 |
nd->increment_coal_deaths(); |
1 | 881 |
nd->decrement_surplus(); |
882 |
} |
|
883 |
} |
|
884 |
} |
|
885 |
// A list for this size may not be found (nd == 0) if |
|
886 |
// This is a death where the appropriate list is now |
|
887 |
// empty and has been removed from the list. |
|
888 |
// This is a birth associated with a LinAB. The chunk |
|
889 |
// for the LinAB is not in the dictionary. |
|
890 |
} |
|
15482
470d0b0c09f1
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
15086
diff
changeset
|
891 |
#endif // INCLUDE_ALL_GCS |
1 | 892 |
|
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
893 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
894 |
bool BinaryTreeDictionary<Chunk_t, FreeList_t>::coal_dict_over_populated(size_t size) { |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
895 |
// For the general type of freelists, encourage coalescing by |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
896 |
// returning true. |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
897 |
return true; |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
898 |
} |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
899 |
|
15482
470d0b0c09f1
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
15086
diff
changeset
|
900 |
#if INCLUDE_ALL_GCS |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
901 |
template <> |
15428
edc310e78c68
8004895: NPG: JMapPermCore test failure caused by warnings about missing field
jmasa
parents:
15086
diff
changeset
|
902 |
bool AFLBinaryTreeDictionary::coal_dict_over_populated(size_t size) { |
4574
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
903 |
if (FLSAlwaysCoalesceLarge) return true; |
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
904 |
|
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
905 |
TreeList<FreeChunk, AdaptiveFreeList<FreeChunk> >* list_of_size = find_list(size); |
1 | 906 |
// None of requested size implies overpopulated. |
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
907 |
return list_of_size == NULL || list_of_size->coal_desired() <= 0 || |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
908 |
list_of_size->count() > list_of_size->coal_desired(); |
1 | 909 |
} |
15482
470d0b0c09f1
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
15086
diff
changeset
|
910 |
#endif // INCLUDE_ALL_GCS |
1 | 911 |
|
912 |
// Closures for walking the binary tree. |
|
913 |
// do_list() walks the free list in a node applying the closure |
|
914 |
// to each free chunk in the list |
|
915 |
// do_tree() walks the nodes in the binary tree applying do_list() |
|
916 |
// to each list at each node. |
|
917 |
||
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
918 |
template <class Chunk_t, class FreeList_t> |
1 | 919 |
class TreeCensusClosure : public StackObj { |
920 |
protected: |
|
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
921 |
virtual void do_list(FreeList_t* fl) = 0; |
1 | 922 |
public: |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
923 |
virtual void do_tree(TreeList<Chunk_t, FreeList_t>* tl) = 0; |
1 | 924 |
}; |
925 |
||
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
926 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
927 |
class AscendTreeCensusClosure : public TreeCensusClosure<Chunk_t, FreeList_t> { |
1 | 928 |
public: |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
929 |
void do_tree(TreeList<Chunk_t, FreeList_t>* tl) { |
1 | 930 |
if (tl != NULL) { |
931 |
do_tree(tl->left()); |
|
14475
4c094dfbbb99
8003259: NPG: Build with gcc 4.7.2 broken by 7045397
coleenp
parents:
14123
diff
changeset
|
932 |
this->do_list(tl); |
1 | 933 |
do_tree(tl->right()); |
934 |
} |
|
935 |
} |
|
936 |
}; |
|
937 |
||
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
938 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
939 |
class DescendTreeCensusClosure : public TreeCensusClosure<Chunk_t, FreeList_t> { |
1 | 940 |
public: |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
941 |
void do_tree(TreeList<Chunk_t, FreeList_t>* tl) { |
1 | 942 |
if (tl != NULL) { |
943 |
do_tree(tl->right()); |
|
14475
4c094dfbbb99
8003259: NPG: Build with gcc 4.7.2 broken by 7045397
coleenp
parents:
14123
diff
changeset
|
944 |
this->do_list(tl); |
1 | 945 |
do_tree(tl->left()); |
946 |
} |
|
947 |
} |
|
948 |
}; |
|
949 |
||
950 |
// For each list in the tree, calculate the desired, desired |
|
951 |
// coalesce, count before sweep, and surplus before sweep. |
|
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
952 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
953 |
class BeginSweepClosure : public AscendTreeCensusClosure<Chunk_t, FreeList_t> { |
1 | 954 |
double _percentage; |
955 |
float _inter_sweep_current; |
|
956 |
float _inter_sweep_estimate; |
|
4574
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
957 |
float _intra_sweep_estimate; |
1 | 958 |
|
959 |
public: |
|
960 |
BeginSweepClosure(double p, float inter_sweep_current, |
|
4574
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
961 |
float inter_sweep_estimate, |
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
962 |
float intra_sweep_estimate) : |
1 | 963 |
_percentage(p), |
964 |
_inter_sweep_current(inter_sweep_current), |
|
4574
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
965 |
_inter_sweep_estimate(inter_sweep_estimate), |
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
966 |
_intra_sweep_estimate(intra_sweep_estimate) { } |
1 | 967 |
|
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
968 |
void do_list(FreeList<Chunk_t>* fl) {} |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
969 |
|
15482
470d0b0c09f1
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
15086
diff
changeset
|
970 |
#if INCLUDE_ALL_GCS |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
971 |
void do_list(AdaptiveFreeList<Chunk_t>* fl) { |
1 | 972 |
double coalSurplusPercent = _percentage; |
4574
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
973 |
fl->compute_desired(_inter_sweep_current, _inter_sweep_estimate, _intra_sweep_estimate); |
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
974 |
fl->set_coal_desired((ssize_t)((double)fl->desired() * coalSurplusPercent)); |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
975 |
fl->set_before_sweep(fl->count()); |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
976 |
fl->set_bfr_surp(fl->surplus()); |
1 | 977 |
} |
15482
470d0b0c09f1
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
15086
diff
changeset
|
978 |
#endif // INCLUDE_ALL_GCS |
1 | 979 |
}; |
980 |
||
981 |
// Used to search the tree until a condition is met. |
|
982 |
// Similar to TreeCensusClosure but searches the |
|
983 |
// tree and returns promptly when found. |
|
984 |
||
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
985 |
template <class Chunk_t, class FreeList_t> |
1 | 986 |
class TreeSearchClosure : public StackObj { |
987 |
protected: |
|
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
988 |
virtual bool do_list(FreeList_t* fl) = 0; |
1 | 989 |
public: |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
990 |
virtual bool do_tree(TreeList<Chunk_t, FreeList_t>* tl) = 0; |
1 | 991 |
}; |
992 |
||
993 |
#if 0 // Don't need this yet but here for symmetry. |
|
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
994 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
995 |
class AscendTreeSearchClosure : public TreeSearchClosure<Chunk_t> { |
1 | 996 |
public: |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
997 |
bool do_tree(TreeList<Chunk_t, FreeList_t>* tl) { |
1 | 998 |
if (tl != NULL) { |
999 |
if (do_tree(tl->left())) return true; |
|
1000 |
if (do_list(tl)) return true; |
|
1001 |
if (do_tree(tl->right())) return true; |
|
1002 |
} |
|
1003 |
return false; |
|
1004 |
} |
|
1005 |
}; |
|
1006 |
#endif |
|
1007 |
||
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
1008 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1009 |
class DescendTreeSearchClosure : public TreeSearchClosure<Chunk_t, FreeList_t> { |
1 | 1010 |
public: |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1011 |
bool do_tree(TreeList<Chunk_t, FreeList_t>* tl) { |
1 | 1012 |
if (tl != NULL) { |
1013 |
if (do_tree(tl->right())) return true; |
|
14475
4c094dfbbb99
8003259: NPG: Build with gcc 4.7.2 broken by 7045397
coleenp
parents:
14123
diff
changeset
|
1014 |
if (this->do_list(tl)) return true; |
1 | 1015 |
if (do_tree(tl->left())) return true; |
1016 |
} |
|
1017 |
return false; |
|
1018 |
} |
|
1019 |
}; |
|
1020 |
||
1021 |
// Searches the tree for a chunk that ends at the |
|
1022 |
// specified address. |
|
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
1023 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1024 |
class EndTreeSearchClosure : public DescendTreeSearchClosure<Chunk_t, FreeList_t> { |
1 | 1025 |
HeapWord* _target; |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1026 |
Chunk_t* _found; |
1 | 1027 |
|
1028 |
public: |
|
1029 |
EndTreeSearchClosure(HeapWord* target) : _target(target), _found(NULL) {} |
|
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
1030 |
bool do_list(FreeList_t* fl) { |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1031 |
Chunk_t* item = fl->head(); |
1 | 1032 |
while (item != NULL) { |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1033 |
if (item->end() == (uintptr_t*) _target) { |
1 | 1034 |
_found = item; |
1035 |
return true; |
|
1036 |
} |
|
1037 |
item = item->next(); |
|
1038 |
} |
|
1039 |
return false; |
|
1040 |
} |
|
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1041 |
Chunk_t* found() { return _found; } |
1 | 1042 |
}; |
1043 |
||
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
1044 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1045 |
Chunk_t* BinaryTreeDictionary<Chunk_t, FreeList_t>::find_chunk_ends_at(HeapWord* target) const { |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1046 |
EndTreeSearchClosure<Chunk_t, FreeList_t> etsc(target); |
1 | 1047 |
bool found_target = etsc.do_tree(root()); |
1048 |
assert(found_target || etsc.found() == NULL, "Consistency check"); |
|
1049 |
assert(!found_target || etsc.found() != NULL, "Consistency check"); |
|
1050 |
return etsc.found(); |
|
1051 |
} |
|
1052 |
||
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
1053 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1054 |
void BinaryTreeDictionary<Chunk_t, FreeList_t>::begin_sweep_dict_census(double coalSurplusPercent, |
4574
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
1055 |
float inter_sweep_current, float inter_sweep_estimate, float intra_sweep_estimate) { |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1056 |
BeginSweepClosure<Chunk_t, FreeList_t> bsc(coalSurplusPercent, inter_sweep_current, |
4574
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
1057 |
inter_sweep_estimate, |
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
1058 |
intra_sweep_estimate); |
1 | 1059 |
bsc.do_tree(root()); |
1060 |
} |
|
1061 |
||
1062 |
// Closures and methods for calculating total bytes returned to the |
|
1063 |
// free lists in the tree. |
|
12507 | 1064 |
#ifndef PRODUCT |
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
1065 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1066 |
class InitializeDictReturnedBytesClosure : public AscendTreeCensusClosure<Chunk_t, FreeList_t> { |
1 | 1067 |
public: |
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
1068 |
void do_list(FreeList_t* fl) { |
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
1069 |
fl->set_returned_bytes(0); |
12507 | 1070 |
} |
1071 |
}; |
|
1 | 1072 |
|
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
1073 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1074 |
void BinaryTreeDictionary<Chunk_t, FreeList_t>::initialize_dict_returned_bytes() { |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1075 |
InitializeDictReturnedBytesClosure<Chunk_t, FreeList_t> idrb; |
12507 | 1076 |
idrb.do_tree(root()); |
1077 |
} |
|
1 | 1078 |
|
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
1079 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1080 |
class ReturnedBytesClosure : public AscendTreeCensusClosure<Chunk_t, FreeList_t> { |
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
1081 |
size_t _dict_returned_bytes; |
12507 | 1082 |
public: |
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
1083 |
ReturnedBytesClosure() { _dict_returned_bytes = 0; } |
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
1084 |
void do_list(FreeList_t* fl) { |
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
1085 |
_dict_returned_bytes += fl->returned_bytes(); |
12507 | 1086 |
} |
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
1087 |
size_t dict_returned_bytes() { return _dict_returned_bytes; } |
12507 | 1088 |
}; |
1 | 1089 |
|
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
1090 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1091 |
size_t BinaryTreeDictionary<Chunk_t, FreeList_t>::sum_dict_returned_bytes() { |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1092 |
ReturnedBytesClosure<Chunk_t, FreeList_t> rbc; |
12507 | 1093 |
rbc.do_tree(root()); |
1 | 1094 |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
1095 |
return rbc.dict_returned_bytes(); |
12507 | 1096 |
} |
1 | 1097 |
|
12507 | 1098 |
// Count the number of entries in the tree. |
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
1099 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1100 |
class treeCountClosure : public DescendTreeCensusClosure<Chunk_t, FreeList_t> { |
12507 | 1101 |
public: |
1102 |
uint count; |
|
1103 |
treeCountClosure(uint c) { count = c; } |
|
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
1104 |
void do_list(FreeList_t* fl) { |
12507 | 1105 |
count++; |
1106 |
} |
|
1107 |
}; |
|
1 | 1108 |
|
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
1109 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1110 |
size_t BinaryTreeDictionary<Chunk_t, FreeList_t>::total_count() { |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1111 |
treeCountClosure<Chunk_t, FreeList_t> ctc(0); |
12507 | 1112 |
ctc.do_tree(root()); |
1113 |
return ctc.count; |
|
1114 |
} |
|
1115 |
#endif // PRODUCT |
|
1 | 1116 |
|
1117 |
// Calculate surpluses for the lists in the tree. |
|
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
1118 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1119 |
class setTreeSurplusClosure : public AscendTreeCensusClosure<Chunk_t, FreeList_t> { |
1 | 1120 |
double percentage; |
1121 |
public: |
|
1122 |
setTreeSurplusClosure(double v) { percentage = v; } |
|
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1123 |
void do_list(FreeList<Chunk_t>* fl) {} |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1124 |
|
15482
470d0b0c09f1
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
15086
diff
changeset
|
1125 |
#if INCLUDE_ALL_GCS |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1126 |
void do_list(AdaptiveFreeList<Chunk_t>* fl) { |
1 | 1127 |
double splitSurplusPercent = percentage; |
1128 |
fl->set_surplus(fl->count() - |
|
1129 |
(ssize_t)((double)fl->desired() * splitSurplusPercent)); |
|
1130 |
} |
|
15482
470d0b0c09f1
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
15086
diff
changeset
|
1131 |
#endif // INCLUDE_ALL_GCS |
1 | 1132 |
}; |
1133 |
||
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
1134 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1135 |
void BinaryTreeDictionary<Chunk_t, FreeList_t>::set_tree_surplus(double splitSurplusPercent) { |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1136 |
setTreeSurplusClosure<Chunk_t, FreeList_t> sts(splitSurplusPercent); |
1 | 1137 |
sts.do_tree(root()); |
1138 |
} |
|
1139 |
||
1140 |
// Set hints for the lists in the tree. |
|
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
1141 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1142 |
class setTreeHintsClosure : public DescendTreeCensusClosure<Chunk_t, FreeList_t> { |
1 | 1143 |
size_t hint; |
1144 |
public: |
|
1145 |
setTreeHintsClosure(size_t v) { hint = v; } |
|
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1146 |
void do_list(FreeList<Chunk_t>* fl) {} |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1147 |
|
15482
470d0b0c09f1
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
15086
diff
changeset
|
1148 |
#if INCLUDE_ALL_GCS |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1149 |
void do_list(AdaptiveFreeList<Chunk_t>* fl) { |
1 | 1150 |
fl->set_hint(hint); |
1151 |
assert(fl->hint() == 0 || fl->hint() > fl->size(), |
|
1152 |
"Current hint is inconsistent"); |
|
1153 |
if (fl->surplus() > 0) { |
|
1154 |
hint = fl->size(); |
|
1155 |
} |
|
1156 |
} |
|
15482
470d0b0c09f1
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
15086
diff
changeset
|
1157 |
#endif // INCLUDE_ALL_GCS |
1 | 1158 |
}; |
1159 |
||
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
1160 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1161 |
void BinaryTreeDictionary<Chunk_t, FreeList_t>::set_tree_hints(void) { |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1162 |
setTreeHintsClosure<Chunk_t, FreeList_t> sth(0); |
1 | 1163 |
sth.do_tree(root()); |
1164 |
} |
|
1165 |
||
1166 |
// Save count before previous sweep and splits and coalesces. |
|
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
1167 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1168 |
class clearTreeCensusClosure : public AscendTreeCensusClosure<Chunk_t, FreeList_t> { |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1169 |
void do_list(FreeList<Chunk_t>* fl) {} |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1170 |
|
15482
470d0b0c09f1
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
15086
diff
changeset
|
1171 |
#if INCLUDE_ALL_GCS |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1172 |
void do_list(AdaptiveFreeList<Chunk_t>* fl) { |
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
1173 |
fl->set_prev_sweep(fl->count()); |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
1174 |
fl->set_coal_births(0); |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
1175 |
fl->set_coal_deaths(0); |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
1176 |
fl->set_split_births(0); |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
1177 |
fl->set_split_deaths(0); |
1 | 1178 |
} |
15482
470d0b0c09f1
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
15086
diff
changeset
|
1179 |
#endif // INCLUDE_ALL_GCS |
1 | 1180 |
}; |
1181 |
||
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
1182 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1183 |
void BinaryTreeDictionary<Chunk_t, FreeList_t>::clear_tree_census(void) { |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1184 |
clearTreeCensusClosure<Chunk_t, FreeList_t> ctc; |
1 | 1185 |
ctc.do_tree(root()); |
1186 |
} |
|
1187 |
||
1188 |
// Do reporting and post sweep clean up. |
|
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
1189 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1190 |
void BinaryTreeDictionary<Chunk_t, FreeList_t>::end_sweep_dict_census(double splitSurplusPercent) { |
1 | 1191 |
// Does walking the tree 3 times hurt? |
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
1192 |
set_tree_surplus(splitSurplusPercent); |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
1193 |
set_tree_hints(); |
1 | 1194 |
if (PrintGC && Verbose) { |
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
1195 |
report_statistics(); |
1 | 1196 |
} |
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
1197 |
clear_tree_census(); |
1 | 1198 |
} |
1199 |
||
1200 |
// Print summary statistics |
|
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
1201 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1202 |
void BinaryTreeDictionary<Chunk_t, FreeList_t>::report_statistics() const { |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1203 |
FreeBlockDictionary<Chunk_t>::verify_par_locked(); |
1 | 1204 |
gclog_or_tty->print("Statistics for BinaryTreeDictionary:\n" |
1205 |
"------------------------------------\n"); |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
1206 |
size_t total_size = total_chunk_size(debug_only(NULL)); |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
1207 |
size_t free_blocks = num_free_blocks(); |
24092
e274d864545a
8039743: Use correct format specifier to print size_t values and pointers in the GC code
stefank
parents:
22884
diff
changeset
|
1208 |
gclog_or_tty->print("Total Free Space: " SIZE_FORMAT "\n", total_size); |
e274d864545a
8039743: Use correct format specifier to print size_t values and pointers in the GC code
stefank
parents:
22884
diff
changeset
|
1209 |
gclog_or_tty->print("Max Chunk Size: " SIZE_FORMAT "\n", max_chunk_size()); |
e274d864545a
8039743: Use correct format specifier to print size_t values and pointers in the GC code
stefank
parents:
22884
diff
changeset
|
1210 |
gclog_or_tty->print("Number of Blocks: " SIZE_FORMAT "\n", free_blocks); |
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
1211 |
if (free_blocks > 0) { |
24092
e274d864545a
8039743: Use correct format specifier to print size_t values and pointers in the GC code
stefank
parents:
22884
diff
changeset
|
1212 |
gclog_or_tty->print("Av. Block Size: " SIZE_FORMAT "\n", total_size/free_blocks); |
1 | 1213 |
} |
24092
e274d864545a
8039743: Use correct format specifier to print size_t values and pointers in the GC code
stefank
parents:
22884
diff
changeset
|
1214 |
gclog_or_tty->print("Tree Height: " SIZE_FORMAT "\n", tree_height()); |
1 | 1215 |
} |
1216 |
||
1217 |
// Print census information - counts, births, deaths, etc. |
|
1218 |
// for each list in the tree. Also print some summary |
|
1219 |
// information. |
|
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
1220 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1221 |
class PrintTreeCensusClosure : public AscendTreeCensusClosure<Chunk_t, FreeList_t> { |
185
cda2a1eb4be5
6668743: CMS: Consolidate block statistics reporting code
ysr
parents:
1
diff
changeset
|
1222 |
int _print_line; |
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
1223 |
size_t _total_free; |
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
1224 |
FreeList_t _total; |
1 | 1225 |
|
1226 |
public: |
|
4574
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
1227 |
PrintTreeCensusClosure() { |
185
cda2a1eb4be5
6668743: CMS: Consolidate block statistics reporting code
ysr
parents:
1
diff
changeset
|
1228 |
_print_line = 0; |
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
1229 |
_total_free = 0; |
1 | 1230 |
} |
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
1231 |
FreeList_t* total() { return &_total; } |
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
1232 |
size_t total_free() { return _total_free; } |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1233 |
void do_list(FreeList<Chunk_t>* fl) { |
185
cda2a1eb4be5
6668743: CMS: Consolidate block statistics reporting code
ysr
parents:
1
diff
changeset
|
1234 |
if (++_print_line >= 40) { |
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
1235 |
FreeList_t::print_labels_on(gclog_or_tty, "size"); |
185
cda2a1eb4be5
6668743: CMS: Consolidate block statistics reporting code
ysr
parents:
1
diff
changeset
|
1236 |
_print_line = 0; |
cda2a1eb4be5
6668743: CMS: Consolidate block statistics reporting code
ysr
parents:
1
diff
changeset
|
1237 |
} |
cda2a1eb4be5
6668743: CMS: Consolidate block statistics reporting code
ysr
parents:
1
diff
changeset
|
1238 |
fl->print_on(gclog_or_tty); |
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
1239 |
_total_free += fl->count() * fl->size() ; |
185
cda2a1eb4be5
6668743: CMS: Consolidate block statistics reporting code
ysr
parents:
1
diff
changeset
|
1240 |
total()->set_count( total()->count() + fl->count() ); |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1241 |
} |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1242 |
|
15482
470d0b0c09f1
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
15086
diff
changeset
|
1243 |
#if INCLUDE_ALL_GCS |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1244 |
void do_list(AdaptiveFreeList<Chunk_t>* fl) { |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1245 |
if (++_print_line >= 40) { |
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
1246 |
FreeList_t::print_labels_on(gclog_or_tty, "size"); |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1247 |
_print_line = 0; |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1248 |
} |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1249 |
fl->print_on(gclog_or_tty); |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1250 |
_total_free += fl->count() * fl->size() ; |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1251 |
total()->set_count( total()->count() + fl->count() ); |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1252 |
total()->set_bfr_surp( total()->bfr_surp() + fl->bfr_surp() ); |
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
1253 |
total()->set_surplus( total()->split_deaths() + fl->surplus() ); |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1254 |
total()->set_desired( total()->desired() + fl->desired() ); |
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
1255 |
total()->set_prev_sweep( total()->prev_sweep() + fl->prev_sweep() ); |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
1256 |
total()->set_before_sweep(total()->before_sweep() + fl->before_sweep()); |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
1257 |
total()->set_coal_births( total()->coal_births() + fl->coal_births() ); |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
1258 |
total()->set_coal_deaths( total()->coal_deaths() + fl->coal_deaths() ); |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
1259 |
total()->set_split_births(total()->split_births() + fl->split_births()); |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
1260 |
total()->set_split_deaths(total()->split_deaths() + fl->split_deaths()); |
1 | 1261 |
} |
15482
470d0b0c09f1
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
15086
diff
changeset
|
1262 |
#endif // INCLUDE_ALL_GCS |
1 | 1263 |
}; |
1264 |
||
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
1265 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1266 |
void BinaryTreeDictionary<Chunk_t, FreeList_t>::print_dict_census(void) const { |
1 | 1267 |
|
1268 |
gclog_or_tty->print("\nBinaryTree\n"); |
|
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
1269 |
FreeList_t::print_labels_on(gclog_or_tty, "size"); |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1270 |
PrintTreeCensusClosure<Chunk_t, FreeList_t> ptc; |
1 | 1271 |
ptc.do_tree(root()); |
1272 |
||
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
1273 |
FreeList_t* total = ptc.total(); |
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
1274 |
FreeList_t::print_labels_on(gclog_or_tty, " "); |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1275 |
} |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1276 |
|
15482
470d0b0c09f1
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
15086
diff
changeset
|
1277 |
#if INCLUDE_ALL_GCS |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1278 |
template <> |
15428
edc310e78c68
8004895: NPG: JMapPermCore test failure caused by warnings about missing field
jmasa
parents:
15086
diff
changeset
|
1279 |
void AFLBinaryTreeDictionary::print_dict_census(void) const { |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1280 |
|
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1281 |
gclog_or_tty->print("\nBinaryTree\n"); |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1282 |
AdaptiveFreeList<FreeChunk>::print_labels_on(gclog_or_tty, "size"); |
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
1283 |
PrintTreeCensusClosure<FreeChunk, AdaptiveFreeList<FreeChunk> > ptc; |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1284 |
ptc.do_tree(root()); |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1285 |
|
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1286 |
AdaptiveFreeList<FreeChunk>* total = ptc.total(); |
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1287 |
AdaptiveFreeList<FreeChunk>::print_labels_on(gclog_or_tty, " "); |
185
cda2a1eb4be5
6668743: CMS: Consolidate block statistics reporting code
ysr
parents:
1
diff
changeset
|
1288 |
total->print_on(gclog_or_tty, "TOTAL\t"); |
1 | 1289 |
gclog_or_tty->print( |
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
1290 |
"total_free(words): " SIZE_FORMAT_W(16) |
185
cda2a1eb4be5
6668743: CMS: Consolidate block statistics reporting code
ysr
parents:
1
diff
changeset
|
1291 |
" growth: %8.5f deficit: %8.5f\n", |
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
1292 |
ptc.total_free(), |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
1293 |
(double)(total->split_births() + total->coal_births() |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
1294 |
- total->split_deaths() - total->coal_deaths()) |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
1295 |
/(total->prev_sweep() != 0 ? (double)total->prev_sweep() : 1.0), |
185
cda2a1eb4be5
6668743: CMS: Consolidate block statistics reporting code
ysr
parents:
1
diff
changeset
|
1296 |
(double)(total->desired() - total->count()) |
cda2a1eb4be5
6668743: CMS: Consolidate block statistics reporting code
ysr
parents:
1
diff
changeset
|
1297 |
/(total->desired() != 0 ? (double)total->desired() : 1.0)); |
1 | 1298 |
} |
15482
470d0b0c09f1
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
15086
diff
changeset
|
1299 |
#endif // INCLUDE_ALL_GCS |
1 | 1300 |
|
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
1301 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1302 |
class PrintFreeListsClosure : public AscendTreeCensusClosure<Chunk_t, FreeList_t> { |
4574
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
1303 |
outputStream* _st; |
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
1304 |
int _print_line; |
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
1305 |
|
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
1306 |
public: |
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
1307 |
PrintFreeListsClosure(outputStream* st) { |
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
1308 |
_st = st; |
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
1309 |
_print_line = 0; |
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
1310 |
} |
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
1311 |
void do_list(FreeList_t* fl) { |
4574
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
1312 |
if (++_print_line >= 40) { |
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
1313 |
FreeList_t::print_labels_on(_st, "size"); |
4574
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
1314 |
_print_line = 0; |
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
1315 |
} |
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
1316 |
fl->print_on(gclog_or_tty); |
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
1317 |
size_t sz = fl->size(); |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1318 |
for (Chunk_t* fc = fl->head(); fc != NULL; |
4574
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
1319 |
fc = fc->next()) { |
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
1320 |
_st->print_cr("\t[" PTR_FORMAT "," PTR_FORMAT ") %s", |
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
1321 |
fc, (HeapWord*)fc + sz, |
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
1322 |
fc->cantCoalesce() ? "\t CC" : ""); |
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
1323 |
} |
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
1324 |
} |
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
1325 |
}; |
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
1326 |
|
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
1327 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1328 |
void BinaryTreeDictionary<Chunk_t, FreeList_t>::print_free_lists(outputStream* st) const { |
4574
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
1329 |
|
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
1330 |
FreeList_t::print_labels_on(st, "size"); |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1331 |
PrintFreeListsClosure<Chunk_t, FreeList_t> pflc(st); |
4574
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
1332 |
pflc.do_tree(root()); |
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
1333 |
} |
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
977
diff
changeset
|
1334 |
|
1 | 1335 |
// Verify the following tree invariants: |
1336 |
// . _root has no parent |
|
1337 |
// . parent and child point to each other |
|
1338 |
// . each node's key correctly related to that of its child(ren) |
|
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
1339 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1340 |
void BinaryTreeDictionary<Chunk_t, FreeList_t>::verify_tree() const { |
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
1341 |
guarantee(root() == NULL || total_free_blocks() == 0 || |
22775 | 1342 |
total_size() != 0, "_total_size shouldn't be 0?"); |
1 | 1343 |
guarantee(root() == NULL || root()->parent() == NULL, "_root shouldn't have parent"); |
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
1344 |
verify_tree_helper(root()); |
1 | 1345 |
} |
1346 |
||
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
1347 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1348 |
size_t BinaryTreeDictionary<Chunk_t, FreeList_t>::verify_prev_free_ptrs(TreeList<Chunk_t, FreeList_t>* tl) { |
1 | 1349 |
size_t ct = 0; |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1350 |
for (Chunk_t* curFC = tl->head(); curFC != NULL; curFC = curFC->next()) { |
1 | 1351 |
ct++; |
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
1352 |
assert(curFC->prev() == NULL || curFC->prev()->is_free(), |
1 | 1353 |
"Chunk should be free"); |
1354 |
} |
|
1355 |
return ct; |
|
1356 |
} |
|
1357 |
||
1358 |
// Note: this helper is recursive rather than iterative, so use with |
|
1359 |
// caution on very deep trees; and watch out for stack overflow errors; |
|
1360 |
// In general, to be used only for debugging. |
|
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
1361 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1362 |
void BinaryTreeDictionary<Chunk_t, FreeList_t>::verify_tree_helper(TreeList<Chunk_t, FreeList_t>* tl) const { |
1 | 1363 |
if (tl == NULL) |
1364 |
return; |
|
1365 |
guarantee(tl->size() != 0, "A list must has a size"); |
|
1366 |
guarantee(tl->left() == NULL || tl->left()->parent() == tl, |
|
1367 |
"parent<-/->left"); |
|
1368 |
guarantee(tl->right() == NULL || tl->right()->parent() == tl, |
|
1369 |
"parent<-/->right");; |
|
1370 |
guarantee(tl->left() == NULL || tl->left()->size() < tl->size(), |
|
1371 |
"parent !> left"); |
|
1372 |
guarantee(tl->right() == NULL || tl->right()->size() > tl->size(), |
|
1373 |
"parent !< left"); |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
1374 |
guarantee(tl->head() == NULL || tl->head()->is_free(), "!Free"); |
1 | 1375 |
guarantee(tl->head() == NULL || tl->head_as_TreeChunk()->list() == tl, |
1376 |
"list inconsistency"); |
|
1377 |
guarantee(tl->count() > 0 || (tl->head() == NULL && tl->tail() == NULL), |
|
1378 |
"list count is inconsistent"); |
|
1379 |
guarantee(tl->count() > 1 || tl->head() == tl->tail(), |
|
1380 |
"list is incorrectly constructed"); |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
1381 |
size_t count = verify_prev_free_ptrs(tl); |
1 | 1382 |
guarantee(count == (size_t)tl->count(), "Node count is incorrect"); |
1383 |
if (tl->head() != NULL) { |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
1384 |
tl->head_as_TreeChunk()->verify_tree_chunk_list(); |
1 | 1385 |
} |
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
1386 |
verify_tree_helper(tl->left()); |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
1387 |
verify_tree_helper(tl->right()); |
1 | 1388 |
} |
1389 |
||
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
1390 |
template <class Chunk_t, class FreeList_t> |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1391 |
void BinaryTreeDictionary<Chunk_t, FreeList_t>::verify() const { |
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
1392 |
verify_tree(); |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
12507
diff
changeset
|
1393 |
guarantee(total_size() == total_size_in_tree(root()), "Total Size inconsistency"); |
1 | 1394 |
} |
12507 | 1395 |
|
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
1396 |
template class TreeList<Metablock, FreeList<Metablock> >; |
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
1397 |
template class BinaryTreeDictionary<Metablock, FreeList<Metablock> >; |
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
1398 |
template class TreeChunk<Metablock, FreeList<Metablock> >; |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1399 |
|
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
1400 |
template class TreeList<Metachunk, FreeList<Metachunk> >; |
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
1401 |
template class BinaryTreeDictionary<Metachunk, FreeList<Metachunk> >; |
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
1402 |
template class TreeChunk<Metachunk, FreeList<Metachunk> >; |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1403 |
|
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1404 |
|
15482
470d0b0c09f1
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
15086
diff
changeset
|
1405 |
#if INCLUDE_ALL_GCS |
12507 | 1406 |
// Explicitly instantiate these types for FreeChunk. |
22884
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
1407 |
template class TreeList<FreeChunk, AdaptiveFreeList<FreeChunk> >; |
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
1408 |
template class BinaryTreeDictionary<FreeChunk, AdaptiveFreeList<FreeChunk> >; |
5cadaf2c3f32
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
22775
diff
changeset
|
1409 |
template class TreeChunk<FreeChunk, AdaptiveFreeList<FreeChunk> >; |
14123
944e56f74fba
7045397: NPG: Add freelists to class loader arenas.
jmasa
parents:
12933
diff
changeset
|
1410 |
|
15482
470d0b0c09f1
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
15086
diff
changeset
|
1411 |
#endif // INCLUDE_ALL_GCS |