author | stuefe |
Wed, 11 Sep 2019 17:36:28 +0200 | |
branch | stuefe-new-metaspace-branch |
changeset 58085 | a5f523f2ff91 |
parent 58063 | bdf136b8ae0e |
permissions | -rw-r--r-- |
50193 | 1 |
/* |
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
52014
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_VIRTUALSPACELIST_HPP |
|
27 |
#define SHARE_MEMORY_METASPACE_VIRTUALSPACELIST_HPP |
|
28 |
||
29 |
#include "memory/allocation.hpp" |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
30 |
#include "memory/metaspace/counter.hpp" |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
31 |
#include "memory/metaspace/commitLimiter.hpp" |
50193 | 32 |
#include "memory/metaspace/virtualSpaceNode.hpp" |
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
33 |
#include "memory/virtualspace.hpp" |
50193 | 34 |
#include "utilities/globalDefinitions.hpp" |
35 |
||
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
36 |
class outputStream; |
50193 | 37 |
|
38 |
namespace metaspace { |
|
39 |
||
40 |
class Metachunk; |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
41 |
class MetachunkListCluster; |
50193 | 42 |
|
43 |
class VirtualSpaceList : public CHeapObj<mtClass> { |
|
44 |
||
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
45 |
// Name |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
46 |
const char* const _name; |
50193 | 47 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
48 |
// Head of the list. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
49 |
VirtualSpaceNode* _first_node; |
50193 | 50 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
51 |
// Number of nodes (kept for statistics only). |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
52 |
IntCounter _nodes_counter; |
50193 | 53 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
54 |
// Whether this list can expand by allocating new nodes. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
55 |
const bool _can_expand; |
50193 | 56 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
57 |
// Whether this list can be purged. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
58 |
const bool _can_purge; |
50193 | 59 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
60 |
// Used to check limits before committing memory. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
61 |
CommitLimiter* const _commit_limiter; |
54437
2ae93028bef3
8221539: [metaspace] Improve MetaspaceObj::is_metaspace_obj() and friends
stuefe
parents:
53244
diff
changeset
|
62 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
63 |
// Statistics |
54437
2ae93028bef3
8221539: [metaspace] Improve MetaspaceObj::is_metaspace_obj() and friends
stuefe
parents:
53244
diff
changeset
|
64 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
65 |
// Holds sum of reserved space, in words, over all list nodes. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
66 |
SizeCounter _reserved_words_counter; |
54437
2ae93028bef3
8221539: [metaspace] Improve MetaspaceObj::is_metaspace_obj() and friends
stuefe
parents:
53244
diff
changeset
|
67 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
68 |
// Holds sum of committed space, in words, over all list nodes. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
69 |
SizeCounter _committed_words_counter; |
50193 | 70 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
71 |
// Create a new node and append it to the list. After |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
72 |
// this function, _current_node shall point to a new empty node. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
73 |
// List must be expandable for this to work. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
74 |
void create_new_node(); |
50193 | 75 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
76 |
public: |
50193 | 77 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
78 |
// Create a new, empty, expandable list. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
79 |
VirtualSpaceList(const char* name, CommitLimiter* commit_limiter); |
50193 | 80 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
81 |
// Create a new list. The list will contain one node only, which uses the given ReservedSpace. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
82 |
// It will be not expandable beyond that first node. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
83 |
VirtualSpaceList(const char* name, ReservedSpace rs, CommitLimiter* commit_limiter); |
50193 | 84 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
85 |
virtual ~VirtualSpaceList(); |
54437
2ae93028bef3
8221539: [metaspace] Improve MetaspaceObj::is_metaspace_obj() and friends
stuefe
parents:
53244
diff
changeset
|
86 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
87 |
// Allocate a root chunk from this list. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
88 |
// 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
|
89 |
// Hence, before using this chunk, it must be committed. |
58085
a5f523f2ff91
Fix jtreg/vmTestbase/metaspace/shrink_grow/CompressedClassSpaceSize
stuefe
parents:
58063
diff
changeset
|
90 |
// May return NULL if vslist would need to be expanded to hold the new root node but |
a5f523f2ff91
Fix jtreg/vmTestbase/metaspace/shrink_grow/CompressedClassSpaceSize
stuefe
parents:
58063
diff
changeset
|
91 |
// the list cannot be expanded (in practice this means we reached CompressedClassSpaceSize). |
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
92 |
Metachunk* allocate_root_chunk(); |
50193 | 93 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
94 |
// Attempts to purge nodes. This will remove and delete nodes which only contain free chunks. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
95 |
// The free chunks are removed from the freelists before the nodes are deleted. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
96 |
// Return number of purged nodes. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
97 |
int purge(MetachunkListCluster* freelists); |
50193 | 98 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
99 |
//// Statistics //// |
50193 | 100 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
101 |
// Return sum of reserved words in all nodes. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
102 |
size_t reserved_words() const { return _reserved_words_counter.get(); } |
50193 | 103 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
104 |
// Return sum of committed words in all nodes. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
105 |
size_t committed_words() const { return _committed_words_counter.get(); } |
50193 | 106 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
107 |
// Return number of nodes in this list. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
108 |
int num_nodes() const { return _nodes_counter.get(); } |
50193 | 109 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
110 |
//// Debug stuff //// |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
111 |
DEBUG_ONLY(void verify(bool slow) const;) |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
112 |
DEBUG_ONLY(void verify_locked(bool slow) const;) |
50193 | 113 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
114 |
// Print all nodes in this space list. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
115 |
void print_on(outputStream* st) const; |
50193 | 116 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
117 |
// Returns true if this pointer is contained in one of our nodes. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
118 |
bool contains(const MetaWord* p) const; |
50193 | 119 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
120 |
private: |
54437
2ae93028bef3
8221539: [metaspace] Improve MetaspaceObj::is_metaspace_obj() and friends
stuefe
parents:
53244
diff
changeset
|
121 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
122 |
static VirtualSpaceList* _vslist_class; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
123 |
static VirtualSpaceList* _vslist_nonclass; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
124 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
125 |
public: |
50193 | 126 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
127 |
static VirtualSpaceList* vslist_class() { return _vslist_class; } |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
128 |
static VirtualSpaceList* vslist_nonclass() { return _vslist_nonclass; } |
50193 | 129 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
130 |
static void set_vslist_class(VirtualSpaceList* vslist_class); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
131 |
static void set_vslist_nonclass(VirtualSpaceList* vslist_class); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
132 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
133 |
|
50193 | 134 |
}; |
135 |
||
136 |
} // namespace metaspace |
|
137 |
||
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
52014
diff
changeset
|
138 |
#endif // SHARE_MEMORY_METASPACE_VIRTUALSPACELIST_HPP |
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
54437
diff
changeset
|
139 |