1 /*
2 * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
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 *
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 *
28 #include "logging/logStream.inline.hpp"
29 #include "memory/binaryTreeDictionary.hpp"
30 #include "memory/freeBlockDictionary.hpp"
31 #include "memory/freeList.hpp"
32 #include "memory/metachunk.hpp"
33 #include "memory/resourceArea.hpp"
34 #include "runtime/globals.hpp"
35 #include "utilities/macros.hpp"
36 #include "utilities/ostream.hpp"
37 #if INCLUDE_ALL_GCS
38 #include "gc/cms/adaptiveFreeList.hpp"
39 #include "gc/cms/freeChunk.hpp"
40 #endif // INCLUDE_ALL_GCS
41
42 ////////////////////////////////////////////////////////////////////////////////
43 // A binary tree based search structure for free blocks.
44 // This is currently used in the Concurrent Mark&Sweep implementation.
45 ////////////////////////////////////////////////////////////////////////////////
46
47 template <class Chunk_t, class FreeList_t>
48 size_t TreeChunk<Chunk_t, FreeList_t>::_min_tree_chunk_size = sizeof(TreeChunk<Chunk_t, FreeList_t>)/HeapWordSize;
49
50 template <class Chunk_t, class FreeList_t>
51 TreeChunk<Chunk_t, FreeList_t>* TreeChunk<Chunk_t, FreeList_t>::as_TreeChunk(Chunk_t* fc) {
52 // Do some assertion checking here.
53 return (TreeChunk<Chunk_t, FreeList_t>*) fc;
54 }
55
56 template <class Chunk_t, class FreeList_t>
57 void TreeChunk<Chunk_t, FreeList_t>::verify_tree_chunk_list() const {
58 TreeChunk<Chunk_t, FreeList_t>* nextTC = (TreeChunk<Chunk_t, FreeList_t>*)next();
59 if (prev() != NULL) { // interior list node shouldn't have tree fields
60 guarantee(embedded_list()->parent() == NULL && embedded_list()->left() == NULL &&
61 embedded_list()->right() == NULL, "should be clear");
62 }
63 if (nextTC != NULL) {
64 guarantee(as_TreeChunk(nextTC->prev()) == this, "broken chain");
65 guarantee(nextTC->size() == size(), "wrong size");
66 nextTC->verify_tree_chunk_list();
67 }
68 }
69
70 template <class Chunk_t, class FreeList_t>
|
1 /*
2 * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
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 *
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 *
28 #include "logging/logStream.inline.hpp"
29 #include "memory/binaryTreeDictionary.hpp"
30 #include "memory/freeBlockDictionary.hpp"
31 #include "memory/freeList.hpp"
32 #include "memory/metachunk.hpp"
33 #include "memory/resourceArea.hpp"
34 #include "runtime/globals.hpp"
35 #include "utilities/macros.hpp"
36 #include "utilities/ostream.hpp"
37 #if INCLUDE_ALL_GCS
38 #include "gc/cms/adaptiveFreeList.hpp"
39 #include "gc/cms/freeChunk.hpp"
40 #endif // INCLUDE_ALL_GCS
41
42 ////////////////////////////////////////////////////////////////////////////////
43 // A binary tree based search structure for free blocks.
44 // This is currently used in the Concurrent Mark&Sweep implementation.
45 ////////////////////////////////////////////////////////////////////////////////
46
47 template <class Chunk_t, class FreeList_t>
48 TreeChunk<Chunk_t, FreeList_t>* TreeChunk<Chunk_t, FreeList_t>::as_TreeChunk(Chunk_t* fc) {
49 // Do some assertion checking here.
50 return (TreeChunk<Chunk_t, FreeList_t>*) fc;
51 }
52
53 template <class Chunk_t, class FreeList_t>
54 void TreeChunk<Chunk_t, FreeList_t>::verify_tree_chunk_list() const {
55 TreeChunk<Chunk_t, FreeList_t>* nextTC = (TreeChunk<Chunk_t, FreeList_t>*)next();
56 if (prev() != NULL) { // interior list node shouldn't have tree fields
57 guarantee(embedded_list()->parent() == NULL && embedded_list()->left() == NULL &&
58 embedded_list()->right() == NULL, "should be clear");
59 }
60 if (nextTC != NULL) {
61 guarantee(as_TreeChunk(nextTC->prev()) == this, "broken chain");
62 guarantee(nextTC->size() == size(), "wrong size");
63 nextTC->verify_tree_chunk_list();
64 }
65 }
66
67 template <class Chunk_t, class FreeList_t>
|