author | stuefe |
Wed, 16 Oct 2019 15:31:05 +0200 | |
branch | stuefe-new-metaspace-branch |
changeset 58645 | 28c7e6711871 |
parent 58063 | bdf136b8ae0e |
child 59135 | 84464aa83a29 |
permissions | -rw-r--r-- |
50193 | 1 |
/* |
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
51334
diff
changeset
|
2 |
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. |
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
3 |
* Copyright (c) 2018, 2019 SAP SE. All rights reserved. |
50193 | 4 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5 |
* |
|
6 |
* This code is free software; you can redistribute it and/or modify it |
|
7 |
* under the terms of the GNU General Public License version 2 only, as |
|
8 |
* published by the Free Software Foundation. |
|
9 |
* |
|
10 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
11 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
12 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
13 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
14 |
* accompanied this code). |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License version |
|
17 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
18 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
19 |
* |
|
20 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
21 |
* or visit www.oracle.com if you need additional information or have any |
|
22 |
* questions. |
|
23 |
* |
|
24 |
*/ |
|
25 |
||
26 |
#ifndef SHARE_MEMORY_METASPACE_VIRTUALSPACENODE_HPP |
|
27 |
#define SHARE_MEMORY_METASPACE_VIRTUALSPACENODE_HPP |
|
28 |
||
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
29 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
30 |
#include <memory/metaspace/settings.hpp> |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
31 |
#include "memory/allocation.hpp" |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
32 |
#include "memory/metaspace/counter.hpp" |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
33 |
#include "memory/metaspace/commitMask.hpp" |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
34 |
#include "memory/metaspace/rootChunkArea.hpp" |
50193 | 35 |
#include "memory/virtualspace.hpp" |
36 |
#include "memory/memRegion.hpp" |
|
37 |
#include "utilities/debug.hpp" |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
38 |
#include "utilities/bitMap.hpp" |
50193 | 39 |
#include "utilities/globalDefinitions.hpp" |
40 |
||
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
41 |
|
50193 | 42 |
class outputStream; |
43 |
||
44 |
namespace metaspace { |
|
45 |
||
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
46 |
class CommitLimiter; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
47 |
class MetachunkListCluster; |
50193 | 48 |
|
58645 | 49 |
// VirtualSpaceNode manages a single address range of the Metaspace. |
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
50 |
// |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
51 |
// That address range may contain interleaved committed and uncommitted |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
52 |
// regions. It keeps track of which regions have committed and offers |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
53 |
// functions to commit and uncommit regions. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
54 |
// |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
55 |
// It allocates and hands out memory ranges, starting at the bottom. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
56 |
// |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
57 |
// Address range must be aligned to root chunk size. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
58 |
// |
50193 | 59 |
class VirtualSpaceNode : public CHeapObj<mtClass> { |
60 |
||
61 |
// Link to next VirtualSpaceNode |
|
62 |
VirtualSpaceNode* _next; |
|
63 |
||
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
64 |
ReservedSpace _rs; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
65 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
66 |
// Start pointer of the area. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
67 |
MetaWord* const _base; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
68 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
69 |
// Size, in words, of the whole node |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
70 |
const size_t _word_size; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
71 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
72 |
// Size, in words, of the range of this node which has been handed out in |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
73 |
// the form of chunks. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
74 |
size_t _used_words; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
75 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
76 |
// The bitmap describing the commit state of the region: |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
77 |
// Each bit covers a region of 64K (see constants::commit_granule_size). |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
78 |
CommitMask _commit_mask; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
79 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
80 |
// An array/LUT of RootChunkArea objects. Each one describes |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
81 |
// fragmentation inside a root chunk. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
82 |
RootChunkAreaLUT _root_chunk_area_lut; |
50193 | 83 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
84 |
// Limiter object to ask before expanding the committed size of this node. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
85 |
CommitLimiter* const _commit_limiter; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
86 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
87 |
// Points to outside size counters which we are to increase/decrease when we commit/uncommit |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
88 |
// space from this node. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
89 |
SizeCounter* const _total_reserved_words_counter; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
90 |
SizeCounter* const _total_committed_words_counter; |
50193 | 91 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
92 |
// For debug and tracing purposes |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
93 |
const int _node_id; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
94 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
95 |
/// committing, uncommitting /// |
50193 | 96 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
97 |
// Given a pointer into this node, calculate the start of the commit granule |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
98 |
// the pointer points into. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
99 |
MetaWord* calc_start_of_granule(MetaWord* p) const { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
100 |
DEBUG_ONLY(check_pointer(p)); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
101 |
return align_down(p, Settings::commit_granule_bytes()); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
102 |
} |
50193 | 103 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
104 |
// Given an address range, ensure it is committed. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
105 |
// |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
106 |
// The range has to be aligned to granule size. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
107 |
// |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
108 |
// Function will: |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
109 |
// - check how many granules in that region are uncommitted; If all are committed, it |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
110 |
// returns true immediately. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
111 |
// - check if committing those uncommitted granules would bring us over the commit limit |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
112 |
// (GC threshold, MaxMetaspaceSize). If true, it returns false. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
113 |
// - commit the memory. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
114 |
// - mark the range as committed in the commit mask |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
115 |
// |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
116 |
// Returns true if success, false if it did hit a commit limit. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
117 |
bool commit_range(MetaWord* p, size_t word_size); |
50193 | 118 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
119 |
//// creation //// |
50193 | 120 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
121 |
// Create a new empty node spanning the given reserved space. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
122 |
VirtualSpaceNode(int node_id, |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
123 |
ReservedSpace rs, |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
124 |
CommitLimiter* limiter, |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
125 |
SizeCounter* reserve_counter, |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
126 |
SizeCounter* commit_counter); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
127 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
128 |
MetaWord* base() const { return _base; } |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
129 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
130 |
public: |
50193 | 131 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
132 |
// Create a node of a given size |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
133 |
static VirtualSpaceNode* create_node(int node_id, |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
134 |
size_t word_size, |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
135 |
CommitLimiter* limiter, |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
136 |
SizeCounter* reserve_words_counter, |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
137 |
SizeCounter* commit_words_counter); |
50193 | 138 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
139 |
// Create a node over an existing space |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
140 |
static VirtualSpaceNode* create_node(int node_id, |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
141 |
ReservedSpace rs, |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
142 |
CommitLimiter* limiter, |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
143 |
SizeCounter* reserve_words_counter, |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
144 |
SizeCounter* commit_words_counter); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
145 |
|
50193 | 146 |
~VirtualSpaceNode(); |
147 |
||
148 |
||
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
149 |
// Reserved size of the whole node. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
150 |
size_t word_size() const { return _word_size; } |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
151 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
152 |
//// Chunk allocation, splitting, merging ///// |
50193 | 153 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
154 |
// Allocate a root chunk from this node. Will fail and return NULL |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
155 |
// if the node is full. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
156 |
// Note: this just returns a chunk whose memory is reserved; no memory is committed yet. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
157 |
// Hence, before using this chunk, it must be committed. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
158 |
// Also, no limits are checked, since no committing takes place. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
159 |
Metachunk* allocate_root_chunk(); |
50193 | 160 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
161 |
// Given a chunk c, split it recursively until you get a chunk of the given target_level. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
162 |
// |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
163 |
// The original chunk must not be part of a freelist. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
164 |
// |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
165 |
// Returns pointer to the result chunk; the splitted-off chunks are added as |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
166 |
// free chunks to the freelists. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
167 |
// |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
168 |
// Returns NULL if chunk cannot be split at least once. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
169 |
Metachunk* split(chklvl_t target_level, Metachunk* c, MetachunkListCluster* freelists); |
50193 | 170 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
171 |
// Given a chunk, attempt to merge it recursively with its neighboring chunks. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
172 |
// |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
173 |
// If successful (merged at least once), returns address of |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
174 |
// the merged chunk; NULL otherwise. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
175 |
// |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
176 |
// The merged chunks are removed from the freelists. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
177 |
// |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
178 |
// !!! Please note that if this method returns a non-NULL value, the |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
179 |
// original chunk will be invalid and should not be accessed anymore! !!! |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
180 |
Metachunk* merge(Metachunk* c, MetachunkListCluster* freelists); |
50193 | 181 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
182 |
// Given a chunk c, which must be "in use" and must not be a root chunk, attempt to |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
183 |
// enlarge it in place by claiming its trailing buddy. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
184 |
// |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
185 |
// This will only work if c is the leader of the buddy pair and the trailing buddy is free. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
186 |
// |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
187 |
// If successful, the follower chunk will be removed from the freelists, the leader chunk c will |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
188 |
// double in size (level decreased by one). |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
189 |
// |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
190 |
// On success, true is returned, false otherwise. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
191 |
bool attempt_enlarge_chunk(Metachunk* c, MetachunkListCluster* freelists); |
50193 | 192 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
193 |
// Attempts to purge the node: |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
194 |
// |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
195 |
// If all chunks living in this node are free, they will all be removed from their freelists |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
196 |
// and deletes the node. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
197 |
// |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
198 |
// Returns true if the node has been deleted, false if not. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
199 |
// !! If this returns true, do not access the node from this point on. !! |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
200 |
bool attempt_purge(MetachunkListCluster* freelists); |
50193 | 201 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
202 |
// Attempts to uncommit free areas according to the rules set in settings. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
203 |
// Returns number of words uncommitted. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
204 |
size_t uncommit_free_areas(); |
50193 | 205 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
206 |
/// misc ///// |
50193 | 207 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
208 |
// Returns size, in words, of the used space in this node alone. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
209 |
// (Notes: |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
210 |
// - This is the space handed out to the ChunkManager, so it is "used" from the viewpoint of this node, |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
211 |
// but not necessarily used for Metadata. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
212 |
// - This may or may not be committed memory. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
213 |
size_t used_words() const { return _used_words; } |
50193 | 214 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
215 |
// Returns size, in words, of how much space is left in this node alone. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
216 |
size_t free_words() const { return _word_size - _used_words; } |
50193 | 217 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
218 |
// Returns size, in words, of committed space in this node alone. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
219 |
// Note: iterates over commit mask and hence may be a tad expensive on large nodes. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
220 |
size_t committed_words() const; |
50193 | 221 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
222 |
//// Committing/uncommitting memory ///// |
50193 | 223 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
224 |
// Given an address range, ensure it is committed. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
225 |
// |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
226 |
// The range does not have to be aligned to granule size. However, the function will always commit |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
227 |
// whole granules. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
228 |
// |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
229 |
// Function will: |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
230 |
// - check how many granules in that region are uncommitted; If all are committed, it |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
231 |
// returns true immediately. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
232 |
// - check if committing those uncommitted granules would bring us over the commit limit |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
233 |
// (GC threshold, MaxMetaspaceSize). If true, it returns false. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
234 |
// - commit the memory. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
235 |
// - mark the range as committed in the commit mask |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
236 |
// |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
237 |
// Returns true if success, false if it did hit a commit limit. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
238 |
bool ensure_range_is_committed(MetaWord* p, size_t word_size); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
239 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
240 |
// Given an address range (which has to be aligned to commit granule size): |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
241 |
// - uncommit it |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
242 |
// - mark it as uncommitted in the commit mask |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
243 |
void uncommit_range(MetaWord* p, size_t word_size); |
50193 | 244 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
245 |
//// List stuff //// |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
246 |
VirtualSpaceNode* next() const { return _next; } |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
247 |
void set_next(VirtualSpaceNode* vsn) { _next = vsn; } |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
248 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
249 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
250 |
/// Debug stuff //// |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
251 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
252 |
// Print a description about this node. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
253 |
void print_on(outputStream* st) const; |
50193 | 254 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
255 |
// Verify counters and basic structure. Slow mode: verify all chunks in depth |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
256 |
bool contains(const MetaWord* p) const { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
257 |
return p >= _base && p < _base + _used_words; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
258 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
259 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
260 |
#ifdef ASSERT |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
261 |
void check_pointer(const MetaWord* p) const { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
262 |
assert(contains(p), "invalid pointer"); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
263 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
264 |
void verify(bool slow) const; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
265 |
#endif |
50193 | 266 |
|
267 |
}; |
|
268 |
||
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
269 |
|
50193 | 270 |
} // namespace metaspace |
271 |
||
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
51334
diff
changeset
|
272 |
#endif // SHARE_MEMORY_METASPACE_VIRTUALSPACENODE_HPP |