1 /*
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.
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 *
146 TreeList<Chunk_t, FreeList_t> _embedded_list; // if non-null, this chunk is on _list
147
148 static size_t _min_tree_chunk_size;
149
150 protected:
151 TreeList<Chunk_t, FreeList_t>* embedded_list() const { return (TreeList<Chunk_t, FreeList_t>*) &_embedded_list; }
152 void set_embedded_list(TreeList<Chunk_t, FreeList_t>* v) { _embedded_list = *v; }
153 public:
154 TreeList<Chunk_t, FreeList_t>* list() { return _list; }
155 void set_list(TreeList<Chunk_t, FreeList_t>* v) { _list = v; }
156 static TreeChunk<Chunk_t, FreeList_t>* as_TreeChunk(Chunk_t* fc);
157 // Initialize fields in a TreeChunk that should be
158 // initialized when the TreeChunk is being added to
159 // a free list in the tree.
160 void initialize() { embedded_list()->initialize(); }
161
162 Chunk_t* next() const { return Chunk_t::next(); }
163 Chunk_t* prev() const { return Chunk_t::prev(); }
164 size_t size() const volatile { return Chunk_t::size(); }
165
166 static size_t min_size() {
167 return _min_tree_chunk_size;
168 }
169
170 // debugging
171 void verify_tree_chunk_list() const;
172 void assert_is_mangled() const;
173 };
174
175
176 template <class Chunk_t, class FreeList_t>
177 class BinaryTreeDictionary: public FreeBlockDictionary<Chunk_t> {
178 friend class VMStructs;
179 size_t _total_size;
180 size_t _total_free_blocks;
181 TreeList<Chunk_t, FreeList_t>* _root;
182
183 // private accessors
184 void set_total_size(size_t v) { _total_size = v; }
185 virtual void inc_total_size(size_t v);
186 virtual void dec_total_size(size_t v);
187 void set_total_free_blocks(size_t v) { _total_free_blocks = v; }
188 TreeList<Chunk_t, FreeList_t>* root() const { return _root; }
189 void set_root(TreeList<Chunk_t, FreeList_t>* v) { _root = v; }
190
191 // This field is added and can be set to point to the
192 // the Mutex used to synchronize access to the
193 // dictionary so that assertion checking can be done.
194 // For example it is set to point to _parDictionaryAllocLock.
|
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 *
146 TreeList<Chunk_t, FreeList_t> _embedded_list; // if non-null, this chunk is on _list
147
148 static size_t _min_tree_chunk_size;
149
150 protected:
151 TreeList<Chunk_t, FreeList_t>* embedded_list() const { return (TreeList<Chunk_t, FreeList_t>*) &_embedded_list; }
152 void set_embedded_list(TreeList<Chunk_t, FreeList_t>* v) { _embedded_list = *v; }
153 public:
154 TreeList<Chunk_t, FreeList_t>* list() { return _list; }
155 void set_list(TreeList<Chunk_t, FreeList_t>* v) { _list = v; }
156 static TreeChunk<Chunk_t, FreeList_t>* as_TreeChunk(Chunk_t* fc);
157 // Initialize fields in a TreeChunk that should be
158 // initialized when the TreeChunk is being added to
159 // a free list in the tree.
160 void initialize() { embedded_list()->initialize(); }
161
162 Chunk_t* next() const { return Chunk_t::next(); }
163 Chunk_t* prev() const { return Chunk_t::prev(); }
164 size_t size() const volatile { return Chunk_t::size(); }
165
166 static size_t min_size();
167
168 // debugging
169 void verify_tree_chunk_list() const;
170 void assert_is_mangled() const;
171 };
172
173 template <class Chunk_t, class FreeList_t>
174 size_t TreeChunk<Chunk_t, FreeList_t>::_min_tree_chunk_size = sizeof(TreeChunk<Chunk_t, FreeList_t>)/HeapWordSize;
175 template <class Chunk_t, class FreeList_t>
176 size_t TreeChunk<Chunk_t, FreeList_t>::min_size() { return _min_tree_chunk_size; }
177
178 template <class Chunk_t, class FreeList_t>
179 class BinaryTreeDictionary: public FreeBlockDictionary<Chunk_t> {
180 friend class VMStructs;
181 size_t _total_size;
182 size_t _total_free_blocks;
183 TreeList<Chunk_t, FreeList_t>* _root;
184
185 // private accessors
186 void set_total_size(size_t v) { _total_size = v; }
187 virtual void inc_total_size(size_t v);
188 virtual void dec_total_size(size_t v);
189 void set_total_free_blocks(size_t v) { _total_free_blocks = v; }
190 TreeList<Chunk_t, FreeList_t>* root() const { return _root; }
191 void set_root(TreeList<Chunk_t, FreeList_t>* v) { _root = v; }
192
193 // This field is added and can be set to point to the
194 // the Mutex used to synchronize access to the
195 // dictionary so that assertion checking can be done.
196 // For example it is set to point to _parDictionaryAllocLock.
|