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 *
23 */
24
25 #include "precompiled.hpp"
26 #include "memory/freeBlockDictionary.hpp"
27 #include "memory/freeList.hpp"
28 #include "memory/metachunk.hpp"
29 #include "memory/sharedHeap.hpp"
30 #include "runtime/globals.hpp"
31 #include "runtime/mutex.hpp"
32 #include "runtime/vmThread.hpp"
33 #include "utilities/macros.hpp"
34
35 #if INCLUDE_ALL_GCS
36 #include "gc_implementation/concurrentMarkSweep/freeChunk.hpp"
37 #endif // INCLUDE_ALL_GCS
38
39 // Free list. A FreeList is used to access a linked list of chunks
40 // of space in the heap. The head and tail are maintained so that
41 // items can be (as in the current implementation) added at the
42 // at the tail of the list and removed from the head of the list to
43 // maintain a FIFO queue.
44
45 template <class Chunk>
46 FreeList<Chunk>::FreeList() :
47 _head(NULL), _tail(NULL)
48 #ifdef ASSERT
49 , _protecting_lock(NULL)
50 #endif
51 {
52 _size = 0;
53 _count = 0;
54 }
55
56 template <class Chunk>
315 "count", "cBirths", "cDeaths", "sBirths", "sDeaths");
316 }
317
318 // Print the AllocationStats for the given free list. If the second argument
319 // to the call is a non-null string, it is printed in the first column;
320 // otherwise, if the argument is null (the default), then the size of the
321 // (free list) block is printed in the first column.
322 template <class Chunk_t>
323 void FreeList<Chunk_t>::print_on(outputStream* st, const char* c) const {
324 if (c != NULL) {
325 st->print("%16s", c);
326 } else {
327 st->print(SIZE_FORMAT_W(16), size());
328 }
329 }
330
331 template class FreeList<Metablock>;
332 template class FreeList<Metachunk>;
333 #if INCLUDE_ALL_GCS
334 template class FreeList<FreeChunk>;
335 #endif // INCLUDE_ALL_GCS
|
1 /*
2 * Copyright (c) 2001, 2014, 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 *
23 */
24
25 #include "precompiled.hpp"
26 #include "memory/freeBlockDictionary.hpp"
27 #include "memory/freeList.hpp"
28 #include "memory/metachunk.hpp"
29 #include "memory/sharedHeap.hpp"
30 #include "runtime/globals.hpp"
31 #include "runtime/mutex.hpp"
32 #include "runtime/vmThread.hpp"
33 #include "utilities/macros.hpp"
34
35 #if INCLUDE_ALL_GCS
36 #include "gc_implementation/concurrentMarkSweep/freeChunk.hpp"
37 #include "gc_implementation/g1/g1CodeCacheRemSet.hpp"
38 #endif // INCLUDE_ALL_GCS
39
40 // Free list. A FreeList is used to access a linked list of chunks
41 // of space in the heap. The head and tail are maintained so that
42 // items can be (as in the current implementation) added at the
43 // at the tail of the list and removed from the head of the list to
44 // maintain a FIFO queue.
45
46 template <class Chunk>
47 FreeList<Chunk>::FreeList() :
48 _head(NULL), _tail(NULL)
49 #ifdef ASSERT
50 , _protecting_lock(NULL)
51 #endif
52 {
53 _size = 0;
54 _count = 0;
55 }
56
57 template <class Chunk>
316 "count", "cBirths", "cDeaths", "sBirths", "sDeaths");
317 }
318
319 // Print the AllocationStats for the given free list. If the second argument
320 // to the call is a non-null string, it is printed in the first column;
321 // otherwise, if the argument is null (the default), then the size of the
322 // (free list) block is printed in the first column.
323 template <class Chunk_t>
324 void FreeList<Chunk_t>::print_on(outputStream* st, const char* c) const {
325 if (c != NULL) {
326 st->print("%16s", c);
327 } else {
328 st->print(SIZE_FORMAT_W(16), size());
329 }
330 }
331
332 template class FreeList<Metablock>;
333 template class FreeList<Metachunk>;
334 #if INCLUDE_ALL_GCS
335 template class FreeList<FreeChunk>;
336 template class FreeList<G1CodeRootChunk>;
337 #endif // INCLUDE_ALL_GCS
|