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