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