author | neliasso |
Fri, 29 Nov 2019 11:26:25 +0100 | |
changeset 59324 | 5e8f9713e343 |
parent 54834 | 39ba09047e19 |
permissions | -rw-r--r-- |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
1 |
/* |
54094 | 2 |
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
4 |
* |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
8 |
* |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
13 |
* accompanied this code). |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
14 |
* |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
18 |
* |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
21 |
* questions. |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
22 |
*/ |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
23 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
24 |
#include "precompiled.hpp" |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
25 |
#include "gc/z/zPhysicalMemory.inline.hpp" |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
26 |
#include "logging/log.hpp" |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
27 |
#include "memory/allocation.inline.hpp" |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
28 |
#include "services/memTracker.hpp" |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
29 |
#include "utilities/debug.hpp" |
50979
270b11dadbaf
8205924: ZGC: Premature OOME due to failure to expand backing file
pliden
parents:
50525
diff
changeset
|
30 |
#include "utilities/globalDefinitions.hpp" |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
31 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
32 |
ZPhysicalMemory::ZPhysicalMemory() : |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
33 |
_nsegments(0), |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
34 |
_segments(NULL) {} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
35 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
36 |
ZPhysicalMemory::ZPhysicalMemory(const ZPhysicalMemorySegment& segment) : |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
37 |
_nsegments(0), |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
38 |
_segments(NULL) { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
39 |
add_segment(segment); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
40 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
41 |
|
54834
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
42 |
ZPhysicalMemory::ZPhysicalMemory(const ZPhysicalMemory& pmem) : |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
43 |
_nsegments(0), |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
44 |
_segments(NULL) { |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
45 |
|
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
46 |
// Copy segments |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
47 |
for (size_t i = 0; i < pmem.nsegments(); i++) { |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
48 |
add_segment(pmem.segment(i)); |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
49 |
} |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
50 |
} |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
51 |
|
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
52 |
const ZPhysicalMemory& ZPhysicalMemory::operator=(const ZPhysicalMemory& pmem) { |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
53 |
// Free segments |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
54 |
delete [] _segments; |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
55 |
_segments = NULL; |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
56 |
_nsegments = 0; |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
57 |
|
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
58 |
// Copy segments |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
59 |
for (size_t i = 0; i < pmem.nsegments(); i++) { |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
60 |
add_segment(pmem.segment(i)); |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
61 |
} |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
62 |
|
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
63 |
return *this; |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
64 |
} |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
65 |
|
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
66 |
ZPhysicalMemory::~ZPhysicalMemory() { |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
67 |
delete [] _segments; |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
68 |
_segments = NULL; |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
69 |
_nsegments = 0; |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
70 |
} |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
71 |
|
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
72 |
size_t ZPhysicalMemory::size() const { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
73 |
size_t size = 0; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
74 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
75 |
for (size_t i = 0; i < _nsegments; i++) { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
76 |
size += _segments[i].size(); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
77 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
78 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
79 |
return size; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
80 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
81 |
|
54834
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
82 |
void ZPhysicalMemory::add_segment(const ZPhysicalMemorySegment& segment) { |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
83 |
// Try merge with last segment |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
84 |
if (_nsegments > 0) { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
85 |
ZPhysicalMemorySegment& last = _segments[_nsegments - 1]; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
86 |
assert(last.end() <= segment.start(), "Segments added out of order"); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
87 |
if (last.end() == segment.start()) { |
54834
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
88 |
last = ZPhysicalMemorySegment(last.start(), last.size() + segment.size()); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
89 |
return; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
90 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
91 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
92 |
|
54834
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
93 |
// Resize array |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
94 |
ZPhysicalMemorySegment* const old_segments = _segments; |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
95 |
_segments = new ZPhysicalMemorySegment[_nsegments + 1]; |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
96 |
for (size_t i = 0; i < _nsegments; i++) { |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
97 |
_segments[i] = old_segments[i]; |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
98 |
} |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
99 |
delete [] old_segments; |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
100 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
101 |
// Add new segment |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
102 |
_segments[_nsegments] = segment; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
103 |
_nsegments++; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
104 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
105 |
|
54834
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
106 |
ZPhysicalMemory ZPhysicalMemory::split(size_t size) { |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
107 |
ZPhysicalMemory pmem; |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
108 |
size_t nsegments = 0; |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
109 |
|
54834
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
110 |
for (size_t i = 0; i < _nsegments; i++) { |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
111 |
const ZPhysicalMemorySegment& segment = _segments[i]; |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
112 |
if (pmem.size() < size) { |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
113 |
if (pmem.size() + segment.size() <= size) { |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
114 |
// Transfer segment |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
115 |
pmem.add_segment(segment); |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
116 |
} else { |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
117 |
// Split segment |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
118 |
const size_t split_size = size - pmem.size(); |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
119 |
pmem.add_segment(ZPhysicalMemorySegment(segment.start(), split_size)); |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
120 |
_segments[nsegments++] = ZPhysicalMemorySegment(segment.start() + split_size, segment.size() - split_size); |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
121 |
} |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
122 |
} else { |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
123 |
// Keep segment |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
124 |
_segments[nsegments++] = segment; |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
125 |
} |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
126 |
} |
54834
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
127 |
|
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
128 |
_nsegments = nsegments; |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
129 |
|
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
130 |
return pmem; |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
131 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
132 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
133 |
bool ZPhysicalMemoryManager::is_initialized() const { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
134 |
return _backing.is_initialized(); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
135 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
136 |
|
54834
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
137 |
void ZPhysicalMemoryManager::warn_commit_limits(size_t max) const { |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
138 |
_backing.warn_commit_limits(max); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
139 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
140 |
|
54834
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
141 |
bool ZPhysicalMemoryManager::supports_uncommit() { |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
142 |
return _backing.supports_uncommit(); |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
143 |
} |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
144 |
|
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
145 |
void ZPhysicalMemoryManager::nmt_commit(const ZPhysicalMemory& pmem, uintptr_t offset) const { |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
146 |
const uintptr_t addr = _backing.nmt_address(offset); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
147 |
const size_t size = pmem.size(); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
148 |
MemTracker::record_virtual_memory_commit((void*)addr, size, CALLER_PC); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
149 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
150 |
|
54834
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
151 |
void ZPhysicalMemoryManager::nmt_uncommit(const ZPhysicalMemory& pmem, uintptr_t offset) const { |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
152 |
if (MemTracker::tracking_level() > NMT_minimal) { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
153 |
const uintptr_t addr = _backing.nmt_address(offset); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
154 |
const size_t size = pmem.size(); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
155 |
Tracker tracker(Tracker::uncommit); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
156 |
tracker.record((address)addr, size); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
157 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
158 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
159 |
|
54834
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
160 |
size_t ZPhysicalMemoryManager::commit(size_t size) { |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
161 |
return _backing.commit(size); |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
162 |
} |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
163 |
|
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
164 |
size_t ZPhysicalMemoryManager::uncommit(size_t size) { |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
165 |
return _backing.uncommit(size); |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
166 |
} |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
167 |
|
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
168 |
ZPhysicalMemory ZPhysicalMemoryManager::alloc(size_t size) { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
169 |
return _backing.alloc(size); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
170 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
171 |
|
54834
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
172 |
void ZPhysicalMemoryManager::free(const ZPhysicalMemory& pmem) { |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
173 |
_backing.free(pmem); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
174 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
175 |
|
54834
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
176 |
void ZPhysicalMemoryManager::map(const ZPhysicalMemory& pmem, uintptr_t offset) const { |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
177 |
_backing.map(pmem, offset); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
178 |
nmt_commit(pmem, offset); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
179 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
180 |
|
54834
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
181 |
void ZPhysicalMemoryManager::unmap(const ZPhysicalMemory& pmem, uintptr_t offset) const { |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
182 |
nmt_uncommit(pmem, offset); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
183 |
_backing.unmap(pmem, offset); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
184 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
185 |
|
54834
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
186 |
void ZPhysicalMemoryManager::debug_map(const ZPhysicalMemory& pmem, uintptr_t offset) const { |
54159
7c23a4432610
8220569: ZGC: Rename and rework ZUnmapBadViews to ZVerifyViews
pliden
parents:
54094
diff
changeset
|
187 |
_backing.debug_map(pmem, offset); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
188 |
} |
54159
7c23a4432610
8220569: ZGC: Rename and rework ZUnmapBadViews to ZVerifyViews
pliden
parents:
54094
diff
changeset
|
189 |
|
54834
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54159
diff
changeset
|
190 |
void ZPhysicalMemoryManager::debug_unmap(const ZPhysicalMemory& pmem, uintptr_t offset) const { |
54159
7c23a4432610
8220569: ZGC: Rename and rework ZUnmapBadViews to ZVerifyViews
pliden
parents:
54094
diff
changeset
|
191 |
_backing.debug_unmap(pmem, offset); |
7c23a4432610
8220569: ZGC: Rename and rework ZUnmapBadViews to ZVerifyViews
pliden
parents:
54094
diff
changeset
|
192 |
} |