author | stuefe |
Mon, 08 Jul 2019 22:30:19 +0200 | |
branch | stuefe-improved-metaspace |
changeset 57464 | 32e61f51ee09 |
parent 54437 | 2ae93028bef3 |
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. |
50193 | 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 |
#ifndef SHARE_MEMORY_METASPACE_VIRTUALSPACENODE_HPP |
|
26 |
#define SHARE_MEMORY_METASPACE_VIRTUALSPACENODE_HPP |
|
27 |
||
28 |
#include "memory/virtualspace.hpp" |
|
29 |
#include "memory/memRegion.hpp" |
|
30 |
#include "utilities/debug.hpp" |
|
31 |
#include "utilities/globalDefinitions.hpp" |
|
32 |
||
33 |
class outputStream; |
|
34 |
||
35 |
namespace metaspace { |
|
36 |
||
37 |
class Metachunk; |
|
57464 | 38 |
|
39 |
||
40 |
||
41 |
// A node in the VirtualSpaceList. |
|
42 |
// |
|
43 |
// VirtualSpaceNodes manage a single address range and a commit high water mark. |
|
44 |
// |
|
45 |
// The address range start and end are aligned to the highest Metachunk size (root chunk size) |
|
46 |
// and memory is only ever requested in units of one root chunk size. |
|
47 |
// |
|
48 |
class VirtualSpaceNode : public CHeapObj<mtClass> { |
|
50193 | 49 |
|
57464 | 50 |
///////////////////////////////// |
51 |
// |
|
52 |
// |--------------------- end() |
|
53 |
// | |
|
54 |
// | (uncommitted) = words_uncommitted() |
|
55 |
// | |
|
56 |
// |--------------------- commit_top() |
|
57 |
// | |
|
58 |
// | (committed unused) = words_committed_unused() |
|
59 |
// | |
|
60 |
// |--------------------- top() |
|
61 |
// | |
|
62 |
// | (committed used) = words_used() |
|
63 |
// | |
|
64 |
// | |
|
65 |
// | |
|
66 |
// |-------------------- start() |
|
67 |
// |
|
50193 | 68 |
|
69 |
// Link to next VirtualSpaceNode |
|
70 |
VirtualSpaceNode* _next; |
|
71 |
||
72 |
ReservedSpace _rs; |
|
73 |
VirtualSpace _virtual_space; |
|
74 |
||
57464 | 75 |
// Current allocated words |
76 |
size_t _used_words; |
|
77 |
||
78 |
// Current committed words |
|
79 |
size_t _committed_words; |
|
50193 | 80 |
|
57464 | 81 |
VirtualSpace* virtual_space() const { return _virtual_space; } |
50193 | 82 |
|
57464 | 83 |
MetaWord* start() const { |
84 |
assert(virtual_space()->low() == virtual_space()->low_boundary(), "sanity"); |
|
85 |
return (MetaWord*) virtual_space()->low_boundary(); |
|
86 |
} |
|
87 |
||
88 |
// End of the used area. |
|
89 |
MetaWord* top() const { return start() + _used_words; } |
|
50193 | 90 |
|
57464 | 91 |
// End of the committed area. |
92 |
MetaWord* commit_top() const { |
|
93 |
assert(virtual_space()->high() == start() + _committed_words, "sanity"); |
|
94 |
return start() + _committed_words; |
|
95 |
} |
|
50193 | 96 |
|
57464 | 97 |
// End of the reserved space; highest address in this node. |
98 |
MetaWord* end() const { return virtual_space()->high_boundary(); } |
|
50193 | 99 |
|
57464 | 100 |
public: |
50193 | 101 |
|
57464 | 102 |
// Create a new empty node of the given size. Memory will be reserved but |
103 |
// completely uncommitted. |
|
104 |
VirtualSpaceNode(size_t wordsize); |
|
50193 | 105 |
|
57464 | 106 |
// Create a new empty node spanning the given reserved space. |
107 |
VirtualSpaceNode(ReservedSpace rs); |
|
108 |
||
109 |
// Releases the node memory. |
|
50193 | 110 |
~VirtualSpaceNode(); |
111 |
||
57464 | 112 |
// Allocate a root chunk from this node. Will fail and return NULL |
113 |
// if the node is full. |
|
114 |
Metachunk* allocate_root_chunk(); |
|
50193 | 115 |
|
57464 | 116 |
// Returns true if this node can be purged (all chunks are free). |
117 |
bool can_be_purged() const; |
|
50193 | 118 |
|
57464 | 119 |
// Purge this node: remove all the chunks in the node from the given chunk manager. |
120 |
// Assumption: all chunks are free (see can_be_purged()). |
|
50193 | 121 |
void purge(ChunkManager* chunk_manager); |
122 |
||
57464 | 123 |
// Verify counters and basic structure. Slow mode: verify all chunks in depth |
53970 | 124 |
DEBUG_ONLY(void verify(bool slow);) |
50193 | 125 |
|
126 |
}; |
|
127 |
||
57464 | 128 |
|
50193 | 129 |
} // namespace metaspace |
130 |
||
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
51334
diff
changeset
|
131 |
#endif // SHARE_MEMORY_METASPACE_VIRTUALSPACENODE_HPP |