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 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_VM_MEMORY_BINARYTREEDICTIONARY_INLINE_HPP
26 #define SHARE_VM_MEMORY_BINARYTREEDICTIONARY_INLINE_HPP
27
28 #include "gc/shared/spaceDecorator.hpp"
29 #include "logging/log.hpp"
30 #include "logging/logStream.hpp"
31 #include "memory/binaryTreeDictionary.hpp"
32 #include "memory/freeList.inline.hpp"
33 #include "memory/metachunk.hpp"
34 #include "memory/resourceArea.hpp"
35 #include "runtime/globals.hpp"
36 #include "utilities/macros.hpp"
37 #include "utilities/ostream.hpp"
38
39 ////////////////////////////////////////////////////////////////////////////////
40 // A binary tree based search structure for free blocks.
41 // This is currently used in the Concurrent Mark&Sweep implementation.
42 ////////////////////////////////////////////////////////////////////////////////
43
44 template <class Chunk_t, class FreeList_t>
45 TreeChunk<Chunk_t, FreeList_t>* TreeChunk<Chunk_t, FreeList_t>::as_TreeChunk(Chunk_t* fc) {
46 // Do some assertion checking here.
47 return (TreeChunk<Chunk_t, FreeList_t>*) fc;
48 }
49
50 template <class Chunk_t, class FreeList_t>
51 void TreeChunk<Chunk_t, FreeList_t>::verify_tree_chunk_list() const {
52 TreeChunk<Chunk_t, FreeList_t>* nextTC = (TreeChunk<Chunk_t, FreeList_t>*)next();
53 if (prev() != NULL) { // interior list node shouldn't have tree fields
54 guarantee(embedded_list()->parent() == NULL && embedded_list()->left() == NULL &&
1003 guarantee(tl->head() == NULL || tl->head()->is_free(), "!Free");
1004 guarantee(tl->head() == NULL || tl->head_as_TreeChunk()->list() == tl,
1005 "list inconsistency");
1006 guarantee(tl->count() > 0 || (tl->head() == NULL && tl->tail() == NULL),
1007 "list count is inconsistent");
1008 guarantee(tl->count() > 1 || tl->head() == tl->tail(),
1009 "list is incorrectly constructed");
1010 size_t count = verify_prev_free_ptrs(tl);
1011 guarantee(count == (size_t)tl->count(), "Node count is incorrect");
1012 if (tl->head() != NULL) {
1013 tl->head_as_TreeChunk()->verify_tree_chunk_list();
1014 }
1015 verify_tree_helper(tl->left());
1016 verify_tree_helper(tl->right());
1017 }
1018
1019 template <class Chunk_t, class FreeList_t>
1020 void BinaryTreeDictionary<Chunk_t, FreeList_t>::verify() const {
1021 verify_tree();
1022 guarantee(total_size() == total_size_in_tree(root()), "Total Size inconsistency");
1023 }
1024
1025 #endif // SHARE_VM_MEMORY_BINARYTREEDICTIONARY_INLINE_HPP
|
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 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_VM_MEMORY_BINARYTREEDICTIONARY_INLINE_HPP
26 #define SHARE_VM_MEMORY_BINARYTREEDICTIONARY_INLINE_HPP
27
28 #include "gc/shared/spaceDecorator.hpp"
29 #include "logging/log.hpp"
30 #include "logging/logStream.hpp"
31 #include "memory/binaryTreeDictionary.hpp"
32 #include "memory/freeList.inline.hpp"
33 #include "memory/resourceArea.hpp"
34 #include "runtime/mutex.hpp"
35 #include "runtime/globals.hpp"
36 #include "utilities/macros.hpp"
37 #include "utilities/ostream.hpp"
38
39 ////////////////////////////////////////////////////////////////////////////////
40 // A binary tree based search structure for free blocks.
41 // This is currently used in the Concurrent Mark&Sweep implementation.
42 ////////////////////////////////////////////////////////////////////////////////
43
44 template <class Chunk_t, class FreeList_t>
45 TreeChunk<Chunk_t, FreeList_t>* TreeChunk<Chunk_t, FreeList_t>::as_TreeChunk(Chunk_t* fc) {
46 // Do some assertion checking here.
47 return (TreeChunk<Chunk_t, FreeList_t>*) fc;
48 }
49
50 template <class Chunk_t, class FreeList_t>
51 void TreeChunk<Chunk_t, FreeList_t>::verify_tree_chunk_list() const {
52 TreeChunk<Chunk_t, FreeList_t>* nextTC = (TreeChunk<Chunk_t, FreeList_t>*)next();
53 if (prev() != NULL) { // interior list node shouldn't have tree fields
54 guarantee(embedded_list()->parent() == NULL && embedded_list()->left() == NULL &&
1003 guarantee(tl->head() == NULL || tl->head()->is_free(), "!Free");
1004 guarantee(tl->head() == NULL || tl->head_as_TreeChunk()->list() == tl,
1005 "list inconsistency");
1006 guarantee(tl->count() > 0 || (tl->head() == NULL && tl->tail() == NULL),
1007 "list count is inconsistent");
1008 guarantee(tl->count() > 1 || tl->head() == tl->tail(),
1009 "list is incorrectly constructed");
1010 size_t count = verify_prev_free_ptrs(tl);
1011 guarantee(count == (size_t)tl->count(), "Node count is incorrect");
1012 if (tl->head() != NULL) {
1013 tl->head_as_TreeChunk()->verify_tree_chunk_list();
1014 }
1015 verify_tree_helper(tl->left());
1016 verify_tree_helper(tl->right());
1017 }
1018
1019 template <class Chunk_t, class FreeList_t>
1020 void BinaryTreeDictionary<Chunk_t, FreeList_t>::verify() const {
1021 verify_tree();
1022 guarantee(total_size() == total_size_in_tree(root()), "Total Size inconsistency");
1023 }
1024
1025 template <class Chunk_t, class FreeList_t>
1026 size_t BinaryTreeDictionary<Chunk_t, FreeList_t>::total_chunk_size(debug_only(const Mutex* lock)) const {
1027 debug_only(
1028 if (lock != NULL && lock->owned_by_self()) {
1029 assert(total_size_in_tree(root()) == total_size(),
1030 "_total_size inconsistency");
1031 }
1032 )
1033 return total_size();
1034 }
1035
1036 #endif // SHARE_VM_MEMORY_BINARYTREEDICTIONARY_INLINE_HPP
|