author | mgronlun |
Wed, 30 Oct 2019 19:43:52 +0100 | |
changeset 58863 | c16ac7a2eba4 |
parent 58815 | a4cdca87152b |
permissions | -rw-r--r-- |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
1 |
/* |
54159
7c23a4432610
8220569: ZGC: Rename and rework ZUnmapBadViews to ZVerifyViews
pliden
parents:
50979
diff
changeset
|
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 |
#ifndef SHARE_GC_Z_ZPAGEALLOCATOR_HPP |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
25 |
#define SHARE_GC_Z_ZPAGEALLOCATOR_HPP |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
26 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
27 |
#include "gc/z/zAllocationFlags.hpp" |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
28 |
#include "gc/z/zList.hpp" |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
29 |
#include "gc/z/zLock.hpp" |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
30 |
#include "gc/z/zPageCache.hpp" |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
31 |
#include "gc/z/zPhysicalMemory.hpp" |
54174 | 32 |
#include "gc/z/zSafeDelete.hpp" |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
33 |
#include "gc/z/zVirtualMemory.hpp" |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
34 |
#include "memory/allocation.hpp" |
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 |
class ZPageAllocRequest; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
37 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
38 |
class ZPageAllocator { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
39 |
friend class VMStructs; |
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 |
private: |
54174 | 42 |
ZLock _lock; |
43 |
ZVirtualMemoryManager _virtual; |
|
44 |
ZPhysicalMemoryManager _physical; |
|
45 |
ZPageCache _cache; |
|
54834
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54618
diff
changeset
|
46 |
const size_t _min_capacity; |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54618
diff
changeset
|
47 |
const size_t _max_capacity; |
54174 | 48 |
const size_t _max_reserve; |
54834
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54618
diff
changeset
|
49 |
size_t _current_max_capacity; |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54618
diff
changeset
|
50 |
size_t _capacity; |
54174 | 51 |
size_t _used_high; |
52 |
size_t _used_low; |
|
53 |
size_t _used; |
|
54 |
size_t _allocated; |
|
55 |
ssize_t _reclaimed; |
|
56 |
ZList<ZPageAllocRequest> _queue; |
|
58815
a4cdca87152b
8232604: ZGC: Make ZVerifyViews mapping and unmapping precise
stefank
parents:
55284
diff
changeset
|
57 |
ZList<ZPageAllocRequest> _satisfied; |
54174 | 58 |
mutable ZSafeDelete<ZPage> _safe_delete; |
54834
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54618
diff
changeset
|
59 |
bool _uncommit; |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54618
diff
changeset
|
60 |
bool _initialized; |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
61 |
|
58815
a4cdca87152b
8232604: ZGC: Make ZVerifyViews mapping and unmapping precise
stefank
parents:
55284
diff
changeset
|
62 |
static ZPage* const gc_marker; |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
63 |
|
54834
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54618
diff
changeset
|
64 |
void prime_cache(size_t size); |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54618
diff
changeset
|
65 |
|
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
66 |
void increase_used(size_t size, bool relocation); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
67 |
void decrease_used(size_t size, bool reclaimed); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
68 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
69 |
ZPage* create_page(uint8_t type, size_t size); |
54174 | 70 |
void destroy_page(ZPage* page); |
71 |
||
54834
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54618
diff
changeset
|
72 |
size_t max_available(bool no_reserve) const; |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54618
diff
changeset
|
73 |
bool ensure_available(size_t size, bool no_reserve); |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54618
diff
changeset
|
74 |
void ensure_uncached_available(size_t size); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
75 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
76 |
void check_out_of_memory_during_initialization(); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
77 |
|
54834
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54618
diff
changeset
|
78 |
ZPage* alloc_page_common_inner(uint8_t type, size_t size, bool no_reserve); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
79 |
ZPage* alloc_page_common(uint8_t type, size_t size, ZAllocationFlags flags); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
80 |
ZPage* alloc_page_blocking(uint8_t type, size_t size, ZAllocationFlags flags); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
81 |
ZPage* alloc_page_nonblocking(uint8_t type, size_t size, ZAllocationFlags flags); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
82 |
|
54834
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54618
diff
changeset
|
83 |
size_t flush_cache(ZPageCacheFlushClosure* cl); |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54618
diff
changeset
|
84 |
void flush_cache_for_allocation(size_t requested); |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54618
diff
changeset
|
85 |
|
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
86 |
void satisfy_alloc_queue(); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
87 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
88 |
public: |
54834
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54618
diff
changeset
|
89 |
ZPageAllocator(size_t min_capacity, |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54618
diff
changeset
|
90 |
size_t initial_capacity, |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54618
diff
changeset
|
91 |
size_t max_capacity, |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54618
diff
changeset
|
92 |
size_t max_reserve); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
93 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
94 |
bool is_initialized() const; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
95 |
|
54834
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54618
diff
changeset
|
96 |
size_t min_capacity() const; |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
97 |
size_t max_capacity() const; |
55284
38006f020b94
8222182: ZGC: Use SoftMaxHeapSize to guide GC heuristics
pliden
parents:
54834
diff
changeset
|
98 |
size_t soft_max_capacity() const; |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
99 |
size_t capacity() const; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
100 |
size_t max_reserve() const; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
101 |
size_t used_high() const; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
102 |
size_t used_low() const; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
103 |
size_t used() const; |
54616 | 104 |
size_t unused() const; |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
105 |
size_t allocated() const; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
106 |
size_t reclaimed() const; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
107 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
108 |
void reset_statistics(); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
109 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
110 |
ZPage* alloc_page(uint8_t type, size_t size, ZAllocationFlags flags); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
111 |
void free_page(ZPage* page, bool reclaimed); |
54174 | 112 |
|
54834
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54618
diff
changeset
|
113 |
uint64_t uncommit(uint64_t delay); |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54618
diff
changeset
|
114 |
|
54174 | 115 |
void enable_deferred_delete() const; |
116 |
void disable_deferred_delete() const; |
|
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
117 |
|
54834
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54618
diff
changeset
|
118 |
void map_page(const ZPage* page) const; |
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54618
diff
changeset
|
119 |
|
39ba09047e19
8222480: Implementation: JEP 351: ZGC: Uncommit Unused Memory
pliden
parents:
54618
diff
changeset
|
120 |
void debug_map_page(const ZPage* page) const; |
58815
a4cdca87152b
8232604: ZGC: Make ZVerifyViews mapping and unmapping precise
stefank
parents:
55284
diff
changeset
|
121 |
void debug_unmap_page(const ZPage* page) const; |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
122 |
|
50582
6464882498b5
8205022: ZGC: SoftReferences not always cleared before throwing OOME
pliden
parents:
50525
diff
changeset
|
123 |
bool is_alloc_stalled() const; |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
124 |
void check_out_of_memory(); |
58815
a4cdca87152b
8232604: ZGC: Make ZVerifyViews mapping and unmapping precise
stefank
parents:
55284
diff
changeset
|
125 |
|
a4cdca87152b
8232604: ZGC: Make ZVerifyViews mapping and unmapping precise
stefank
parents:
55284
diff
changeset
|
126 |
void pages_do(ZPageClosure* cl) const; |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
127 |
}; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
128 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
129 |
#endif // SHARE_GC_Z_ZPAGEALLOCATOR_HPP |