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