author | stuefe |
Wed, 16 Oct 2019 16:10:24 +0200 | |
branch | stuefe-new-metaspace-branch |
changeset 58646 | bcdba1c9f1fe |
parent 58227 | 0e7d9a23261e |
child 59272 | 54750b448264 |
permissions | -rw-r--r-- |
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
1 |
/* |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
2 |
* Copyright (c) 2018, 2019, SAP SE. All rights reserved. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
3 |
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
4 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
5 |
* |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
6 |
* This code is free software; you can redistribute it and/or modify it |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
7 |
* under the terms of the GNU General Public License version 2 only, as |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
8 |
* published by the Free Software Foundation. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
9 |
* |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
10 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
11 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
12 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
13 |
* version 2 for more details (a copy is included in the LICENSE file that |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
14 |
* accompanied this code). |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
15 |
* |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
16 |
* You should have received a copy of the GNU General Public License version |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
17 |
* 2 along with this work; if not, write to the Free Software Foundation, |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
18 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
19 |
* |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
20 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
21 |
* or visit www.oracle.com if you need additional information or have any |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
22 |
* questions. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
23 |
* |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
24 |
*/ |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
25 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
26 |
#ifndef SHARE_MEMORY_METASPACE_CLASSLOADERMETASPACE_HPP |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
27 |
#define SHARE_MEMORY_METASPACE_CLASSLOADERMETASPACE_HPP |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
28 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
29 |
#include "memory/allocation.hpp" |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
30 |
#include "memory/metaspace/metaspaceEnums.hpp" |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
31 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
32 |
class Mutex; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
33 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
34 |
namespace metaspace { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
35 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
36 |
class SpaceManager; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
37 |
struct clms_stats_t; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
38 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
39 |
class ClassLoaderMetaspace : public CHeapObj<mtClass> { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
40 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
41 |
// The CLD lock. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
42 |
Mutex* const _lock; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
43 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
44 |
const MetaspaceType _space_type; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
45 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
46 |
SpaceManager* _non_class_space_manager; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
47 |
SpaceManager* _class_space_manager; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
48 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
49 |
Mutex* lock() const { return _lock; } |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
50 |
SpaceManager* non_class_space_manager() const { return _non_class_space_manager; } |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
51 |
SpaceManager* class_space_manager() const { return _class_space_manager; } |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
52 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
53 |
SpaceManager* get_space_manager(bool is_class) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
54 |
return is_class ? class_space_manager() : non_class_space_manager(); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
55 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
56 |
|
58646
bcdba1c9f1fe
Remove experimental MetaspaceSeparateMicroCLDs feature, since its effect was underwhelming
stuefe
parents:
58227
diff
changeset
|
57 |
// Returns true if this class loader is of a type which will only ever load one class. |
bcdba1c9f1fe
Remove experimental MetaspaceSeparateMicroCLDs feature, since its effect was underwhelming
stuefe
parents:
58227
diff
changeset
|
58 |
bool is_micro() const { |
bcdba1c9f1fe
Remove experimental MetaspaceSeparateMicroCLDs feature, since its effect was underwhelming
stuefe
parents:
58227
diff
changeset
|
59 |
return _space_type == metaspace::UnsafeAnonymousMetaspaceType || |
bcdba1c9f1fe
Remove experimental MetaspaceSeparateMicroCLDs feature, since its effect was underwhelming
stuefe
parents:
58227
diff
changeset
|
60 |
_space_type == metaspace::ReflectionMetaspaceType; |
bcdba1c9f1fe
Remove experimental MetaspaceSeparateMicroCLDs feature, since its effect was underwhelming
stuefe
parents:
58227
diff
changeset
|
61 |
} |
bcdba1c9f1fe
Remove experimental MetaspaceSeparateMicroCLDs feature, since its effect was underwhelming
stuefe
parents:
58227
diff
changeset
|
62 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
63 |
public: |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
64 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
65 |
ClassLoaderMetaspace(Mutex* lock, MetaspaceType space_type); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
66 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
67 |
~ClassLoaderMetaspace(); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
68 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
69 |
MetaspaceType space_type() const { return _space_type; } |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
70 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
71 |
// Allocate word_size words from Metaspace. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
72 |
MetaWord* allocate(size_t word_size, MetadataType mdType); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
73 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
74 |
// Attempt to expand the GC threshold to be good for at least another word_size words |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
75 |
// and allocate. Returns NULL if failure. Used during Metaspace GC. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
76 |
MetaWord* expand_and_allocate(size_t word_size, MetadataType mdType); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
77 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
78 |
// Prematurely returns a metaspace allocation to the _block_freelists |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
79 |
// because it is not needed anymore. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
80 |
void deallocate(MetaWord* ptr, size_t word_size, bool is_class); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
81 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
82 |
// Update statistics. This walks all in-use chunks. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
83 |
void add_to_statistics(clms_stats_t* out) const; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
84 |
|
58227 | 85 |
DEBUG_ONLY(void verify() const;) |
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
86 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
87 |
// TODO |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
88 |
size_t allocated_blocks_bytes() const { return 0; } |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
89 |
size_t allocated_chunks_bytes() const { return 0; } |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
90 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
91 |
}; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
92 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
93 |
} // namespace metaspace |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
94 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
95 |
#endif // SHARE_MEMORY_METASPACE_CLASSLOADERMETASPACE_HPP |