Mercurial > hg > truffle
annotate src/share/vm/memory/metachunk.hpp @ 7403:807f1d348f7b
Merge
author | collins |
---|---|
date | Fri, 14 Dec 2012 11:45:55 -0800 |
parents | 90273fc0a981 |
children | e51c9860cf66 |
rev | line source |
---|---|
6885 | 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_METACHUNK_HPP | |
25 #define SHARE_VM_MEMORY_METACHUNK_HPP | |
26 | |
27 // Metachunk - Quantum of allocation from a Virtualspace | |
28 // Metachunks are reused (when freed are put on a global freelist) and | |
29 // have no permanent association to a SpaceManager. | |
30 | |
31 // +--------------+ <- end | |
32 // | | --+ ---+ | |
33 // | | | free | | |
34 // | | | | | |
35 // | | | | capacity | |
36 // | | | | | |
37 // | | <- top --+ | | |
38 // | | ---+ | | |
39 // | | | used | | |
40 // | | | | | |
41 // | | | | | |
42 // +--------------+ <- bottom ---+ ---+ | |
43 | |
44 class Metachunk VALUE_OBJ_CLASS_SPEC { | |
45 // link to support lists of chunks | |
46 Metachunk* _next; | |
47 Metachunk* _prev; | |
48 | |
49 MetaWord* _bottom; | |
50 MetaWord* _end; | |
51 MetaWord* _top; | |
52 size_t _word_size; | |
53 // Used in a guarantee() so included in the Product builds | |
54 // even through it is only for debugging. | |
55 bool _is_free; | |
56 | |
57 // Metachunks are allocated out of a MetadataVirtualSpace and | |
58 // and use some of its space to describe itself (plus alignment | |
59 // considerations). Metadata is allocated in the rest of the chunk. | |
60 // This size is the overhead of maintaining the Metachunk within | |
61 // the space. | |
62 static size_t _overhead; | |
63 | |
64 void set_bottom(MetaWord* v) { _bottom = v; } | |
65 void set_end(MetaWord* v) { _end = v; } | |
66 void set_top(MetaWord* v) { _top = v; } | |
67 void set_word_size(size_t v) { _word_size = v; } | |
68 public: | |
69 #ifdef ASSERT | |
70 Metachunk() : _bottom(NULL), _end(NULL), _top(NULL), _is_free(false) {} | |
71 #else | |
72 Metachunk() : _bottom(NULL), _end(NULL), _top(NULL) {} | |
73 #endif | |
74 | |
75 // Used to add a Metachunk to a list of Metachunks | |
76 void set_next(Metachunk* v) { _next = v; assert(v != this, "Boom");} | |
77 void set_prev(Metachunk* v) { _prev = v; assert(v != this, "Boom");} | |
78 | |
79 MetaWord* allocate(size_t word_size); | |
80 static Metachunk* initialize(MetaWord* ptr, size_t word_size); | |
81 | |
82 // Accessors | |
83 Metachunk* next() const { return _next; } | |
84 Metachunk* prev() const { return _prev; } | |
85 MetaWord* bottom() const { return _bottom; } | |
86 MetaWord* end() const { return _end; } | |
87 MetaWord* top() const { return _top; } | |
88 size_t word_size() const { return _word_size; } | |
89 size_t size() const volatile { return _word_size; } | |
90 void set_size(size_t v) { _word_size = v; } | |
91 bool is_free() { return _is_free; } | |
92 void set_is_free(bool v) { _is_free = v; } | |
93 static size_t overhead() { return _overhead; } | |
94 void clear_next() { set_next(NULL); } | |
95 void link_prev(Metachunk* ptr) { set_prev(ptr); } | |
96 uintptr_t* end() { return ((uintptr_t*) this) + size(); } | |
97 bool cantCoalesce() const { return false; } | |
98 void link_next(Metachunk* ptr) { set_next(ptr); } | |
99 void link_after(Metachunk* ptr){ | |
100 link_next(ptr); | |
101 if (ptr != NULL) ptr->link_prev(this); | |
102 } | |
103 | |
104 // Reset top to bottom so chunk can be reused. | |
105 void reset_empty() { _top = (_bottom + _overhead); } | |
106 bool is_empty() { return _top == (_bottom + _overhead); } | |
107 | |
108 // used (has been allocated) | |
109 // free (available for future allocations) | |
110 // capacity (total size of chunk) | |
111 size_t used_word_size(); | |
112 size_t free_word_size(); | |
113 size_t capacity_word_size(); | |
114 | |
115 // Debug support | |
116 #ifdef ASSERT | |
117 void* prev_addr() const { return (void*)&_prev; } | |
118 void* next_addr() const { return (void*)&_next; } | |
119 void* size_addr() const { return (void*)&_word_size; } | |
120 #endif | |
121 bool verify_chunk_in_free_list(Metachunk* tc) const { return true; } | |
122 bool verify_par_locked() { return true; } | |
123 | |
124 void assert_is_mangled() const {/* Don't check "\*/} | |
125 | |
7185
90273fc0a981
8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents:
6885
diff
changeset
|
126 NOT_PRODUCT(void mangle();) |
6885 | 127 |
128 void print_on(outputStream* st) const; | |
129 void verify(); | |
130 }; | |
131 #endif // SHARE_VM_MEMORY_METACHUNK_HPP |