Mercurial > hg > truffle
comparison src/share/vm/memory/metablock.hpp @ 6885:685df3c6f84b
7045397: NPG: Add freelists to class loader arenas.
Reviewed-by: coleenp, stefank, jprovino, ohair
author | jmasa |
---|---|
date | Tue, 18 Sep 2012 23:35:42 -0700 |
parents | |
children | 335b388c4b28 |
comparison
equal
deleted
inserted
replaced
6877:d0e7716b179e | 6885:685df3c6f84b |
---|---|
1 /* | |
2 * Copyright (c) 2012, 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 #ifndef SHARE_VM_MEMORY_METABLOCK_HPP | |
25 #define SHARE_VM_MEMORY_METABLOCK_HPP | |
26 | |
27 // Metablock are the unit of allocation from a Chunk. It is initialized | |
28 // with the size of the requested allocation. That size is overwritten | |
29 // once the allocation returns. | |
30 // | |
31 // A Metablock may be reused by its SpaceManager but are never moved between | |
32 // SpaceManagers. There is no explicit link to the Metachunk | |
33 // from which it was allocated. Metablock may be deallocated and | |
34 // put on a freelist but the space is never freed, rather | |
35 // the Metachunk it is a part of will be deallocated when it's | |
36 // associated class loader is collected. | |
37 | |
38 class Metablock VALUE_OBJ_CLASS_SPEC { | |
39 friend class VMStructs; | |
40 private: | |
41 // Used to align the allocation (see below). | |
42 union block_t { | |
43 void* _data[3]; | |
44 struct header_t { | |
45 size_t _word_size; | |
46 Metablock* _next; | |
47 Metablock* _prev; | |
48 } _header; | |
49 } _block; | |
50 static size_t _min_block_byte_size; | |
51 static size_t _overhead; | |
52 | |
53 typedef union block_t Block; | |
54 typedef struct header_t Header; | |
55 const Block* block() const { return &_block; } | |
56 const Block::header_t* header() const { return &(block()->_header); } | |
57 public: | |
58 | |
59 static Metablock* initialize(MetaWord* p, size_t word_size); | |
60 | |
61 // This places the body of the block at a 2 word boundary | |
62 // because every block starts on a 2 word boundary. Work out | |
63 // how to make the body on a 2 word boundary if the block | |
64 // starts on a arbitrary boundary. JJJ | |
65 | |
66 size_t word_size() const { return header()->_word_size; } | |
67 void set_word_size(size_t v) { _block._header._word_size = v; } | |
68 size_t size() const volatile { return _block._header._word_size; } | |
69 void set_size(size_t v) { _block._header._word_size = v; } | |
70 Metablock* next() const { return header()->_next; } | |
71 void set_next(Metablock* v) { _block._header._next = v; } | |
72 Metablock* prev() const { return header()->_prev; } | |
73 void set_prev(Metablock* v) { _block._header._prev = v; } | |
74 | |
75 static size_t min_block_byte_size() { return _min_block_byte_size; } | |
76 static size_t overhead() { return _overhead; } | |
77 | |
78 bool is_free() { return header()->_word_size != 0; } | |
79 void clear_next() { set_next(NULL); } | |
80 void link_prev(Metablock* ptr) { set_prev(ptr); } | |
81 uintptr_t* end() { return ((uintptr_t*) this) + size(); } | |
82 bool cantCoalesce() const { return false; } | |
83 void link_next(Metablock* ptr) { set_next(ptr); } | |
84 void link_after(Metablock* ptr){ | |
85 link_next(ptr); | |
86 if (ptr != NULL) ptr->link_prev(this); | |
87 } | |
88 | |
89 // Should not be needed in a free list of Metablocks | |
90 void markNotFree() { ShouldNotReachHere(); } | |
91 | |
92 // Debug support | |
93 #ifdef ASSERT | |
94 void* prev_addr() const { return (void*)&_block._header._prev; } | |
95 void* next_addr() const { return (void*)&_block._header._next; } | |
96 void* size_addr() const { return (void*)&_block._header._word_size; } | |
97 #endif | |
98 bool verify_chunk_in_free_list(Metablock* tc) const { return true; } | |
99 bool verify_par_locked() { return true; } | |
100 | |
101 void assert_is_mangled() const {/* Don't check "\*/} | |
102 }; | |
103 #endif // SHARE_VM_MEMORY_METABLOCK_HPP |