Mercurial > hg > truffle
annotate src/share/vm/memory/metaspace.cpp @ 17930:8c7ba9f705a1
8043308: new hotspot build - hs25.20-b16
Reviewed-by: jcoomes
author | amurillo |
---|---|
date | Fri, 16 May 2014 03:28:59 -0700 |
parents | 270d7cb38f40 |
children | 7384f6a12fc1 |
rev | line source |
---|---|
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1 /* |
8712
3efdfd6ddbf2
8003553: NPG: metaspace objects should be zeroed in constructors
coleenp
parents:
8040
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 #include "precompiled.hpp" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
25 #include "gc_interface/collectedHeap.hpp" |
12303
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
26 #include "memory/allocation.hpp" |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
27 #include "memory/binaryTreeDictionary.hpp" |
6885 | 28 #include "memory/freeList.hpp" |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
29 #include "memory/collectorPolicy.hpp" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
30 #include "memory/filemap.hpp" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
31 #include "memory/freeList.hpp" |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
32 #include "memory/gcLocker.hpp" |
6885 | 33 #include "memory/metachunk.hpp" |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
34 #include "memory/metaspace.hpp" |
17768
daef39043d2c
8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents:
17695
diff
changeset
|
35 #include "memory/metaspaceGCThresholdUpdater.hpp" |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
36 #include "memory/metaspaceShared.hpp" |
17768
daef39043d2c
8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents:
17695
diff
changeset
|
37 #include "memory/metaspaceTracer.hpp" |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
38 #include "memory/resourceArea.hpp" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
39 #include "memory/universe.hpp" |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
40 #include "runtime/atomic.inline.hpp" |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
41 #include "runtime/globals.hpp" |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
42 #include "runtime/init.hpp" |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
43 #include "runtime/java.hpp" |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
44 #include "runtime/mutex.hpp" |
7176
59c790074993
8003635: NPG: AsynchGetCallTrace broken by Method* virtual call
coleenp
parents:
6969
diff
changeset
|
45 #include "runtime/orderAccess.hpp" |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
46 #include "services/memTracker.hpp" |
12839
a6414751d537
8025996: Track metaspace usage when metaspace is expanded
stefank
parents:
12838
diff
changeset
|
47 #include "services/memoryService.hpp" |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
48 #include "utilities/copy.hpp" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
49 #include "utilities/debug.hpp" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
50 |
17695
ab36007d6358
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
17663
diff
changeset
|
51 typedef BinaryTreeDictionary<Metablock, FreeList<Metablock> > BlockTreeDictionary; |
ab36007d6358
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
17663
diff
changeset
|
52 typedef BinaryTreeDictionary<Metachunk, FreeList<Metachunk> > ChunkTreeDictionary; |
12902 | 53 |
54 // Set this constant to enable slow integrity checking of the free chunk lists | |
6969
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
55 const bool metaspace_slow_verify = false; |
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
56 |
12231
24e87613ee58
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
12226
diff
changeset
|
57 size_t const allocation_from_dictionary_limit = 4 * K; |
6725
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 MetaWord* last_allocated = 0; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
60 |
13000
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
12998
diff
changeset
|
61 size_t Metaspace::_compressed_class_space_size; |
17768
daef39043d2c
8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents:
17695
diff
changeset
|
62 const MetaspaceTracer* Metaspace::_tracer = NULL; |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
63 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
64 // Used in declarations in SpaceManager and ChunkManager |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
65 enum ChunkIndex { |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
66 ZeroIndex = 0, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
67 SpecializedIndex = ZeroIndex, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
68 SmallIndex = SpecializedIndex + 1, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
69 MediumIndex = SmallIndex + 1, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
70 HumongousIndex = MediumIndex + 1, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
71 NumberOfFreeLists = 3, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
72 NumberOfInUseLists = 4 |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
73 }; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
74 |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
75 enum ChunkSizes { // in words. |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
76 ClassSpecializedChunk = 128, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
77 SpecializedChunk = 128, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
78 ClassSmallChunk = 256, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
79 SmallChunk = 512, |
11064
de2d15ce3d4a
8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents:
10376
diff
changeset
|
80 ClassMediumChunk = 4 * K, |
12979
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
81 MediumChunk = 8 * K |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
82 }; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
83 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
84 static ChunkIndex next_chunk_index(ChunkIndex i) { |
6885 | 85 assert(i < NumberOfInUseLists, "Out of bound"); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
86 return (ChunkIndex) (i+1); |
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 |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
89 volatile intptr_t MetaspaceGC::_capacity_until_GC = 0; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
90 uint MetaspaceGC::_shrink_factor = 0; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
91 bool MetaspaceGC::_should_concurrent_collect = false; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
92 |
10101
df254344edf1
8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents:
8813
diff
changeset
|
93 typedef class FreeList<Metachunk> ChunkList; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
94 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
95 // Manages the global free lists of chunks. |
12303
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
96 class ChunkManager : public CHeapObj<mtInternal> { |
12979
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
97 friend class TestVirtualSpaceNodeTest; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
98 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
99 // Free list of chunks of different sizes. |
10175 | 100 // SpecializedChunk |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
101 // SmallChunk |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
102 // MediumChunk |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
103 // HumongousChunk |
6885 | 104 ChunkList _free_chunks[NumberOfFreeLists]; |
105 | |
106 // HumongousChunk | |
107 ChunkTreeDictionary _humongous_dictionary; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
108 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
109 // ChunkManager in all lists of this type |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
110 size_t _free_chunks_total; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
111 size_t _free_chunks_count; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
112 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
113 void dec_free_chunks_total(size_t v) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
114 assert(_free_chunks_count > 0 && |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
115 _free_chunks_total > 0, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
116 "About to go negative"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
117 Atomic::add_ptr(-1, &_free_chunks_count); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
118 jlong minus_v = (jlong) - (jlong) v; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
119 Atomic::add_ptr(minus_v, &_free_chunks_total); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
120 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
121 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
122 // Debug support |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
123 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
124 size_t sum_free_chunks(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
125 size_t sum_free_chunks_count(); |
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 void locked_verify_free_chunks_total(); |
6969
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
128 void slow_locked_verify_free_chunks_total() { |
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
129 if (metaspace_slow_verify) { |
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
130 locked_verify_free_chunks_total(); |
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
131 } |
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
132 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
133 void locked_verify_free_chunks_count(); |
6969
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
134 void slow_locked_verify_free_chunks_count() { |
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
135 if (metaspace_slow_verify) { |
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
136 locked_verify_free_chunks_count(); |
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
137 } |
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
138 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
139 void verify_free_chunks_count(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
140 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
141 public: |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
142 |
12303
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
143 ChunkManager(size_t specialized_size, size_t small_size, size_t medium_size) |
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
144 : _free_chunks_total(0), _free_chunks_count(0) { |
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
145 _free_chunks[SpecializedIndex].set_size(specialized_size); |
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
146 _free_chunks[SmallIndex].set_size(small_size); |
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
147 _free_chunks[MediumIndex].set_size(medium_size); |
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
148 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
149 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
150 // add or delete (return) a chunk to the global freelist. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
151 Metachunk* chunk_freelist_allocate(size_t word_size); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
152 |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
153 // Map a size to a list index assuming that there are lists |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
154 // for special, small, medium, and humongous chunks. |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
155 static ChunkIndex list_index(size_t size); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
156 |
10175 | 157 // Remove the chunk from its freelist. It is |
158 // expected to be on one of the _free_chunks[] lists. | |
159 void remove_chunk(Metachunk* chunk); | |
160 | |
10101
df254344edf1
8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents:
8813
diff
changeset
|
161 // Add the simple linked list of chunks to the freelist of chunks |
df254344edf1
8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents:
8813
diff
changeset
|
162 // of type index. |
df254344edf1
8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents:
8813
diff
changeset
|
163 void return_chunks(ChunkIndex index, Metachunk* chunks); |
df254344edf1
8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents:
8813
diff
changeset
|
164 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
165 // Total of the space in the free chunks list |
12235 | 166 size_t free_chunks_total_words(); |
167 size_t free_chunks_total_bytes(); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
168 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
169 // Number of chunks in the free chunks list |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
170 size_t free_chunks_count(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
171 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
172 void inc_free_chunks_total(size_t v, size_t count = 1) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
173 Atomic::add_ptr(count, &_free_chunks_count); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
174 Atomic::add_ptr(v, &_free_chunks_total); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
175 } |
6885 | 176 ChunkTreeDictionary* humongous_dictionary() { |
177 return &_humongous_dictionary; | |
178 } | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
179 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
180 ChunkList* free_chunks(ChunkIndex index); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
181 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
182 // Returns the list for the given chunk word size. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
183 ChunkList* find_free_chunks_list(size_t word_size); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
184 |
12906
94c0343b1887
8026715: Remove the MetaDataDeallocateALot develop flag
stefank
parents:
12902
diff
changeset
|
185 // Remove from a list by size. Selects list based on size of chunk. |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
186 Metachunk* free_chunks_get(size_t chunk_word_size); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
187 |
17771
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
188 #define index_bounds_check(index) \ |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
189 assert(index == SpecializedIndex || \ |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
190 index == SmallIndex || \ |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
191 index == MediumIndex || \ |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
192 index == HumongousIndex, err_msg("Bad index: %d", (int) index)) |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
193 |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
194 size_t num_free_chunks(ChunkIndex index) const { |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
195 index_bounds_check(index); |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
196 |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
197 if (index == HumongousIndex) { |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
198 return _humongous_dictionary.total_free_blocks(); |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
199 } |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
200 |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
201 ssize_t count = _free_chunks[index].count(); |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
202 return count == -1 ? 0 : (size_t) count; |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
203 } |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
204 |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
205 size_t size_free_chunks_in_bytes(ChunkIndex index) const { |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
206 index_bounds_check(index); |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
207 |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
208 size_t word_size = 0; |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
209 if (index == HumongousIndex) { |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
210 word_size = _humongous_dictionary.total_size(); |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
211 } else { |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
212 const size_t size_per_chunk_in_words = _free_chunks[index].size(); |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
213 word_size = size_per_chunk_in_words * num_free_chunks(index); |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
214 } |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
215 |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
216 return word_size * BytesPerWord; |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
217 } |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
218 |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
219 MetaspaceChunkFreeListSummary chunk_free_list_summary() const { |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
220 return MetaspaceChunkFreeListSummary(num_free_chunks(SpecializedIndex), |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
221 num_free_chunks(SmallIndex), |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
222 num_free_chunks(MediumIndex), |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
223 num_free_chunks(HumongousIndex), |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
224 size_free_chunks_in_bytes(SpecializedIndex), |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
225 size_free_chunks_in_bytes(SmallIndex), |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
226 size_free_chunks_in_bytes(MediumIndex), |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
227 size_free_chunks_in_bytes(HumongousIndex)); |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
228 } |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
229 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
230 // Debug support |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
231 void verify(); |
6969
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
232 void slow_verify() { |
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
233 if (metaspace_slow_verify) { |
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
234 verify(); |
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
235 } |
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
236 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
237 void locked_verify(); |
6969
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
238 void slow_locked_verify() { |
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
239 if (metaspace_slow_verify) { |
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
240 locked_verify(); |
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
241 } |
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
242 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
243 void verify_free_chunks_total(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
244 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
245 void locked_print_free_chunks(outputStream* st); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
246 void locked_print_sum_free_chunks(outputStream* st); |
6885 | 247 |
12303
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
248 void print_on(outputStream* st) const; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
249 }; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
250 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
251 // Used to manage the free list of Metablocks (a block corresponds |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
252 // to the allocation of a quantum of metadata). |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
253 class BlockFreelist VALUE_OBJ_CLASS_SPEC { |
6885 | 254 BlockTreeDictionary* _dictionary; |
255 | |
12231
24e87613ee58
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
12226
diff
changeset
|
256 // Only allocate and split from freelist if the size of the allocation |
24e87613ee58
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
12226
diff
changeset
|
257 // is at least 1/4th the size of the available block. |
24e87613ee58
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
12226
diff
changeset
|
258 const static int WasteMultiplier = 4; |
24e87613ee58
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
12226
diff
changeset
|
259 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
260 // Accessors |
6885 | 261 BlockTreeDictionary* dictionary() const { return _dictionary; } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
262 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
263 public: |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
264 BlockFreelist(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
265 ~BlockFreelist(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
266 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
267 // Get and return a block to the free list |
6885 | 268 MetaWord* get_block(size_t word_size); |
269 void return_block(MetaWord* p, size_t word_size); | |
270 | |
271 size_t total_size() { | |
272 if (dictionary() == NULL) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
273 return 0; |
6885 | 274 } else { |
275 return dictionary()->total_size(); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
276 } |
6885 | 277 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
278 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
279 void print_on(outputStream* st) const; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
280 }; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
281 |
12902 | 282 // A VirtualSpaceList node. |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
283 class VirtualSpaceNode : public CHeapObj<mtClass> { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
284 friend class VirtualSpaceList; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
285 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
286 // Link to next VirtualSpaceNode |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
287 VirtualSpaceNode* _next; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
288 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
289 // total in the VirtualSpace |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
290 MemRegion _reserved; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
291 ReservedSpace _rs; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
292 VirtualSpace _virtual_space; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
293 MetaWord* _top; |
10175 | 294 // count of chunks contained in this VirtualSpace |
295 uintx _container_count; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
296 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
297 // Convenience functions to access the _virtual_space |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
298 char* low() const { return virtual_space()->low(); } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
299 char* high() const { return virtual_space()->high(); } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
300 |
10175 | 301 // The first Metachunk will be allocated at the bottom of the |
302 // VirtualSpace | |
303 Metachunk* first_chunk() { return (Metachunk*) bottom(); } | |
304 | |
12979
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
305 // Committed but unused space in the virtual space |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
306 size_t free_words_in_vs() const; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
307 public: |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
308 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
309 VirtualSpaceNode(size_t byte_size); |
10175 | 310 VirtualSpaceNode(ReservedSpace rs) : _top(NULL), _next(NULL), _rs(rs), _container_count(0) {} |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
311 ~VirtualSpaceNode(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
312 |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
313 // Convenience functions for logical bottom and end |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
314 MetaWord* bottom() const { return (MetaWord*) _virtual_space.low(); } |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
315 MetaWord* end() const { return (MetaWord*) _virtual_space.high(); } |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
316 |
12236
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
317 size_t reserved_words() const { return _virtual_space.reserved_size() / BytesPerWord; } |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
318 size_t committed_words() const { return _virtual_space.actual_committed_size() / BytesPerWord; } |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
319 |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
320 bool is_pre_committed() const { return _virtual_space.special(); } |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
321 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
322 // address of next available space in _virtual_space; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
323 // Accessors |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
324 VirtualSpaceNode* next() { return _next; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
325 void set_next(VirtualSpaceNode* v) { _next = v; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
326 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
327 void set_reserved(MemRegion const v) { _reserved = v; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
328 void set_top(MetaWord* v) { _top = v; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
329 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
330 // Accessors |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
331 MemRegion* reserved() { return &_reserved; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
332 VirtualSpace* virtual_space() const { return (VirtualSpace*) &_virtual_space; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
333 |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
334 // Returns true if "word_size" is available in the VirtualSpace |
13439
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
335 bool is_available(size_t word_size) { return word_size <= pointer_delta(end(), _top, sizeof(MetaWord)); } |
6725
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 MetaWord* top() const { return _top; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
338 void inc_top(size_t word_size) { _top += word_size; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
339 |
10175 | 340 uintx container_count() { return _container_count; } |
12303
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
341 void inc_container_count(); |
10175 | 342 void dec_container_count(); |
343 #ifdef ASSERT | |
12303
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
344 uint container_count_slow(); |
10175 | 345 void verify_container_count(); |
346 #endif | |
347 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
348 // used and capacity in this single entry in the list |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
349 size_t used_words_in_vs() const; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
350 size_t capacity_words_in_vs() const; |
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 bool initialize(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
353 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
354 // get space from the virtual space |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
355 Metachunk* take_from_committed(size_t chunk_word_size); |
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 // Allocate a chunk from the virtual space and return it. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
358 Metachunk* get_chunk_vs(size_t chunk_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 // Expands/shrinks the committed space in a virtual space. Delegates |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
361 // to Virtualspace |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
362 bool expand_by(size_t min_words, size_t preferred_words); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
363 |
10175 | 364 // In preparation for deleting this node, remove all the chunks |
365 // in the node from any freelist. | |
366 void purge(ChunkManager* chunk_manager); | |
367 | |
12979
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
368 // If an allocation doesn't fit in the current node a new node is created. |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
369 // Allocate chunks out of the remaining committed space in this node |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
370 // to avoid wasting that memory. |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
371 // This always adds up because all the chunk sizes are multiples of |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
372 // the smallest chunk size. |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
373 void retire(ChunkManager* chunk_manager); |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
374 |
7185
90273fc0a981
8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents:
6969
diff
changeset
|
375 #ifdef ASSERT |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
376 // Debug support |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
377 void mangle(); |
7185
90273fc0a981
8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents:
6969
diff
changeset
|
378 #endif |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
379 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
380 void print_on(outputStream* st) const; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
381 }; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
382 |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
383 #define assert_is_ptr_aligned(ptr, alignment) \ |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
384 assert(is_ptr_aligned(ptr, alignment), \ |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
385 err_msg(PTR_FORMAT " is not aligned to " \ |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
386 SIZE_FORMAT, ptr, alignment)) |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
387 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
388 #define assert_is_size_aligned(size, alignment) \ |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
389 assert(is_size_aligned(size, alignment), \ |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
390 err_msg(SIZE_FORMAT " is not aligned to " \ |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
391 SIZE_FORMAT, size, alignment)) |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
392 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
393 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
394 // Decide if large pages should be committed when the memory is reserved. |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
395 static bool should_commit_large_pages_when_reserving(size_t bytes) { |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
396 if (UseLargePages && UseLargePagesInMetaspace && !os::can_commit_large_page_memory()) { |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
397 size_t words = bytes / BytesPerWord; |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
398 bool is_class = false; // We never reserve large pages for the class space. |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
399 if (MetaspaceGC::can_expand(words, is_class) && |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
400 MetaspaceGC::allowed_expansion() >= words) { |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
401 return true; |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
402 } |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
403 } |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
404 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
405 return false; |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
406 } |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
407 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
408 // byte_size is the size of the associated virtualspace. |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
409 VirtualSpaceNode::VirtualSpaceNode(size_t bytes) : _top(NULL), _next(NULL), _rs(), _container_count(0) { |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
410 assert_is_size_aligned(bytes, Metaspace::reserve_alignment()); |
8752
82f49e8e2c28
8009614: nsk/split_verifier/stress/ifelse/ifelse002_30 fails with 'assert((size & (granularity - 1)) == 0) failed: size not aligned to os::vm_allocation_granularity()
zgu
parents:
8712
diff
changeset
|
411 |
8804
91bf0bdae37b
8008217: CDS: Class data sharing limits the malloc heap on Solaris
coleenp
parents:
8754
diff
changeset
|
412 // This allocates memory with mmap. For DumpSharedspaces, try to reserve |
91bf0bdae37b
8008217: CDS: Class data sharing limits the malloc heap on Solaris
coleenp
parents:
8754
diff
changeset
|
413 // configurable address, generally at the top of the Java heap so other |
91bf0bdae37b
8008217: CDS: Class data sharing limits the malloc heap on Solaris
coleenp
parents:
8754
diff
changeset
|
414 // memory addresses don't conflict. |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
415 if (DumpSharedSpaces) { |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
416 bool large_pages = false; // No large pages when dumping the CDS archive. |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
417 char* shared_base = (char*)align_ptr_up((char*)SharedBaseAddress, Metaspace::reserve_alignment()); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
418 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
419 _rs = ReservedSpace(bytes, Metaspace::reserve_alignment(), large_pages, shared_base, 0); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
420 if (_rs.is_reserved()) { |
8804
91bf0bdae37b
8008217: CDS: Class data sharing limits the malloc heap on Solaris
coleenp
parents:
8754
diff
changeset
|
421 assert(shared_base == 0 || _rs.base() == shared_base, "should match"); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
422 } else { |
8804
91bf0bdae37b
8008217: CDS: Class data sharing limits the malloc heap on Solaris
coleenp
parents:
8754
diff
changeset
|
423 // Get a mmap region anywhere if the SharedBaseAddress fails. |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
424 _rs = ReservedSpace(bytes, Metaspace::reserve_alignment(), large_pages); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
425 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
426 MetaspaceShared::set_shared_rs(&_rs); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
427 } else { |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
428 bool large_pages = should_commit_large_pages_when_reserving(bytes); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
429 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
430 _rs = ReservedSpace(bytes, Metaspace::reserve_alignment(), large_pages); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
431 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
432 |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
433 if (_rs.is_reserved()) { |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
434 assert(_rs.base() != NULL, "Catch if we get a NULL address"); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
435 assert(_rs.size() != 0, "Catch if we get a 0 size"); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
436 assert_is_ptr_aligned(_rs.base(), Metaspace::reserve_alignment()); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
437 assert_is_size_aligned(_rs.size(), Metaspace::reserve_alignment()); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
438 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
439 MemTracker::record_virtual_memory_type((address)_rs.base(), mtClass); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
440 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
441 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
442 |
10175 | 443 void VirtualSpaceNode::purge(ChunkManager* chunk_manager) { |
444 Metachunk* chunk = first_chunk(); | |
445 Metachunk* invalid_chunk = (Metachunk*) top(); | |
446 while (chunk < invalid_chunk ) { | |
12902 | 447 assert(chunk->is_tagged_free(), "Should be tagged free"); |
448 MetaWord* next = ((MetaWord*)chunk) + chunk->word_size(); | |
449 chunk_manager->remove_chunk(chunk); | |
450 assert(chunk->next() == NULL && | |
451 chunk->prev() == NULL, | |
452 "Was not removed from its list"); | |
453 chunk = (Metachunk*) next; | |
10175 | 454 } |
455 } | |
456 | |
457 #ifdef ASSERT | |
458 uint VirtualSpaceNode::container_count_slow() { | |
459 uint count = 0; | |
460 Metachunk* chunk = first_chunk(); | |
461 Metachunk* invalid_chunk = (Metachunk*) top(); | |
462 while (chunk < invalid_chunk ) { | |
463 MetaWord* next = ((MetaWord*)chunk) + chunk->word_size(); | |
464 // Don't count the chunks on the free lists. Those are | |
465 // still part of the VirtualSpaceNode but not currently | |
466 // counted. | |
12902 | 467 if (!chunk->is_tagged_free()) { |
10175 | 468 count++; |
469 } | |
470 chunk = (Metachunk*) next; | |
471 } | |
472 return count; | |
473 } | |
474 #endif | |
475 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
476 // List of VirtualSpaces for metadata allocation. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
477 class VirtualSpaceList : public CHeapObj<mtClass> { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
478 friend class VirtualSpaceNode; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
479 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
480 enum VirtualSpaceSizes { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
481 VirtualSpaceSize = 256 * K |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
482 }; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
483 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
484 // Head of the list |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
485 VirtualSpaceNode* _virtual_space_list; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
486 // virtual space currently being used for allocations |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
487 VirtualSpaceNode* _current_virtual_space; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
488 |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
489 // Is this VirtualSpaceList used for the compressed class space |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
490 bool _is_class; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
491 |
12236
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
492 // Sum of reserved and committed memory in the virtual spaces |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
493 size_t _reserved_words; |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
494 size_t _committed_words; |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
495 |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
496 // Number of virtual spaces |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
497 size_t _virtual_space_count; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
498 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
499 ~VirtualSpaceList(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
500 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
501 VirtualSpaceNode* virtual_space_list() const { return _virtual_space_list; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
502 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
503 void set_virtual_space_list(VirtualSpaceNode* v) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
504 _virtual_space_list = v; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
505 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
506 void set_current_virtual_space(VirtualSpaceNode* v) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
507 _current_virtual_space = v; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
508 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
509 |
12236
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
510 void link_vs(VirtualSpaceNode* new_entry); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
511 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
512 // Get another virtual space and add it to the list. This |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
513 // is typically prompted by a failed attempt to allocate a chunk |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
514 // and is typically followed by the allocation of a chunk. |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
515 bool create_new_virtual_space(size_t vs_word_size); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
516 |
12979
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
517 // Chunk up the unused committed space in the current |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
518 // virtual space and add the chunks to the free list. |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
519 void retire_current_virtual_space(); |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
520 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
521 public: |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
522 VirtualSpaceList(size_t word_size); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
523 VirtualSpaceList(ReservedSpace rs); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
524 |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
525 size_t free_bytes(); |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
526 |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
527 Metachunk* get_new_chunk(size_t word_size, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
528 size_t grow_chunks_by_words, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
529 size_t medium_chunk_bunch); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
530 |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
531 bool expand_node_by(VirtualSpaceNode* node, |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
532 size_t min_words, |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
533 size_t preferred_words); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
534 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
535 bool expand_by(size_t min_words, |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
536 size_t preferred_words); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
537 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
538 VirtualSpaceNode* current_virtual_space() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
539 return _current_virtual_space; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
540 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
541 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
542 bool is_class() const { return _is_class; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
543 |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
544 bool initialization_succeeded() { return _virtual_space_list != NULL; } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
545 |
12236
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
546 size_t reserved_words() { return _reserved_words; } |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
547 size_t reserved_bytes() { return reserved_words() * BytesPerWord; } |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
548 size_t committed_words() { return _committed_words; } |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
549 size_t committed_bytes() { return committed_words() * BytesPerWord; } |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
550 |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
551 void inc_reserved_words(size_t v); |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
552 void dec_reserved_words(size_t v); |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
553 void inc_committed_words(size_t v); |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
554 void dec_committed_words(size_t v); |
10175 | 555 void inc_virtual_space_count(); |
556 void dec_virtual_space_count(); | |
557 | |
558 // Unlink empty VirtualSpaceNodes and free it. | |
12303
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
559 void purge(ChunkManager* chunk_manager); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
560 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
561 void print_on(outputStream* st) const; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
562 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
563 class VirtualSpaceListIterator : public StackObj { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
564 VirtualSpaceNode* _virtual_spaces; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
565 public: |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
566 VirtualSpaceListIterator(VirtualSpaceNode* virtual_spaces) : |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
567 _virtual_spaces(virtual_spaces) {} |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
568 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
569 bool repeat() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
570 return _virtual_spaces != NULL; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
571 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
572 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
573 VirtualSpaceNode* get_next() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
574 VirtualSpaceNode* result = _virtual_spaces; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
575 if (_virtual_spaces != NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
576 _virtual_spaces = _virtual_spaces->next(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
577 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
578 return result; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
579 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
580 }; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
581 }; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
582 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
583 class Metadebug : AllStatic { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
584 // Debugging support for Metaspaces |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
585 static int _allocation_fail_alot_count; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
586 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
587 public: |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
588 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
589 static void init_allocation_fail_alot_count(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
590 #ifdef ASSERT |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
591 static bool test_metadata_failure(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
592 #endif |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
593 }; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
594 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
595 int Metadebug::_allocation_fail_alot_count = 0; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
596 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
597 // SpaceManager - used by Metaspace to handle allocations |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
598 class SpaceManager : public CHeapObj<mtClass> { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
599 friend class Metaspace; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
600 friend class Metadebug; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
601 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
602 private: |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
603 |
17663
40353abd7984
8029178: Parallel class loading test anonymous-simple gets SIGSEGV in Metaspace::contains
coleenp
parents:
13439
diff
changeset
|
604 // protects allocations |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
605 Mutex* const _lock; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
606 |
10330
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10191
diff
changeset
|
607 // Type of metadata allocated. |
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10191
diff
changeset
|
608 Metaspace::MetadataType _mdtype; |
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10191
diff
changeset
|
609 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
610 // List of chunks in use by this SpaceManager. Allocations |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
611 // are done from the current chunk. The list is used for deallocating |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
612 // chunks when the SpaceManager is freed. |
6885 | 613 Metachunk* _chunks_in_use[NumberOfInUseLists]; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
614 Metachunk* _current_chunk; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
615 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
616 // Number of small chunks to allocate to a manager |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
617 // If class space manager, small chunks are unlimited |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
618 static uint const _small_chunk_limit; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
619 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
620 // Sum of all space in allocated chunks |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
621 size_t _allocated_blocks_words; |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
622 |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
623 // Sum of all allocated chunks |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
624 size_t _allocated_chunks_words; |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
625 size_t _allocated_chunks_count; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
626 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
627 // Free lists of blocks are per SpaceManager since they |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
628 // are assumed to be in chunks in use by the SpaceManager |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
629 // and all chunks in use by a SpaceManager are freed when |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
630 // the class loader using the SpaceManager is collected. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
631 BlockFreelist _block_freelists; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
632 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
633 // protects virtualspace and chunk expansions |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
634 static const char* _expand_lock_name; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
635 static const int _expand_lock_rank; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
636 static Mutex* const _expand_lock; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
637 |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
638 private: |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
639 // Accessors |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
640 Metachunk* chunks_in_use(ChunkIndex index) const { return _chunks_in_use[index]; } |
17663
40353abd7984
8029178: Parallel class loading test anonymous-simple gets SIGSEGV in Metaspace::contains
coleenp
parents:
13439
diff
changeset
|
641 void set_chunks_in_use(ChunkIndex index, Metachunk* v) { |
40353abd7984
8029178: Parallel class loading test anonymous-simple gets SIGSEGV in Metaspace::contains
coleenp
parents:
13439
diff
changeset
|
642 // ensure lock-free iteration sees fully initialized node |
40353abd7984
8029178: Parallel class loading test anonymous-simple gets SIGSEGV in Metaspace::contains
coleenp
parents:
13439
diff
changeset
|
643 OrderAccess::storestore(); |
40353abd7984
8029178: Parallel class loading test anonymous-simple gets SIGSEGV in Metaspace::contains
coleenp
parents:
13439
diff
changeset
|
644 _chunks_in_use[index] = v; |
40353abd7984
8029178: Parallel class loading test anonymous-simple gets SIGSEGV in Metaspace::contains
coleenp
parents:
13439
diff
changeset
|
645 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
646 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
647 BlockFreelist* block_freelists() const { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
648 return (BlockFreelist*) &_block_freelists; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
649 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
650 |
10330
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10191
diff
changeset
|
651 Metaspace::MetadataType mdtype() { return _mdtype; } |
12303
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
652 |
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
653 VirtualSpaceList* vs_list() const { return Metaspace::get_space_list(_mdtype); } |
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
654 ChunkManager* chunk_manager() const { return Metaspace::get_chunk_manager(_mdtype); } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
655 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
656 Metachunk* current_chunk() const { return _current_chunk; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
657 void set_current_chunk(Metachunk* v) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
658 _current_chunk = v; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
659 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
660 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
661 Metachunk* find_current_chunk(size_t word_size); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
662 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
663 // Add chunk to the list of chunks in use |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
664 void add_chunk(Metachunk* v, bool make_current); |
12231
24e87613ee58
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
12226
diff
changeset
|
665 void retire_current_chunk(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
666 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
667 Mutex* lock() const { return _lock; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
668 |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
669 const char* chunk_size_name(ChunkIndex index) const; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
670 |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
671 protected: |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
672 void initialize(); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
673 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
674 public: |
10330
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10191
diff
changeset
|
675 SpaceManager(Metaspace::MetadataType mdtype, |
12303
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
676 Mutex* lock); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
677 ~SpaceManager(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
678 |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
679 enum ChunkMultiples { |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
680 MediumChunkMultiple = 4 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
681 }; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
682 |
12303
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
683 bool is_class() { return _mdtype == Metaspace::ClassType; } |
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
684 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
685 // Accessors |
12979
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
686 size_t specialized_chunk_size() { return (size_t) is_class() ? ClassSpecializedChunk : SpecializedChunk; } |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
687 size_t small_chunk_size() { return (size_t) is_class() ? ClassSmallChunk : SmallChunk; } |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
688 size_t medium_chunk_size() { return (size_t) is_class() ? ClassMediumChunk : MediumChunk; } |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
689 size_t medium_chunk_bunch() { return medium_chunk_size() * MediumChunkMultiple; } |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
690 |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
691 size_t smallest_chunk_size() { return specialized_chunk_size(); } |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
692 |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
693 size_t allocated_blocks_words() const { return _allocated_blocks_words; } |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
694 size_t allocated_blocks_bytes() const { return _allocated_blocks_words * BytesPerWord; } |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
695 size_t allocated_chunks_words() const { return _allocated_chunks_words; } |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
696 size_t allocated_chunks_count() const { return _allocated_chunks_count; } |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
697 |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
698 bool is_humongous(size_t word_size) { return word_size > medium_chunk_size(); } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
699 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
700 static Mutex* expand_lock() { return _expand_lock; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
701 |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
702 // Increment the per Metaspace and global running sums for Metachunks |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
703 // by the given size. This is used when a Metachunk to added to |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
704 // the in-use list. |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
705 void inc_size_metrics(size_t words); |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
706 // Increment the per Metaspace and global running sums Metablocks by the given |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
707 // size. This is used when a Metablock is allocated. |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
708 void inc_used_metrics(size_t words); |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
709 // Delete the portion of the running sums for this SpaceManager. That is, |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
710 // the globals running sums for the Metachunks and Metablocks are |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
711 // decremented for all the Metachunks in-use by this SpaceManager. |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
712 void dec_total_from_size_metrics(); |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
713 |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
714 // Set the sizes for the initial chunks. |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
715 void get_initial_chunk_sizes(Metaspace::MetaspaceType type, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
716 size_t* chunk_word_size, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
717 size_t* class_chunk_word_size); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
718 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
719 size_t sum_capacity_in_chunks_in_use() const; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
720 size_t sum_used_in_chunks_in_use() const; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
721 size_t sum_free_in_chunks_in_use() const; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
722 size_t sum_waste_in_chunks_in_use() const; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
723 size_t sum_waste_in_chunks_in_use(ChunkIndex index ) const; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
724 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
725 size_t sum_count_in_chunks_in_use(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
726 size_t sum_count_in_chunks_in_use(ChunkIndex i); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
727 |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
728 Metachunk* get_new_chunk(size_t word_size, size_t grow_chunks_by_words); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
729 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
730 // Block allocation and deallocation. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
731 // Allocates a block from the current chunk |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
732 MetaWord* allocate(size_t word_size); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
733 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
734 // Helper for allocations |
6885 | 735 MetaWord* allocate_work(size_t word_size); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
736 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
737 // Returns a block to the per manager freelist |
6885 | 738 void deallocate(MetaWord* p, size_t word_size); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
739 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
740 // Based on the allocation size and a minimum chunk size, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
741 // returned chunk size (for expanding space for chunk allocation). |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
742 size_t calc_chunk_size(size_t allocation_word_size); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
743 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
744 // Called when an allocation from the current chunk fails. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
745 // Gets a new chunk (may require getting a new virtual space), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
746 // and allocates from that chunk. |
6885 | 747 MetaWord* grow_and_allocate(size_t word_size); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
748 |
12839
a6414751d537
8025996: Track metaspace usage when metaspace is expanded
stefank
parents:
12838
diff
changeset
|
749 // Notify memory usage to MemoryService. |
a6414751d537
8025996: Track metaspace usage when metaspace is expanded
stefank
parents:
12838
diff
changeset
|
750 void track_metaspace_memory_usage(); |
a6414751d537
8025996: Track metaspace usage when metaspace is expanded
stefank
parents:
12838
diff
changeset
|
751 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
752 // debugging support. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
753 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
754 void dump(outputStream* const out) const; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
755 void print_on(outputStream* st) const; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
756 void locked_print_chunks_in_use_on(outputStream* st) const; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
757 |
17663
40353abd7984
8029178: Parallel class loading test anonymous-simple gets SIGSEGV in Metaspace::contains
coleenp
parents:
13439
diff
changeset
|
758 bool contains(const void *ptr); |
40353abd7984
8029178: Parallel class loading test anonymous-simple gets SIGSEGV in Metaspace::contains
coleenp
parents:
13439
diff
changeset
|
759 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
760 void verify(); |
7208
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
7187
diff
changeset
|
761 void verify_chunk_size(Metachunk* chunk); |
7185
90273fc0a981
8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents:
6969
diff
changeset
|
762 NOT_PRODUCT(void mangle_freed_chunks();) |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
763 #ifdef ASSERT |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
764 void verify_allocated_blocks_words(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
765 #endif |
10376
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
766 |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
767 size_t get_raw_word_size(size_t word_size) { |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
768 size_t byte_size = word_size * BytesPerWord; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
769 |
12902 | 770 size_t raw_bytes_size = MAX2(byte_size, sizeof(Metablock)); |
771 raw_bytes_size = align_size_up(raw_bytes_size, Metachunk::object_alignment()); | |
772 | |
10376
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
773 size_t raw_word_size = raw_bytes_size / BytesPerWord; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
774 assert(raw_word_size * BytesPerWord == raw_bytes_size, "Size problem"); |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
775 |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
776 return raw_word_size; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
777 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
778 }; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
779 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
780 uint const SpaceManager::_small_chunk_limit = 4; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
781 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
782 const char* SpaceManager::_expand_lock_name = |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
783 "SpaceManager chunk allocation lock"; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
784 const int SpaceManager::_expand_lock_rank = Monitor::leaf - 1; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
785 Mutex* const SpaceManager::_expand_lock = |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
786 new Mutex(SpaceManager::_expand_lock_rank, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
787 SpaceManager::_expand_lock_name, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
788 Mutex::_allow_vm_block_flag); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
789 |
10175 | 790 void VirtualSpaceNode::inc_container_count() { |
791 assert_lock_strong(SpaceManager::expand_lock()); | |
792 _container_count++; | |
793 assert(_container_count == container_count_slow(), | |
794 err_msg("Inconsistency in countainer_count _container_count " SIZE_FORMAT | |
12303
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
795 " container_count_slow() " SIZE_FORMAT, |
10175 | 796 _container_count, container_count_slow())); |
797 } | |
798 | |
799 void VirtualSpaceNode::dec_container_count() { | |
800 assert_lock_strong(SpaceManager::expand_lock()); | |
801 _container_count--; | |
802 } | |
803 | |
804 #ifdef ASSERT | |
805 void VirtualSpaceNode::verify_container_count() { | |
806 assert(_container_count == container_count_slow(), | |
807 err_msg("Inconsistency in countainer_count _container_count " SIZE_FORMAT | |
12303
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
808 " container_count_slow() " SIZE_FORMAT, _container_count, container_count_slow())); |
10175 | 809 } |
810 #endif | |
811 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
812 // BlockFreelist methods |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
813 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
814 BlockFreelist::BlockFreelist() : _dictionary(NULL) {} |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
815 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
816 BlockFreelist::~BlockFreelist() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
817 if (_dictionary != NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
818 if (Verbose && TraceMetadataChunkAllocation) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
819 _dictionary->print_free_lists(gclog_or_tty); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
820 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
821 delete _dictionary; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
822 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
823 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
824 |
6885 | 825 void BlockFreelist::return_block(MetaWord* p, size_t word_size) { |
12902 | 826 Metablock* free_chunk = ::new (p) Metablock(word_size); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
827 if (dictionary() == NULL) { |
6885 | 828 _dictionary = new BlockTreeDictionary(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
829 } |
6885 | 830 dictionary()->return_chunk(free_chunk); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
831 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
832 |
6885 | 833 MetaWord* BlockFreelist::get_block(size_t word_size) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
834 if (dictionary() == NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
835 return NULL; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
836 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
837 |
17695
ab36007d6358
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
17663
diff
changeset
|
838 if (word_size < TreeChunk<Metablock, FreeList<Metablock> >::min_size()) { |
6885 | 839 // Dark matter. Too small for dictionary. |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
840 return NULL; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
841 } |
6885 | 842 |
843 Metablock* free_block = | |
12231
24e87613ee58
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
12226
diff
changeset
|
844 dictionary()->get_chunk(word_size, FreeBlockDictionary<Metablock>::atLeast); |
6885 | 845 if (free_block == NULL) { |
846 return NULL; | |
847 } | |
848 | |
12231
24e87613ee58
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
12226
diff
changeset
|
849 const size_t block_size = free_block->size(); |
24e87613ee58
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
12226
diff
changeset
|
850 if (block_size > WasteMultiplier * word_size) { |
24e87613ee58
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
12226
diff
changeset
|
851 return_block((MetaWord*)free_block, block_size); |
24e87613ee58
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
12226
diff
changeset
|
852 return NULL; |
24e87613ee58
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
12226
diff
changeset
|
853 } |
24e87613ee58
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
12226
diff
changeset
|
854 |
24e87613ee58
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
12226
diff
changeset
|
855 MetaWord* new_block = (MetaWord*)free_block; |
24e87613ee58
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
12226
diff
changeset
|
856 assert(block_size >= word_size, "Incorrect size of block from freelist"); |
24e87613ee58
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
12226
diff
changeset
|
857 const size_t unused = block_size - word_size; |
17695
ab36007d6358
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
17663
diff
changeset
|
858 if (unused >= TreeChunk<Metablock, FreeList<Metablock> >::min_size()) { |
12231
24e87613ee58
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
12226
diff
changeset
|
859 return_block(new_block + word_size, unused); |
24e87613ee58
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
12226
diff
changeset
|
860 } |
24e87613ee58
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
12226
diff
changeset
|
861 |
24e87613ee58
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
12226
diff
changeset
|
862 return new_block; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
863 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
864 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
865 void BlockFreelist::print_on(outputStream* st) const { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
866 if (dictionary() == NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
867 return; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
868 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
869 dictionary()->print_free_lists(st); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
870 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
871 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
872 // VirtualSpaceNode methods |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
873 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
874 VirtualSpaceNode::~VirtualSpaceNode() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
875 _rs.release(); |
10175 | 876 #ifdef ASSERT |
877 size_t word_size = sizeof(*this) / BytesPerWord; | |
878 Copy::fill_to_words((HeapWord*) this, word_size, 0xf1f1f1f1); | |
879 #endif | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
880 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
881 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
882 size_t VirtualSpaceNode::used_words_in_vs() const { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
883 return pointer_delta(top(), bottom(), sizeof(MetaWord)); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
884 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
885 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
886 // Space committed in the VirtualSpace |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
887 size_t VirtualSpaceNode::capacity_words_in_vs() const { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
888 return pointer_delta(end(), bottom(), sizeof(MetaWord)); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
889 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
890 |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
891 size_t VirtualSpaceNode::free_words_in_vs() const { |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
892 return pointer_delta(end(), top(), sizeof(MetaWord)); |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
893 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
894 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
895 // Allocates the chunk from the virtual space only. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
896 // This interface is also used internally for debugging. Not all |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
897 // chunks removed here are necessarily used for allocation. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
898 Metachunk* VirtualSpaceNode::take_from_committed(size_t chunk_word_size) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
899 // Bottom of the new chunk |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
900 MetaWord* chunk_limit = top(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
901 assert(chunk_limit != NULL, "Not safe to call this method"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
902 |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
903 // The virtual spaces are always expanded by the |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
904 // commit granularity to enforce the following condition. |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
905 // Without this the is_available check will not work correctly. |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
906 assert(_virtual_space.committed_size() == _virtual_space.actual_committed_size(), |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
907 "The committed memory doesn't match the expanded memory."); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
908 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
909 if (!is_available(chunk_word_size)) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
910 if (TraceMetadataChunkAllocation) { |
12240
8c5e6482cbfc
8024752: Log TraceMetadata* output to gclog_or_tty instead of tty
stefank
parents:
12239
diff
changeset
|
911 gclog_or_tty->print("VirtualSpaceNode::take_from_committed() not available %d words ", chunk_word_size); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
912 // Dump some information about the virtual space that is nearly full |
12240
8c5e6482cbfc
8024752: Log TraceMetadata* output to gclog_or_tty instead of tty
stefank
parents:
12239
diff
changeset
|
913 print_on(gclog_or_tty); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
914 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
915 return NULL; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
916 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
917 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
918 // Take the space (bump top on the current virtual space). |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
919 inc_top(chunk_word_size); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
920 |
10175 | 921 // Initialize the chunk |
922 Metachunk* result = ::new (chunk_limit) Metachunk(chunk_word_size, this); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
923 return result; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
924 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
925 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
926 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
927 // Expand the virtual space (commit more of the reserved space) |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
928 bool VirtualSpaceNode::expand_by(size_t min_words, size_t preferred_words) { |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
929 size_t min_bytes = min_words * BytesPerWord; |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
930 size_t preferred_bytes = preferred_words * BytesPerWord; |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
931 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
932 size_t uncommitted = virtual_space()->reserved_size() - virtual_space()->actual_committed_size(); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
933 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
934 if (uncommitted < min_bytes) { |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
935 return false; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
936 } |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
937 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
938 size_t commit = MIN2(preferred_bytes, uncommitted); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
939 bool result = virtual_space()->expand_by(commit, false); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
940 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
941 assert(result, "Failed to commit memory"); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
942 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
943 return result; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
944 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
945 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
946 Metachunk* VirtualSpaceNode::get_chunk_vs(size_t chunk_word_size) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
947 assert_lock_strong(SpaceManager::expand_lock()); |
10175 | 948 Metachunk* result = take_from_committed(chunk_word_size); |
949 if (result != NULL) { | |
950 inc_container_count(); | |
951 } | |
952 return result; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
953 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
954 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
955 bool VirtualSpaceNode::initialize() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
956 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
957 if (!_rs.is_reserved()) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
958 return false; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
959 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
960 |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
961 // These are necessary restriction to make sure that the virtual space always |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
962 // grows in steps of Metaspace::commit_alignment(). If both base and size are |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
963 // aligned only the middle alignment of the VirtualSpace is used. |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
964 assert_is_ptr_aligned(_rs.base(), Metaspace::commit_alignment()); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
965 assert_is_size_aligned(_rs.size(), Metaspace::commit_alignment()); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
966 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
967 // ReservedSpaces marked as special will have the entire memory |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
968 // pre-committed. Setting a committed size will make sure that |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
969 // committed_size and actual_committed_size agrees. |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
970 size_t pre_committed_size = _rs.special() ? _rs.size() : 0; |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
971 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
972 bool result = virtual_space()->initialize_with_granularity(_rs, pre_committed_size, |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
973 Metaspace::commit_alignment()); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
974 if (result) { |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
975 assert(virtual_space()->committed_size() == virtual_space()->actual_committed_size(), |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
976 "Checking that the pre-committed memory was registered by the VirtualSpace"); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
977 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
978 set_top((MetaWord*)virtual_space()->low()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
979 set_reserved(MemRegion((HeapWord*)_rs.base(), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
980 (HeapWord*)(_rs.base() + _rs.size()))); |
6726
03049e0e8544
7195823: NPG: CMS reserved() doesn't match _rs.base().
coleenp
parents:
6725
diff
changeset
|
981 |
03049e0e8544
7195823: NPG: CMS reserved() doesn't match _rs.base().
coleenp
parents:
6725
diff
changeset
|
982 assert(reserved()->start() == (HeapWord*) _rs.base(), |
03049e0e8544
7195823: NPG: CMS reserved() doesn't match _rs.base().
coleenp
parents:
6725
diff
changeset
|
983 err_msg("Reserved start was not set properly " PTR_FORMAT |
03049e0e8544
7195823: NPG: CMS reserved() doesn't match _rs.base().
coleenp
parents:
6725
diff
changeset
|
984 " != " PTR_FORMAT, reserved()->start(), _rs.base())); |
03049e0e8544
7195823: NPG: CMS reserved() doesn't match _rs.base().
coleenp
parents:
6725
diff
changeset
|
985 assert(reserved()->word_size() == _rs.size() / BytesPerWord, |
03049e0e8544
7195823: NPG: CMS reserved() doesn't match _rs.base().
coleenp
parents:
6725
diff
changeset
|
986 err_msg("Reserved size was not set properly " SIZE_FORMAT |
03049e0e8544
7195823: NPG: CMS reserved() doesn't match _rs.base().
coleenp
parents:
6725
diff
changeset
|
987 " != " SIZE_FORMAT, reserved()->word_size(), |
03049e0e8544
7195823: NPG: CMS reserved() doesn't match _rs.base().
coleenp
parents:
6725
diff
changeset
|
988 _rs.size() / BytesPerWord)); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
989 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
990 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
991 return result; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
992 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
993 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
994 void VirtualSpaceNode::print_on(outputStream* st) const { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
995 size_t used = used_words_in_vs(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
996 size_t capacity = capacity_words_in_vs(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
997 VirtualSpace* vs = virtual_space(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
998 st->print_cr(" space @ " PTR_FORMAT " " SIZE_FORMAT "K, %3d%% used " |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
999 "[" PTR_FORMAT ", " PTR_FORMAT ", " |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1000 PTR_FORMAT ", " PTR_FORMAT ")", |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1001 vs, capacity / K, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1002 capacity == 0 ? 0 : used * 100 / capacity, |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1003 bottom(), top(), end(), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1004 vs->high_boundary()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1005 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1006 |
7185
90273fc0a981
8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents:
6969
diff
changeset
|
1007 #ifdef ASSERT |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1008 void VirtualSpaceNode::mangle() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1009 size_t word_size = capacity_words_in_vs(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1010 Copy::fill_to_words((HeapWord*) low(), word_size, 0xf1f1f1f1); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1011 } |
7185
90273fc0a981
8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents:
6969
diff
changeset
|
1012 #endif // ASSERT |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1013 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1014 // VirtualSpaceList methods |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1015 // Space allocated from the VirtualSpace |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1016 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1017 VirtualSpaceList::~VirtualSpaceList() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1018 VirtualSpaceListIterator iter(virtual_space_list()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1019 while (iter.repeat()) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1020 VirtualSpaceNode* vsl = iter.get_next(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1021 delete vsl; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1022 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1023 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1024 |
12236
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
1025 void VirtualSpaceList::inc_reserved_words(size_t v) { |
10175 | 1026 assert_lock_strong(SpaceManager::expand_lock()); |
12236
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
1027 _reserved_words = _reserved_words + v; |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
1028 } |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
1029 void VirtualSpaceList::dec_reserved_words(size_t v) { |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
1030 assert_lock_strong(SpaceManager::expand_lock()); |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
1031 _reserved_words = _reserved_words - v; |
10175 | 1032 } |
12236
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
1033 |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1034 #define assert_committed_below_limit() \ |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1035 assert(MetaspaceAux::committed_bytes() <= MaxMetaspaceSize, \ |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1036 err_msg("Too much committed memory. Committed: " SIZE_FORMAT \ |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1037 " limit (MaxMetaspaceSize): " SIZE_FORMAT, \ |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1038 MetaspaceAux::committed_bytes(), MaxMetaspaceSize)); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1039 |
12236
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
1040 void VirtualSpaceList::inc_committed_words(size_t v) { |
10175 | 1041 assert_lock_strong(SpaceManager::expand_lock()); |
12236
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
1042 _committed_words = _committed_words + v; |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1043 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1044 assert_committed_below_limit(); |
12236
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
1045 } |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
1046 void VirtualSpaceList::dec_committed_words(size_t v) { |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
1047 assert_lock_strong(SpaceManager::expand_lock()); |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
1048 _committed_words = _committed_words - v; |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1049 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1050 assert_committed_below_limit(); |
10175 | 1051 } |
1052 | |
1053 void VirtualSpaceList::inc_virtual_space_count() { | |
1054 assert_lock_strong(SpaceManager::expand_lock()); | |
1055 _virtual_space_count++; | |
1056 } | |
1057 void VirtualSpaceList::dec_virtual_space_count() { | |
1058 assert_lock_strong(SpaceManager::expand_lock()); | |
1059 _virtual_space_count--; | |
1060 } | |
1061 | |
1062 void ChunkManager::remove_chunk(Metachunk* chunk) { | |
1063 size_t word_size = chunk->word_size(); | |
1064 ChunkIndex index = list_index(word_size); | |
1065 if (index != HumongousIndex) { | |
1066 free_chunks(index)->remove_chunk(chunk); | |
1067 } else { | |
1068 humongous_dictionary()->remove_chunk(chunk); | |
1069 } | |
1070 | |
1071 // Chunk is being removed from the chunks free list. | |
12902 | 1072 dec_free_chunks_total(chunk->word_size()); |
10175 | 1073 } |
1074 | |
1075 // Walk the list of VirtualSpaceNodes and delete | |
1076 // nodes with a 0 container_count. Remove Metachunks in | |
1077 // the node from their respective freelists. | |
12303
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
1078 void VirtualSpaceList::purge(ChunkManager* chunk_manager) { |
10175 | 1079 assert_lock_strong(SpaceManager::expand_lock()); |
1080 // Don't use a VirtualSpaceListIterator because this | |
1081 // list is being changed and a straightforward use of an iterator is not safe. | |
1082 VirtualSpaceNode* purged_vsl = NULL; | |
1083 VirtualSpaceNode* prev_vsl = virtual_space_list(); | |
1084 VirtualSpaceNode* next_vsl = prev_vsl; | |
1085 while (next_vsl != NULL) { | |
1086 VirtualSpaceNode* vsl = next_vsl; | |
1087 next_vsl = vsl->next(); | |
1088 // Don't free the current virtual space since it will likely | |
1089 // be needed soon. | |
1090 if (vsl->container_count() == 0 && vsl != current_virtual_space()) { | |
1091 // Unlink it from the list | |
1092 if (prev_vsl == vsl) { | |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1093 // This is the case of the current node being the first node. |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1094 assert(vsl == virtual_space_list(), "Expected to be the first node"); |
10175 | 1095 set_virtual_space_list(vsl->next()); |
1096 } else { | |
1097 prev_vsl->set_next(vsl->next()); | |
1098 } | |
1099 | |
12303
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
1100 vsl->purge(chunk_manager); |
12236
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
1101 dec_reserved_words(vsl->reserved_words()); |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
1102 dec_committed_words(vsl->committed_words()); |
10175 | 1103 dec_virtual_space_count(); |
1104 purged_vsl = vsl; | |
1105 delete vsl; | |
1106 } else { | |
1107 prev_vsl = vsl; | |
1108 } | |
1109 } | |
1110 #ifdef ASSERT | |
1111 if (purged_vsl != NULL) { | |
1112 // List should be stable enough to use an iterator here. | |
1113 VirtualSpaceListIterator iter(virtual_space_list()); | |
1114 while (iter.repeat()) { | |
1115 VirtualSpaceNode* vsl = iter.get_next(); | |
1116 assert(vsl != purged_vsl, "Purge of vsl failed"); | |
1117 } | |
1118 } | |
1119 #endif | |
1120 } | |
1121 | |
12979
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
1122 void VirtualSpaceList::retire_current_virtual_space() { |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
1123 assert_lock_strong(SpaceManager::expand_lock()); |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
1124 |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
1125 VirtualSpaceNode* vsn = current_virtual_space(); |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
1126 |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
1127 ChunkManager* cm = is_class() ? Metaspace::chunk_manager_class() : |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
1128 Metaspace::chunk_manager_metadata(); |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
1129 |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
1130 vsn->retire(cm); |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
1131 } |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
1132 |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
1133 void VirtualSpaceNode::retire(ChunkManager* chunk_manager) { |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
1134 for (int i = (int)MediumIndex; i >= (int)ZeroIndex; --i) { |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
1135 ChunkIndex index = (ChunkIndex)i; |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
1136 size_t chunk_size = chunk_manager->free_chunks(index)->size(); |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
1137 |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
1138 while (free_words_in_vs() >= chunk_size) { |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
1139 DEBUG_ONLY(verify_container_count();) |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
1140 Metachunk* chunk = get_chunk_vs(chunk_size); |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
1141 assert(chunk != NULL, "allocation should have been successful"); |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
1142 |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
1143 chunk_manager->return_chunks(index, chunk); |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
1144 chunk_manager->inc_free_chunks_total(chunk_size); |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
1145 DEBUG_ONLY(verify_container_count();) |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
1146 } |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
1147 } |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
1148 assert(free_words_in_vs() == 0, "should be empty now"); |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
1149 } |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
1150 |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1151 VirtualSpaceList::VirtualSpaceList(size_t word_size) : |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1152 _is_class(false), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1153 _virtual_space_list(NULL), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1154 _current_virtual_space(NULL), |
12236
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
1155 _reserved_words(0), |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
1156 _committed_words(0), |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1157 _virtual_space_count(0) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1158 MutexLockerEx cl(SpaceManager::expand_lock(), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1159 Mutex::_no_safepoint_check_flag); |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1160 create_new_virtual_space(word_size); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1161 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1162 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1163 VirtualSpaceList::VirtualSpaceList(ReservedSpace rs) : |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1164 _is_class(true), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1165 _virtual_space_list(NULL), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1166 _current_virtual_space(NULL), |
12236
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
1167 _reserved_words(0), |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
1168 _committed_words(0), |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1169 _virtual_space_count(0) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1170 MutexLockerEx cl(SpaceManager::expand_lock(), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1171 Mutex::_no_safepoint_check_flag); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1172 VirtualSpaceNode* class_entry = new VirtualSpaceNode(rs); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1173 bool succeeded = class_entry->initialize(); |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1174 if (succeeded) { |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1175 link_vs(class_entry); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1176 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1177 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1178 |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
1179 size_t VirtualSpaceList::free_bytes() { |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
1180 return virtual_space_list()->free_words_in_vs() * BytesPerWord; |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
1181 } |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
1182 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1183 // Allocate another meta virtual space and add it to the list. |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1184 bool VirtualSpaceList::create_new_virtual_space(size_t vs_word_size) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1185 assert_lock_strong(SpaceManager::expand_lock()); |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1186 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1187 if (is_class()) { |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1188 assert(false, "We currently don't support more than one VirtualSpace for" |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1189 " the compressed class space. The initialization of the" |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1190 " CCS uses another code path and should not hit this path."); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1191 return false; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1192 } |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1193 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1194 if (vs_word_size == 0) { |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1195 assert(false, "vs_word_size should always be at least _reserve_alignment large."); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1196 return false; |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1197 } |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1198 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1199 // Reserve the space |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1200 size_t vs_byte_size = vs_word_size * BytesPerWord; |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1201 assert_is_size_aligned(vs_byte_size, Metaspace::reserve_alignment()); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1202 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1203 // Allocate the meta virtual space and initialize it. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1204 VirtualSpaceNode* new_entry = new VirtualSpaceNode(vs_byte_size); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1205 if (!new_entry->initialize()) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1206 delete new_entry; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1207 return false; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1208 } else { |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1209 assert(new_entry->reserved_words() == vs_word_size, |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1210 "Reserved memory size differs from requested memory size"); |
12236
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
1211 link_vs(new_entry); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1212 return true; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1213 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1214 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1215 |
12236
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
1216 void VirtualSpaceList::link_vs(VirtualSpaceNode* new_entry) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1217 if (virtual_space_list() == NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1218 set_virtual_space_list(new_entry); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1219 } else { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1220 current_virtual_space()->set_next(new_entry); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1221 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1222 set_current_virtual_space(new_entry); |
12236
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
1223 inc_reserved_words(new_entry->reserved_words()); |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
1224 inc_committed_words(new_entry->committed_words()); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1225 inc_virtual_space_count(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1226 #ifdef ASSERT |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1227 new_entry->mangle(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1228 #endif |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1229 if (TraceMetavirtualspaceAllocation && Verbose) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1230 VirtualSpaceNode* vsl = current_virtual_space(); |
12240
8c5e6482cbfc
8024752: Log TraceMetadata* output to gclog_or_tty instead of tty
stefank
parents:
12239
diff
changeset
|
1231 vsl->print_on(gclog_or_tty); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1232 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1233 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1234 |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1235 bool VirtualSpaceList::expand_node_by(VirtualSpaceNode* node, |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1236 size_t min_words, |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1237 size_t preferred_words) { |
12236
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
1238 size_t before = node->committed_words(); |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
1239 |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1240 bool result = node->expand_by(min_words, preferred_words); |
12236
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
1241 |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
1242 size_t after = node->committed_words(); |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
1243 |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
1244 // after and before can be the same if the memory was pre-committed. |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1245 assert(after >= before, "Inconsistency"); |
12236
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
1246 inc_committed_words(after - before); |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
1247 |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
1248 return result; |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
1249 } |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
1250 |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1251 bool VirtualSpaceList::expand_by(size_t min_words, size_t preferred_words) { |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1252 assert_is_size_aligned(min_words, Metaspace::commit_alignment_words()); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1253 assert_is_size_aligned(preferred_words, Metaspace::commit_alignment_words()); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1254 assert(min_words <= preferred_words, "Invalid arguments"); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1255 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1256 if (!MetaspaceGC::can_expand(min_words, this->is_class())) { |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1257 return false; |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1258 } |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1259 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1260 size_t allowed_expansion_words = MetaspaceGC::allowed_expansion(); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1261 if (allowed_expansion_words < min_words) { |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1262 return false; |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1263 } |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1264 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1265 size_t max_expansion_words = MIN2(preferred_words, allowed_expansion_words); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1266 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1267 // Commit more memory from the the current virtual space. |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1268 bool vs_expanded = expand_node_by(current_virtual_space(), |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1269 min_words, |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1270 max_expansion_words); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1271 if (vs_expanded) { |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1272 return true; |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1273 } |
12979
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
1274 retire_current_virtual_space(); |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1275 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1276 // Get another virtual space. |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1277 size_t grow_vs_words = MAX2((size_t)VirtualSpaceSize, preferred_words); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1278 grow_vs_words = align_size_up(grow_vs_words, Metaspace::reserve_alignment_words()); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1279 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1280 if (create_new_virtual_space(grow_vs_words)) { |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1281 if (current_virtual_space()->is_pre_committed()) { |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1282 // The memory was pre-committed, so we are done here. |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1283 assert(min_words <= current_virtual_space()->committed_words(), |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1284 "The new VirtualSpace was pre-committed, so it" |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1285 "should be large enough to fit the alloc request."); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1286 return true; |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1287 } |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1288 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1289 return expand_node_by(current_virtual_space(), |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1290 min_words, |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1291 max_expansion_words); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1292 } |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1293 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1294 return false; |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1295 } |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1296 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1297 Metachunk* VirtualSpaceList::get_new_chunk(size_t word_size, |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1298 size_t grow_chunks_by_words, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1299 size_t medium_chunk_bunch) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1300 |
12303
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
1301 // Allocate a chunk out of the current virtual space. |
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
1302 Metachunk* next = current_virtual_space()->get_chunk_vs(grow_chunks_by_words); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1303 |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1304 if (next != NULL) { |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1305 return next; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1306 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1307 |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1308 // The expand amount is currently only determined by the requested sizes |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1309 // and not how much committed memory is left in the current virtual space. |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1310 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1311 size_t min_word_size = align_size_up(grow_chunks_by_words, Metaspace::commit_alignment_words()); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1312 size_t preferred_word_size = align_size_up(medium_chunk_bunch, Metaspace::commit_alignment_words()); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1313 if (min_word_size >= preferred_word_size) { |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1314 // Can happen when humongous chunks are allocated. |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1315 preferred_word_size = min_word_size; |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1316 } |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1317 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1318 bool expanded = expand_by(min_word_size, preferred_word_size); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1319 if (expanded) { |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1320 next = current_virtual_space()->get_chunk_vs(grow_chunks_by_words); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1321 assert(next != NULL, "The allocation was expected to succeed after the expansion"); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1322 } |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1323 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1324 return next; |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1325 } |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1326 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1327 void VirtualSpaceList::print_on(outputStream* st) const { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1328 if (TraceMetadataChunkAllocation && Verbose) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1329 VirtualSpaceListIterator iter(virtual_space_list()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1330 while (iter.repeat()) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1331 VirtualSpaceNode* node = iter.get_next(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1332 node->print_on(st); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1333 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1334 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1335 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1336 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1337 // MetaspaceGC methods |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1338 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1339 // VM_CollectForMetadataAllocation is the vm operation used to GC. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1340 // Within the VM operation after the GC the attempt to allocate the metadata |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1341 // should succeed. If the GC did not free enough space for the metaspace |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1342 // allocation, the HWM is increased so that another virtualspace will be |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1343 // allocated for the metadata. With perm gen the increase in the perm |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1344 // gen had bounds, MinMetaspaceExpansion and MaxMetaspaceExpansion. The |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1345 // metaspace policy uses those as the small and large steps for the HWM. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1346 // |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1347 // After the GC the compute_new_size() for MetaspaceGC is called to |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1348 // resize the capacity of the metaspaces. The current implementation |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
1349 // is based on the flags MinMetaspaceFreeRatio and MaxMetaspaceFreeRatio used |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1350 // to resize the Java heap by some GC's. New flags can be implemented |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
1351 // if really needed. MinMetaspaceFreeRatio is used to calculate how much |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1352 // free space is desirable in the metaspace capacity to decide how much |
8040
a83cd101fd62
8005452: NPG: Create new flags for Metaspace resizing policy
jmasa
parents:
8007
diff
changeset
|
1353 // to increase the HWM. MaxMetaspaceFreeRatio is used to decide how much |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1354 // free space is desirable in the metaspace capacity before decreasing |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1355 // the HWM. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1356 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1357 // Calculate the amount to increase the high water mark (HWM). |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1358 // Increase by a minimum amount (MinMetaspaceExpansion) so that |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1359 // another expansion is not requested too soon. If that is not |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1360 // enough to satisfy the allocation, increase by MaxMetaspaceExpansion. |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1361 // If that is still not enough, expand by the size of the allocation |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1362 // plus some. |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1363 size_t MetaspaceGC::delta_capacity_until_GC(size_t bytes) { |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1364 size_t min_delta = MinMetaspaceExpansion; |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1365 size_t max_delta = MaxMetaspaceExpansion; |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1366 size_t delta = align_size_up(bytes, Metaspace::commit_alignment()); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1367 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1368 if (delta <= min_delta) { |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1369 delta = min_delta; |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1370 } else if (delta <= max_delta) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1371 // Don't want to hit the high water mark on the next |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1372 // allocation so make the delta greater than just enough |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1373 // for this allocation. |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1374 delta = max_delta; |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1375 } else { |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1376 // This allocation is large but the next ones are probably not |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1377 // so increase by the minimum. |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1378 delta = delta + min_delta; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1379 } |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1380 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1381 assert_is_size_aligned(delta, Metaspace::commit_alignment()); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1382 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1383 return delta; |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1384 } |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1385 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1386 size_t MetaspaceGC::capacity_until_GC() { |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1387 size_t value = (size_t)OrderAccess::load_ptr_acquire(&_capacity_until_GC); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1388 assert(value >= MetaspaceSize, "Not initialied properly?"); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1389 return value; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1390 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1391 |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1392 size_t MetaspaceGC::inc_capacity_until_GC(size_t v) { |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1393 assert_is_size_aligned(v, Metaspace::commit_alignment()); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1394 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1395 return (size_t)Atomic::add_ptr(v, &_capacity_until_GC); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1396 } |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1397 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1398 size_t MetaspaceGC::dec_capacity_until_GC(size_t v) { |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1399 assert_is_size_aligned(v, Metaspace::commit_alignment()); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1400 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1401 return (size_t)Atomic::add_ptr(-(intptr_t)v, &_capacity_until_GC); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1402 } |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1403 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1404 bool MetaspaceGC::can_expand(size_t word_size, bool is_class) { |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1405 // Check if the compressed class space is full. |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1406 if (is_class && Metaspace::using_class_space()) { |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1407 size_t class_committed = MetaspaceAux::committed_bytes(Metaspace::ClassType); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1408 if (class_committed + word_size * BytesPerWord > CompressedClassSpaceSize) { |
11064
de2d15ce3d4a
8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents:
10376
diff
changeset
|
1409 return false; |
de2d15ce3d4a
8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents:
10376
diff
changeset
|
1410 } |
8790
7f0cb32dd233
8004241: NPG: Metaspace occupies more memory than specified by -XX:MaxMetaspaceSize option
mgerdin
parents:
8786
diff
changeset
|
1411 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1412 |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1413 // Check if the user has imposed a limit on the metaspace memory. |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1414 size_t committed_bytes = MetaspaceAux::committed_bytes(); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1415 if (committed_bytes + word_size * BytesPerWord > MaxMetaspaceSize) { |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1416 return false; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1417 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1418 |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1419 return true; |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1420 } |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1421 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1422 size_t MetaspaceGC::allowed_expansion() { |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1423 size_t committed_bytes = MetaspaceAux::committed_bytes(); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1424 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1425 size_t left_until_max = MaxMetaspaceSize - committed_bytes; |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1426 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1427 // Always grant expansion if we are initiating the JVM, |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1428 // or if the GC_locker is preventing GCs. |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1429 if (!is_init_completed() || GC_locker::is_active_and_needs_gc()) { |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1430 return left_until_max / BytesPerWord; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1431 } |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1432 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1433 size_t capacity_until_gc = capacity_until_GC(); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1434 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1435 if (capacity_until_gc <= committed_bytes) { |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1436 return 0; |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1437 } |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1438 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1439 size_t left_until_GC = capacity_until_gc - committed_bytes; |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1440 size_t left_to_commit = MIN2(left_until_GC, left_until_max); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1441 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1442 return left_to_commit / BytesPerWord; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1443 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1444 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1445 void MetaspaceGC::compute_new_size() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1446 assert(_shrink_factor <= 100, "invalid shrink factor"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1447 uint current_shrink_factor = _shrink_factor; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1448 _shrink_factor = 0; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1449 |
17866
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17771
diff
changeset
|
1450 const size_t used_after_gc = MetaspaceAux::capacity_bytes(); |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
1451 const size_t capacity_until_GC = MetaspaceGC::capacity_until_GC(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1452 |
8040
a83cd101fd62
8005452: NPG: Create new flags for Metaspace resizing policy
jmasa
parents:
8007
diff
changeset
|
1453 const double minimum_free_percentage = MinMetaspaceFreeRatio / 100.0; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1454 const double maximum_used_percentage = 1.0 - minimum_free_percentage; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1455 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1456 const double min_tmp = used_after_gc / maximum_used_percentage; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1457 size_t minimum_desired_capacity = |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1458 (size_t)MIN2(min_tmp, double(max_uintx)); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1459 // Don't shrink less than the initial generation size |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1460 minimum_desired_capacity = MAX2(minimum_desired_capacity, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1461 MetaspaceSize); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1462 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1463 if (PrintGCDetails && Verbose) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1464 gclog_or_tty->print_cr("\nMetaspaceGC::compute_new_size: "); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1465 gclog_or_tty->print_cr(" " |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1466 " minimum_free_percentage: %6.2f" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1467 " maximum_used_percentage: %6.2f", |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1468 minimum_free_percentage, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1469 maximum_used_percentage); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1470 gclog_or_tty->print_cr(" " |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
1471 " used_after_gc : %6.1fKB", |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
1472 used_after_gc / (double) K); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1473 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1474 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1475 |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
1476 size_t shrink_bytes = 0; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1477 if (capacity_until_GC < minimum_desired_capacity) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1478 // If we have less capacity below the metaspace HWM, then |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1479 // increment the HWM. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1480 size_t expand_bytes = minimum_desired_capacity - capacity_until_GC; |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1481 expand_bytes = align_size_up(expand_bytes, Metaspace::commit_alignment()); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1482 // Don't expand unless it's significant |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1483 if (expand_bytes >= MinMetaspaceExpansion) { |
17768
daef39043d2c
8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents:
17695
diff
changeset
|
1484 size_t new_capacity_until_GC = MetaspaceGC::inc_capacity_until_GC(expand_bytes); |
daef39043d2c
8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents:
17695
diff
changeset
|
1485 Metaspace::tracer()->report_gc_threshold(capacity_until_GC, |
daef39043d2c
8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents:
17695
diff
changeset
|
1486 new_capacity_until_GC, |
daef39043d2c
8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents:
17695
diff
changeset
|
1487 MetaspaceGCThresholdUpdater::ComputeNewSize); |
daef39043d2c
8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents:
17695
diff
changeset
|
1488 if (PrintGCDetails && Verbose) { |
daef39043d2c
8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents:
17695
diff
changeset
|
1489 gclog_or_tty->print_cr(" expanding:" |
daef39043d2c
8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents:
17695
diff
changeset
|
1490 " minimum_desired_capacity: %6.1fKB" |
daef39043d2c
8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents:
17695
diff
changeset
|
1491 " expand_bytes: %6.1fKB" |
daef39043d2c
8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents:
17695
diff
changeset
|
1492 " MinMetaspaceExpansion: %6.1fKB" |
daef39043d2c
8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents:
17695
diff
changeset
|
1493 " new metaspace HWM: %6.1fKB", |
daef39043d2c
8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents:
17695
diff
changeset
|
1494 minimum_desired_capacity / (double) K, |
daef39043d2c
8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents:
17695
diff
changeset
|
1495 expand_bytes / (double) K, |
daef39043d2c
8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents:
17695
diff
changeset
|
1496 MinMetaspaceExpansion / (double) K, |
daef39043d2c
8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents:
17695
diff
changeset
|
1497 new_capacity_until_GC / (double) K); |
daef39043d2c
8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents:
17695
diff
changeset
|
1498 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1499 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1500 return; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1501 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1502 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1503 // No expansion, now see if we want to shrink |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1504 // We would never want to shrink more than this |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
1505 size_t max_shrink_bytes = capacity_until_GC - minimum_desired_capacity; |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
1506 assert(max_shrink_bytes >= 0, err_msg("max_shrink_bytes " SIZE_FORMAT, |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
1507 max_shrink_bytes)); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1508 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1509 // Should shrinking be considered? |
8040
a83cd101fd62
8005452: NPG: Create new flags for Metaspace resizing policy
jmasa
parents:
8007
diff
changeset
|
1510 if (MaxMetaspaceFreeRatio < 100) { |
a83cd101fd62
8005452: NPG: Create new flags for Metaspace resizing policy
jmasa
parents:
8007
diff
changeset
|
1511 const double maximum_free_percentage = MaxMetaspaceFreeRatio / 100.0; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1512 const double minimum_used_percentage = 1.0 - maximum_free_percentage; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1513 const double max_tmp = used_after_gc / minimum_used_percentage; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1514 size_t maximum_desired_capacity = (size_t)MIN2(max_tmp, double(max_uintx)); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1515 maximum_desired_capacity = MAX2(maximum_desired_capacity, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1516 MetaspaceSize); |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
1517 if (PrintGCDetails && Verbose) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1518 gclog_or_tty->print_cr(" " |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1519 " maximum_free_percentage: %6.2f" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1520 " minimum_used_percentage: %6.2f", |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1521 maximum_free_percentage, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1522 minimum_used_percentage); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1523 gclog_or_tty->print_cr(" " |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
1524 " minimum_desired_capacity: %6.1fKB" |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
1525 " maximum_desired_capacity: %6.1fKB", |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1526 minimum_desired_capacity / (double) K, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1527 maximum_desired_capacity / (double) K); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1528 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1529 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1530 assert(minimum_desired_capacity <= maximum_desired_capacity, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1531 "sanity check"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1532 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1533 if (capacity_until_GC > maximum_desired_capacity) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1534 // Capacity too large, compute shrinking size |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
1535 shrink_bytes = capacity_until_GC - maximum_desired_capacity; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1536 // We don't want shrink all the way back to initSize if people call |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1537 // System.gc(), because some programs do that between "phases" and then |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1538 // we'd just have to grow the heap up again for the next phase. So we |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1539 // damp the shrinking: 0% on the first call, 10% on the second call, 40% |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1540 // on the third call, and 100% by the fourth call. But if we recompute |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1541 // size without shrinking, it goes back to 0%. |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
1542 shrink_bytes = shrink_bytes / 100 * current_shrink_factor; |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1543 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1544 shrink_bytes = align_size_down(shrink_bytes, Metaspace::commit_alignment()); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1545 |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
1546 assert(shrink_bytes <= max_shrink_bytes, |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1547 err_msg("invalid shrink size " SIZE_FORMAT " not <= " SIZE_FORMAT, |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
1548 shrink_bytes, max_shrink_bytes)); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1549 if (current_shrink_factor == 0) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1550 _shrink_factor = 10; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1551 } else { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1552 _shrink_factor = MIN2(current_shrink_factor * 4, (uint) 100); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1553 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1554 if (PrintGCDetails && Verbose) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1555 gclog_or_tty->print_cr(" " |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1556 " shrinking:" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1557 " initSize: %.1fK" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1558 " maximum_desired_capacity: %.1fK", |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1559 MetaspaceSize / (double) K, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1560 maximum_desired_capacity / (double) K); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1561 gclog_or_tty->print_cr(" " |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
1562 " shrink_bytes: %.1fK" |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1563 " current_shrink_factor: %d" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1564 " new shrink factor: %d" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1565 " MinMetaspaceExpansion: %.1fK", |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
1566 shrink_bytes / (double) K, |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1567 current_shrink_factor, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1568 _shrink_factor, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1569 MinMetaspaceExpansion / (double) K); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1570 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1571 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1572 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1573 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1574 // Don't shrink unless it's significant |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
1575 if (shrink_bytes >= MinMetaspaceExpansion && |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
1576 ((capacity_until_GC - shrink_bytes) >= MetaspaceSize)) { |
17768
daef39043d2c
8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents:
17695
diff
changeset
|
1577 size_t new_capacity_until_GC = MetaspaceGC::dec_capacity_until_GC(shrink_bytes); |
daef39043d2c
8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents:
17695
diff
changeset
|
1578 Metaspace::tracer()->report_gc_threshold(capacity_until_GC, |
daef39043d2c
8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents:
17695
diff
changeset
|
1579 new_capacity_until_GC, |
daef39043d2c
8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents:
17695
diff
changeset
|
1580 MetaspaceGCThresholdUpdater::ComputeNewSize); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1581 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1582 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1583 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1584 // Metadebug methods |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1585 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1586 void Metadebug::init_allocation_fail_alot_count() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1587 if (MetadataAllocationFailALot) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1588 _allocation_fail_alot_count = |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1589 1+(long)((double)MetadataAllocationFailALotInterval*os::random()/(max_jint+1.0)); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1590 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1591 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1592 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1593 #ifdef ASSERT |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1594 bool Metadebug::test_metadata_failure() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1595 if (MetadataAllocationFailALot && |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1596 Threads::is_vm_complete()) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1597 if (_allocation_fail_alot_count > 0) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1598 _allocation_fail_alot_count--; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1599 } else { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1600 if (TraceMetadataChunkAllocation && Verbose) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1601 gclog_or_tty->print_cr("Metadata allocation failing for " |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1602 "MetadataAllocationFailALot"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1603 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1604 init_allocation_fail_alot_count(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1605 return true; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1606 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1607 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1608 return false; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1609 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1610 #endif |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1611 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1612 // ChunkManager methods |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1613 |
12235 | 1614 size_t ChunkManager::free_chunks_total_words() { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1615 return _free_chunks_total; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1616 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1617 |
12235 | 1618 size_t ChunkManager::free_chunks_total_bytes() { |
1619 return free_chunks_total_words() * BytesPerWord; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1620 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1621 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1622 size_t ChunkManager::free_chunks_count() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1623 #ifdef ASSERT |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1624 if (!UseConcMarkSweepGC && !SpaceManager::expand_lock()->is_locked()) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1625 MutexLockerEx cl(SpaceManager::expand_lock(), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1626 Mutex::_no_safepoint_check_flag); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1627 // This lock is only needed in debug because the verification |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1628 // of the _free_chunks_totals walks the list of free chunks |
6969
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
1629 slow_locked_verify_free_chunks_count(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1630 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1631 #endif |
6969
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
1632 return _free_chunks_count; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1633 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1634 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1635 void ChunkManager::locked_verify_free_chunks_total() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1636 assert_lock_strong(SpaceManager::expand_lock()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1637 assert(sum_free_chunks() == _free_chunks_total, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1638 err_msg("_free_chunks_total " SIZE_FORMAT " is not the" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1639 " same as sum " SIZE_FORMAT, _free_chunks_total, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1640 sum_free_chunks())); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1641 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1642 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1643 void ChunkManager::verify_free_chunks_total() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1644 MutexLockerEx cl(SpaceManager::expand_lock(), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1645 Mutex::_no_safepoint_check_flag); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1646 locked_verify_free_chunks_total(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1647 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1648 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1649 void ChunkManager::locked_verify_free_chunks_count() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1650 assert_lock_strong(SpaceManager::expand_lock()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1651 assert(sum_free_chunks_count() == _free_chunks_count, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1652 err_msg("_free_chunks_count " SIZE_FORMAT " is not the" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1653 " same as sum " SIZE_FORMAT, _free_chunks_count, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1654 sum_free_chunks_count())); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1655 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1656 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1657 void ChunkManager::verify_free_chunks_count() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1658 #ifdef ASSERT |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1659 MutexLockerEx cl(SpaceManager::expand_lock(), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1660 Mutex::_no_safepoint_check_flag); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1661 locked_verify_free_chunks_count(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1662 #endif |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1663 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1664 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1665 void ChunkManager::verify() { |
6969
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
1666 MutexLockerEx cl(SpaceManager::expand_lock(), |
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
1667 Mutex::_no_safepoint_check_flag); |
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
1668 locked_verify(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1669 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1670 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1671 void ChunkManager::locked_verify() { |
6885 | 1672 locked_verify_free_chunks_count(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1673 locked_verify_free_chunks_total(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1674 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1675 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1676 void ChunkManager::locked_print_free_chunks(outputStream* st) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1677 assert_lock_strong(SpaceManager::expand_lock()); |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1678 st->print_cr("Free chunk total " SIZE_FORMAT " count " SIZE_FORMAT, |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1679 _free_chunks_total, _free_chunks_count); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1680 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1681 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1682 void ChunkManager::locked_print_sum_free_chunks(outputStream* st) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1683 assert_lock_strong(SpaceManager::expand_lock()); |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1684 st->print_cr("Sum free chunk total " SIZE_FORMAT " count " SIZE_FORMAT, |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1685 sum_free_chunks(), sum_free_chunks_count()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1686 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1687 ChunkList* ChunkManager::free_chunks(ChunkIndex index) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1688 return &_free_chunks[index]; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1689 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1690 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1691 // These methods that sum the free chunk lists are used in printing |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1692 // methods that are used in product builds. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1693 size_t ChunkManager::sum_free_chunks() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1694 assert_lock_strong(SpaceManager::expand_lock()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1695 size_t result = 0; |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1696 for (ChunkIndex i = ZeroIndex; i < NumberOfFreeLists; i = next_chunk_index(i)) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1697 ChunkList* list = free_chunks(i); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1698 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1699 if (list == NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1700 continue; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1701 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1702 |
10101
df254344edf1
8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents:
8813
diff
changeset
|
1703 result = result + list->count() * list->size(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1704 } |
6885 | 1705 result = result + humongous_dictionary()->total_size(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1706 return result; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1707 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1708 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1709 size_t ChunkManager::sum_free_chunks_count() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1710 assert_lock_strong(SpaceManager::expand_lock()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1711 size_t count = 0; |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1712 for (ChunkIndex i = ZeroIndex; i < NumberOfFreeLists; i = next_chunk_index(i)) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1713 ChunkList* list = free_chunks(i); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1714 if (list == NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1715 continue; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1716 } |
10101
df254344edf1
8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents:
8813
diff
changeset
|
1717 count = count + list->count(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1718 } |
6885 | 1719 count = count + humongous_dictionary()->total_free_blocks(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1720 return count; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1721 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1722 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1723 ChunkList* ChunkManager::find_free_chunks_list(size_t word_size) { |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1724 ChunkIndex index = list_index(word_size); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1725 assert(index < HumongousIndex, "No humongous list"); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1726 return free_chunks(index); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1727 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1728 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1729 Metachunk* ChunkManager::free_chunks_get(size_t word_size) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1730 assert_lock_strong(SpaceManager::expand_lock()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1731 |
6969
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
1732 slow_locked_verify(); |
6885 | 1733 |
1734 Metachunk* chunk = NULL; | |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1735 if (list_index(word_size) != HumongousIndex) { |
6885 | 1736 ChunkList* free_list = find_free_chunks_list(word_size); |
1737 assert(free_list != NULL, "Sanity check"); | |
1738 | |
1739 chunk = free_list->head(); | |
1740 | |
1741 if (chunk == NULL) { | |
1742 return NULL; | |
1743 } | |
1744 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1745 // Remove the chunk as the head of the list. |
10101
df254344edf1
8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents:
8813
diff
changeset
|
1746 free_list->remove_chunk(chunk); |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1747 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1748 if (TraceMetadataChunkAllocation && Verbose) { |
12240
8c5e6482cbfc
8024752: Log TraceMetadata* output to gclog_or_tty instead of tty
stefank
parents:
12239
diff
changeset
|
1749 gclog_or_tty->print_cr("ChunkManager::free_chunks_get: free_list " |
8c5e6482cbfc
8024752: Log TraceMetadata* output to gclog_or_tty instead of tty
stefank
parents:
12239
diff
changeset
|
1750 PTR_FORMAT " head " PTR_FORMAT " size " SIZE_FORMAT, |
8c5e6482cbfc
8024752: Log TraceMetadata* output to gclog_or_tty instead of tty
stefank
parents:
12239
diff
changeset
|
1751 free_list, chunk, chunk->word_size()); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1752 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1753 } else { |
6885 | 1754 chunk = humongous_dictionary()->get_chunk( |
1755 word_size, | |
1756 FreeBlockDictionary<Metachunk>::atLeast); | |
1757 | |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1758 if (chunk == NULL) { |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1759 return NULL; |
6885 | 1760 } |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1761 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1762 if (TraceMetadataHumongousAllocation) { |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1763 size_t waste = chunk->word_size() - word_size; |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1764 gclog_or_tty->print_cr("Free list allocate humongous chunk size " |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1765 SIZE_FORMAT " for requested size " SIZE_FORMAT |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1766 " waste " SIZE_FORMAT, |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1767 chunk->word_size(), word_size, waste); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1768 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1769 } |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1770 |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1771 // Chunk is being removed from the chunks free list. |
12902 | 1772 dec_free_chunks_total(chunk->word_size()); |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
1773 |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1774 // Remove it from the links to this freelist |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1775 chunk->set_next(NULL); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1776 chunk->set_prev(NULL); |
10175 | 1777 #ifdef ASSERT |
1778 // Chunk is no longer on any freelist. Setting to false make container_count_slow() | |
1779 // work. | |
12902 | 1780 chunk->set_is_tagged_free(false); |
10175 | 1781 #endif |
12303
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
1782 chunk->container()->inc_container_count(); |
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
1783 |
6969
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
1784 slow_locked_verify(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1785 return chunk; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1786 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1787 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1788 Metachunk* ChunkManager::chunk_freelist_allocate(size_t word_size) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1789 assert_lock_strong(SpaceManager::expand_lock()); |
6969
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
1790 slow_locked_verify(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1791 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1792 // Take from the beginning of the list |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1793 Metachunk* chunk = free_chunks_get(word_size); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1794 if (chunk == NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1795 return NULL; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1796 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1797 |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1798 assert((word_size <= chunk->word_size()) || |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1799 list_index(chunk->word_size() == HumongousIndex), |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1800 "Non-humongous variable sized chunk"); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1801 if (TraceMetadataChunkAllocation) { |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1802 size_t list_count; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1803 if (list_index(word_size) < HumongousIndex) { |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1804 ChunkList* list = find_free_chunks_list(word_size); |
10101
df254344edf1
8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents:
8813
diff
changeset
|
1805 list_count = list->count(); |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1806 } else { |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1807 list_count = humongous_dictionary()->total_count(); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1808 } |
12240
8c5e6482cbfc
8024752: Log TraceMetadata* output to gclog_or_tty instead of tty
stefank
parents:
12239
diff
changeset
|
1809 gclog_or_tty->print("ChunkManager::chunk_freelist_allocate: " PTR_FORMAT " chunk " |
8c5e6482cbfc
8024752: Log TraceMetadata* output to gclog_or_tty instead of tty
stefank
parents:
12239
diff
changeset
|
1810 PTR_FORMAT " size " SIZE_FORMAT " count " SIZE_FORMAT " ", |
8c5e6482cbfc
8024752: Log TraceMetadata* output to gclog_or_tty instead of tty
stefank
parents:
12239
diff
changeset
|
1811 this, chunk, chunk->word_size(), list_count); |
8c5e6482cbfc
8024752: Log TraceMetadata* output to gclog_or_tty instead of tty
stefank
parents:
12239
diff
changeset
|
1812 locked_print_free_chunks(gclog_or_tty); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1813 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1814 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1815 return chunk; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1816 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1817 |
12303
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
1818 void ChunkManager::print_on(outputStream* out) const { |
6885 | 1819 if (PrintFLSStatistics != 0) { |
12303
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
1820 const_cast<ChunkManager *>(this)->humongous_dictionary()->report_statistics(); |
6885 | 1821 } |
1822 } | |
1823 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1824 // SpaceManager methods |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1825 |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1826 void SpaceManager::get_initial_chunk_sizes(Metaspace::MetaspaceType type, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1827 size_t* chunk_word_size, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1828 size_t* class_chunk_word_size) { |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1829 switch (type) { |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1830 case Metaspace::BootMetaspaceType: |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1831 *chunk_word_size = Metaspace::first_chunk_word_size(); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1832 *class_chunk_word_size = Metaspace::first_class_chunk_word_size(); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1833 break; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1834 case Metaspace::ROMetaspaceType: |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1835 *chunk_word_size = SharedReadOnlySize / wordSize; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1836 *class_chunk_word_size = ClassSpecializedChunk; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1837 break; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1838 case Metaspace::ReadWriteMetaspaceType: |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1839 *chunk_word_size = SharedReadWriteSize / wordSize; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1840 *class_chunk_word_size = ClassSpecializedChunk; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1841 break; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1842 case Metaspace::AnonymousMetaspaceType: |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1843 case Metaspace::ReflectionMetaspaceType: |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1844 *chunk_word_size = SpecializedChunk; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1845 *class_chunk_word_size = ClassSpecializedChunk; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1846 break; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1847 default: |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1848 *chunk_word_size = SmallChunk; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1849 *class_chunk_word_size = ClassSmallChunk; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1850 break; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1851 } |
8007
d9058e388631
8007257: NPG: metaspace.cpp: Incorrect arguments in calls to err_msg
mikael
parents:
7447
diff
changeset
|
1852 assert(*chunk_word_size != 0 && *class_chunk_word_size != 0, |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1853 err_msg("Initial chunks sizes bad: data " SIZE_FORMAT |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1854 " class " SIZE_FORMAT, |
8007
d9058e388631
8007257: NPG: metaspace.cpp: Incorrect arguments in calls to err_msg
mikael
parents:
7447
diff
changeset
|
1855 *chunk_word_size, *class_chunk_word_size)); |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1856 } |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1857 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1858 size_t SpaceManager::sum_free_in_chunks_in_use() const { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1859 MutexLockerEx cl(lock(), Mutex::_no_safepoint_check_flag); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1860 size_t free = 0; |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1861 for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1862 Metachunk* chunk = chunks_in_use(i); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1863 while (chunk != NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1864 free += chunk->free_word_size(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1865 chunk = chunk->next(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1866 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1867 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1868 return free; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1869 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1870 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1871 size_t SpaceManager::sum_waste_in_chunks_in_use() const { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1872 MutexLockerEx cl(lock(), Mutex::_no_safepoint_check_flag); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1873 size_t result = 0; |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1874 for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1875 result += sum_waste_in_chunks_in_use(i); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1876 } |
6885 | 1877 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1878 return result; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1879 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1880 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1881 size_t SpaceManager::sum_waste_in_chunks_in_use(ChunkIndex index) const { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1882 size_t result = 0; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1883 Metachunk* chunk = chunks_in_use(index); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1884 // Count the free space in all the chunk but not the |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1885 // current chunk from which allocations are still being done. |
11064
de2d15ce3d4a
8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents:
10376
diff
changeset
|
1886 while (chunk != NULL) { |
de2d15ce3d4a
8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents:
10376
diff
changeset
|
1887 if (chunk != current_chunk()) { |
6885 | 1888 result += chunk->free_word_size(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1889 } |
11064
de2d15ce3d4a
8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents:
10376
diff
changeset
|
1890 chunk = chunk->next(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1891 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1892 return result; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1893 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1894 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1895 size_t SpaceManager::sum_capacity_in_chunks_in_use() const { |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
1896 // For CMS use "allocated_chunks_words()" which does not need the |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
1897 // Metaspace lock. For the other collectors sum over the |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
1898 // lists. Use both methods as a check that "allocated_chunks_words()" |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
1899 // is correct. That is, sum_capacity_in_chunks() is too expensive |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
1900 // to use in the product and allocated_chunks_words() should be used |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
1901 // but allow for checking that allocated_chunks_words() returns the same |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
1902 // value as sum_capacity_in_chunks_in_use() which is the definitive |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
1903 // answer. |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
1904 if (UseConcMarkSweepGC) { |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
1905 return allocated_chunks_words(); |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
1906 } else { |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
1907 MutexLockerEx cl(lock(), Mutex::_no_safepoint_check_flag); |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
1908 size_t sum = 0; |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
1909 for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) { |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
1910 Metachunk* chunk = chunks_in_use(i); |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
1911 while (chunk != NULL) { |
12902 | 1912 sum += chunk->word_size(); |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
1913 chunk = chunk->next(); |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
1914 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1915 } |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
1916 return sum; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1917 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1918 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1919 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1920 size_t SpaceManager::sum_count_in_chunks_in_use() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1921 size_t count = 0; |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1922 for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1923 count = count + sum_count_in_chunks_in_use(i); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1924 } |
6885 | 1925 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1926 return count; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1927 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1928 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1929 size_t SpaceManager::sum_count_in_chunks_in_use(ChunkIndex i) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1930 size_t count = 0; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1931 Metachunk* chunk = chunks_in_use(i); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1932 while (chunk != NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1933 count++; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1934 chunk = chunk->next(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1935 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1936 return count; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1937 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1938 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1939 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1940 size_t SpaceManager::sum_used_in_chunks_in_use() const { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1941 MutexLockerEx cl(lock(), Mutex::_no_safepoint_check_flag); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1942 size_t used = 0; |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1943 for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1944 Metachunk* chunk = chunks_in_use(i); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1945 while (chunk != NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1946 used += chunk->used_word_size(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1947 chunk = chunk->next(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1948 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1949 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1950 return used; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1951 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1952 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1953 void SpaceManager::locked_print_chunks_in_use_on(outputStream* st) const { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1954 |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1955 for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) { |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1956 Metachunk* chunk = chunks_in_use(i); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1957 st->print("SpaceManager: %s " PTR_FORMAT, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1958 chunk_size_name(i), chunk); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1959 if (chunk != NULL) { |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1960 st->print_cr(" free " SIZE_FORMAT, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1961 chunk->free_word_size()); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1962 } else { |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1963 st->print_cr(""); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1964 } |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1965 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1966 |
12303
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
1967 chunk_manager()->locked_print_free_chunks(st); |
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
1968 chunk_manager()->locked_print_sum_free_chunks(st); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1969 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1970 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1971 size_t SpaceManager::calc_chunk_size(size_t word_size) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1972 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1973 // Decide between a small chunk and a medium chunk. Up to |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1974 // _small_chunk_limit small chunks can be allocated but |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1975 // once a medium chunk has been allocated, no more small |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1976 // chunks will be allocated. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1977 size_t chunk_word_size; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1978 if (chunks_in_use(MediumIndex) == NULL && |
11064
de2d15ce3d4a
8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents:
10376
diff
changeset
|
1979 sum_count_in_chunks_in_use(SmallIndex) < _small_chunk_limit) { |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1980 chunk_word_size = (size_t) small_chunk_size(); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1981 if (word_size + Metachunk::overhead() > small_chunk_size()) { |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1982 chunk_word_size = medium_chunk_size(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1983 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1984 } else { |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1985 chunk_word_size = medium_chunk_size(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1986 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1987 |
12979
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
1988 // Might still need a humongous chunk. Enforce |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
1989 // humongous allocations sizes to be aligned up to |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
1990 // the smallest chunk size. |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1991 size_t if_humongous_sized_chunk = |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1992 align_size_up(word_size + Metachunk::overhead(), |
12979
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
1993 smallest_chunk_size()); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1994 chunk_word_size = |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1995 MAX2((size_t) chunk_word_size, if_humongous_sized_chunk); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1996 |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1997 assert(!SpaceManager::is_humongous(word_size) || |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1998 chunk_word_size == if_humongous_sized_chunk, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
1999 err_msg("Size calculation is wrong, word_size " SIZE_FORMAT |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2000 " chunk_word_size " SIZE_FORMAT, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2001 word_size, chunk_word_size)); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2002 if (TraceMetadataHumongousAllocation && |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2003 SpaceManager::is_humongous(word_size)) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2004 gclog_or_tty->print_cr("Metadata humongous allocation:"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2005 gclog_or_tty->print_cr(" word_size " PTR_FORMAT, word_size); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2006 gclog_or_tty->print_cr(" chunk_word_size " PTR_FORMAT, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2007 chunk_word_size); |
6885 | 2008 gclog_or_tty->print_cr(" chunk overhead " PTR_FORMAT, |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2009 Metachunk::overhead()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2010 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2011 return chunk_word_size; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2012 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2013 |
12839
a6414751d537
8025996: Track metaspace usage when metaspace is expanded
stefank
parents:
12838
diff
changeset
|
2014 void SpaceManager::track_metaspace_memory_usage() { |
a6414751d537
8025996: Track metaspace usage when metaspace is expanded
stefank
parents:
12838
diff
changeset
|
2015 if (is_init_completed()) { |
a6414751d537
8025996: Track metaspace usage when metaspace is expanded
stefank
parents:
12838
diff
changeset
|
2016 if (is_class()) { |
a6414751d537
8025996: Track metaspace usage when metaspace is expanded
stefank
parents:
12838
diff
changeset
|
2017 MemoryService::track_compressed_class_memory_usage(); |
a6414751d537
8025996: Track metaspace usage when metaspace is expanded
stefank
parents:
12838
diff
changeset
|
2018 } |
a6414751d537
8025996: Track metaspace usage when metaspace is expanded
stefank
parents:
12838
diff
changeset
|
2019 MemoryService::track_metaspace_memory_usage(); |
a6414751d537
8025996: Track metaspace usage when metaspace is expanded
stefank
parents:
12838
diff
changeset
|
2020 } |
a6414751d537
8025996: Track metaspace usage when metaspace is expanded
stefank
parents:
12838
diff
changeset
|
2021 } |
a6414751d537
8025996: Track metaspace usage when metaspace is expanded
stefank
parents:
12838
diff
changeset
|
2022 |
6885 | 2023 MetaWord* SpaceManager::grow_and_allocate(size_t word_size) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2024 assert(vs_list()->current_virtual_space() != NULL, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2025 "Should have been set"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2026 assert(current_chunk() == NULL || |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2027 current_chunk()->allocate(word_size) == NULL, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2028 "Don't need to expand"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2029 MutexLockerEx cl(SpaceManager::expand_lock(), Mutex::_no_safepoint_check_flag); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2030 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2031 if (TraceMetadataChunkAllocation && Verbose) { |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2032 size_t words_left = 0; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2033 size_t words_used = 0; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2034 if (current_chunk() != NULL) { |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2035 words_left = current_chunk()->free_word_size(); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2036 words_used = current_chunk()->used_word_size(); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2037 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2038 gclog_or_tty->print_cr("SpaceManager::grow_and_allocate for " SIZE_FORMAT |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2039 " words " SIZE_FORMAT " words used " SIZE_FORMAT |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2040 " words left", |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2041 word_size, words_used, words_left); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2042 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2043 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2044 // Get another chunk out of the virtual space |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2045 size_t grow_chunks_by_words = calc_chunk_size(word_size); |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2046 Metachunk* next = get_new_chunk(word_size, grow_chunks_by_words); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2047 |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
2048 MetaWord* mem = NULL; |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
2049 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2050 // If a chunk was available, add it to the in-use chunk list |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2051 // and do an allocation from it. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2052 if (next != NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2053 // Add to this manager's list of chunks in use. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2054 add_chunk(next, false); |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
2055 mem = next->allocate(word_size); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2056 } |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
2057 |
12839
a6414751d537
8025996: Track metaspace usage when metaspace is expanded
stefank
parents:
12838
diff
changeset
|
2058 // Track metaspace memory usage statistic. |
a6414751d537
8025996: Track metaspace usage when metaspace is expanded
stefank
parents:
12838
diff
changeset
|
2059 track_metaspace_memory_usage(); |
a6414751d537
8025996: Track metaspace usage when metaspace is expanded
stefank
parents:
12838
diff
changeset
|
2060 |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
2061 return mem; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2062 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2063 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2064 void SpaceManager::print_on(outputStream* st) const { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2065 |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2066 for (ChunkIndex i = ZeroIndex; |
6885 | 2067 i < NumberOfInUseLists ; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2068 i = next_chunk_index(i) ) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2069 st->print_cr(" chunks_in_use " PTR_FORMAT " chunk size " PTR_FORMAT, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2070 chunks_in_use(i), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2071 chunks_in_use(i) == NULL ? 0 : chunks_in_use(i)->word_size()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2072 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2073 st->print_cr(" waste: Small " SIZE_FORMAT " Medium " SIZE_FORMAT |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2074 " Humongous " SIZE_FORMAT, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2075 sum_waste_in_chunks_in_use(SmallIndex), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2076 sum_waste_in_chunks_in_use(MediumIndex), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2077 sum_waste_in_chunks_in_use(HumongousIndex)); |
6885 | 2078 // block free lists |
2079 if (block_freelists() != NULL) { | |
2080 st->print_cr("total in block free lists " SIZE_FORMAT, | |
2081 block_freelists()->total_size()); | |
2082 } | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2083 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2084 |
10330
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10191
diff
changeset
|
2085 SpaceManager::SpaceManager(Metaspace::MetadataType mdtype, |
12303
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
2086 Mutex* lock) : |
10330
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10191
diff
changeset
|
2087 _mdtype(mdtype), |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2088 _allocated_blocks_words(0), |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2089 _allocated_chunks_words(0), |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2090 _allocated_chunks_count(0), |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2091 _lock(lock) |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2092 { |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2093 initialize(); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2094 } |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2095 |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2096 void SpaceManager::inc_size_metrics(size_t words) { |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2097 assert_lock_strong(SpaceManager::expand_lock()); |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2098 // Total of allocated Metachunks and allocated Metachunks count |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2099 // for each SpaceManager |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2100 _allocated_chunks_words = _allocated_chunks_words + words; |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2101 _allocated_chunks_count++; |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2102 // Global total of capacity in allocated Metachunks |
10330
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10191
diff
changeset
|
2103 MetaspaceAux::inc_capacity(mdtype(), words); |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2104 // Global total of allocated Metablocks. |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2105 // used_words_slow() includes the overhead in each |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2106 // Metachunk so include it in the used when the |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2107 // Metachunk is first added (so only added once per |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2108 // Metachunk). |
10330
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10191
diff
changeset
|
2109 MetaspaceAux::inc_used(mdtype(), Metachunk::overhead()); |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2110 } |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2111 |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2112 void SpaceManager::inc_used_metrics(size_t words) { |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2113 // Add to the per SpaceManager total |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2114 Atomic::add_ptr(words, &_allocated_blocks_words); |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2115 // Add to the global total |
10330
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10191
diff
changeset
|
2116 MetaspaceAux::inc_used(mdtype(), words); |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2117 } |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2118 |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2119 void SpaceManager::dec_total_from_size_metrics() { |
10330
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10191
diff
changeset
|
2120 MetaspaceAux::dec_capacity(mdtype(), allocated_chunks_words()); |
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10191
diff
changeset
|
2121 MetaspaceAux::dec_used(mdtype(), allocated_blocks_words()); |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2122 // Also deduct the overhead per Metachunk |
10330
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10191
diff
changeset
|
2123 MetaspaceAux::dec_used(mdtype(), allocated_chunks_count() * Metachunk::overhead()); |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2124 } |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2125 |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2126 void SpaceManager::initialize() { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2127 Metadebug::init_allocation_fail_alot_count(); |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2128 for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2129 _chunks_in_use[i] = NULL; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2130 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2131 _current_chunk = NULL; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2132 if (TraceMetadataChunkAllocation && Verbose) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2133 gclog_or_tty->print_cr("SpaceManager(): " PTR_FORMAT, this); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2134 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2135 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2136 |
10101
df254344edf1
8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents:
8813
diff
changeset
|
2137 void ChunkManager::return_chunks(ChunkIndex index, Metachunk* chunks) { |
df254344edf1
8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents:
8813
diff
changeset
|
2138 if (chunks == NULL) { |
df254344edf1
8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents:
8813
diff
changeset
|
2139 return; |
df254344edf1
8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents:
8813
diff
changeset
|
2140 } |
df254344edf1
8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents:
8813
diff
changeset
|
2141 ChunkList* list = free_chunks(index); |
df254344edf1
8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents:
8813
diff
changeset
|
2142 assert(list->size() == chunks->word_size(), "Mismatch in chunk sizes"); |
df254344edf1
8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents:
8813
diff
changeset
|
2143 assert_lock_strong(SpaceManager::expand_lock()); |
df254344edf1
8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents:
8813
diff
changeset
|
2144 Metachunk* cur = chunks; |
df254344edf1
8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents:
8813
diff
changeset
|
2145 |
10175 | 2146 // This returns chunks one at a time. If a new |
10101
df254344edf1
8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents:
8813
diff
changeset
|
2147 // class List can be created that is a base class |
df254344edf1
8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents:
8813
diff
changeset
|
2148 // of FreeList then something like FreeList::prepend() |
df254344edf1
8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents:
8813
diff
changeset
|
2149 // can be used in place of this loop |
df254344edf1
8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents:
8813
diff
changeset
|
2150 while (cur != NULL) { |
10175 | 2151 assert(cur->container() != NULL, "Container should have been set"); |
2152 cur->container()->dec_container_count(); | |
10101
df254344edf1
8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents:
8813
diff
changeset
|
2153 // Capture the next link before it is changed |
df254344edf1
8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents:
8813
diff
changeset
|
2154 // by the call to return_chunk_at_head(); |
df254344edf1
8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents:
8813
diff
changeset
|
2155 Metachunk* next = cur->next(); |
12902 | 2156 DEBUG_ONLY(cur->set_is_tagged_free(true);) |
10101
df254344edf1
8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents:
8813
diff
changeset
|
2157 list->return_chunk_at_head(cur); |
df254344edf1
8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents:
8813
diff
changeset
|
2158 cur = next; |
df254344edf1
8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents:
8813
diff
changeset
|
2159 } |
df254344edf1
8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents:
8813
diff
changeset
|
2160 } |
df254344edf1
8011173: NPG: Replace the ChunkList implementation with class FreeList<Metachunk>
jmasa
parents:
8813
diff
changeset
|
2161 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2162 SpaceManager::~SpaceManager() { |
8784
79af1312fc2c
8005602: NPG: classunloading does not happen while CMS GC with -XX:+CMSClassUnloadingEnabled is used
mgerdin
parents:
8738
diff
changeset
|
2163 // This call this->_lock which can't be done while holding expand_lock() |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2164 assert(sum_capacity_in_chunks_in_use() == allocated_chunks_words(), |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2165 err_msg("sum_capacity_in_chunks_in_use() " SIZE_FORMAT |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2166 " allocated_chunks_words() " SIZE_FORMAT, |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2167 sum_capacity_in_chunks_in_use(), allocated_chunks_words())); |
8784
79af1312fc2c
8005602: NPG: classunloading does not happen while CMS GC with -XX:+CMSClassUnloadingEnabled is used
mgerdin
parents:
8738
diff
changeset
|
2168 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2169 MutexLockerEx fcl(SpaceManager::expand_lock(), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2170 Mutex::_no_safepoint_check_flag); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2171 |
12303
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
2172 chunk_manager()->slow_locked_verify(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2173 |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2174 dec_total_from_size_metrics(); |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2175 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2176 if (TraceMetadataChunkAllocation && Verbose) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2177 gclog_or_tty->print_cr("~SpaceManager(): " PTR_FORMAT, this); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2178 locked_print_chunks_in_use_on(gclog_or_tty); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2179 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2180 |
10175 | 2181 // Do not mangle freed Metachunks. The chunk size inside Metachunks |
2182 // is during the freeing of a VirtualSpaceNodes. | |
7185
90273fc0a981
8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents:
6969
diff
changeset
|
2183 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2184 // Have to update before the chunks_in_use lists are emptied |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2185 // below. |
12303
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
2186 chunk_manager()->inc_free_chunks_total(allocated_chunks_words(), |
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
2187 sum_count_in_chunks_in_use()); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2188 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2189 // Add all the chunks in use by this space manager |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2190 // to the global list of free chunks. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2191 |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2192 // Follow each list of chunks-in-use and add them to the |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2193 // free lists. Each list is NULL terminated. |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2194 |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2195 for (ChunkIndex i = ZeroIndex; i < HumongousIndex; i = next_chunk_index(i)) { |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2196 if (TraceMetadataChunkAllocation && Verbose) { |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2197 gclog_or_tty->print_cr("returned %d %s chunks to freelist", |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2198 sum_count_in_chunks_in_use(i), |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2199 chunk_size_name(i)); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2200 } |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2201 Metachunk* chunks = chunks_in_use(i); |
12303
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
2202 chunk_manager()->return_chunks(i, chunks); |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2203 set_chunks_in_use(i, NULL); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2204 if (TraceMetadataChunkAllocation && Verbose) { |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2205 gclog_or_tty->print_cr("updated freelist count %d %s", |
12303
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
2206 chunk_manager()->free_chunks(i)->count(), |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2207 chunk_size_name(i)); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2208 } |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2209 assert(i != HumongousIndex, "Humongous chunks are handled explicitly later"); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2210 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2211 |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2212 // The medium chunk case may be optimized by passing the head and |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2213 // tail of the medium chunk list to add_at_head(). The tail is often |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2214 // the current chunk but there are probably exceptions. |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2215 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2216 // Humongous chunks |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2217 if (TraceMetadataChunkAllocation && Verbose) { |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2218 gclog_or_tty->print_cr("returned %d %s humongous chunks to dictionary", |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2219 sum_count_in_chunks_in_use(HumongousIndex), |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2220 chunk_size_name(HumongousIndex)); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2221 gclog_or_tty->print("Humongous chunk dictionary: "); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2222 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2223 // Humongous chunks are never the current chunk. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2224 Metachunk* humongous_chunks = chunks_in_use(HumongousIndex); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2225 |
6885 | 2226 while (humongous_chunks != NULL) { |
2227 #ifdef ASSERT | |
12902 | 2228 humongous_chunks->set_is_tagged_free(true); |
6885 | 2229 #endif |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2230 if (TraceMetadataChunkAllocation && Verbose) { |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2231 gclog_or_tty->print(PTR_FORMAT " (" SIZE_FORMAT ") ", |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2232 humongous_chunks, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2233 humongous_chunks->word_size()); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2234 } |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2235 assert(humongous_chunks->word_size() == (size_t) |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2236 align_size_up(humongous_chunks->word_size(), |
12979
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
2237 smallest_chunk_size()), |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2238 err_msg("Humongous chunk size is wrong: word size " SIZE_FORMAT |
8007
d9058e388631
8007257: NPG: metaspace.cpp: Incorrect arguments in calls to err_msg
mikael
parents:
7447
diff
changeset
|
2239 " granularity %d", |
12979
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
2240 humongous_chunks->word_size(), smallest_chunk_size())); |
6885 | 2241 Metachunk* next_humongous_chunks = humongous_chunks->next(); |
10175 | 2242 humongous_chunks->container()->dec_container_count(); |
12303
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
2243 chunk_manager()->humongous_dictionary()->return_chunk(humongous_chunks); |
6885 | 2244 humongous_chunks = next_humongous_chunks; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2245 } |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2246 if (TraceMetadataChunkAllocation && Verbose) { |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2247 gclog_or_tty->print_cr(""); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2248 gclog_or_tty->print_cr("updated dictionary count %d %s", |
12303
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
2249 chunk_manager()->humongous_dictionary()->total_count(), |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2250 chunk_size_name(HumongousIndex)); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2251 } |
12303
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
2252 chunk_manager()->slow_locked_verify(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2253 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2254 |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2255 const char* SpaceManager::chunk_size_name(ChunkIndex index) const { |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2256 switch (index) { |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2257 case SpecializedIndex: |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2258 return "Specialized"; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2259 case SmallIndex: |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2260 return "Small"; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2261 case MediumIndex: |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2262 return "Medium"; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2263 case HumongousIndex: |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2264 return "Humongous"; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2265 default: |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2266 return NULL; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2267 } |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2268 } |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2269 |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2270 ChunkIndex ChunkManager::list_index(size_t size) { |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2271 switch (size) { |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2272 case SpecializedChunk: |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2273 assert(SpecializedChunk == ClassSpecializedChunk, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2274 "Need branch for ClassSpecializedChunk"); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2275 return SpecializedIndex; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2276 case SmallChunk: |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2277 case ClassSmallChunk: |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2278 return SmallIndex; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2279 case MediumChunk: |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2280 case ClassMediumChunk: |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2281 return MediumIndex; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2282 default: |
7447
1de1b145f6bc
8005486: NPG: Incorrect assertion in ChunkManager::list_index()
jmasa
parents:
7446
diff
changeset
|
2283 assert(size > MediumChunk || size > ClassMediumChunk, |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2284 "Not a humongous chunk"); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2285 return HumongousIndex; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2286 } |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2287 } |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2288 |
6885 | 2289 void SpaceManager::deallocate(MetaWord* p, size_t word_size) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2290 assert_lock_strong(_lock); |
11966 | 2291 size_t raw_word_size = get_raw_word_size(word_size); |
17695
ab36007d6358
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
17663
diff
changeset
|
2292 size_t min_size = TreeChunk<Metablock, FreeList<Metablock> >::min_size(); |
11966 | 2293 assert(raw_word_size >= min_size, |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2294 err_msg("Should not deallocate dark matter " SIZE_FORMAT "<" SIZE_FORMAT, word_size, min_size)); |
11966 | 2295 block_freelists()->return_block(p, raw_word_size); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2296 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2297 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2298 // Adds a chunk to the list of chunks in use. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2299 void SpaceManager::add_chunk(Metachunk* new_chunk, bool make_current) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2300 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2301 assert(new_chunk != NULL, "Should not be NULL"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2302 assert(new_chunk->next() == NULL, "Should not be on a list"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2303 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2304 new_chunk->reset_empty(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2305 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2306 // Find the correct list and and set the current |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2307 // chunk for that list. |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2308 ChunkIndex index = ChunkManager::list_index(new_chunk->word_size()); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2309 |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2310 if (index != HumongousIndex) { |
12231
24e87613ee58
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
12226
diff
changeset
|
2311 retire_current_chunk(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2312 set_current_chunk(new_chunk); |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2313 new_chunk->set_next(chunks_in_use(index)); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2314 set_chunks_in_use(index, new_chunk); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2315 } else { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2316 // For null class loader data and DumpSharedSpaces, the first chunk isn't |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2317 // small, so small will be null. Link this first chunk as the current |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2318 // chunk. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2319 if (make_current) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2320 // Set as the current chunk but otherwise treat as a humongous chunk. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2321 set_current_chunk(new_chunk); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2322 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2323 // Link at head. The _current_chunk only points to a humongous chunk for |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2324 // the null class loader metaspace (class and data virtual space managers) |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2325 // any humongous chunks so will not point to the tail |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2326 // of the humongous chunks list. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2327 new_chunk->set_next(chunks_in_use(HumongousIndex)); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2328 set_chunks_in_use(HumongousIndex, new_chunk); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2329 |
7447
1de1b145f6bc
8005486: NPG: Incorrect assertion in ChunkManager::list_index()
jmasa
parents:
7446
diff
changeset
|
2330 assert(new_chunk->word_size() > medium_chunk_size(), "List inconsistency"); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2331 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2332 |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2333 // Add to the running sum of capacity |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2334 inc_size_metrics(new_chunk->word_size()); |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2335 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2336 assert(new_chunk->is_empty(), "Not ready for reuse"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2337 if (TraceMetadataChunkAllocation && Verbose) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2338 gclog_or_tty->print("SpaceManager::add_chunk: %d) ", |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2339 sum_count_in_chunks_in_use()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2340 new_chunk->print_on(gclog_or_tty); |
12303
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
2341 chunk_manager()->locked_print_free_chunks(gclog_or_tty); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2342 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2343 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2344 |
12231
24e87613ee58
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
12226
diff
changeset
|
2345 void SpaceManager::retire_current_chunk() { |
24e87613ee58
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
12226
diff
changeset
|
2346 if (current_chunk() != NULL) { |
24e87613ee58
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
12226
diff
changeset
|
2347 size_t remaining_words = current_chunk()->free_word_size(); |
17695
ab36007d6358
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
17663
diff
changeset
|
2348 if (remaining_words >= TreeChunk<Metablock, FreeList<Metablock> >::min_size()) { |
12231
24e87613ee58
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
12226
diff
changeset
|
2349 block_freelists()->return_block(current_chunk()->allocate(remaining_words), remaining_words); |
24e87613ee58
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
12226
diff
changeset
|
2350 inc_used_metrics(remaining_words); |
24e87613ee58
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
12226
diff
changeset
|
2351 } |
24e87613ee58
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
12226
diff
changeset
|
2352 } |
24e87613ee58
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
12226
diff
changeset
|
2353 } |
24e87613ee58
8009561: NPG: Metaspace fragmentation when retiring a Metachunk
mgerdin
parents:
12226
diff
changeset
|
2354 |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2355 Metachunk* SpaceManager::get_new_chunk(size_t word_size, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2356 size_t grow_chunks_by_words) { |
12303
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
2357 // Get a chunk from the chunk freelist |
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
2358 Metachunk* next = chunk_manager()->chunk_freelist_allocate(grow_chunks_by_words); |
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
2359 |
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
2360 if (next == NULL) { |
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
2361 next = vs_list()->get_new_chunk(word_size, |
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
2362 grow_chunks_by_words, |
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
2363 medium_chunk_bunch()); |
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
2364 } |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2365 |
12239 | 2366 if (TraceMetadataHumongousAllocation && next != NULL && |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2367 SpaceManager::is_humongous(next->word_size())) { |
12239 | 2368 gclog_or_tty->print_cr(" new humongous chunk word size " |
2369 PTR_FORMAT, next->word_size()); | |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2370 } |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2371 |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2372 return next; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2373 } |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2374 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2375 MetaWord* SpaceManager::allocate(size_t word_size) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2376 MutexLockerEx cl(lock(), Mutex::_no_safepoint_check_flag); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2377 |
10376
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
2378 size_t raw_word_size = get_raw_word_size(word_size); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2379 BlockFreelist* fl = block_freelists(); |
6885 | 2380 MetaWord* p = NULL; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2381 // Allocation from the dictionary is expensive in the sense that |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2382 // the dictionary has to be searched for a size. Don't allocate |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2383 // from the dictionary until it starts to get fat. Is this |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2384 // a reasonable policy? Maybe an skinny dictionary is fast enough |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2385 // for allocations. Do some profiling. JJJ |
6885 | 2386 if (fl->total_size() > allocation_from_dictionary_limit) { |
2387 p = fl->get_block(raw_word_size); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2388 } |
6885 | 2389 if (p == NULL) { |
2390 p = allocate_work(raw_word_size); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2391 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2392 |
6885 | 2393 return p; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2394 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2395 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2396 // Returns the address of spaced allocated for "word_size". |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2397 // This methods does not know about blocks (Metablocks) |
6885 | 2398 MetaWord* SpaceManager::allocate_work(size_t word_size) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2399 assert_lock_strong(_lock); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2400 #ifdef ASSERT |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2401 if (Metadebug::test_metadata_failure()) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2402 return NULL; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2403 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2404 #endif |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2405 // Is there space in the current chunk? |
6885 | 2406 MetaWord* result = NULL; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2407 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2408 // For DumpSharedSpaces, only allocate out of the current chunk which is |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2409 // never null because we gave it the size we wanted. Caller reports out |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2410 // of memory if this returns null. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2411 if (DumpSharedSpaces) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2412 assert(current_chunk() != NULL, "should never happen"); |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2413 inc_used_metrics(word_size); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2414 return current_chunk()->allocate(word_size); // caller handles null result |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2415 } |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
2416 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2417 if (current_chunk() != NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2418 result = current_chunk()->allocate(word_size); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2419 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2420 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2421 if (result == NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2422 result = grow_and_allocate(word_size); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2423 } |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
2424 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
2425 if (result != NULL) { |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2426 inc_used_metrics(word_size); |
6885 | 2427 assert(result != (MetaWord*) chunks_in_use(MediumIndex), |
2428 "Head of the list is being allocated"); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2429 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2430 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2431 return result; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2432 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2433 |
17663
40353abd7984
8029178: Parallel class loading test anonymous-simple gets SIGSEGV in Metaspace::contains
coleenp
parents:
13439
diff
changeset
|
2434 // This function looks at the chunks in the metaspace without locking. |
40353abd7984
8029178: Parallel class loading test anonymous-simple gets SIGSEGV in Metaspace::contains
coleenp
parents:
13439
diff
changeset
|
2435 // The chunks are added with store ordering and not deleted except for at |
40353abd7984
8029178: Parallel class loading test anonymous-simple gets SIGSEGV in Metaspace::contains
coleenp
parents:
13439
diff
changeset
|
2436 // unloading time. |
40353abd7984
8029178: Parallel class loading test anonymous-simple gets SIGSEGV in Metaspace::contains
coleenp
parents:
13439
diff
changeset
|
2437 bool SpaceManager::contains(const void *ptr) { |
40353abd7984
8029178: Parallel class loading test anonymous-simple gets SIGSEGV in Metaspace::contains
coleenp
parents:
13439
diff
changeset
|
2438 for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) |
40353abd7984
8029178: Parallel class loading test anonymous-simple gets SIGSEGV in Metaspace::contains
coleenp
parents:
13439
diff
changeset
|
2439 { |
40353abd7984
8029178: Parallel class loading test anonymous-simple gets SIGSEGV in Metaspace::contains
coleenp
parents:
13439
diff
changeset
|
2440 Metachunk* curr = chunks_in_use(i); |
40353abd7984
8029178: Parallel class loading test anonymous-simple gets SIGSEGV in Metaspace::contains
coleenp
parents:
13439
diff
changeset
|
2441 while (curr != NULL) { |
40353abd7984
8029178: Parallel class loading test anonymous-simple gets SIGSEGV in Metaspace::contains
coleenp
parents:
13439
diff
changeset
|
2442 if (curr->contains(ptr)) return true; |
40353abd7984
8029178: Parallel class loading test anonymous-simple gets SIGSEGV in Metaspace::contains
coleenp
parents:
13439
diff
changeset
|
2443 curr = curr->next(); |
40353abd7984
8029178: Parallel class loading test anonymous-simple gets SIGSEGV in Metaspace::contains
coleenp
parents:
13439
diff
changeset
|
2444 } |
40353abd7984
8029178: Parallel class loading test anonymous-simple gets SIGSEGV in Metaspace::contains
coleenp
parents:
13439
diff
changeset
|
2445 } |
40353abd7984
8029178: Parallel class loading test anonymous-simple gets SIGSEGV in Metaspace::contains
coleenp
parents:
13439
diff
changeset
|
2446 return false; |
40353abd7984
8029178: Parallel class loading test anonymous-simple gets SIGSEGV in Metaspace::contains
coleenp
parents:
13439
diff
changeset
|
2447 } |
40353abd7984
8029178: Parallel class loading test anonymous-simple gets SIGSEGV in Metaspace::contains
coleenp
parents:
13439
diff
changeset
|
2448 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2449 void SpaceManager::verify() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2450 // If there are blocks in the dictionary, then |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2451 // verfication of chunks does not work since |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2452 // being in the dictionary alters a chunk. |
6885 | 2453 if (block_freelists()->total_size() == 0) { |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2454 for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2455 Metachunk* curr = chunks_in_use(i); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2456 while (curr != NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2457 curr->verify(); |
7208
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
7187
diff
changeset
|
2458 verify_chunk_size(curr); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2459 curr = curr->next(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2460 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2461 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2462 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2463 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2464 |
7208
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
7187
diff
changeset
|
2465 void SpaceManager::verify_chunk_size(Metachunk* chunk) { |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
7187
diff
changeset
|
2466 assert(is_humongous(chunk->word_size()) || |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2467 chunk->word_size() == medium_chunk_size() || |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2468 chunk->word_size() == small_chunk_size() || |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2469 chunk->word_size() == specialized_chunk_size(), |
7208
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
7187
diff
changeset
|
2470 "Chunk size is wrong"); |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
7187
diff
changeset
|
2471 return; |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
7187
diff
changeset
|
2472 } |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
7187
diff
changeset
|
2473 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2474 #ifdef ASSERT |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2475 void SpaceManager::verify_allocated_blocks_words() { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2476 // Verification is only guaranteed at a safepoint. |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2477 assert(SafepointSynchronize::is_at_safepoint() || !Universe::is_fully_initialized(), |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2478 "Verification can fail if the applications is running"); |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2479 assert(allocated_blocks_words() == sum_used_in_chunks_in_use(), |
8007
d9058e388631
8007257: NPG: metaspace.cpp: Incorrect arguments in calls to err_msg
mikael
parents:
7447
diff
changeset
|
2480 err_msg("allocation total is not consistent " SIZE_FORMAT |
d9058e388631
8007257: NPG: metaspace.cpp: Incorrect arguments in calls to err_msg
mikael
parents:
7447
diff
changeset
|
2481 " vs " SIZE_FORMAT, |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2482 allocated_blocks_words(), sum_used_in_chunks_in_use())); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2483 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2484 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2485 #endif |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2486 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2487 void SpaceManager::dump(outputStream* const out) const { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2488 size_t curr_total = 0; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2489 size_t waste = 0; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2490 uint i = 0; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2491 size_t used = 0; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2492 size_t capacity = 0; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2493 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2494 // Add up statistics for all chunks in this SpaceManager. |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2495 for (ChunkIndex index = ZeroIndex; |
6885 | 2496 index < NumberOfInUseLists; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2497 index = next_chunk_index(index)) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2498 for (Metachunk* curr = chunks_in_use(index); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2499 curr != NULL; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2500 curr = curr->next()) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2501 out->print("%d) ", i++); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2502 curr->print_on(out); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2503 curr_total += curr->word_size(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2504 used += curr->used_word_size(); |
12902 | 2505 capacity += curr->word_size(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2506 waste += curr->free_word_size() + curr->overhead();; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2507 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2508 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2509 |
12239 | 2510 if (TraceMetadataChunkAllocation && Verbose) { |
2511 block_freelists()->print_on(out); | |
2512 } | |
2513 | |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2514 size_t free = current_chunk() == NULL ? 0 : current_chunk()->free_word_size(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2515 // Free space isn't wasted. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2516 waste -= free; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2517 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2518 out->print_cr("total of all chunks " SIZE_FORMAT " used " SIZE_FORMAT |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2519 " free " SIZE_FORMAT " capacity " SIZE_FORMAT |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2520 " waste " SIZE_FORMAT, curr_total, used, free, capacity, waste); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2521 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2522 |
7185
90273fc0a981
8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents:
6969
diff
changeset
|
2523 #ifndef PRODUCT |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2524 void SpaceManager::mangle_freed_chunks() { |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2525 for (ChunkIndex index = ZeroIndex; |
6885 | 2526 index < NumberOfInUseLists; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2527 index = next_chunk_index(index)) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2528 for (Metachunk* curr = chunks_in_use(index); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2529 curr != NULL; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2530 curr = curr->next()) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2531 curr->mangle(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2532 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2533 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2534 } |
7185
90273fc0a981
8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents:
6969
diff
changeset
|
2535 #endif // PRODUCT |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2536 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2537 // MetaspaceAux |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2538 |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2539 |
17866
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17771
diff
changeset
|
2540 size_t MetaspaceAux::_capacity_words[] = {0, 0}; |
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17771
diff
changeset
|
2541 size_t MetaspaceAux::_used_words[] = {0, 0}; |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2542 |
12063
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
12056
diff
changeset
|
2543 size_t MetaspaceAux::free_bytes(Metaspace::MetadataType mdtype) { |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
12056
diff
changeset
|
2544 VirtualSpaceList* list = Metaspace::get_space_list(mdtype); |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
12056
diff
changeset
|
2545 return list == NULL ? 0 : list->free_bytes(); |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
12056
diff
changeset
|
2546 } |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
12056
diff
changeset
|
2547 |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2548 size_t MetaspaceAux::free_bytes() { |
12063
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
12056
diff
changeset
|
2549 return free_bytes(Metaspace::ClassType) + free_bytes(Metaspace::NonClassType); |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2550 } |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2551 |
10330
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10191
diff
changeset
|
2552 void MetaspaceAux::dec_capacity(Metaspace::MetadataType mdtype, size_t words) { |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2553 assert_lock_strong(SpaceManager::expand_lock()); |
17866
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17771
diff
changeset
|
2554 assert(words <= capacity_words(mdtype), |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2555 err_msg("About to decrement below 0: words " SIZE_FORMAT |
17866
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17771
diff
changeset
|
2556 " is greater than _capacity_words[%u] " SIZE_FORMAT, |
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17771
diff
changeset
|
2557 words, mdtype, capacity_words(mdtype))); |
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17771
diff
changeset
|
2558 _capacity_words[mdtype] -= words; |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2559 } |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2560 |
10330
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10191
diff
changeset
|
2561 void MetaspaceAux::inc_capacity(Metaspace::MetadataType mdtype, size_t words) { |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2562 assert_lock_strong(SpaceManager::expand_lock()); |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2563 // Needs to be atomic |
17866
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17771
diff
changeset
|
2564 _capacity_words[mdtype] += words; |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2565 } |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2566 |
10330
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10191
diff
changeset
|
2567 void MetaspaceAux::dec_used(Metaspace::MetadataType mdtype, size_t words) { |
17866
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17771
diff
changeset
|
2568 assert(words <= used_words(mdtype), |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2569 err_msg("About to decrement below 0: words " SIZE_FORMAT |
17866
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17771
diff
changeset
|
2570 " is greater than _used_words[%u] " SIZE_FORMAT, |
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17771
diff
changeset
|
2571 words, mdtype, used_words(mdtype))); |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2572 // For CMS deallocation of the Metaspaces occurs during the |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2573 // sweep which is a concurrent phase. Protection by the expand_lock() |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2574 // is not enough since allocation is on a per Metaspace basis |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2575 // and protected by the Metaspace lock. |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2576 jlong minus_words = (jlong) - (jlong) words; |
17866
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17771
diff
changeset
|
2577 Atomic::add_ptr(minus_words, &_used_words[mdtype]); |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2578 } |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2579 |
10330
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10191
diff
changeset
|
2580 void MetaspaceAux::inc_used(Metaspace::MetadataType mdtype, size_t words) { |
17866
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17771
diff
changeset
|
2581 // _used_words tracks allocations for |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2582 // each piece of metadata. Those allocations are |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2583 // generally done concurrently by different application |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2584 // threads so must be done atomically. |
17866
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17771
diff
changeset
|
2585 Atomic::add_ptr(words, &_used_words[mdtype]); |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2586 } |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2587 |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2588 size_t MetaspaceAux::used_bytes_slow(Metaspace::MetadataType mdtype) { |
6730
5d2156bcb78b
7195789: NPG: assert(used + free == capacity) failed: Accounting is wrong
jmasa
parents:
6726
diff
changeset
|
2589 size_t used = 0; |
5d2156bcb78b
7195789: NPG: assert(used + free == capacity) failed: Accounting is wrong
jmasa
parents:
6726
diff
changeset
|
2590 ClassLoaderDataGraphMetaspaceIterator iter; |
5d2156bcb78b
7195789: NPG: assert(used + free == capacity) failed: Accounting is wrong
jmasa
parents:
6726
diff
changeset
|
2591 while (iter.repeat()) { |
5d2156bcb78b
7195789: NPG: assert(used + free == capacity) failed: Accounting is wrong
jmasa
parents:
6726
diff
changeset
|
2592 Metaspace* msp = iter.get_next(); |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2593 // Sum allocated_blocks_words for each metaspace |
6730
5d2156bcb78b
7195789: NPG: assert(used + free == capacity) failed: Accounting is wrong
jmasa
parents:
6726
diff
changeset
|
2594 if (msp != NULL) { |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2595 used += msp->used_words_slow(mdtype); |
6730
5d2156bcb78b
7195789: NPG: assert(used + free == capacity) failed: Accounting is wrong
jmasa
parents:
6726
diff
changeset
|
2596 } |
5d2156bcb78b
7195789: NPG: assert(used + free == capacity) failed: Accounting is wrong
jmasa
parents:
6726
diff
changeset
|
2597 } |
5d2156bcb78b
7195789: NPG: assert(used + free == capacity) failed: Accounting is wrong
jmasa
parents:
6726
diff
changeset
|
2598 return used * BytesPerWord; |
5d2156bcb78b
7195789: NPG: assert(used + free == capacity) failed: Accounting is wrong
jmasa
parents:
6726
diff
changeset
|
2599 } |
5d2156bcb78b
7195789: NPG: assert(used + free == capacity) failed: Accounting is wrong
jmasa
parents:
6726
diff
changeset
|
2600 |
12235 | 2601 size_t MetaspaceAux::free_bytes_slow(Metaspace::MetadataType mdtype) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2602 size_t free = 0; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2603 ClassLoaderDataGraphMetaspaceIterator iter; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2604 while (iter.repeat()) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2605 Metaspace* msp = iter.get_next(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2606 if (msp != NULL) { |
12235 | 2607 free += msp->free_words_slow(mdtype); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2608 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2609 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2610 return free * BytesPerWord; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2611 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2612 |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2613 size_t MetaspaceAux::capacity_bytes_slow(Metaspace::MetadataType mdtype) { |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2614 if ((mdtype == Metaspace::ClassType) && !Metaspace::using_class_space()) { |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2615 return 0; |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2616 } |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2617 // Don't count the space in the freelists. That space will be |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2618 // added to the capacity calculation as needed. |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2619 size_t capacity = 0; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2620 ClassLoaderDataGraphMetaspaceIterator iter; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2621 while (iter.repeat()) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2622 Metaspace* msp = iter.get_next(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2623 if (msp != NULL) { |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2624 capacity += msp->capacity_words_slow(mdtype); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2625 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2626 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2627 return capacity * BytesPerWord; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2628 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2629 |
12235 | 2630 size_t MetaspaceAux::capacity_bytes_slow() { |
2631 #ifdef PRODUCT | |
17866
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17771
diff
changeset
|
2632 // Use capacity_bytes() in PRODUCT instead of this function. |
12235 | 2633 guarantee(false, "Should not call capacity_bytes_slow() in the PRODUCT"); |
2634 #endif | |
2635 size_t class_capacity = capacity_bytes_slow(Metaspace::ClassType); | |
2636 size_t non_class_capacity = capacity_bytes_slow(Metaspace::NonClassType); | |
17866
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17771
diff
changeset
|
2637 assert(capacity_bytes() == class_capacity + non_class_capacity, |
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17771
diff
changeset
|
2638 err_msg("bad accounting: capacity_bytes() " SIZE_FORMAT |
12235 | 2639 " class_capacity + non_class_capacity " SIZE_FORMAT |
2640 " class_capacity " SIZE_FORMAT " non_class_capacity " SIZE_FORMAT, | |
17866
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17771
diff
changeset
|
2641 capacity_bytes(), class_capacity + non_class_capacity, |
12235 | 2642 class_capacity, non_class_capacity)); |
2643 | |
2644 return class_capacity + non_class_capacity; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2645 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2646 |
12235 | 2647 size_t MetaspaceAux::reserved_bytes(Metaspace::MetadataType mdtype) { |
2648 VirtualSpaceList* list = Metaspace::get_space_list(mdtype); | |
12236
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
2649 return list == NULL ? 0 : list->reserved_bytes(); |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
2650 } |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
2651 |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
2652 size_t MetaspaceAux::committed_bytes(Metaspace::MetadataType mdtype) { |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
2653 VirtualSpaceList* list = Metaspace::get_space_list(mdtype); |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
2654 return list == NULL ? 0 : list->committed_bytes(); |
12235 | 2655 } |
2656 | |
2657 size_t MetaspaceAux::min_chunk_size_words() { return Metaspace::first_chunk_word_size(); } | |
2658 | |
2659 size_t MetaspaceAux::free_chunks_total_words(Metaspace::MetadataType mdtype) { | |
12303
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
2660 ChunkManager* chunk_manager = Metaspace::get_chunk_manager(mdtype); |
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
2661 if (chunk_manager == NULL) { |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2662 return 0; |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2663 } |
12303
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
2664 chunk_manager->slow_verify(); |
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
2665 return chunk_manager->free_chunks_total_words(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2666 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2667 |
12235 | 2668 size_t MetaspaceAux::free_chunks_total_bytes(Metaspace::MetadataType mdtype) { |
2669 return free_chunks_total_words(mdtype) * BytesPerWord; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2670 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2671 |
12235 | 2672 size_t MetaspaceAux::free_chunks_total_words() { |
2673 return free_chunks_total_words(Metaspace::ClassType) + | |
2674 free_chunks_total_words(Metaspace::NonClassType); | |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2675 } |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2676 |
12235 | 2677 size_t MetaspaceAux::free_chunks_total_bytes() { |
2678 return free_chunks_total_words() * BytesPerWord; | |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2679 } |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2680 |
17771
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
2681 bool MetaspaceAux::has_chunk_free_list(Metaspace::MetadataType mdtype) { |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
2682 return Metaspace::get_chunk_manager(mdtype) != NULL; |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
2683 } |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
2684 |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
2685 MetaspaceChunkFreeListSummary MetaspaceAux::chunk_free_list_summary(Metaspace::MetadataType mdtype) { |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
2686 if (!has_chunk_free_list(mdtype)) { |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
2687 return MetaspaceChunkFreeListSummary(); |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
2688 } |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
2689 |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
2690 const ChunkManager* cm = Metaspace::get_chunk_manager(mdtype); |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
2691 return cm->chunk_free_list_summary(); |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
2692 } |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
2693 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2694 void MetaspaceAux::print_metaspace_change(size_t prev_metadata_used) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2695 gclog_or_tty->print(", [Metaspace:"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2696 if (PrintGCDetails && Verbose) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2697 gclog_or_tty->print(" " SIZE_FORMAT |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2698 "->" SIZE_FORMAT |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2699 "(" SIZE_FORMAT ")", |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2700 prev_metadata_used, |
17866
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17771
diff
changeset
|
2701 used_bytes(), |
12235 | 2702 reserved_bytes()); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2703 } else { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2704 gclog_or_tty->print(" " SIZE_FORMAT "K" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2705 "->" SIZE_FORMAT "K" |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2706 "(" SIZE_FORMAT "K)", |
12235 | 2707 prev_metadata_used/K, |
17866
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17771
diff
changeset
|
2708 used_bytes()/K, |
12235 | 2709 reserved_bytes()/K); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2710 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2711 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2712 gclog_or_tty->print("]"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2713 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2714 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2715 // This is printed when PrintGCDetails |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2716 void MetaspaceAux::print_on(outputStream* out) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2717 Metaspace::MetadataType nct = Metaspace::NonClassType; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2718 |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
2719 out->print_cr(" Metaspace " |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
2720 "used " SIZE_FORMAT "K, " |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
2721 "capacity " SIZE_FORMAT "K, " |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
2722 "committed " SIZE_FORMAT "K, " |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
2723 "reserved " SIZE_FORMAT "K", |
17866
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17771
diff
changeset
|
2724 used_bytes()/K, |
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17771
diff
changeset
|
2725 capacity_bytes()/K, |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
2726 committed_bytes()/K, |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
2727 reserved_bytes()/K); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
2728 |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2729 if (Metaspace::using_class_space()) { |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2730 Metaspace::MetadataType ct = Metaspace::ClassType; |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2731 out->print_cr(" class space " |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
2732 "used " SIZE_FORMAT "K, " |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
2733 "capacity " SIZE_FORMAT "K, " |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
2734 "committed " SIZE_FORMAT "K, " |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
2735 "reserved " SIZE_FORMAT "K", |
17866
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17771
diff
changeset
|
2736 used_bytes(ct)/K, |
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17771
diff
changeset
|
2737 capacity_bytes(ct)/K, |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
2738 committed_bytes(ct)/K, |
12235 | 2739 reserved_bytes(ct)/K); |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2740 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2741 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2742 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2743 // Print information for class space and data space separately. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2744 // This is almost the same as above. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2745 void MetaspaceAux::print_on(outputStream* out, Metaspace::MetadataType mdtype) { |
12235 | 2746 size_t free_chunks_capacity_bytes = free_chunks_total_bytes(mdtype); |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2747 size_t capacity_bytes = capacity_bytes_slow(mdtype); |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2748 size_t used_bytes = used_bytes_slow(mdtype); |
12235 | 2749 size_t free_bytes = free_bytes_slow(mdtype); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2750 size_t used_and_free = used_bytes + free_bytes + |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2751 free_chunks_capacity_bytes; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2752 out->print_cr(" Chunk accounting: used in chunks " SIZE_FORMAT |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2753 "K + unused in chunks " SIZE_FORMAT "K + " |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2754 " capacity in free chunks " SIZE_FORMAT "K = " SIZE_FORMAT |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2755 "K capacity in allocated chunks " SIZE_FORMAT "K", |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2756 used_bytes / K, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2757 free_bytes / K, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2758 free_chunks_capacity_bytes / K, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2759 used_and_free / K, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2760 capacity_bytes / K); |
8738
1c88b99a2b01
8009282: Assertion "assert(used_and_free == capacity_bytes) failed: Accounting is wrong" failed with -XX:+Verbose -XX:+TraceMetadataChunkAllocation
mgerdin
parents:
8040
diff
changeset
|
2761 // Accounting can only be correct if we got the values during a safepoint |
1c88b99a2b01
8009282: Assertion "assert(used_and_free == capacity_bytes) failed: Accounting is wrong" failed with -XX:+Verbose -XX:+TraceMetadataChunkAllocation
mgerdin
parents:
8040
diff
changeset
|
2762 assert(!SafepointSynchronize::is_at_safepoint() || used_and_free == capacity_bytes, "Accounting is wrong"); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2763 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2764 |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2765 // Print total fragmentation for class metaspaces |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2766 void MetaspaceAux::print_class_waste(outputStream* out) { |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2767 assert(Metaspace::using_class_space(), "class metaspace not used"); |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2768 size_t cls_specialized_waste = 0, cls_small_waste = 0, cls_medium_waste = 0; |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2769 size_t cls_specialized_count = 0, cls_small_count = 0, cls_medium_count = 0, cls_humongous_count = 0; |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2770 ClassLoaderDataGraphMetaspaceIterator iter; |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2771 while (iter.repeat()) { |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2772 Metaspace* msp = iter.get_next(); |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2773 if (msp != NULL) { |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2774 cls_specialized_waste += msp->class_vsm()->sum_waste_in_chunks_in_use(SpecializedIndex); |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2775 cls_specialized_count += msp->class_vsm()->sum_count_in_chunks_in_use(SpecializedIndex); |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2776 cls_small_waste += msp->class_vsm()->sum_waste_in_chunks_in_use(SmallIndex); |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2777 cls_small_count += msp->class_vsm()->sum_count_in_chunks_in_use(SmallIndex); |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2778 cls_medium_waste += msp->class_vsm()->sum_waste_in_chunks_in_use(MediumIndex); |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2779 cls_medium_count += msp->class_vsm()->sum_count_in_chunks_in_use(MediumIndex); |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2780 cls_humongous_count += msp->class_vsm()->sum_count_in_chunks_in_use(HumongousIndex); |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2781 } |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2782 } |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2783 out->print_cr(" class: " SIZE_FORMAT " specialized(s) " SIZE_FORMAT ", " |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2784 SIZE_FORMAT " small(s) " SIZE_FORMAT ", " |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2785 SIZE_FORMAT " medium(s) " SIZE_FORMAT ", " |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2786 "large count " SIZE_FORMAT, |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2787 cls_specialized_count, cls_specialized_waste, |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2788 cls_small_count, cls_small_waste, |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2789 cls_medium_count, cls_medium_waste, cls_humongous_count); |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2790 } |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2791 |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2792 // Print total fragmentation for data and class metaspaces separately |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2793 void MetaspaceAux::print_waste(outputStream* out) { |
11064
de2d15ce3d4a
8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents:
10376
diff
changeset
|
2794 size_t specialized_waste = 0, small_waste = 0, medium_waste = 0; |
de2d15ce3d4a
8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents:
10376
diff
changeset
|
2795 size_t specialized_count = 0, small_count = 0, medium_count = 0, humongous_count = 0; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2796 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2797 ClassLoaderDataGraphMetaspaceIterator iter; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2798 while (iter.repeat()) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2799 Metaspace* msp = iter.get_next(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2800 if (msp != NULL) { |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2801 specialized_waste += msp->vsm()->sum_waste_in_chunks_in_use(SpecializedIndex); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2802 specialized_count += msp->vsm()->sum_count_in_chunks_in_use(SpecializedIndex); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2803 small_waste += msp->vsm()->sum_waste_in_chunks_in_use(SmallIndex); |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2804 small_count += msp->vsm()->sum_count_in_chunks_in_use(SmallIndex); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2805 medium_waste += msp->vsm()->sum_waste_in_chunks_in_use(MediumIndex); |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2806 medium_count += msp->vsm()->sum_count_in_chunks_in_use(MediumIndex); |
11064
de2d15ce3d4a
8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents:
10376
diff
changeset
|
2807 humongous_count += msp->vsm()->sum_count_in_chunks_in_use(HumongousIndex); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2808 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2809 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2810 out->print_cr("Total fragmentation waste (words) doesn't count free space"); |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2811 out->print_cr(" data: " SIZE_FORMAT " specialized(s) " SIZE_FORMAT ", " |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2812 SIZE_FORMAT " small(s) " SIZE_FORMAT ", " |
11064
de2d15ce3d4a
8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents:
10376
diff
changeset
|
2813 SIZE_FORMAT " medium(s) " SIZE_FORMAT ", " |
de2d15ce3d4a
8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents:
10376
diff
changeset
|
2814 "large count " SIZE_FORMAT, |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2815 specialized_count, specialized_waste, small_count, |
11064
de2d15ce3d4a
8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents:
10376
diff
changeset
|
2816 small_waste, medium_count, medium_waste, humongous_count); |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2817 if (Metaspace::using_class_space()) { |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2818 print_class_waste(out); |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2819 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2820 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2821 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2822 // Dump global metaspace things from the end of ClassLoaderDataGraph |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2823 void MetaspaceAux::dump(outputStream* out) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2824 out->print_cr("All Metaspace:"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2825 out->print("data space: "); print_on(out, Metaspace::NonClassType); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2826 out->print("class space: "); print_on(out, Metaspace::ClassType); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2827 print_waste(out); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2828 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2829 |
6969
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
2830 void MetaspaceAux::verify_free_chunks() { |
12303
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
2831 Metaspace::chunk_manager_metadata()->verify(); |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2832 if (Metaspace::using_class_space()) { |
12303
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
2833 Metaspace::chunk_manager_class()->verify(); |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2834 } |
6969
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
2835 } |
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
2836 |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2837 void MetaspaceAux::verify_capacity() { |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2838 #ifdef ASSERT |
17866
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17771
diff
changeset
|
2839 size_t running_sum_capacity_bytes = capacity_bytes(); |
10330
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10191
diff
changeset
|
2840 // For purposes of the running sum of capacity, verify against capacity |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2841 size_t capacity_in_use_bytes = capacity_bytes_slow(); |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2842 assert(running_sum_capacity_bytes == capacity_in_use_bytes, |
17866
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17771
diff
changeset
|
2843 err_msg("capacity_words() * BytesPerWord " SIZE_FORMAT |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2844 " capacity_bytes_slow()" SIZE_FORMAT, |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2845 running_sum_capacity_bytes, capacity_in_use_bytes)); |
10330
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10191
diff
changeset
|
2846 for (Metaspace::MetadataType i = Metaspace::ClassType; |
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10191
diff
changeset
|
2847 i < Metaspace:: MetadataTypeCount; |
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10191
diff
changeset
|
2848 i = (Metaspace::MetadataType)(i + 1)) { |
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10191
diff
changeset
|
2849 size_t capacity_in_use_bytes = capacity_bytes_slow(i); |
17866
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17771
diff
changeset
|
2850 assert(capacity_bytes(i) == capacity_in_use_bytes, |
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17771
diff
changeset
|
2851 err_msg("capacity_bytes(%u) " SIZE_FORMAT |
10330
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10191
diff
changeset
|
2852 " capacity_bytes_slow(%u)" SIZE_FORMAT, |
17866
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17771
diff
changeset
|
2853 i, capacity_bytes(i), i, capacity_in_use_bytes)); |
10330
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10191
diff
changeset
|
2854 } |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2855 #endif |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2856 } |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2857 |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2858 void MetaspaceAux::verify_used() { |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2859 #ifdef ASSERT |
17866
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17771
diff
changeset
|
2860 size_t running_sum_used_bytes = used_bytes(); |
10330
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10191
diff
changeset
|
2861 // For purposes of the running sum of used, verify against used |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2862 size_t used_in_use_bytes = used_bytes_slow(); |
17866
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17771
diff
changeset
|
2863 assert(used_bytes() == used_in_use_bytes, |
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17771
diff
changeset
|
2864 err_msg("used_bytes() " SIZE_FORMAT |
10330
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10191
diff
changeset
|
2865 " used_bytes_slow()" SIZE_FORMAT, |
17866
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17771
diff
changeset
|
2866 used_bytes(), used_in_use_bytes)); |
10330
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10191
diff
changeset
|
2867 for (Metaspace::MetadataType i = Metaspace::ClassType; |
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10191
diff
changeset
|
2868 i < Metaspace:: MetadataTypeCount; |
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10191
diff
changeset
|
2869 i = (Metaspace::MetadataType)(i + 1)) { |
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10191
diff
changeset
|
2870 size_t used_in_use_bytes = used_bytes_slow(i); |
17866
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17771
diff
changeset
|
2871 assert(used_bytes(i) == used_in_use_bytes, |
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17771
diff
changeset
|
2872 err_msg("used_bytes(%u) " SIZE_FORMAT |
10330
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10191
diff
changeset
|
2873 " used_bytes_slow(%u)" SIZE_FORMAT, |
17866
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17771
diff
changeset
|
2874 i, used_bytes(i), i, used_in_use_bytes)); |
10330
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10191
diff
changeset
|
2875 } |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2876 #endif |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2877 } |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2878 |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2879 void MetaspaceAux::verify_metrics() { |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2880 verify_capacity(); |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2881 verify_used(); |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2882 } |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2883 |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
2884 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2885 // Metaspace methods |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2886 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2887 size_t Metaspace::_first_chunk_word_size = 0; |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2888 size_t Metaspace::_first_class_chunk_word_size = 0; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2889 |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
2890 size_t Metaspace::_commit_alignment = 0; |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
2891 size_t Metaspace::_reserve_alignment = 0; |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
2892 |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2893 Metaspace::Metaspace(Mutex* lock, MetaspaceType type) { |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
2894 initialize(lock, type); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2895 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2896 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2897 Metaspace::~Metaspace() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2898 delete _vsm; |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2899 if (using_class_space()) { |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2900 delete _class_vsm; |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2901 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2902 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2903 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2904 VirtualSpaceList* Metaspace::_space_list = NULL; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2905 VirtualSpaceList* Metaspace::_class_space_list = NULL; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2906 |
12303
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
2907 ChunkManager* Metaspace::_chunk_manager_metadata = NULL; |
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
2908 ChunkManager* Metaspace::_chunk_manager_class = NULL; |
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
2909 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2910 #define VIRTUALSPACEMULTIPLIER 2 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2911 |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2912 #ifdef _LP64 |
13000
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
12998
diff
changeset
|
2913 static const uint64_t UnscaledClassSpaceMax = (uint64_t(max_juint) + 1); |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
12998
diff
changeset
|
2914 |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2915 void Metaspace::set_narrow_klass_base_and_shift(address metaspace_base, address cds_base) { |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2916 // Figure out the narrow_klass_base and the narrow_klass_shift. The |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2917 // narrow_klass_base is the lower of the metaspace base and the cds base |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2918 // (if cds is enabled). The narrow_klass_shift depends on the distance |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2919 // between the lower base and higher address. |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2920 address lower_base; |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2921 address higher_address; |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2922 if (UseSharedSpaces) { |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2923 higher_address = MAX2((address)(cds_base + FileMapInfo::shared_spaces_size()), |
13000
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
12998
diff
changeset
|
2924 (address)(metaspace_base + compressed_class_space_size())); |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2925 lower_base = MIN2(metaspace_base, cds_base); |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2926 } else { |
13000
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
12998
diff
changeset
|
2927 higher_address = metaspace_base + compressed_class_space_size(); |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2928 lower_base = metaspace_base; |
13000
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
12998
diff
changeset
|
2929 |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
12998
diff
changeset
|
2930 uint64_t klass_encoding_max = UnscaledClassSpaceMax << LogKlassAlignmentInBytes; |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
12998
diff
changeset
|
2931 // If compressed class space fits in lower 32G, we don't need a base. |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
12998
diff
changeset
|
2932 if (higher_address <= (address)klass_encoding_max) { |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
12998
diff
changeset
|
2933 lower_base = 0; // effectively lower base is zero. |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
12998
diff
changeset
|
2934 } |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2935 } |
13000
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
12998
diff
changeset
|
2936 |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2937 Universe::set_narrow_klass_base(lower_base); |
13000
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
12998
diff
changeset
|
2938 |
13037
c8fc12209830
8027616: Off by one error in putback for compressed oops nashorn performance improvement
coleenp
parents:
13001
diff
changeset
|
2939 if ((uint64_t)(higher_address - lower_base) <= UnscaledClassSpaceMax) { |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2940 Universe::set_narrow_klass_shift(0); |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2941 } else { |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2942 assert(!UseSharedSpaces, "Cannot shift with UseSharedSpaces"); |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2943 Universe::set_narrow_klass_shift(LogKlassAlignmentInBytes); |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2944 } |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2945 } |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2946 |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2947 // Return TRUE if the specified metaspace_base and cds_base are close enough |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2948 // to work with compressed klass pointers. |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2949 bool Metaspace::can_use_cds_with_metaspace_addr(char* metaspace_base, address cds_base) { |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2950 assert(cds_base != 0 && UseSharedSpaces, "Only use with CDS"); |
12226
7944aba7ba41
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
12110
diff
changeset
|
2951 assert(UseCompressedClassPointers, "Only use with CompressedKlassPtrs"); |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2952 address lower_base = MIN2((address)metaspace_base, cds_base); |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2953 address higher_address = MAX2((address)(cds_base + FileMapInfo::shared_spaces_size()), |
13000
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
12998
diff
changeset
|
2954 (address)(metaspace_base + compressed_class_space_size())); |
13037
c8fc12209830
8027616: Off by one error in putback for compressed oops nashorn performance improvement
coleenp
parents:
13001
diff
changeset
|
2955 return ((uint64_t)(higher_address - lower_base) <= UnscaledClassSpaceMax); |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2956 } |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2957 |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2958 // Try to allocate the metaspace at the requested addr. |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2959 void Metaspace::allocate_metaspace_compressed_klass_ptrs(char* requested_addr, address cds_base) { |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2960 assert(using_class_space(), "called improperly"); |
12226
7944aba7ba41
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
12110
diff
changeset
|
2961 assert(UseCompressedClassPointers, "Only use with CompressedKlassPtrs"); |
13000
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
12998
diff
changeset
|
2962 assert(compressed_class_space_size() < KlassEncodingMetaspaceMax, |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2963 "Metaspace size is too big"); |
13000
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
12998
diff
changeset
|
2964 assert_is_ptr_aligned(requested_addr, _reserve_alignment); |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
12998
diff
changeset
|
2965 assert_is_ptr_aligned(cds_base, _reserve_alignment); |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
12998
diff
changeset
|
2966 assert_is_size_aligned(compressed_class_space_size(), _reserve_alignment); |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
2967 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
2968 // Don't use large pages for the class space. |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
2969 bool large_pages = false; |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2970 |
13000
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
12998
diff
changeset
|
2971 ReservedSpace metaspace_rs = ReservedSpace(compressed_class_space_size(), |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
2972 _reserve_alignment, |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
2973 large_pages, |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
2974 requested_addr, 0); |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2975 if (!metaspace_rs.is_reserved()) { |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2976 if (UseSharedSpaces) { |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
2977 size_t increment = align_size_up(1*G, _reserve_alignment); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
2978 |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2979 // Keep trying to allocate the metaspace, increasing the requested_addr |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2980 // by 1GB each time, until we reach an address that will no longer allow |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2981 // use of CDS with compressed klass pointers. |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2982 char *addr = requested_addr; |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
2983 while (!metaspace_rs.is_reserved() && (addr + increment > addr) && |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
2984 can_use_cds_with_metaspace_addr(addr + increment, cds_base)) { |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
2985 addr = addr + increment; |
13000
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
12998
diff
changeset
|
2986 metaspace_rs = ReservedSpace(compressed_class_space_size(), |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
2987 _reserve_alignment, large_pages, addr, 0); |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2988 } |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2989 } |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2990 |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2991 // If no successful allocation then try to allocate the space anywhere. If |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2992 // that fails then OOM doom. At this point we cannot try allocating the |
12226
7944aba7ba41
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
12110
diff
changeset
|
2993 // metaspace as if UseCompressedClassPointers is off because too much |
7944aba7ba41
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
12110
diff
changeset
|
2994 // initialization has happened that depends on UseCompressedClassPointers. |
7944aba7ba41
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
12110
diff
changeset
|
2995 // So, UseCompressedClassPointers cannot be turned off at this point. |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2996 if (!metaspace_rs.is_reserved()) { |
13000
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
12998
diff
changeset
|
2997 metaspace_rs = ReservedSpace(compressed_class_space_size(), |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
2998 _reserve_alignment, large_pages); |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
2999 if (!metaspace_rs.is_reserved()) { |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3000 vm_exit_during_initialization(err_msg("Could not allocate metaspace: %d bytes", |
13000
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
12998
diff
changeset
|
3001 compressed_class_space_size())); |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3002 } |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3003 } |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3004 } |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3005 |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3006 // If we got here then the metaspace got allocated. |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3007 MemTracker::record_virtual_memory_type((address)metaspace_rs.base(), mtClass); |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3008 |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3009 // Verify that we can use shared spaces. Otherwise, turn off CDS. |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3010 if (UseSharedSpaces && !can_use_cds_with_metaspace_addr(metaspace_rs.base(), cds_base)) { |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3011 FileMapInfo::stop_sharing_and_unmap( |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3012 "Could not allocate metaspace at a compatible address"); |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3013 } |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3014 |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3015 set_narrow_klass_base_and_shift((address)metaspace_rs.base(), |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3016 UseSharedSpaces ? (address)cds_base : 0); |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3017 |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3018 initialize_class_space(metaspace_rs); |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3019 |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3020 if (PrintCompressedOopsMode || (PrintMiscellaneous && Verbose)) { |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3021 gclog_or_tty->print_cr("Narrow klass base: " PTR_FORMAT ", Narrow klass shift: " SIZE_FORMAT, |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3022 Universe::narrow_klass_base(), Universe::narrow_klass_shift()); |
13000
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
12998
diff
changeset
|
3023 gclog_or_tty->print_cr("Compressed class space size: " SIZE_FORMAT " Address: " PTR_FORMAT " Req Addr: " PTR_FORMAT, |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
12998
diff
changeset
|
3024 compressed_class_space_size(), metaspace_rs.base(), requested_addr); |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3025 } |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3026 } |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3027 |
12226
7944aba7ba41
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
12110
diff
changeset
|
3028 // For UseCompressedClassPointers the class space is reserved above the top of |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3029 // the Java heap. The argument passed in is at the base of the compressed space. |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3030 void Metaspace::initialize_class_space(ReservedSpace rs) { |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3031 // The reserved space size may be bigger because of alignment, esp with UseLargePages |
12226
7944aba7ba41
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
12110
diff
changeset
|
3032 assert(rs.size() >= CompressedClassSpaceSize, |
7944aba7ba41
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
12110
diff
changeset
|
3033 err_msg(SIZE_FORMAT " != " UINTX_FORMAT, rs.size(), CompressedClassSpaceSize)); |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3034 assert(using_class_space(), "Must be using class space"); |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3035 _class_space_list = new VirtualSpaceList(rs); |
12303
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
3036 _chunk_manager_class = new ChunkManager(SpecializedChunk, ClassSmallChunk, ClassMediumChunk); |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3037 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3038 if (!_class_space_list->initialization_succeeded()) { |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3039 vm_exit_during_initialization("Failed to setup compressed class space virtual space list."); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3040 } |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3041 } |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3042 |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3043 #endif |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3044 |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3045 void Metaspace::ergo_initialize() { |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3046 if (DumpSharedSpaces) { |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3047 // Using large pages when dumping the shared archive is currently not implemented. |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3048 FLAG_SET_ERGO(bool, UseLargePagesInMetaspace, false); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3049 } |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3050 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3051 size_t page_size = os::vm_page_size(); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3052 if (UseLargePages && UseLargePagesInMetaspace) { |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3053 page_size = os::large_page_size(); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3054 } |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3055 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3056 _commit_alignment = page_size; |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3057 _reserve_alignment = MAX2(page_size, (size_t)os::vm_allocation_granularity()); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3058 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3059 // Do not use FLAG_SET_ERGO to update MaxMetaspaceSize, since this will |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3060 // override if MaxMetaspaceSize was set on the command line or not. |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3061 // This information is needed later to conform to the specification of the |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3062 // java.lang.management.MemoryUsage API. |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3063 // |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3064 // Ideally, we would be able to set the default value of MaxMetaspaceSize in |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3065 // globals.hpp to the aligned value, but this is not possible, since the |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3066 // alignment depends on other flags being parsed. |
13058
3aee6bc29547
8026852: Use restricted_align_down in collector policy code
jwilhelm
parents:
12980
diff
changeset
|
3067 MaxMetaspaceSize = align_size_down_bounded(MaxMetaspaceSize, _reserve_alignment); |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3068 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3069 if (MetaspaceSize > MaxMetaspaceSize) { |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3070 MetaspaceSize = MaxMetaspaceSize; |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3071 } |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3072 |
13058
3aee6bc29547
8026852: Use restricted_align_down in collector policy code
jwilhelm
parents:
12980
diff
changeset
|
3073 MetaspaceSize = align_size_down_bounded(MetaspaceSize, _commit_alignment); |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3074 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3075 assert(MetaspaceSize <= MaxMetaspaceSize, "MetaspaceSize should be limited by MaxMetaspaceSize"); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3076 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3077 if (MetaspaceSize < 256*K) { |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3078 vm_exit_during_initialization("Too small initial Metaspace size"); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3079 } |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3080 |
13058
3aee6bc29547
8026852: Use restricted_align_down in collector policy code
jwilhelm
parents:
12980
diff
changeset
|
3081 MinMetaspaceExpansion = align_size_down_bounded(MinMetaspaceExpansion, _commit_alignment); |
3aee6bc29547
8026852: Use restricted_align_down in collector policy code
jwilhelm
parents:
12980
diff
changeset
|
3082 MaxMetaspaceExpansion = align_size_down_bounded(MaxMetaspaceExpansion, _commit_alignment); |
3aee6bc29547
8026852: Use restricted_align_down in collector policy code
jwilhelm
parents:
12980
diff
changeset
|
3083 |
3aee6bc29547
8026852: Use restricted_align_down in collector policy code
jwilhelm
parents:
12980
diff
changeset
|
3084 CompressedClassSpaceSize = align_size_down_bounded(CompressedClassSpaceSize, _reserve_alignment); |
13000
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
12998
diff
changeset
|
3085 set_compressed_class_space_size(CompressedClassSpaceSize); |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3086 } |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3087 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3088 void Metaspace::global_initialize() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3089 // Initialize the alignment for shared spaces. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3090 int max_alignment = os::vm_page_size(); |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3091 size_t cds_total = 0; |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3092 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3093 MetaspaceShared::set_max_alignment(max_alignment); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3094 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3095 if (DumpSharedSpaces) { |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3096 SharedReadOnlySize = align_size_up(SharedReadOnlySize, max_alignment); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3097 SharedReadWriteSize = align_size_up(SharedReadWriteSize, max_alignment); |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3098 SharedMiscDataSize = align_size_up(SharedMiscDataSize, max_alignment); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3099 SharedMiscCodeSize = align_size_up(SharedMiscCodeSize, max_alignment); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3100 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3101 // Initialize with the sum of the shared space sizes. The read-only |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3102 // and read write metaspace chunks will be allocated out of this and the |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3103 // remainder is the misc code and data chunks. |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3104 cds_total = FileMapInfo::shared_spaces_size(); |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3105 cds_total = align_size_up(cds_total, _reserve_alignment); |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3106 _space_list = new VirtualSpaceList(cds_total/wordSize); |
12303
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
3107 _chunk_manager_metadata = new ChunkManager(SpecializedChunk, SmallChunk, MediumChunk); |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3108 |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3109 if (!_space_list->initialization_succeeded()) { |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3110 vm_exit_during_initialization("Unable to dump shared archive.", NULL); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3111 } |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3112 |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3113 #ifdef _LP64 |
13000
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
12998
diff
changeset
|
3114 if (cds_total + compressed_class_space_size() > UnscaledClassSpaceMax) { |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3115 vm_exit_during_initialization("Unable to dump shared archive.", |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3116 err_msg("Size of archive (" SIZE_FORMAT ") + compressed class space (" |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3117 SIZE_FORMAT ") == total (" SIZE_FORMAT ") is larger than compressed " |
13000
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
12998
diff
changeset
|
3118 "klass limit: " SIZE_FORMAT, cds_total, compressed_class_space_size(), |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
12998
diff
changeset
|
3119 cds_total + compressed_class_space_size(), UnscaledClassSpaceMax)); |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3120 } |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3121 |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3122 // Set the compressed klass pointer base so that decoding of these pointers works |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3123 // properly when creating the shared archive. |
12226
7944aba7ba41
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
12110
diff
changeset
|
3124 assert(UseCompressedOops && UseCompressedClassPointers, |
7944aba7ba41
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
12110
diff
changeset
|
3125 "UseCompressedOops and UseCompressedClassPointers must be set"); |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3126 Universe::set_narrow_klass_base((address)_space_list->current_virtual_space()->bottom()); |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3127 if (TraceMetavirtualspaceAllocation && Verbose) { |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3128 gclog_or_tty->print_cr("Setting_narrow_klass_base to Address: " PTR_FORMAT, |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3129 _space_list->current_virtual_space()->bottom()); |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3130 } |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3131 |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3132 Universe::set_narrow_klass_shift(0); |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3133 #endif |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3134 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3135 } else { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3136 // If using shared space, open the file that contains the shared space |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3137 // and map in the memory before initializing the rest of metaspace (so |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3138 // the addresses don't conflict) |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3139 address cds_address = NULL; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3140 if (UseSharedSpaces) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3141 FileMapInfo* mapinfo = new FileMapInfo(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3142 memset(mapinfo, 0, sizeof(FileMapInfo)); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3143 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3144 // Open the shared archive file, read and validate the header. If |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3145 // initialization fails, shared spaces [UseSharedSpaces] are |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3146 // disabled and the file is closed. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3147 // Map in spaces now also |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3148 if (mapinfo->initialize() && MetaspaceShared::map_shared_spaces(mapinfo)) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3149 FileMapInfo::set_current_info(mapinfo); |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3150 cds_total = FileMapInfo::shared_spaces_size(); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3151 cds_address = (address)mapinfo->region_base(0); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3152 } else { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3153 assert(!mapinfo->is_open() && !UseSharedSpaces, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3154 "archive file not closed or shared spaces not disabled."); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3155 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3156 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3157 |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3158 #ifdef _LP64 |
12226
7944aba7ba41
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
12110
diff
changeset
|
3159 // If UseCompressedClassPointers is set then allocate the metaspace area |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3160 // above the heap and above the CDS area (if it exists). |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3161 if (using_class_space()) { |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3162 if (UseSharedSpaces) { |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3163 char* cds_end = (char*)(cds_address + cds_total); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3164 cds_end = (char *)align_ptr_up(cds_end, _reserve_alignment); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3165 allocate_metaspace_compressed_klass_ptrs(cds_end, cds_address); |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3166 } else { |
13000
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
12998
diff
changeset
|
3167 char* base = (char*)align_ptr_up(Universe::heap()->reserved_region().end(), _reserve_alignment); |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
12998
diff
changeset
|
3168 allocate_metaspace_compressed_klass_ptrs(base, 0); |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3169 } |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3170 } |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3171 #endif |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3172 |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
3173 // Initialize these before initializing the VirtualSpaceList |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3174 _first_chunk_word_size = InitialBootClassLoaderMetaspaceSize / BytesPerWord; |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
3175 _first_chunk_word_size = align_word_size_up(_first_chunk_word_size); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
3176 // Make the first class chunk bigger than a medium chunk so it's not put |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
3177 // on the medium chunk list. The next chunk will be small and progress |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
3178 // from there. This size calculated by -version. |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
3179 _first_class_chunk_word_size = MIN2((size_t)MediumChunk*6, |
12226
7944aba7ba41
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
12110
diff
changeset
|
3180 (CompressedClassSpaceSize/BytesPerWord)*2); |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
3181 _first_class_chunk_word_size = align_word_size_up(_first_class_chunk_word_size); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3182 // Arbitrarily set the initial virtual space to a multiple |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3183 // of the boot class loader size. |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3184 size_t word_size = VIRTUALSPACEMULTIPLIER * _first_chunk_word_size; |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3185 word_size = align_size_up(word_size, Metaspace::reserve_alignment_words()); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3186 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3187 // Initialize the list of virtual spaces. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3188 _space_list = new VirtualSpaceList(word_size); |
12303
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
3189 _chunk_manager_metadata = new ChunkManager(SpecializedChunk, SmallChunk, MediumChunk); |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3190 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3191 if (!_space_list->initialization_succeeded()) { |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3192 vm_exit_during_initialization("Unable to setup metadata virtual space list.", NULL); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3193 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3194 } |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3195 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3196 MetaspaceGC::initialize(); |
17768
daef39043d2c
8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents:
17695
diff
changeset
|
3197 _tracer = new MetaspaceTracer(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3198 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3199 |
12303
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
3200 Metachunk* Metaspace::get_initialization_chunk(MetadataType mdtype, |
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
3201 size_t chunk_word_size, |
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
3202 size_t chunk_bunch) { |
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
3203 // Get a chunk from the chunk freelist |
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
3204 Metachunk* chunk = get_chunk_manager(mdtype)->chunk_freelist_allocate(chunk_word_size); |
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
3205 if (chunk != NULL) { |
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
3206 return chunk; |
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
3207 } |
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
3208 |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3209 return get_space_list(mdtype)->get_new_chunk(chunk_word_size, chunk_word_size, chunk_bunch); |
12303
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
3210 } |
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
3211 |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3212 void Metaspace::initialize(Mutex* lock, MetaspaceType type) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3213 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3214 assert(space_list() != NULL, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3215 "Metadata VirtualSpaceList has not been initialized"); |
12303
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
3216 assert(chunk_manager_metadata() != NULL, |
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
3217 "Metadata ChunkManager has not been initialized"); |
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
3218 |
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
3219 _vsm = new SpaceManager(NonClassType, lock); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3220 if (_vsm == NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3221 return; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3222 } |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
3223 size_t word_size; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
3224 size_t class_word_size; |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3225 vsm()->get_initial_chunk_sizes(type, &word_size, &class_word_size); |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3226 |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3227 if (using_class_space()) { |
12303
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
3228 assert(class_space_list() != NULL, |
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
3229 "Class VirtualSpaceList has not been initialized"); |
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
3230 assert(chunk_manager_class() != NULL, |
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
3231 "Class ChunkManager has not been initialized"); |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3232 |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3233 // Allocate SpaceManager for classes. |
12303
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
3234 _class_vsm = new SpaceManager(ClassType, lock); |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3235 if (_class_vsm == NULL) { |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3236 return; |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3237 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3238 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3239 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3240 MutexLockerEx cl(SpaceManager::expand_lock(), Mutex::_no_safepoint_check_flag); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3241 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3242 // Allocate chunk for metadata objects |
12303
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
3243 Metachunk* new_chunk = get_initialization_chunk(NonClassType, |
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
3244 word_size, |
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
3245 vsm()->medium_chunk_bunch()); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3246 assert(!DumpSharedSpaces || new_chunk != NULL, "should have enough space for both chunks"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3247 if (new_chunk != NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3248 // Add to this manager's list of chunks in use and current_chunk(). |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3249 vsm()->add_chunk(new_chunk, true); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3250 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3251 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3252 // Allocate chunk for class metadata objects |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3253 if (using_class_space()) { |
12303
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
3254 Metachunk* class_chunk = get_initialization_chunk(ClassType, |
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
3255 class_word_size, |
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
3256 class_vsm()->medium_chunk_bunch()); |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3257 if (class_chunk != NULL) { |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3258 class_vsm()->add_chunk(class_chunk, true); |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3259 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3260 } |
10376
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
3261 |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
3262 _alloc_record_head = NULL; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
3263 _alloc_record_tail = NULL; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3264 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3265 |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
3266 size_t Metaspace::align_word_size_up(size_t word_size) { |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
3267 size_t byte_size = word_size * wordSize; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
3268 return ReservedSpace::allocation_align_size_up(byte_size) / wordSize; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
3269 } |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
3270 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3271 MetaWord* Metaspace::allocate(size_t word_size, MetadataType mdtype) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3272 // DumpSharedSpaces doesn't use class metadata area (yet) |
12226
7944aba7ba41
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
12110
diff
changeset
|
3273 // Also, don't use class_vsm() unless UseCompressedClassPointers is true. |
12340
bc918fd1e584
8025279: metaspace/flags/maxMetaspaceSize throws OOM: out of Compressed Klass space
mgerdin
parents:
12306
diff
changeset
|
3274 if (is_class_space_allocation(mdtype)) { |
6885 | 3275 return class_vsm()->allocate(word_size); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3276 } else { |
6885 | 3277 return vsm()->allocate(word_size); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3278 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3279 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3280 |
6753
8da5e203b993
7197557: NPG: nsk/sysdict/vm/stress/chain/chain004 hangs intermittently
jmasa
parents:
6736
diff
changeset
|
3281 MetaWord* Metaspace::expand_and_allocate(size_t word_size, MetadataType mdtype) { |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3282 size_t delta_bytes = MetaspaceGC::delta_capacity_until_GC(word_size * BytesPerWord); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3283 assert(delta_bytes > 0, "Must be"); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3284 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3285 size_t after_inc = MetaspaceGC::inc_capacity_until_GC(delta_bytes); |
17768
daef39043d2c
8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents:
17695
diff
changeset
|
3286 |
daef39043d2c
8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents:
17695
diff
changeset
|
3287 // capacity_until_GC might be updated concurrently, must calculate previous value. |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3288 size_t before_inc = after_inc - delta_bytes; |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3289 |
17768
daef39043d2c
8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents:
17695
diff
changeset
|
3290 tracer()->report_gc_threshold(before_inc, after_inc, |
daef39043d2c
8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents:
17695
diff
changeset
|
3291 MetaspaceGCThresholdUpdater::ExpandAndAllocate); |
6753
8da5e203b993
7197557: NPG: nsk/sysdict/vm/stress/chain/chain004 hangs intermittently
jmasa
parents:
6736
diff
changeset
|
3292 if (PrintGCDetails && Verbose) { |
8da5e203b993
7197557: NPG: nsk/sysdict/vm/stress/chain/chain004 hangs intermittently
jmasa
parents:
6736
diff
changeset
|
3293 gclog_or_tty->print_cr("Increase capacity to GC from " SIZE_FORMAT |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3294 " to " SIZE_FORMAT, before_inc, after_inc); |
6753
8da5e203b993
7197557: NPG: nsk/sysdict/vm/stress/chain/chain004 hangs intermittently
jmasa
parents:
6736
diff
changeset
|
3295 } |
6885 | 3296 |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3297 return allocate(word_size, mdtype); |
6753
8da5e203b993
7197557: NPG: nsk/sysdict/vm/stress/chain/chain004 hangs intermittently
jmasa
parents:
6736
diff
changeset
|
3298 } |
8da5e203b993
7197557: NPG: nsk/sysdict/vm/stress/chain/chain004 hangs intermittently
jmasa
parents:
6736
diff
changeset
|
3299 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3300 // Space allocated in the Metaspace. This may |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3301 // be across several metadata virtual spaces. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3302 char* Metaspace::bottom() const { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3303 assert(DumpSharedSpaces, "only useful and valid for dumping shared spaces"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3304 return (char*)vsm()->current_chunk()->bottom(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3305 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3306 |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
3307 size_t Metaspace::used_words_slow(MetadataType mdtype) const { |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3308 if (mdtype == ClassType) { |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3309 return using_class_space() ? class_vsm()->sum_used_in_chunks_in_use() : 0; |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3310 } else { |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3311 return vsm()->sum_used_in_chunks_in_use(); // includes overhead! |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3312 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3313 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3314 |
12235 | 3315 size_t Metaspace::free_words_slow(MetadataType mdtype) const { |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3316 if (mdtype == ClassType) { |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3317 return using_class_space() ? class_vsm()->sum_free_in_chunks_in_use() : 0; |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3318 } else { |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3319 return vsm()->sum_free_in_chunks_in_use(); |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3320 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3321 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3322 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3323 // Space capacity in the Metaspace. It includes |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3324 // space in the list of chunks from which allocations |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3325 // have been made. Don't include space in the global freelist and |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3326 // in the space available in the dictionary which |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3327 // is already counted in some chunk. |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
3328 size_t Metaspace::capacity_words_slow(MetadataType mdtype) const { |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3329 if (mdtype == ClassType) { |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3330 return using_class_space() ? class_vsm()->sum_capacity_in_chunks_in_use() : 0; |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3331 } else { |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3332 return vsm()->sum_capacity_in_chunks_in_use(); |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3333 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3334 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3335 |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
3336 size_t Metaspace::used_bytes_slow(MetadataType mdtype) const { |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
3337 return used_words_slow(mdtype) * BytesPerWord; |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
3338 } |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
3339 |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
3340 size_t Metaspace::capacity_bytes_slow(MetadataType mdtype) const { |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
3341 return capacity_words_slow(mdtype) * BytesPerWord; |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
3342 } |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
3343 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3344 void Metaspace::deallocate(MetaWord* ptr, size_t word_size, bool is_class) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3345 if (SafepointSynchronize::is_at_safepoint()) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3346 assert(Thread::current()->is_VM_thread(), "should be the VM thread"); |
6885 | 3347 // Don't take Heap_lock |
10191
601183f604b2
8013129: Possible deadlock with Metaspace locks due to mixed usage of safepoint aware and non-safepoint aware locking
mgerdin
parents:
10183
diff
changeset
|
3348 MutexLockerEx ml(vsm()->lock(), Mutex::_no_safepoint_check_flag); |
17695
ab36007d6358
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
17663
diff
changeset
|
3349 if (word_size < TreeChunk<Metablock, FreeList<Metablock> >::min_size()) { |
6885 | 3350 // Dark matter. Too small for dictionary. |
3351 #ifdef ASSERT | |
3352 Copy::fill_to_words((HeapWord*)ptr, word_size, 0xf5f5f5f5); | |
3353 #endif | |
3354 return; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3355 } |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3356 if (is_class && using_class_space()) { |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3357 class_vsm()->deallocate(ptr, word_size); |
6885 | 3358 } else { |
3359 vsm()->deallocate(ptr, word_size); | |
3360 } | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3361 } else { |
10191
601183f604b2
8013129: Possible deadlock with Metaspace locks due to mixed usage of safepoint aware and non-safepoint aware locking
mgerdin
parents:
10183
diff
changeset
|
3362 MutexLockerEx ml(vsm()->lock(), Mutex::_no_safepoint_check_flag); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3363 |
17695
ab36007d6358
8034171: Remove use of template template parameters from binaryTreeDictionary.
goetz
parents:
17663
diff
changeset
|
3364 if (word_size < TreeChunk<Metablock, FreeList<Metablock> >::min_size()) { |
6885 | 3365 // Dark matter. Too small for dictionary. |
3366 #ifdef ASSERT | |
3367 Copy::fill_to_words((HeapWord*)ptr, word_size, 0xf5f5f5f5); | |
3368 #endif | |
3369 return; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3370 } |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3371 if (is_class && using_class_space()) { |
6885 | 3372 class_vsm()->deallocate(ptr, word_size); |
3373 } else { | |
3374 vsm()->deallocate(ptr, word_size); | |
3375 } | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3376 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3377 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3378 |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3379 |
12902 | 3380 MetaWord* Metaspace::allocate(ClassLoaderData* loader_data, size_t word_size, |
10376
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
3381 bool read_only, MetaspaceObj::Type type, TRAPS) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3382 if (HAS_PENDING_EXCEPTION) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3383 assert(false, "Should not allocate with exception pending"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3384 return NULL; // caller does a CHECK_NULL too |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3385 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3386 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3387 assert(loader_data != NULL, "Should never pass around a NULL loader_data. " |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3388 "ClassLoaderData::the_null_class_loader_data() should have been used."); |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3389 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3390 // Allocate in metaspaces without taking out a lock, because it deadlocks |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3391 // with the SymbolTable_lock. Dumping is single threaded for now. We'll have |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3392 // to revisit this for application class data sharing. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3393 if (DumpSharedSpaces) { |
10376
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
3394 assert(type > MetaspaceObj::UnknownType && type < MetaspaceObj::_number_of_types, "sanity"); |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
3395 Metaspace* space = read_only ? loader_data->ro_metaspace() : loader_data->rw_metaspace(); |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3396 MetaWord* result = space->allocate(word_size, NonClassType); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3397 if (result == NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3398 report_out_of_shared_space(read_only ? SharedReadOnly : SharedReadWrite); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3399 } |
12902 | 3400 |
3401 space->record_allocation(result, type, space->vsm()->get_raw_word_size(word_size)); | |
3402 | |
3403 // Zero initialize. | |
3404 Copy::fill_to_aligned_words((HeapWord*)result, word_size, 0); | |
3405 | |
3406 return result; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3407 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3408 |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3409 MetadataType mdtype = (type == MetaspaceObj::ClassType) ? ClassType : NonClassType; |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3410 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3411 // Try to allocate metadata. |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3412 MetaWord* result = loader_data->metaspace_non_null()->allocate(word_size, mdtype); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3413 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3414 if (result == NULL) { |
17769
bc7714614ad8
8036699: Add trace event when a metaspace allocation fails
ehelin
parents:
17768
diff
changeset
|
3415 tracer()->report_metaspace_allocation_failure(loader_data, word_size, type, mdtype); |
bc7714614ad8
8036699: Add trace event when a metaspace allocation fails
ehelin
parents:
17768
diff
changeset
|
3416 |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3417 // Allocation failed. |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3418 if (is_init_completed()) { |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3419 // Only start a GC if the bootstrapping has completed. |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3420 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3421 // Try to clean out some memory and retry. |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3422 result = Universe::heap()->collector_policy()->satisfy_failed_metadata_allocation( |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3423 loader_data, word_size, mdtype); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3424 } |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3425 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3426 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3427 if (result == NULL) { |
17770
5af31f70a866
8036701: Add trace event when a metaspace throws out of memory error
ehelin
parents:
17769
diff
changeset
|
3428 report_metadata_oome(loader_data, word_size, type, mdtype, CHECK_NULL); |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3429 } |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3430 |
12902 | 3431 // Zero initialize. |
3432 Copy::fill_to_aligned_words((HeapWord*)result, word_size, 0); | |
3433 | |
3434 return result; | |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3435 } |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3436 |
12998
a6177f601c64
8026822: metaspace/flags/maxMetaspaceSize throws OOM of unexpected type.java.lang.OutOfMemoryError: Compressed class space
hseigel
parents:
12906
diff
changeset
|
3437 size_t Metaspace::class_chunk_size(size_t word_size) { |
a6177f601c64
8026822: metaspace/flags/maxMetaspaceSize throws OOM of unexpected type.java.lang.OutOfMemoryError: Compressed class space
hseigel
parents:
12906
diff
changeset
|
3438 assert(using_class_space(), "Has to use class space"); |
a6177f601c64
8026822: metaspace/flags/maxMetaspaceSize throws OOM of unexpected type.java.lang.OutOfMemoryError: Compressed class space
hseigel
parents:
12906
diff
changeset
|
3439 return class_vsm()->calc_chunk_size(word_size); |
a6177f601c64
8026822: metaspace/flags/maxMetaspaceSize throws OOM of unexpected type.java.lang.OutOfMemoryError: Compressed class space
hseigel
parents:
12906
diff
changeset
|
3440 } |
a6177f601c64
8026822: metaspace/flags/maxMetaspaceSize throws OOM of unexpected type.java.lang.OutOfMemoryError: Compressed class space
hseigel
parents:
12906
diff
changeset
|
3441 |
17770
5af31f70a866
8036701: Add trace event when a metaspace throws out of memory error
ehelin
parents:
17769
diff
changeset
|
3442 void Metaspace::report_metadata_oome(ClassLoaderData* loader_data, size_t word_size, MetaspaceObj::Type type, MetadataType mdtype, TRAPS) { |
5af31f70a866
8036701: Add trace event when a metaspace throws out of memory error
ehelin
parents:
17769
diff
changeset
|
3443 tracer()->report_metadata_oom(loader_data, word_size, type, mdtype); |
5af31f70a866
8036701: Add trace event when a metaspace throws out of memory error
ehelin
parents:
17769
diff
changeset
|
3444 |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3445 // If result is still null, we are out of memory. |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3446 if (Verbose && TraceMetadataChunkAllocation) { |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3447 gclog_or_tty->print_cr("Metaspace allocation failed for size " |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3448 SIZE_FORMAT, word_size); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3449 if (loader_data->metaspace_or_null() != NULL) { |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3450 loader_data->dump(gclog_or_tty); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3451 } |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3452 MetaspaceAux::dump(gclog_or_tty); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3453 } |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3454 |
12998
a6177f601c64
8026822: metaspace/flags/maxMetaspaceSize throws OOM of unexpected type.java.lang.OutOfMemoryError: Compressed class space
hseigel
parents:
12906
diff
changeset
|
3455 bool out_of_compressed_class_space = false; |
a6177f601c64
8026822: metaspace/flags/maxMetaspaceSize throws OOM of unexpected type.java.lang.OutOfMemoryError: Compressed class space
hseigel
parents:
12906
diff
changeset
|
3456 if (is_class_space_allocation(mdtype)) { |
a6177f601c64
8026822: metaspace/flags/maxMetaspaceSize throws OOM of unexpected type.java.lang.OutOfMemoryError: Compressed class space
hseigel
parents:
12906
diff
changeset
|
3457 Metaspace* metaspace = loader_data->metaspace_non_null(); |
a6177f601c64
8026822: metaspace/flags/maxMetaspaceSize throws OOM of unexpected type.java.lang.OutOfMemoryError: Compressed class space
hseigel
parents:
12906
diff
changeset
|
3458 out_of_compressed_class_space = |
a6177f601c64
8026822: metaspace/flags/maxMetaspaceSize throws OOM of unexpected type.java.lang.OutOfMemoryError: Compressed class space
hseigel
parents:
12906
diff
changeset
|
3459 MetaspaceAux::committed_bytes(Metaspace::ClassType) + |
a6177f601c64
8026822: metaspace/flags/maxMetaspaceSize throws OOM of unexpected type.java.lang.OutOfMemoryError: Compressed class space
hseigel
parents:
12906
diff
changeset
|
3460 (metaspace->class_chunk_size(word_size) * BytesPerWord) > |
a6177f601c64
8026822: metaspace/flags/maxMetaspaceSize throws OOM of unexpected type.java.lang.OutOfMemoryError: Compressed class space
hseigel
parents:
12906
diff
changeset
|
3461 CompressedClassSpaceSize; |
a6177f601c64
8026822: metaspace/flags/maxMetaspaceSize throws OOM of unexpected type.java.lang.OutOfMemoryError: Compressed class space
hseigel
parents:
12906
diff
changeset
|
3462 } |
a6177f601c64
8026822: metaspace/flags/maxMetaspaceSize throws OOM of unexpected type.java.lang.OutOfMemoryError: Compressed class space
hseigel
parents:
12906
diff
changeset
|
3463 |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3464 // -XX:+HeapDumpOnOutOfMemoryError and -XX:OnOutOfMemoryError support |
12998
a6177f601c64
8026822: metaspace/flags/maxMetaspaceSize throws OOM of unexpected type.java.lang.OutOfMemoryError: Compressed class space
hseigel
parents:
12906
diff
changeset
|
3465 const char* space_string = out_of_compressed_class_space ? |
a6177f601c64
8026822: metaspace/flags/maxMetaspaceSize throws OOM of unexpected type.java.lang.OutOfMemoryError: Compressed class space
hseigel
parents:
12906
diff
changeset
|
3466 "Compressed class space" : "Metaspace"; |
a6177f601c64
8026822: metaspace/flags/maxMetaspaceSize throws OOM of unexpected type.java.lang.OutOfMemoryError: Compressed class space
hseigel
parents:
12906
diff
changeset
|
3467 |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3468 report_java_out_of_memory(space_string); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3469 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3470 if (JvmtiExport::should_post_resource_exhausted()) { |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3471 JvmtiExport::post_resource_exhausted( |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3472 JVMTI_RESOURCE_EXHAUSTED_OOM_ERROR, |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3473 space_string); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3474 } |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3475 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3476 if (!is_init_completed()) { |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3477 vm_exit_during_initialization("OutOfMemoryError", space_string); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3478 } |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3479 |
12998
a6177f601c64
8026822: metaspace/flags/maxMetaspaceSize throws OOM of unexpected type.java.lang.OutOfMemoryError: Compressed class space
hseigel
parents:
12906
diff
changeset
|
3480 if (out_of_compressed_class_space) { |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3481 THROW_OOP(Universe::out_of_memory_error_class_metaspace()); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3482 } else { |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3483 THROW_OOP(Universe::out_of_memory_error_metaspace()); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
3484 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3485 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3486 |
17769
bc7714614ad8
8036699: Add trace event when a metaspace allocation fails
ehelin
parents:
17768
diff
changeset
|
3487 const char* Metaspace::metadata_type_name(Metaspace::MetadataType mdtype) { |
bc7714614ad8
8036699: Add trace event when a metaspace allocation fails
ehelin
parents:
17768
diff
changeset
|
3488 switch (mdtype) { |
bc7714614ad8
8036699: Add trace event when a metaspace allocation fails
ehelin
parents:
17768
diff
changeset
|
3489 case Metaspace::ClassType: return "Class"; |
bc7714614ad8
8036699: Add trace event when a metaspace allocation fails
ehelin
parents:
17768
diff
changeset
|
3490 case Metaspace::NonClassType: return "Metadata"; |
bc7714614ad8
8036699: Add trace event when a metaspace allocation fails
ehelin
parents:
17768
diff
changeset
|
3491 default: |
bc7714614ad8
8036699: Add trace event when a metaspace allocation fails
ehelin
parents:
17768
diff
changeset
|
3492 assert(false, err_msg("Got bad mdtype: %d", (int) mdtype)); |
bc7714614ad8
8036699: Add trace event when a metaspace allocation fails
ehelin
parents:
17768
diff
changeset
|
3493 return NULL; |
bc7714614ad8
8036699: Add trace event when a metaspace allocation fails
ehelin
parents:
17768
diff
changeset
|
3494 } |
bc7714614ad8
8036699: Add trace event when a metaspace allocation fails
ehelin
parents:
17768
diff
changeset
|
3495 } |
bc7714614ad8
8036699: Add trace event when a metaspace allocation fails
ehelin
parents:
17768
diff
changeset
|
3496 |
10376
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
3497 void Metaspace::record_allocation(void* ptr, MetaspaceObj::Type type, size_t word_size) { |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
3498 assert(DumpSharedSpaces, "sanity"); |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
3499 |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
3500 AllocRecord *rec = new AllocRecord((address)ptr, type, (int)word_size * HeapWordSize); |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
3501 if (_alloc_record_head == NULL) { |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
3502 _alloc_record_head = _alloc_record_tail = rec; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
3503 } else { |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
3504 _alloc_record_tail->_next = rec; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
3505 _alloc_record_tail = rec; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
3506 } |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
3507 } |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
3508 |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
3509 void Metaspace::iterate(Metaspace::AllocRecordClosure *closure) { |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
3510 assert(DumpSharedSpaces, "unimplemented for !DumpSharedSpaces"); |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
3511 |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
3512 address last_addr = (address)bottom(); |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
3513 |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
3514 for (AllocRecord *rec = _alloc_record_head; rec; rec = rec->_next) { |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
3515 address ptr = rec->_ptr; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
3516 if (last_addr < ptr) { |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
3517 closure->doit(last_addr, MetaspaceObj::UnknownType, ptr - last_addr); |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
3518 } |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
3519 closure->doit(ptr, rec->_type, rec->_byte_size); |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
3520 last_addr = ptr + rec->_byte_size; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
3521 } |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
3522 |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
3523 address top = ((address)bottom()) + used_bytes_slow(Metaspace::NonClassType); |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
3524 if (last_addr < top) { |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
3525 closure->doit(last_addr, MetaspaceObj::UnknownType, top - last_addr); |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
3526 } |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
3527 } |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
3528 |
12303
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
3529 void Metaspace::purge(MetadataType mdtype) { |
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
3530 get_space_list(mdtype)->purge(get_chunk_manager(mdtype)); |
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
3531 } |
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
3532 |
10175 | 3533 void Metaspace::purge() { |
3534 MutexLockerEx cl(SpaceManager::expand_lock(), | |
3535 Mutex::_no_safepoint_check_flag); | |
12303
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
3536 purge(NonClassType); |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3537 if (using_class_space()) { |
12303
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12302
diff
changeset
|
3538 purge(ClassType); |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3539 } |
10175 | 3540 } |
3541 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3542 void Metaspace::print_on(outputStream* out) const { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3543 // Print both class virtual space counts and metaspace. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3544 if (Verbose) { |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3545 vsm()->print_on(out); |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3546 if (using_class_space()) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3547 class_vsm()->print_on(out); |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3548 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3549 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3550 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3551 |
17663
40353abd7984
8029178: Parallel class loading test anonymous-simple gets SIGSEGV in Metaspace::contains
coleenp
parents:
13439
diff
changeset
|
3552 bool Metaspace::contains(const void* ptr) { |
40353abd7984
8029178: Parallel class loading test anonymous-simple gets SIGSEGV in Metaspace::contains
coleenp
parents:
13439
diff
changeset
|
3553 if (vsm()->contains(ptr)) return true; |
40353abd7984
8029178: Parallel class loading test anonymous-simple gets SIGSEGV in Metaspace::contains
coleenp
parents:
13439
diff
changeset
|
3554 if (using_class_space()) { |
40353abd7984
8029178: Parallel class loading test anonymous-simple gets SIGSEGV in Metaspace::contains
coleenp
parents:
13439
diff
changeset
|
3555 return class_vsm()->contains(ptr); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3556 } |
17663
40353abd7984
8029178: Parallel class loading test anonymous-simple gets SIGSEGV in Metaspace::contains
coleenp
parents:
13439
diff
changeset
|
3557 return false; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3558 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3559 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3560 void Metaspace::verify() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3561 vsm()->verify(); |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3562 if (using_class_space()) { |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3563 class_vsm()->verify(); |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3564 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3565 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3566 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3567 void Metaspace::dump(outputStream* const out) const { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3568 out->print_cr("\nVirtual space manager: " INTPTR_FORMAT, vsm()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3569 vsm()->dump(out); |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3570 if (using_class_space()) { |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3571 out->print_cr("\nClass space manager: " INTPTR_FORMAT, class_vsm()); |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3572 class_vsm()->dump(out); |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11966
diff
changeset
|
3573 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3574 } |
12236
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
3575 |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
3576 /////////////// Unit tests /////////////// |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
3577 |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
3578 #ifndef PRODUCT |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
3579 |
12306
03f493ce3a71
8025228: assert(new_entry->reserved_words() == vs_word_size) fails in nightly
brutisso
parents:
12303
diff
changeset
|
3580 class TestMetaspaceAuxTest : AllStatic { |
12236
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
3581 public: |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
3582 static void test_reserved() { |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
3583 size_t reserved = MetaspaceAux::reserved_bytes(); |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
3584 |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
3585 assert(reserved > 0, "assert"); |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
3586 |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
3587 size_t committed = MetaspaceAux::committed_bytes(); |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
3588 assert(committed <= reserved, "assert"); |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
3589 |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
3590 size_t reserved_metadata = MetaspaceAux::reserved_bytes(Metaspace::NonClassType); |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
3591 assert(reserved_metadata > 0, "assert"); |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
3592 assert(reserved_metadata <= reserved, "assert"); |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
3593 |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
3594 if (UseCompressedClassPointers) { |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
3595 size_t reserved_class = MetaspaceAux::reserved_bytes(Metaspace::ClassType); |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
3596 assert(reserved_class > 0, "assert"); |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
3597 assert(reserved_class < reserved, "assert"); |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
3598 } |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
3599 } |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
3600 |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
3601 static void test_committed() { |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
3602 size_t committed = MetaspaceAux::committed_bytes(); |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
3603 |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
3604 assert(committed > 0, "assert"); |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
3605 |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
3606 size_t reserved = MetaspaceAux::reserved_bytes(); |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
3607 assert(committed <= reserved, "assert"); |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
3608 |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
3609 size_t committed_metadata = MetaspaceAux::committed_bytes(Metaspace::NonClassType); |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
3610 assert(committed_metadata > 0, "assert"); |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
3611 assert(committed_metadata <= committed, "assert"); |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
3612 |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
3613 if (UseCompressedClassPointers) { |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
3614 size_t committed_class = MetaspaceAux::committed_bytes(Metaspace::ClassType); |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
3615 assert(committed_class > 0, "assert"); |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
3616 assert(committed_class < committed, "assert"); |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
3617 } |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
3618 } |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
3619 |
12306
03f493ce3a71
8025228: assert(new_entry->reserved_words() == vs_word_size) fails in nightly
brutisso
parents:
12303
diff
changeset
|
3620 static void test_virtual_space_list_large_chunk() { |
03f493ce3a71
8025228: assert(new_entry->reserved_words() == vs_word_size) fails in nightly
brutisso
parents:
12303
diff
changeset
|
3621 VirtualSpaceList* vs_list = new VirtualSpaceList(os::vm_allocation_granularity()); |
03f493ce3a71
8025228: assert(new_entry->reserved_words() == vs_word_size) fails in nightly
brutisso
parents:
12303
diff
changeset
|
3622 MutexLockerEx cl(SpaceManager::expand_lock(), Mutex::_no_safepoint_check_flag); |
03f493ce3a71
8025228: assert(new_entry->reserved_words() == vs_word_size) fails in nightly
brutisso
parents:
12303
diff
changeset
|
3623 // A size larger than VirtualSpaceSize (256k) and add one page to make it _not_ be |
03f493ce3a71
8025228: assert(new_entry->reserved_words() == vs_word_size) fails in nightly
brutisso
parents:
12303
diff
changeset
|
3624 // vm_allocation_granularity aligned on Windows. |
03f493ce3a71
8025228: assert(new_entry->reserved_words() == vs_word_size) fails in nightly
brutisso
parents:
12303
diff
changeset
|
3625 size_t large_size = (size_t)(2*256*K + (os::vm_page_size()/BytesPerWord)); |
03f493ce3a71
8025228: assert(new_entry->reserved_words() == vs_word_size) fails in nightly
brutisso
parents:
12303
diff
changeset
|
3626 large_size += (os::vm_page_size()/BytesPerWord); |
03f493ce3a71
8025228: assert(new_entry->reserved_words() == vs_word_size) fails in nightly
brutisso
parents:
12303
diff
changeset
|
3627 vs_list->get_new_chunk(large_size, large_size, 0); |
03f493ce3a71
8025228: assert(new_entry->reserved_words() == vs_word_size) fails in nightly
brutisso
parents:
12303
diff
changeset
|
3628 } |
03f493ce3a71
8025228: assert(new_entry->reserved_words() == vs_word_size) fails in nightly
brutisso
parents:
12303
diff
changeset
|
3629 |
12236
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
3630 static void test() { |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
3631 test_reserved(); |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
3632 test_committed(); |
12306
03f493ce3a71
8025228: assert(new_entry->reserved_words() == vs_word_size) fails in nightly
brutisso
parents:
12303
diff
changeset
|
3633 test_virtual_space_list_large_chunk(); |
12236
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
3634 } |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
3635 }; |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
3636 |
12306
03f493ce3a71
8025228: assert(new_entry->reserved_words() == vs_word_size) fails in nightly
brutisso
parents:
12303
diff
changeset
|
3637 void TestMetaspaceAux_test() { |
03f493ce3a71
8025228: assert(new_entry->reserved_words() == vs_word_size) fails in nightly
brutisso
parents:
12303
diff
changeset
|
3638 TestMetaspaceAuxTest::test(); |
12236
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
3639 } |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
3640 |
12979
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3641 class TestVirtualSpaceNodeTest { |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3642 static void chunk_up(size_t words_left, size_t& num_medium_chunks, |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3643 size_t& num_small_chunks, |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3644 size_t& num_specialized_chunks) { |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3645 num_medium_chunks = words_left / MediumChunk; |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3646 words_left = words_left % MediumChunk; |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3647 |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3648 num_small_chunks = words_left / SmallChunk; |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3649 words_left = words_left % SmallChunk; |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3650 // how many specialized chunks can we get? |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3651 num_specialized_chunks = words_left / SpecializedChunk; |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3652 assert(words_left % SpecializedChunk == 0, "should be nothing left"); |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3653 } |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3654 |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3655 public: |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3656 static void test() { |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3657 MutexLockerEx ml(SpaceManager::expand_lock(), Mutex::_no_safepoint_check_flag); |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3658 const size_t vsn_test_size_words = MediumChunk * 4; |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3659 const size_t vsn_test_size_bytes = vsn_test_size_words * BytesPerWord; |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3660 |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3661 // The chunk sizes must be multiples of eachother, or this will fail |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3662 STATIC_ASSERT(MediumChunk % SmallChunk == 0); |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3663 STATIC_ASSERT(SmallChunk % SpecializedChunk == 0); |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3664 |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3665 { // No committed memory in VSN |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3666 ChunkManager cm(SpecializedChunk, SmallChunk, MediumChunk); |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3667 VirtualSpaceNode vsn(vsn_test_size_bytes); |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3668 vsn.initialize(); |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3669 vsn.retire(&cm); |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3670 assert(cm.sum_free_chunks_count() == 0, "did not commit any memory in the VSN"); |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3671 } |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3672 |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3673 { // All of VSN is committed, half is used by chunks |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3674 ChunkManager cm(SpecializedChunk, SmallChunk, MediumChunk); |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3675 VirtualSpaceNode vsn(vsn_test_size_bytes); |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3676 vsn.initialize(); |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3677 vsn.expand_by(vsn_test_size_words, vsn_test_size_words); |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3678 vsn.get_chunk_vs(MediumChunk); |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3679 vsn.get_chunk_vs(MediumChunk); |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3680 vsn.retire(&cm); |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3681 assert(cm.sum_free_chunks_count() == 2, "should have been memory left for 2 medium chunks"); |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3682 assert(cm.sum_free_chunks() == 2*MediumChunk, "sizes should add up"); |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3683 } |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3684 |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3685 { // 4 pages of VSN is committed, some is used by chunks |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3686 ChunkManager cm(SpecializedChunk, SmallChunk, MediumChunk); |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3687 VirtualSpaceNode vsn(vsn_test_size_bytes); |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3688 const size_t page_chunks = 4 * (size_t)os::vm_page_size() / BytesPerWord; |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3689 assert(page_chunks < MediumChunk, "Test expects medium chunks to be at least 4*page_size"); |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3690 vsn.initialize(); |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3691 vsn.expand_by(page_chunks, page_chunks); |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3692 vsn.get_chunk_vs(SmallChunk); |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3693 vsn.get_chunk_vs(SpecializedChunk); |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3694 vsn.retire(&cm); |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3695 |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3696 // committed - used = words left to retire |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3697 const size_t words_left = page_chunks - SmallChunk - SpecializedChunk; |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3698 |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3699 size_t num_medium_chunks, num_small_chunks, num_spec_chunks; |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3700 chunk_up(words_left, num_medium_chunks, num_small_chunks, num_spec_chunks); |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3701 |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3702 assert(num_medium_chunks == 0, "should not get any medium chunks"); |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3703 assert(cm.sum_free_chunks_count() == (num_small_chunks + num_spec_chunks), "should be space for 3 chunks"); |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3704 assert(cm.sum_free_chunks() == words_left, "sizes should add up"); |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3705 } |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3706 |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3707 { // Half of VSN is committed, a humongous chunk is used |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3708 ChunkManager cm(SpecializedChunk, SmallChunk, MediumChunk); |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3709 VirtualSpaceNode vsn(vsn_test_size_bytes); |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3710 vsn.initialize(); |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3711 vsn.expand_by(MediumChunk * 2, MediumChunk * 2); |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3712 vsn.get_chunk_vs(MediumChunk + SpecializedChunk); // Humongous chunks will be aligned up to MediumChunk + SpecializedChunk |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3713 vsn.retire(&cm); |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3714 |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3715 const size_t words_left = MediumChunk * 2 - (MediumChunk + SpecializedChunk); |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3716 size_t num_medium_chunks, num_small_chunks, num_spec_chunks; |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3717 chunk_up(words_left, num_medium_chunks, num_small_chunks, num_spec_chunks); |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3718 |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3719 assert(num_medium_chunks == 0, "should not get any medium chunks"); |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3720 assert(cm.sum_free_chunks_count() == (num_small_chunks + num_spec_chunks), "should be space for 3 chunks"); |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3721 assert(cm.sum_free_chunks() == words_left, "sizes should add up"); |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3722 } |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3723 |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3724 } |
13439
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3725 |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3726 #define assert_is_available_positive(word_size) \ |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3727 assert(vsn.is_available(word_size), \ |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3728 err_msg(#word_size ": " PTR_FORMAT " bytes were not available in " \ |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3729 "VirtualSpaceNode [" PTR_FORMAT ", " PTR_FORMAT ")", \ |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3730 (uintptr_t)(word_size * BytesPerWord), vsn.bottom(), vsn.end())); |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3731 |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3732 #define assert_is_available_negative(word_size) \ |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3733 assert(!vsn.is_available(word_size), \ |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3734 err_msg(#word_size ": " PTR_FORMAT " bytes should not be available in " \ |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3735 "VirtualSpaceNode [" PTR_FORMAT ", " PTR_FORMAT ")", \ |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3736 (uintptr_t)(word_size * BytesPerWord), vsn.bottom(), vsn.end())); |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3737 |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3738 static void test_is_available_positive() { |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3739 // Reserve some memory. |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3740 VirtualSpaceNode vsn(os::vm_allocation_granularity()); |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3741 assert(vsn.initialize(), "Failed to setup VirtualSpaceNode"); |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3742 |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3743 // Commit some memory. |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3744 size_t commit_word_size = os::vm_allocation_granularity() / BytesPerWord; |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3745 bool expanded = vsn.expand_by(commit_word_size, commit_word_size); |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3746 assert(expanded, "Failed to commit"); |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3747 |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3748 // Check that is_available accepts the committed size. |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3749 assert_is_available_positive(commit_word_size); |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3750 |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3751 // Check that is_available accepts half the committed size. |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3752 size_t expand_word_size = commit_word_size / 2; |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3753 assert_is_available_positive(expand_word_size); |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3754 } |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3755 |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3756 static void test_is_available_negative() { |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3757 // Reserve some memory. |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3758 VirtualSpaceNode vsn(os::vm_allocation_granularity()); |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3759 assert(vsn.initialize(), "Failed to setup VirtualSpaceNode"); |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3760 |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3761 // Commit some memory. |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3762 size_t commit_word_size = os::vm_allocation_granularity() / BytesPerWord; |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3763 bool expanded = vsn.expand_by(commit_word_size, commit_word_size); |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3764 assert(expanded, "Failed to commit"); |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3765 |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3766 // Check that is_available doesn't accept a too large size. |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3767 size_t two_times_commit_word_size = commit_word_size * 2; |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3768 assert_is_available_negative(two_times_commit_word_size); |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3769 } |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3770 |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3771 static void test_is_available_overflow() { |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3772 // Reserve some memory. |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3773 VirtualSpaceNode vsn(os::vm_allocation_granularity()); |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3774 assert(vsn.initialize(), "Failed to setup VirtualSpaceNode"); |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3775 |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3776 // Commit some memory. |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3777 size_t commit_word_size = os::vm_allocation_granularity() / BytesPerWord; |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3778 bool expanded = vsn.expand_by(commit_word_size, commit_word_size); |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3779 assert(expanded, "Failed to commit"); |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3780 |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3781 // Calculate a size that will overflow the virtual space size. |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3782 void* virtual_space_max = (void*)(uintptr_t)-1; |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3783 size_t bottom_to_max = pointer_delta(virtual_space_max, vsn.bottom(), 1); |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3784 size_t overflow_size = bottom_to_max + BytesPerWord; |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3785 size_t overflow_word_size = overflow_size / BytesPerWord; |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3786 |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3787 // Check that is_available can handle the overflow. |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3788 assert_is_available_negative(overflow_word_size); |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3789 } |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3790 |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3791 static void test_is_available() { |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3792 TestVirtualSpaceNodeTest::test_is_available_positive(); |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3793 TestVirtualSpaceNodeTest::test_is_available_negative(); |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3794 TestVirtualSpaceNodeTest::test_is_available_overflow(); |
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3795 } |
12979
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3796 }; |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3797 |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3798 void TestVirtualSpaceNode_test() { |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3799 TestVirtualSpaceNodeTest::test(); |
13439
fa76dce60db7
8029106: JVM crashes in Metachunk::Metachunk during parallel class redefinition (PrivateMLetController, anonymous-simple_copy_1)
stefank
parents:
13068
diff
changeset
|
3800 TestVirtualSpaceNodeTest::test_is_available(); |
12979
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3801 } |
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12906
diff
changeset
|
3802 |
12236
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
3803 #endif |