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