Mercurial > hg > truffle
annotate src/share/vm/memory/metaspace.hpp @ 11969:c65045599519
8021314: minimal1.make needs to force off components not supported by the minimal VM
Reviewed-by: coleenp, bpittore
author | dholmes |
---|---|
date | Thu, 25 Jul 2013 21:05:29 -0400 |
parents | f2110083203d |
children | 740e263c80c6 |
rev | line source |
---|---|
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1 /* |
10376
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
2 * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4 * |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
8 * |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
13 * accompanied this code). |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
14 * |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
18 * |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
21 * questions. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
22 * |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
23 */ |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
24 #ifndef SHARE_VM_MEMORY_METASPACE_HPP |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
25 #define SHARE_VM_MEMORY_METASPACE_HPP |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
26 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
27 #include "memory/allocation.hpp" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
28 #include "memory/memRegion.hpp" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
29 #include "runtime/virtualspace.hpp" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
30 #include "utilities/exceptions.hpp" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
31 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
32 // Metaspace |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
33 // |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
34 // Metaspaces are Arenas for the VM's metadata. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
35 // They are allocated one per class loader object, and one for the null |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
36 // bootstrap class loader |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
37 // Eventually for bootstrap loader we'll have a read-only section and read-write |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
38 // to write for DumpSharedSpaces and read for UseSharedSpaces |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
39 // |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
40 // block X ---+ +-------------------+ |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
41 // | | Virtualspace | |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
42 // | | | |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
43 // | | | |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
44 // | |-------------------| |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
45 // | || Chunk | |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
46 // | || | |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
47 // | ||---------- | |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
48 // +------>||| block 0 | | |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
49 // ||---------- | |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
50 // ||| block 1 | | |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
51 // ||---------- | |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
52 // || | |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
53 // |-------------------| |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
54 // | | |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
55 // | | |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
56 // +-------------------+ |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
57 // |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
58 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
59 class ClassLoaderData; |
6885 | 60 class Metablock; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
61 class MetaWord; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
62 class Mutex; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
63 class outputStream; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
64 class SpaceManager; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
65 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
66 // Metaspaces each have a SpaceManager and allocations |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
67 // are done by the SpaceManager. Allocations are done |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
68 // out of the current Metachunk. When the current Metachunk |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
69 // is exhausted, the SpaceManager gets a new one from |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
70 // the current VirtualSpace. When the VirtualSpace is exhausted |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
71 // the SpaceManager gets a new one. The SpaceManager |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
72 // also manages freelists of available Chunks. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
73 // |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
74 // Currently the space manager maintains the list of |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
75 // virtual spaces and the list of chunks in use. Its |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
76 // allocate() method returns a block for use as a |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
77 // quantum of metadata. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
78 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
79 class VirtualSpaceList; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
80 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
81 class Metaspace : public CHeapObj<mtClass> { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
82 friend class VMStructs; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
83 friend class SpaceManager; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
84 friend class VM_CollectForMetadataAllocation; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
85 friend class MetaspaceGC; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
86 friend class MetaspaceAux; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
87 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
88 public: |
10330
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10183
diff
changeset
|
89 enum MetadataType {ClassType = 0, |
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10183
diff
changeset
|
90 NonClassType = ClassType + 1, |
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10183
diff
changeset
|
91 MetadataTypeCount = ClassType + 2 |
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10183
diff
changeset
|
92 }; |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
93 enum MetaspaceType { |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
94 StandardMetaspaceType, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
95 BootMetaspaceType, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
96 ROMetaspaceType, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
97 ReadWriteMetaspaceType, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
98 AnonymousMetaspaceType, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
99 ReflectionMetaspaceType |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
100 }; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
101 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
102 private: |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
103 void initialize(Mutex* lock, MetaspaceType type); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
104 |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
105 // Align up the word size to the allocation word size |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
106 static size_t align_word_size_up(size_t); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
107 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
108 static size_t _first_chunk_word_size; |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
109 static size_t _first_class_chunk_word_size; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
110 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
111 SpaceManager* _vsm; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
112 SpaceManager* vsm() const { return _vsm; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
113 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
114 SpaceManager* _class_vsm; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
115 SpaceManager* class_vsm() const { return _class_vsm; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
116 |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
117 // Allocate space for metadata of type mdtype. This is space |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
118 // within a Metachunk and is used by |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
119 // allocate(ClassLoaderData*, size_t, bool, MetadataType, TRAPS) |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
120 // which returns a Metablock. |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
121 MetaWord* allocate(size_t word_size, MetadataType mdtype); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
122 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
123 // Virtual Space lists for both classes and other metadata |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
124 static VirtualSpaceList* _space_list; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
125 static VirtualSpaceList* _class_space_list; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
126 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
127 static VirtualSpaceList* space_list() { return _space_list; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
128 static VirtualSpaceList* class_space_list() { return _class_space_list; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
129 |
10376
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
130 // This is used by DumpSharedSpaces only, where only _vsm is used. So we will |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
131 // maintain a single list for now. |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
132 void record_allocation(void* ptr, MetaspaceObj::Type type, size_t word_size); |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
133 |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
134 class AllocRecord : public CHeapObj<mtClass> { |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
135 public: |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
136 AllocRecord(address ptr, MetaspaceObj::Type type, int byte_size) |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
137 : _next(NULL), _ptr(ptr), _type(type), _byte_size(byte_size) {} |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
138 AllocRecord *_next; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
139 address _ptr; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
140 MetaspaceObj::Type _type; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
141 int _byte_size; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
142 }; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
143 |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
144 AllocRecord * _alloc_record_head; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
145 AllocRecord * _alloc_record_tail; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
146 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
147 public: |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
148 |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
149 Metaspace(Mutex* lock, MetaspaceType type); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
150 ~Metaspace(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
151 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
152 // Initialize globals for Metaspace |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
153 static void global_initialize(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
154 static void initialize_class_space(ReservedSpace rs); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
155 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
156 static size_t first_chunk_word_size() { return _first_chunk_word_size; } |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
157 static size_t first_class_chunk_word_size() { return _first_class_chunk_word_size; } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
158 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
159 char* bottom() const; |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
160 size_t used_words_slow(MetadataType mdtype) const; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
161 size_t free_words(MetadataType mdtype) const; |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
162 size_t capacity_words_slow(MetadataType mdtype) const; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
163 size_t waste_words(MetadataType mdtype) const; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
164 |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
165 size_t used_bytes_slow(MetadataType mdtype) const; |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
166 size_t capacity_bytes_slow(MetadataType mdtype) const; |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
167 |
10376
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
168 static Metablock* allocate(ClassLoaderData* loader_data, size_t word_size, |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
169 bool read_only, MetaspaceObj::Type type, TRAPS); |
6753
8da5e203b993
7197557: NPG: nsk/sysdict/vm/stress/chain/chain004 hangs intermittently
jmasa
parents:
6734
diff
changeset
|
170 void deallocate(MetaWord* ptr, size_t byte_size, bool is_class); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
171 |
6753
8da5e203b993
7197557: NPG: nsk/sysdict/vm/stress/chain/chain004 hangs intermittently
jmasa
parents:
6734
diff
changeset
|
172 MetaWord* expand_and_allocate(size_t size, |
8da5e203b993
7197557: NPG: nsk/sysdict/vm/stress/chain/chain004 hangs intermittently
jmasa
parents:
6734
diff
changeset
|
173 MetadataType mdtype); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
174 |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6753
diff
changeset
|
175 static bool is_initialized() { return _class_space_list != NULL; } |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6753
diff
changeset
|
176 |
7176
59c790074993
8003635: NPG: AsynchGetCallTrace broken by Method* virtual call
coleenp
parents:
6969
diff
changeset
|
177 static bool contains(const void *ptr); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
178 void dump(outputStream* const out) const; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
179 |
10175 | 180 // Free empty virtualspaces |
181 static void purge(); | |
182 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
183 void print_on(outputStream* st) const; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
184 // Debugging support |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
185 void verify(); |
10376
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
186 |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
187 class AllocRecordClosure : public StackObj { |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
188 public: |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
189 virtual void doit(address ptr, MetaspaceObj::Type type, int byte_size) = 0; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
190 }; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
191 |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
192 void iterate(AllocRecordClosure *closure); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
193 }; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
194 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
195 class MetaspaceAux : AllStatic { |
10405 | 196 static size_t free_chunks_total(Metaspace::MetadataType mdtype); |
197 static size_t free_chunks_total_in_bytes(Metaspace::MetadataType mdtype); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
198 |
10405 | 199 public: |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
200 // Statistics for class space and data space in metaspace. |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
201 |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
202 // These methods iterate over the classloader data graph |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
203 // for the given Metaspace type. These are slow. |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
204 static size_t used_bytes_slow(Metaspace::MetadataType mdtype); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
205 static size_t free_in_bytes(Metaspace::MetadataType mdtype); |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
206 static size_t capacity_bytes_slow(Metaspace::MetadataType mdtype); |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
207 |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
208 // Iterates over the virtual space list. |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
209 static size_t reserved_in_bytes(Metaspace::MetadataType mdtype); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
210 |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
211 // Running sum of space in all Metachunks that has been |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
212 // allocated to a Metaspace. This is used instead of |
10330
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10183
diff
changeset
|
213 // iterating over all the classloaders. One for each |
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10183
diff
changeset
|
214 // type of Metadata |
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10183
diff
changeset
|
215 static size_t _allocated_capacity_words[Metaspace:: MetadataTypeCount]; |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
216 // Running sum of space in all Metachunks that have |
10330
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10183
diff
changeset
|
217 // are being used for metadata. One for each |
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10183
diff
changeset
|
218 // type of Metadata. |
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10183
diff
changeset
|
219 static size_t _allocated_used_words[Metaspace:: MetadataTypeCount]; |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
220 |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
221 public: |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
222 // Decrement and increment _allocated_capacity_words |
10330
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10183
diff
changeset
|
223 static void dec_capacity(Metaspace::MetadataType type, size_t words); |
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10183
diff
changeset
|
224 static void inc_capacity(Metaspace::MetadataType type, size_t words); |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
225 |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
226 // Decrement and increment _allocated_used_words |
10330
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10183
diff
changeset
|
227 static void dec_used(Metaspace::MetadataType type, size_t words); |
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10183
diff
changeset
|
228 static void inc_used(Metaspace::MetadataType type, size_t words); |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
229 |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
230 // Total of space allocated to metadata in all Metaspaces. |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
231 // This sums the space used in each Metachunk by |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
232 // iterating over the classloader data graph |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
233 static size_t used_bytes_slow() { |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
234 return used_bytes_slow(Metaspace::ClassType) + |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
235 used_bytes_slow(Metaspace::NonClassType); |
7435
c71879335291
8005108: NPG: MetaspaceAux::used_in_bytes(), capacity_in_bytes() and reserved_in_bytes() return inconsistent numbers
stefank
parents:
7187
diff
changeset
|
236 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
237 |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
238 // Used by MetaspaceCounters |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
239 static size_t free_chunks_total(); |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
240 static size_t free_chunks_total_in_bytes(); |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
241 |
10330
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10183
diff
changeset
|
242 static size_t allocated_capacity_words(Metaspace::MetadataType mdtype) { |
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10183
diff
changeset
|
243 return _allocated_capacity_words[mdtype]; |
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10183
diff
changeset
|
244 } |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
245 static size_t allocated_capacity_words() { |
10330
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10183
diff
changeset
|
246 return _allocated_capacity_words[Metaspace::ClassType] + |
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10183
diff
changeset
|
247 _allocated_capacity_words[Metaspace::NonClassType]; |
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10183
diff
changeset
|
248 } |
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10183
diff
changeset
|
249 static size_t allocated_capacity_bytes(Metaspace::MetadataType mdtype) { |
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10183
diff
changeset
|
250 return allocated_capacity_words(mdtype) * BytesPerWord; |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
251 } |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
252 static size_t allocated_capacity_bytes() { |
10330
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10183
diff
changeset
|
253 return allocated_capacity_words() * BytesPerWord; |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
254 } |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
255 |
10330
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10183
diff
changeset
|
256 static size_t allocated_used_words(Metaspace::MetadataType mdtype) { |
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10183
diff
changeset
|
257 return _allocated_used_words[mdtype]; |
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10183
diff
changeset
|
258 } |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
259 static size_t allocated_used_words() { |
10330
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10183
diff
changeset
|
260 return _allocated_used_words[Metaspace::ClassType] + |
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10183
diff
changeset
|
261 _allocated_used_words[Metaspace::NonClassType]; |
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10183
diff
changeset
|
262 } |
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10183
diff
changeset
|
263 static size_t allocated_used_bytes(Metaspace::MetadataType mdtype) { |
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10183
diff
changeset
|
264 return allocated_used_words(mdtype) * BytesPerWord; |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
265 } |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
266 static size_t allocated_used_bytes() { |
10330
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10183
diff
changeset
|
267 return allocated_used_words() * BytesPerWord; |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
268 } |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
269 |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
270 static size_t free_bytes(); |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
271 |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
272 // Total capacity in all Metaspaces |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
273 static size_t capacity_bytes_slow() { |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
274 #ifdef PRODUCT |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
275 // Use allocated_capacity_bytes() in PRODUCT instead of this function. |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
276 guarantee(false, "Should not call capacity_bytes_slow() in the PRODUCT"); |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
277 #endif |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
278 size_t class_capacity = capacity_bytes_slow(Metaspace::ClassType); |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
279 size_t non_class_capacity = capacity_bytes_slow(Metaspace::NonClassType); |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
280 assert(allocated_capacity_bytes() == class_capacity + non_class_capacity, |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
281 err_msg("bad accounting: allocated_capacity_bytes() " SIZE_FORMAT |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
282 " class_capacity + non_class_capacity " SIZE_FORMAT |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
283 " class_capacity " SIZE_FORMAT " non_class_capacity " SIZE_FORMAT, |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
284 allocated_capacity_bytes(), class_capacity + non_class_capacity, |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
285 class_capacity, non_class_capacity)); |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
286 |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
287 return class_capacity + non_class_capacity; |
7435
c71879335291
8005108: NPG: MetaspaceAux::used_in_bytes(), capacity_in_bytes() and reserved_in_bytes() return inconsistent numbers
stefank
parents:
7187
diff
changeset
|
288 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
289 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
290 // Total space reserved in all Metaspaces |
7435
c71879335291
8005108: NPG: MetaspaceAux::used_in_bytes(), capacity_in_bytes() and reserved_in_bytes() return inconsistent numbers
stefank
parents:
7187
diff
changeset
|
291 static size_t reserved_in_bytes() { |
c71879335291
8005108: NPG: MetaspaceAux::used_in_bytes(), capacity_in_bytes() and reserved_in_bytes() return inconsistent numbers
stefank
parents:
7187
diff
changeset
|
292 return reserved_in_bytes(Metaspace::ClassType) + |
c71879335291
8005108: NPG: MetaspaceAux::used_in_bytes(), capacity_in_bytes() and reserved_in_bytes() return inconsistent numbers
stefank
parents:
7187
diff
changeset
|
293 reserved_in_bytes(Metaspace::NonClassType); |
c71879335291
8005108: NPG: MetaspaceAux::used_in_bytes(), capacity_in_bytes() and reserved_in_bytes() return inconsistent numbers
stefank
parents:
7187
diff
changeset
|
294 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
295 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
296 static size_t min_chunk_size(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
297 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
298 // Print change in used metadata. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
299 static void print_metaspace_change(size_t prev_metadata_used); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
300 static void print_on(outputStream * out); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
301 static void print_on(outputStream * out, Metaspace::MetadataType mdtype); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
302 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
303 static void print_waste(outputStream* out); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
304 static void dump(outputStream* out); |
6969
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
305 static void verify_free_chunks(); |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
306 // Checks that the values returned by allocated_capacity_bytes() and |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
307 // capacity_bytes_slow() are the same. |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
308 static void verify_capacity(); |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
309 static void verify_used(); |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
310 static void verify_metrics(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
311 }; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
312 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
313 // Metaspace are deallocated when their class loader are GC'ed. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
314 // This class implements a policy for inducing GC's to recover |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
315 // Metaspaces. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
316 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
317 class MetaspaceGC : AllStatic { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
318 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
319 // The current high-water-mark for inducing a GC. When |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
320 // the capacity of all space in the virtual lists reaches this value, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
321 // a GC is induced and the value is increased. This should be changed |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
322 // to the space actually used for allocations to avoid affects of |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
323 // fragmentation losses to partially used chunks. Size is in words. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
324 static size_t _capacity_until_GC; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
325 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
326 // After a GC is done any allocation that fails should try to expand |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
327 // the capacity of the Metaspaces. This flag is set during attempts |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
328 // to allocate in the VMGCOperation that does the GC. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
329 static bool _expand_after_GC; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
330 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
331 // For a CMS collection, signal that a concurrent collection should |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
332 // be started. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
333 static bool _should_concurrent_collect; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
334 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
335 static uint _shrink_factor; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
336 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
337 static void set_capacity_until_GC(size_t v) { _capacity_until_GC = v; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
338 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
339 static size_t shrink_factor() { return _shrink_factor; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
340 void set_shrink_factor(uint v) { _shrink_factor = v; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
341 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
342 public: |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
343 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
344 static size_t capacity_until_GC() { return _capacity_until_GC; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
345 static void inc_capacity_until_GC(size_t v) { _capacity_until_GC += v; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
346 static void dec_capacity_until_GC(size_t v) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
347 _capacity_until_GC = _capacity_until_GC > v ? _capacity_until_GC - v : 0; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
348 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
349 static bool expand_after_GC() { return _expand_after_GC; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
350 static void set_expand_after_GC(bool v) { _expand_after_GC = v; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
351 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
352 static bool should_concurrent_collect() { return _should_concurrent_collect; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
353 static void set_should_concurrent_collect(bool v) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
354 _should_concurrent_collect = v; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
355 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
356 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
357 // The amount to increase the high-water-mark (_capacity_until_GC) |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
358 static size_t delta_capacity_until_GC(size_t word_size); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
359 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
360 // It is expected that this will be called when the current capacity |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
361 // has been used and a GC should be considered. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
362 static bool should_expand(VirtualSpaceList* vsl, size_t word_size); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
363 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
364 // Calculate the new high-water mark at which to induce |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
365 // a GC. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
366 static void compute_new_size(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
367 }; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
368 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
369 #endif // SHARE_VM_MEMORY_METASPACE_HPP |