Mercurial > hg > truffle
comparison src/share/vm/memory/binaryTreeDictionary.hpp @ 14518:d8041d695d19
Merged with jdk9/dev/hotspot changeset 3812c088b945
author | twisti |
---|---|
date | Tue, 11 Mar 2014 18:45:59 -0700 |
parents | aa8fab3bed11 |
children | 4ca6dc0799b6 |
comparison
equal
deleted
inserted
replaced
14141:f97c5ec83832 | 14518:d8041d695d19 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 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 | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
35 */ | 35 */ |
36 | 36 |
37 // A TreeList is a FreeList which can be used to maintain a | 37 // A TreeList is a FreeList which can be used to maintain a |
38 // binary tree of free lists. | 38 // binary tree of free lists. |
39 | 39 |
40 template <class Chunk_t, template <class> class FreeList_t> class TreeChunk; | 40 template <class Chunk_t, class FreeList_t> class TreeChunk; |
41 template <class Chunk_t, template <class> class FreeList_t> class BinaryTreeDictionary; | 41 template <class Chunk_t, class FreeList_t> class BinaryTreeDictionary; |
42 template <class Chunk_t, template <class> class FreeList_t> class AscendTreeCensusClosure; | 42 template <class Chunk_t, class FreeList_t> class AscendTreeCensusClosure; |
43 template <class Chunk_t, template <class> class FreeList_t> class DescendTreeCensusClosure; | 43 template <class Chunk_t, class FreeList_t> class DescendTreeCensusClosure; |
44 template <class Chunk_t, template <class> class FreeList_t> class DescendTreeSearchClosure; | 44 template <class Chunk_t, class FreeList_t> class DescendTreeSearchClosure; |
45 | 45 |
46 class FreeChunk; | 46 class FreeChunk; |
47 template <class> class AdaptiveFreeList; | 47 template <class> class AdaptiveFreeList; |
48 typedef BinaryTreeDictionary<FreeChunk, AdaptiveFreeList> AFLBinaryTreeDictionary; | 48 typedef BinaryTreeDictionary<FreeChunk, AdaptiveFreeList<FreeChunk> > AFLBinaryTreeDictionary; |
49 | 49 |
50 template <class Chunk_t, template <class> class FreeList_t> | 50 template <class Chunk_t, class FreeList_t> |
51 class TreeList : public FreeList_t<Chunk_t> { | 51 class TreeList : public FreeList_t { |
52 friend class TreeChunk<Chunk_t, FreeList_t>; | 52 friend class TreeChunk<Chunk_t, FreeList_t>; |
53 friend class BinaryTreeDictionary<Chunk_t, FreeList_t>; | 53 friend class BinaryTreeDictionary<Chunk_t, FreeList_t>; |
54 friend class AscendTreeCensusClosure<Chunk_t, FreeList_t>; | 54 friend class AscendTreeCensusClosure<Chunk_t, FreeList_t>; |
55 friend class DescendTreeCensusClosure<Chunk_t, FreeList_t>; | 55 friend class DescendTreeCensusClosure<Chunk_t, FreeList_t>; |
56 friend class DescendTreeSearchClosure<Chunk_t, FreeList_t>; | 56 friend class DescendTreeSearchClosure<Chunk_t, FreeList_t>; |
64 TreeList<Chunk_t, FreeList_t>* parent() const { return _parent; } | 64 TreeList<Chunk_t, FreeList_t>* parent() const { return _parent; } |
65 TreeList<Chunk_t, FreeList_t>* left() const { return _left; } | 65 TreeList<Chunk_t, FreeList_t>* left() const { return _left; } |
66 TreeList<Chunk_t, FreeList_t>* right() const { return _right; } | 66 TreeList<Chunk_t, FreeList_t>* right() const { return _right; } |
67 | 67 |
68 // Wrapper on call to base class, to get the template to compile. | 68 // Wrapper on call to base class, to get the template to compile. |
69 Chunk_t* head() const { return FreeList_t<Chunk_t>::head(); } | 69 Chunk_t* head() const { return FreeList_t::head(); } |
70 Chunk_t* tail() const { return FreeList_t<Chunk_t>::tail(); } | 70 Chunk_t* tail() const { return FreeList_t::tail(); } |
71 void set_head(Chunk_t* head) { FreeList_t<Chunk_t>::set_head(head); } | 71 void set_head(Chunk_t* head) { FreeList_t::set_head(head); } |
72 void set_tail(Chunk_t* tail) { FreeList_t<Chunk_t>::set_tail(tail); } | 72 void set_tail(Chunk_t* tail) { FreeList_t::set_tail(tail); } |
73 | 73 |
74 size_t size() const { return FreeList_t<Chunk_t>::size(); } | 74 size_t size() const { return FreeList_t::size(); } |
75 | 75 |
76 // Accessors for links in tree. | 76 // Accessors for links in tree. |
77 | 77 |
78 void set_left(TreeList<Chunk_t, FreeList_t>* tl) { | 78 void set_left(TreeList<Chunk_t, FreeList_t>* tl) { |
79 _left = tl; | 79 _left = tl; |
88 void set_parent(TreeList<Chunk_t, FreeList_t>* tl) { _parent = tl; } | 88 void set_parent(TreeList<Chunk_t, FreeList_t>* tl) { _parent = tl; } |
89 | 89 |
90 void clear_left() { _left = NULL; } | 90 void clear_left() { _left = NULL; } |
91 void clear_right() { _right = NULL; } | 91 void clear_right() { _right = NULL; } |
92 void clear_parent() { _parent = NULL; } | 92 void clear_parent() { _parent = NULL; } |
93 void initialize() { clear_left(); clear_right(), clear_parent(); FreeList_t<Chunk_t>::initialize(); } | 93 void initialize() { clear_left(); clear_right(), clear_parent(); FreeList_t::initialize(); } |
94 | 94 |
95 // For constructing a TreeList from a Tree chunk or | 95 // For constructing a TreeList from a Tree chunk or |
96 // address and size. | 96 // address and size. |
97 TreeList(); | 97 TreeList(); |
98 static TreeList<Chunk_t, FreeList_t>* | 98 static TreeList<Chunk_t, FreeList_t>* |
137 // the first chunk in the list is distinguished in this fashion | 137 // the first chunk in the list is distinguished in this fashion |
138 // (also is the node in the tree), it is the last chunk to be found | 138 // (also is the node in the tree), it is the last chunk to be found |
139 // on the free list for a node in the tree and is only removed if | 139 // on the free list for a node in the tree and is only removed if |
140 // it is the last chunk on the free list. | 140 // it is the last chunk on the free list. |
141 | 141 |
142 template <class Chunk_t, template <class> class FreeList_t> | 142 template <class Chunk_t, class FreeList_t> |
143 class TreeChunk : public Chunk_t { | 143 class TreeChunk : public Chunk_t { |
144 friend class TreeList<Chunk_t, FreeList_t>; | 144 friend class TreeList<Chunk_t, FreeList_t>; |
145 TreeList<Chunk_t, FreeList_t>* _list; | 145 TreeList<Chunk_t, FreeList_t>* _list; |
146 TreeList<Chunk_t, FreeList_t> _embedded_list; // if non-null, this chunk is on _list | 146 TreeList<Chunk_t, FreeList_t> _embedded_list; // if non-null, this chunk is on _list |
147 | 147 |
171 void verify_tree_chunk_list() const; | 171 void verify_tree_chunk_list() const; |
172 void assert_is_mangled() const; | 172 void assert_is_mangled() const; |
173 }; | 173 }; |
174 | 174 |
175 | 175 |
176 template <class Chunk_t, template <class> class FreeList_t> | 176 template <class Chunk_t, class FreeList_t> |
177 class BinaryTreeDictionary: public FreeBlockDictionary<Chunk_t> { | 177 class BinaryTreeDictionary: public FreeBlockDictionary<Chunk_t> { |
178 friend class VMStructs; | 178 friend class VMStructs; |
179 size_t _total_size; | 179 size_t _total_size; |
180 size_t _total_free_blocks; | 180 size_t _total_free_blocks; |
181 TreeList<Chunk_t, FreeList_t>* _root; | 181 TreeList<Chunk_t, FreeList_t>* _root; |
320 // Accessors for statistics | 320 // Accessors for statistics |
321 void set_tree_surplus(double splitSurplusPercent); | 321 void set_tree_surplus(double splitSurplusPercent); |
322 void set_tree_hints(void); | 322 void set_tree_hints(void); |
323 // Reset statistics for all the lists in the tree. | 323 // Reset statistics for all the lists in the tree. |
324 void clear_tree_census(void); | 324 void clear_tree_census(void); |
325 // Print the statistcis for all the lists in the tree. Also may | 325 // Print the statistics for all the lists in the tree. Also may |
326 // print out summaries. | 326 // print out summaries. |
327 void print_dict_census(void) const; | 327 void print_dict_census(void) const; |
328 void print_free_lists(outputStream* st) const; | 328 void print_free_lists(outputStream* st) const; |
329 | 329 |
330 // For debugging. Returns the sum of the _returned_bytes for | 330 // For debugging. Returns the sum of the _returned_bytes for |