author | stefank |
Thu, 15 Mar 2018 21:29:36 +0100 | |
changeset 49593 | 4dd58ecc9912 |
parent 48153 | cfa2c43e58c2 |
child 51070 | 2f4c3cac8556 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
49593
4dd58ecc9912
8200105: Remove cyclic dependency between oop.inline.hpp and collectedHeap.inline.hpp
stefank
parents:
48153
diff
changeset
|
2 |
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. |
1 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
3261
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
3261
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
3261
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
37428
6e724f3d488b
8152896: Convert PrintCompressedOopsMode to Unified Logging
rprotacio
parents:
35898
diff
changeset
|
26 |
#include "logging/log.hpp" |
6e724f3d488b
8152896: Convert PrintCompressedOopsMode to Unified Logging
rprotacio
parents:
35898
diff
changeset
|
27 |
#include "memory/resourceArea.hpp" |
30291
54cdc5c1a9cb
8068352: Move virtualspace.* out of src/share/vm/runtime to memory directory
coleenp
parents:
30166
diff
changeset
|
28 |
#include "memory/virtualspace.hpp" |
7397 | 29 |
#include "oops/markOop.hpp" |
30 |
#include "oops/oop.inline.hpp" |
|
49593
4dd58ecc9912
8200105: Remove cyclic dependency between oop.inline.hpp and collectedHeap.inline.hpp
stefank
parents:
48153
diff
changeset
|
31 |
#include "runtime/os.inline.hpp" |
13195 | 32 |
#include "services/memTracker.hpp" |
46625 | 33 |
#include "utilities/align.hpp" |
1 | 34 |
|
35 |
// ReservedSpace |
|
19546
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
36 |
|
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
37 |
// Dummy constructor |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
38 |
ReservedSpace::ReservedSpace() : _base(NULL), _size(0), _noaccess_prefix(0), |
48153
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
39 |
_alignment(0), _special(false), _executable(false), _fd_for_heap(-1) { |
19546
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
40 |
} |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
41 |
|
48153
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
42 |
ReservedSpace::ReservedSpace(size_t size, size_t preferred_page_size) : _fd_for_heap(-1) { |
30166
a85188117643
8077255: TracePageSizes output reports wrong page size on Windows with G1
tschatzl
parents:
30158
diff
changeset
|
43 |
bool has_preferred_page_size = preferred_page_size != 0; |
28631 | 44 |
// Want to use large pages where possible and pad with small pages. |
30166
a85188117643
8077255: TracePageSizes output reports wrong page size on Windows with G1
tschatzl
parents:
30158
diff
changeset
|
45 |
size_t page_size = has_preferred_page_size ? preferred_page_size : os::page_size_for_region_unaligned(size, 1); |
19546
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
46 |
bool large_pages = page_size != (size_t)os::vm_page_size(); |
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
29580
diff
changeset
|
47 |
size_t alignment; |
30166
a85188117643
8077255: TracePageSizes output reports wrong page size on Windows with G1
tschatzl
parents:
30158
diff
changeset
|
48 |
if (large_pages && has_preferred_page_size) { |
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
29580
diff
changeset
|
49 |
alignment = MAX2(page_size, (size_t)os::vm_allocation_granularity()); |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
29580
diff
changeset
|
50 |
// ReservedSpace initialization requires size to be aligned to the given |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
29580
diff
changeset
|
51 |
// alignment. Align the size up. |
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
52 |
size = align_up(size, alignment); |
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
29580
diff
changeset
|
53 |
} else { |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
29580
diff
changeset
|
54 |
// Don't force the alignment to be large page aligned, |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
29580
diff
changeset
|
55 |
// since that will waste memory. |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
29580
diff
changeset
|
56 |
alignment = os::vm_allocation_granularity(); |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
29580
diff
changeset
|
57 |
} |
28372
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
58 |
initialize(size, alignment, large_pages, NULL, false); |
1 | 59 |
} |
60 |
||
61 |
ReservedSpace::ReservedSpace(size_t size, size_t alignment, |
|
823
9a5271881bc0
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
1
diff
changeset
|
62 |
bool large, |
48153
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
63 |
char* requested_address) : _fd_for_heap(-1) { |
28372
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
64 |
initialize(size, alignment, large, requested_address, false); |
2268 | 65 |
} |
66 |
||
67 |
ReservedSpace::ReservedSpace(size_t size, size_t alignment, |
|
68 |
bool large, |
|
48153
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
69 |
bool executable) : _fd_for_heap(-1) { |
28372
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
70 |
initialize(size, alignment, large, NULL, executable); |
1 | 71 |
} |
72 |
||
48153
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
73 |
// Helper method |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
74 |
static void unmap_or_release_memory(char* base, size_t size, bool is_file_mapped) { |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
75 |
if (is_file_mapped) { |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
76 |
if (!os::unmap_memory(base, size)) { |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
77 |
fatal("os::unmap_memory failed"); |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
78 |
} |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
79 |
} else if (!os::release_memory(base, size)) { |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
80 |
fatal("os::release_memory failed"); |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
81 |
} |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
82 |
} |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
83 |
|
5898 | 84 |
// Helper method. |
85 |
static bool failed_to_reserve_as_requested(char* base, char* requested_address, |
|
48153
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
86 |
const size_t size, bool special, bool is_file_mapped = false) |
5898 | 87 |
{ |
88 |
if (base == requested_address || requested_address == NULL) |
|
89 |
return false; // did not fail |
|
90 |
||
91 |
if (base != NULL) { |
|
92 |
// Different reserve address may be acceptable in other cases |
|
93 |
// but for compressed oops heap should be at requested address. |
|
94 |
assert(UseCompressedOops, "currently requested address used only for compressed oops"); |
|
37428
6e724f3d488b
8152896: Convert PrintCompressedOopsMode to Unified Logging
rprotacio
parents:
35898
diff
changeset
|
95 |
log_debug(gc, heap, coops)("Reserved memory not at requested address: " PTR_FORMAT " vs " PTR_FORMAT, p2i(base), p2i(requested_address)); |
5898 | 96 |
// OS ignored requested address. Try different address. |
97 |
if (special) { |
|
98 |
if (!os::release_memory_special(base, size)) { |
|
99 |
fatal("os::release_memory_special failed"); |
|
100 |
} |
|
101 |
} else { |
|
48153
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
102 |
unmap_or_release_memory(base, size, is_file_mapped); |
5898 | 103 |
} |
104 |
} |
|
105 |
return true; |
|
106 |
} |
|
107 |
||
1 | 108 |
void ReservedSpace::initialize(size_t size, size_t alignment, bool large, |
823
9a5271881bc0
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
1
diff
changeset
|
109 |
char* requested_address, |
2268 | 110 |
bool executable) { |
1 | 111 |
const size_t granularity = os::vm_allocation_granularity(); |
10237
df347ffafa0d
7069863: G1: SIGSEGV running SPECjbb2011 and -UseBiasedLocking
johnc
parents:
7397
diff
changeset
|
112 |
assert((size & (granularity - 1)) == 0, |
1 | 113 |
"size not aligned to os::vm_allocation_granularity()"); |
10237
df347ffafa0d
7069863: G1: SIGSEGV running SPECjbb2011 and -UseBiasedLocking
johnc
parents:
7397
diff
changeset
|
114 |
assert((alignment & (granularity - 1)) == 0, |
1 | 115 |
"alignment not aligned to os::vm_allocation_granularity()"); |
116 |
assert(alignment == 0 || is_power_of_2((intptr_t)alignment), |
|
117 |
"not a power of 2"); |
|
118 |
||
10237
df347ffafa0d
7069863: G1: SIGSEGV running SPECjbb2011 and -UseBiasedLocking
johnc
parents:
7397
diff
changeset
|
119 |
alignment = MAX2(alignment, (size_t)os::vm_page_size()); |
df347ffafa0d
7069863: G1: SIGSEGV running SPECjbb2011 and -UseBiasedLocking
johnc
parents:
7397
diff
changeset
|
120 |
|
1 | 121 |
_base = NULL; |
122 |
_size = 0; |
|
123 |
_special = false; |
|
2268 | 124 |
_executable = executable; |
1 | 125 |
_alignment = 0; |
823
9a5271881bc0
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
1
diff
changeset
|
126 |
_noaccess_prefix = 0; |
1 | 127 |
if (size == 0) { |
128 |
return; |
|
129 |
} |
|
130 |
||
131 |
// If OS doesn't support demand paging for large page memory, we need |
|
132 |
// to use reserve_memory_special() to reserve and pin the entire region. |
|
48153
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
133 |
// If there is a backing file directory for this space then whether |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
134 |
// large pages are allocated is up to the filesystem of the backing file. |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
135 |
// So we ignore the UseLargePages flag in this case. |
1 | 136 |
bool special = large && !os::can_commit_large_page_memory(); |
48153
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
137 |
if (special && _fd_for_heap != -1) { |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
138 |
special = false; |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
139 |
if (UseLargePages && (!FLAG_IS_DEFAULT(UseLargePages) || |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
140 |
!FLAG_IS_DEFAULT(LargePageSizeInBytes))) { |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
141 |
log_debug(gc, heap)("Ignoring UseLargePages since large page support is up to the file system of the backing file for Java heap"); |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
142 |
} |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
143 |
} |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
144 |
|
1 | 145 |
char* base = NULL; |
146 |
||
147 |
if (special) { |
|
148 |
||
19546
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
149 |
base = os::reserve_memory_special(size, alignment, requested_address, executable); |
1 | 150 |
|
151 |
if (base != NULL) { |
|
5898 | 152 |
if (failed_to_reserve_as_requested(base, requested_address, size, true)) { |
153 |
// OS ignored requested address. Try different address. |
|
154 |
return; |
|
155 |
} |
|
19546
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
156 |
// Check alignment constraints. |
10237
df347ffafa0d
7069863: G1: SIGSEGV running SPECjbb2011 and -UseBiasedLocking
johnc
parents:
7397
diff
changeset
|
157 |
assert((uintptr_t) base % alignment == 0, |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31620
diff
changeset
|
158 |
"Large pages returned a non-aligned address, base: " |
33148
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
33105
diff
changeset
|
159 |
PTR_FORMAT " alignment: " SIZE_FORMAT_HEX, |
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
33105
diff
changeset
|
160 |
p2i(base), alignment); |
1 | 161 |
_special = true; |
162 |
} else { |
|
163 |
// failed; try to reserve regular memory below |
|
5898 | 164 |
if (UseLargePages && (!FLAG_IS_DEFAULT(UseLargePages) || |
165 |
!FLAG_IS_DEFAULT(LargePageSizeInBytes))) { |
|
37428
6e724f3d488b
8152896: Convert PrintCompressedOopsMode to Unified Logging
rprotacio
parents:
35898
diff
changeset
|
166 |
log_debug(gc, heap, coops)("Reserve regular memory without large pages"); |
5898 | 167 |
} |
1 | 168 |
} |
169 |
} |
|
170 |
||
171 |
if (base == NULL) { |
|
172 |
// Optimistically assume that the OSes returns an aligned base pointer. |
|
173 |
// When reserving a large address range, most OSes seem to align to at |
|
174 |
// least 64K. |
|
175 |
||
176 |
// If the memory was requested at a particular address, use |
|
177 |
// os::attempt_reserve_memory_at() to avoid over mapping something |
|
178 |
// important. If available space is not detected, return NULL. |
|
179 |
||
180 |
if (requested_address != 0) { |
|
48153
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
181 |
base = os::attempt_reserve_memory_at(size, requested_address, _fd_for_heap); |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
182 |
if (failed_to_reserve_as_requested(base, requested_address, size, false, _fd_for_heap != -1)) { |
5898 | 183 |
// OS ignored requested address. Try different address. |
184 |
base = NULL; |
|
185 |
} |
|
1 | 186 |
} else { |
48153
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
187 |
base = os::reserve_memory(size, NULL, alignment, _fd_for_heap); |
1 | 188 |
} |
189 |
||
190 |
if (base == NULL) return; |
|
191 |
||
192 |
// Check alignment constraints |
|
28372
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
193 |
if ((((size_t)base) & (alignment - 1)) != 0) { |
1 | 194 |
// Base not aligned, retry |
48153
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
195 |
unmap_or_release_memory(base, size, _fd_for_heap != -1 /*is_file_mapped*/); |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
196 |
|
14840
8994c2377547
7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents:
13728
diff
changeset
|
197 |
// Make sure that size is aligned |
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
198 |
size = align_up(size, alignment); |
48153
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
199 |
base = os::reserve_memory_aligned(size, alignment, _fd_for_heap); |
10237
df347ffafa0d
7069863: G1: SIGSEGV running SPECjbb2011 and -UseBiasedLocking
johnc
parents:
7397
diff
changeset
|
200 |
|
df347ffafa0d
7069863: G1: SIGSEGV running SPECjbb2011 and -UseBiasedLocking
johnc
parents:
7397
diff
changeset
|
201 |
if (requested_address != 0 && |
48153
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
202 |
failed_to_reserve_as_requested(base, requested_address, size, false, _fd_for_heap != -1)) { |
10237
df347ffafa0d
7069863: G1: SIGSEGV running SPECjbb2011 and -UseBiasedLocking
johnc
parents:
7397
diff
changeset
|
203 |
// As a result of the alignment constraints, the allocated base differs |
df347ffafa0d
7069863: G1: SIGSEGV running SPECjbb2011 and -UseBiasedLocking
johnc
parents:
7397
diff
changeset
|
204 |
// from the requested address. Return back to the caller who can |
df347ffafa0d
7069863: G1: SIGSEGV running SPECjbb2011 and -UseBiasedLocking
johnc
parents:
7397
diff
changeset
|
205 |
// take remedial action (like try again without a requested address). |
df347ffafa0d
7069863: G1: SIGSEGV running SPECjbb2011 and -UseBiasedLocking
johnc
parents:
7397
diff
changeset
|
206 |
assert(_base == NULL, "should be"); |
df347ffafa0d
7069863: G1: SIGSEGV running SPECjbb2011 and -UseBiasedLocking
johnc
parents:
7397
diff
changeset
|
207 |
return; |
df347ffafa0d
7069863: G1: SIGSEGV running SPECjbb2011 and -UseBiasedLocking
johnc
parents:
7397
diff
changeset
|
208 |
} |
1 | 209 |
} |
210 |
} |
|
211 |
// Done |
|
212 |
_base = base; |
|
213 |
_size = size; |
|
10237
df347ffafa0d
7069863: G1: SIGSEGV running SPECjbb2011 and -UseBiasedLocking
johnc
parents:
7397
diff
changeset
|
214 |
_alignment = alignment; |
48153
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
215 |
// If heap is reserved with a backing file, the entire space has been committed. So set the _special flag to true |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
216 |
if (_fd_for_heap != -1) { |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
217 |
_special = true; |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
218 |
} |
1 | 219 |
} |
220 |
||
221 |
||
222 |
ReservedSpace::ReservedSpace(char* base, size_t size, size_t alignment, |
|
2268 | 223 |
bool special, bool executable) { |
1 | 224 |
assert((size % os::vm_allocation_granularity()) == 0, |
225 |
"size not allocation aligned"); |
|
226 |
_base = base; |
|
227 |
_size = size; |
|
228 |
_alignment = alignment; |
|
823
9a5271881bc0
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
1
diff
changeset
|
229 |
_noaccess_prefix = 0; |
1 | 230 |
_special = special; |
2268 | 231 |
_executable = executable; |
1 | 232 |
} |
233 |
||
234 |
||
235 |
ReservedSpace ReservedSpace::first_part(size_t partition_size, size_t alignment, |
|
236 |
bool split, bool realloc) { |
|
237 |
assert(partition_size <= size(), "partition failed"); |
|
238 |
if (split) { |
|
2268 | 239 |
os::split_reserved_memory(base(), size(), partition_size, realloc); |
1 | 240 |
} |
2268 | 241 |
ReservedSpace result(base(), partition_size, alignment, special(), |
242 |
executable()); |
|
1 | 243 |
return result; |
244 |
} |
|
245 |
||
246 |
||
247 |
ReservedSpace |
|
248 |
ReservedSpace::last_part(size_t partition_size, size_t alignment) { |
|
249 |
assert(partition_size <= size(), "partition failed"); |
|
250 |
ReservedSpace result(base() + partition_size, size() - partition_size, |
|
2268 | 251 |
alignment, special(), executable()); |
1 | 252 |
return result; |
253 |
} |
|
254 |
||
255 |
||
256 |
size_t ReservedSpace::page_align_size_up(size_t size) { |
|
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
257 |
return align_up(size, os::vm_page_size()); |
1 | 258 |
} |
259 |
||
260 |
||
261 |
size_t ReservedSpace::page_align_size_down(size_t size) { |
|
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
262 |
return align_down(size, os::vm_page_size()); |
1 | 263 |
} |
264 |
||
265 |
||
266 |
size_t ReservedSpace::allocation_align_size_up(size_t size) { |
|
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
267 |
return align_up(size, os::vm_allocation_granularity()); |
1 | 268 |
} |
269 |
||
270 |
||
271 |
size_t ReservedSpace::allocation_align_size_down(size_t size) { |
|
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
272 |
return align_down(size, os::vm_allocation_granularity()); |
1 | 273 |
} |
274 |
||
275 |
||
276 |
void ReservedSpace::release() { |
|
277 |
if (is_reserved()) { |
|
823
9a5271881bc0
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
1
diff
changeset
|
278 |
char *real_base = _base - _noaccess_prefix; |
9a5271881bc0
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
1
diff
changeset
|
279 |
const size_t real_size = _size + _noaccess_prefix; |
1 | 280 |
if (special()) { |
48153
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
281 |
if (_fd_for_heap != -1) { |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
282 |
os::unmap_memory(real_base, real_size); |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
283 |
} else { |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
284 |
os::release_memory_special(real_base, real_size); |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
285 |
} |
1 | 286 |
} else{ |
823
9a5271881bc0
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
1
diff
changeset
|
287 |
os::release_memory(real_base, real_size); |
1 | 288 |
} |
289 |
_base = NULL; |
|
290 |
_size = 0; |
|
823
9a5271881bc0
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
1
diff
changeset
|
291 |
_noaccess_prefix = 0; |
28372
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
292 |
_alignment = 0; |
1 | 293 |
_special = false; |
2268 | 294 |
_executable = false; |
1 | 295 |
} |
296 |
} |
|
297 |
||
28372
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
298 |
static size_t noaccess_prefix_size(size_t alignment) { |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
299 |
return lcm(os::vm_page_size(), alignment); |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
300 |
} |
5898 | 301 |
|
28372
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
302 |
void ReservedHeapSpace::establish_noaccess_prefix() { |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
303 |
assert(_alignment >= (size_t)os::vm_page_size(), "must be at least page size big"); |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
304 |
_noaccess_prefix = noaccess_prefix_size(_alignment); |
823
9a5271881bc0
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
1
diff
changeset
|
305 |
|
28372
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
306 |
if (base() && base() + _size > (char *)OopEncodingHeapMax) { |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
307 |
if (true |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
308 |
WIN64_ONLY(&& !UseLargePages) |
42061
67176803a846
8168490: Use the LL/ULL suffixes to define 64-bit integer literals on Windows
simonis
parents:
39966
diff
changeset
|
309 |
AIX_ONLY(&& os::vm_page_size() != 64*K)) { |
28372
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
310 |
// Protect memory at the base of the allocated region. |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
311 |
// If special, the page was committed (only matters on windows) |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
312 |
if (!os::protect_memory(_base, _noaccess_prefix, os::MEM_PROT_NONE, _special)) { |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
313 |
fatal("cannot protect protection page"); |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
314 |
} |
37428
6e724f3d488b
8152896: Convert PrintCompressedOopsMode to Unified Logging
rprotacio
parents:
35898
diff
changeset
|
315 |
log_debug(gc, heap, coops)("Protected page at the reserved heap base: " |
6e724f3d488b
8152896: Convert PrintCompressedOopsMode to Unified Logging
rprotacio
parents:
35898
diff
changeset
|
316 |
PTR_FORMAT " / " INTX_FORMAT " bytes", |
6e724f3d488b
8152896: Convert PrintCompressedOopsMode to Unified Logging
rprotacio
parents:
35898
diff
changeset
|
317 |
p2i(_base), |
6e724f3d488b
8152896: Convert PrintCompressedOopsMode to Unified Logging
rprotacio
parents:
35898
diff
changeset
|
318 |
_noaccess_prefix); |
28372
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
319 |
assert(Universe::narrow_oop_use_implicit_null_checks() == true, "not initialized?"); |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
320 |
} else { |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
321 |
Universe::set_narrow_oop_use_implicit_null_checks(false); |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
322 |
} |
5898 | 323 |
} |
823
9a5271881bc0
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
1
diff
changeset
|
324 |
|
9a5271881bc0
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
1
diff
changeset
|
325 |
_base += _noaccess_prefix; |
9a5271881bc0
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
1
diff
changeset
|
326 |
_size -= _noaccess_prefix; |
28372
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
327 |
assert(((uintptr_t)_base % _alignment == 0), "must be exactly of required alignment"); |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
328 |
} |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
329 |
|
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
330 |
// Tries to allocate memory of size 'size' at address requested_address with alignment 'alignment'. |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
331 |
// Does not check whether the reserved memory actually is at requested_address, as the memory returned |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
332 |
// might still fulfill the wishes of the caller. |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
333 |
// Assures the memory is aligned to 'alignment'. |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
334 |
// NOTE: If ReservedHeapSpace already points to some reserved memory this is freed, first. |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
335 |
void ReservedHeapSpace::try_reserve_heap(size_t size, |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
336 |
size_t alignment, |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
337 |
bool large, |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
338 |
char* requested_address) { |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
339 |
if (_base != NULL) { |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
340 |
// We tried before, but we didn't like the address delivered. |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
341 |
release(); |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
342 |
} |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
343 |
|
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
344 |
// If OS doesn't support demand paging for large page memory, we need |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
345 |
// to use reserve_memory_special() to reserve and pin the entire region. |
48153
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
346 |
// If there is a backing file directory for this space then whether |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
347 |
// large pages are allocated is up to the filesystem of the backing file. |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
348 |
// So we ignore the UseLargePages flag in this case. |
28372
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
349 |
bool special = large && !os::can_commit_large_page_memory(); |
48153
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
350 |
if (special && _fd_for_heap != -1) { |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
351 |
special = false; |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
352 |
if (UseLargePages && (!FLAG_IS_DEFAULT(UseLargePages) || |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
353 |
!FLAG_IS_DEFAULT(LargePageSizeInBytes))) { |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
354 |
log_debug(gc, heap)("Cannot allocate large pages for Java Heap when AllocateHeapAt option is set."); |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
355 |
} |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
356 |
} |
28372
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
357 |
char* base = NULL; |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
358 |
|
37428
6e724f3d488b
8152896: Convert PrintCompressedOopsMode to Unified Logging
rprotacio
parents:
35898
diff
changeset
|
359 |
log_trace(gc, heap, coops)("Trying to allocate at address " PTR_FORMAT |
6e724f3d488b
8152896: Convert PrintCompressedOopsMode to Unified Logging
rprotacio
parents:
35898
diff
changeset
|
360 |
" heap of size " SIZE_FORMAT_HEX, |
6e724f3d488b
8152896: Convert PrintCompressedOopsMode to Unified Logging
rprotacio
parents:
35898
diff
changeset
|
361 |
p2i(requested_address), |
6e724f3d488b
8152896: Convert PrintCompressedOopsMode to Unified Logging
rprotacio
parents:
35898
diff
changeset
|
362 |
size); |
28372
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
363 |
|
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
364 |
if (special) { |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
365 |
base = os::reserve_memory_special(size, alignment, requested_address, false); |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
366 |
|
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
367 |
if (base != NULL) { |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
368 |
// Check alignment constraints. |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
369 |
assert((uintptr_t) base % alignment == 0, |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31620
diff
changeset
|
370 |
"Large pages returned a non-aligned address, base: " |
33148
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
33105
diff
changeset
|
371 |
PTR_FORMAT " alignment: " SIZE_FORMAT_HEX, |
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
33105
diff
changeset
|
372 |
p2i(base), alignment); |
28372
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
373 |
_special = true; |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
374 |
} |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
375 |
} |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
376 |
|
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
377 |
if (base == NULL) { |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
378 |
// Failed; try to reserve regular memory below |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
379 |
if (UseLargePages && (!FLAG_IS_DEFAULT(UseLargePages) || |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
380 |
!FLAG_IS_DEFAULT(LargePageSizeInBytes))) { |
37428
6e724f3d488b
8152896: Convert PrintCompressedOopsMode to Unified Logging
rprotacio
parents:
35898
diff
changeset
|
381 |
log_debug(gc, heap, coops)("Reserve regular memory without large pages"); |
28372
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
382 |
} |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
383 |
|
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
384 |
// Optimistically assume that the OSes returns an aligned base pointer. |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
385 |
// When reserving a large address range, most OSes seem to align to at |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
386 |
// least 64K. |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
387 |
|
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
388 |
// If the memory was requested at a particular address, use |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
389 |
// os::attempt_reserve_memory_at() to avoid over mapping something |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
390 |
// important. If available space is not detected, return NULL. |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
391 |
|
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
392 |
if (requested_address != 0) { |
48153
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
393 |
base = os::attempt_reserve_memory_at(size, requested_address, _fd_for_heap); |
28372
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
394 |
} else { |
48153
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
395 |
base = os::reserve_memory(size, NULL, alignment, _fd_for_heap); |
28372
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
396 |
} |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
397 |
} |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
398 |
if (base == NULL) { return; } |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
399 |
|
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
400 |
// Done |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
401 |
_base = base; |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
402 |
_size = size; |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
403 |
_alignment = alignment; |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
404 |
|
48153
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
405 |
// If heap is reserved with a backing file, the entire space has been committed. So set the _special flag to true |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
406 |
if (_fd_for_heap != -1) { |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
407 |
_special = true; |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
408 |
} |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
409 |
|
28372
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
410 |
// Check alignment constraints |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
411 |
if ((((size_t)base) & (alignment - 1)) != 0) { |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
412 |
// Base not aligned, retry. |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
413 |
release(); |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
414 |
} |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
415 |
} |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
416 |
|
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
417 |
void ReservedHeapSpace::try_reserve_range(char *highest_start, |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
418 |
char *lowest_start, |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
419 |
size_t attach_point_alignment, |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
420 |
char *aligned_heap_base_min_address, |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
421 |
char *upper_bound, |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
422 |
size_t size, |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
423 |
size_t alignment, |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
424 |
bool large) { |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
425 |
const size_t attach_range = highest_start - lowest_start; |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
426 |
// Cap num_attempts at possible number. |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
427 |
// At least one is possible even for 0 sized attach range. |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
428 |
const uint64_t num_attempts_possible = (attach_range / attach_point_alignment) + 1; |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
429 |
const uint64_t num_attempts_to_try = MIN2((uint64_t)HeapSearchSteps, num_attempts_possible); |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
430 |
|
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
431 |
const size_t stepsize = (attach_range == 0) ? // Only one try. |
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
432 |
(size_t) highest_start : align_up(attach_range / num_attempts_to_try, attach_point_alignment); |
28372
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
433 |
|
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
434 |
// Try attach points from top to bottom. |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
435 |
char* attach_point = highest_start; |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
436 |
while (attach_point >= lowest_start && |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
437 |
attach_point <= highest_start && // Avoid wrap around. |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
438 |
((_base == NULL) || |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
439 |
(_base < aligned_heap_base_min_address || _base + size > upper_bound))) { |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
440 |
try_reserve_heap(size, alignment, large, attach_point); |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
441 |
attach_point -= stepsize; |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
442 |
} |
823
9a5271881bc0
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
1
diff
changeset
|
443 |
} |
9a5271881bc0
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
1
diff
changeset
|
444 |
|
28372
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
445 |
#define SIZE_64K ((uint64_t) UCONST64( 0x10000)) |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
446 |
#define SIZE_256M ((uint64_t) UCONST64( 0x10000000)) |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
447 |
#define SIZE_32G ((uint64_t) UCONST64( 0x800000000)) |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
448 |
|
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
449 |
// Helper for heap allocation. Returns an array with addresses |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
450 |
// (OS-specific) which are suited for disjoint base mode. Array is |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
451 |
// NULL terminated. |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
452 |
static char** get_attach_addresses_for_disjoint_mode() { |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
453 |
static uint64_t addresses[] = { |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
454 |
2 * SIZE_32G, |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
455 |
3 * SIZE_32G, |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
456 |
4 * SIZE_32G, |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
457 |
8 * SIZE_32G, |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
458 |
10 * SIZE_32G, |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
459 |
1 * SIZE_64K * SIZE_32G, |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
460 |
2 * SIZE_64K * SIZE_32G, |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
461 |
3 * SIZE_64K * SIZE_32G, |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
462 |
4 * SIZE_64K * SIZE_32G, |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
463 |
16 * SIZE_64K * SIZE_32G, |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
464 |
32 * SIZE_64K * SIZE_32G, |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
465 |
34 * SIZE_64K * SIZE_32G, |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
466 |
0 |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
467 |
}; |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
468 |
|
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
469 |
// Sort out addresses smaller than HeapBaseMinAddress. This assumes |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
470 |
// the array is sorted. |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
471 |
uint i = 0; |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
472 |
while (addresses[i] != 0 && |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
473 |
(addresses[i] < OopEncodingHeapMax || addresses[i] < HeapBaseMinAddress)) { |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
474 |
i++; |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
475 |
} |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
476 |
uint start = i; |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
477 |
|
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
478 |
// Avoid more steps than requested. |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
479 |
i = 0; |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
480 |
while (addresses[start+i] != 0) { |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
481 |
if (i == HeapSearchSteps) { |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
482 |
addresses[start+i] = 0; |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
483 |
break; |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
484 |
} |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
485 |
i++; |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
486 |
} |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
487 |
|
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
488 |
return (char**) &addresses[start]; |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
489 |
} |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
490 |
|
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
491 |
void ReservedHeapSpace::initialize_compressed_heap(const size_t size, size_t alignment, bool large) { |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
492 |
guarantee(size + noaccess_prefix_size(alignment) <= OopEncodingHeapMax, |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
493 |
"can not allocate compressed oop heap for this size"); |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
494 |
guarantee(alignment == MAX2(alignment, (size_t)os::vm_page_size()), "alignment too small"); |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
495 |
assert(HeapBaseMinAddress > 0, "sanity"); |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
496 |
|
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
497 |
const size_t granularity = os::vm_allocation_granularity(); |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
498 |
assert((size & (granularity - 1)) == 0, |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
499 |
"size not aligned to os::vm_allocation_granularity()"); |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
500 |
assert((alignment & (granularity - 1)) == 0, |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
501 |
"alignment not aligned to os::vm_allocation_granularity()"); |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
502 |
assert(alignment == 0 || is_power_of_2((intptr_t)alignment), |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
503 |
"not a power of 2"); |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
504 |
|
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
505 |
// The necessary attach point alignment for generated wish addresses. |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
506 |
// This is needed to increase the chance of attaching for mmap and shmat. |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
507 |
const size_t os_attach_point_alignment = |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
508 |
AIX_ONLY(SIZE_256M) // Known shm boundary alignment. |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
509 |
NOT_AIX(os::vm_allocation_granularity()); |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
510 |
const size_t attach_point_alignment = lcm(alignment, os_attach_point_alignment); |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
511 |
|
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
512 |
char *aligned_heap_base_min_address = (char *)align_up((void *)HeapBaseMinAddress, alignment); |
28372
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
513 |
size_t noaccess_prefix = ((aligned_heap_base_min_address + size) > (char*)OopEncodingHeapMax) ? |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
514 |
noaccess_prefix_size(alignment) : 0; |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
515 |
|
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
516 |
// Attempt to alloc at user-given address. |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
517 |
if (!FLAG_IS_DEFAULT(HeapBaseMinAddress)) { |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
518 |
try_reserve_heap(size + noaccess_prefix, alignment, large, aligned_heap_base_min_address); |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
519 |
if (_base != aligned_heap_base_min_address) { // Enforce this exact address. |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
520 |
release(); |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
521 |
} |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
522 |
} |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
523 |
|
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
524 |
// Keep heap at HeapBaseMinAddress. |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
525 |
if (_base == NULL) { |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
526 |
|
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
527 |
// Try to allocate the heap at addresses that allow efficient oop compression. |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
528 |
// Different schemes are tried, in order of decreasing optimization potential. |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
529 |
// |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
530 |
// For this, try_reserve_heap() is called with the desired heap base addresses. |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
531 |
// A call into the os layer to allocate at a given address can return memory |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
532 |
// at a different address than requested. Still, this might be memory at a useful |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
533 |
// address. try_reserve_heap() always returns this allocated memory, as only here |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
534 |
// the criteria for a good heap are checked. |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
535 |
|
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
536 |
// Attempt to allocate so that we can run without base and scale (32-Bit unscaled compressed oops). |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
537 |
// Give it several tries from top of range to bottom. |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
538 |
if (aligned_heap_base_min_address + size <= (char *)UnscaledOopHeapMax) { |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
539 |
|
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
540 |
// Calc address range within we try to attach (range of possible start addresses). |
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
541 |
char* const highest_start = align_down((char *)UnscaledOopHeapMax - size, attach_point_alignment); |
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
542 |
char* const lowest_start = align_up(aligned_heap_base_min_address, attach_point_alignment); |
28372
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
543 |
try_reserve_range(highest_start, lowest_start, attach_point_alignment, |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
544 |
aligned_heap_base_min_address, (char *)UnscaledOopHeapMax, size, alignment, large); |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
545 |
} |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
546 |
|
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
547 |
// zerobased: Attempt to allocate in the lower 32G. |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
548 |
// But leave room for the compressed class pointers, which is allocated above |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
549 |
// the heap. |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
550 |
char *zerobased_max = (char *)OopEncodingHeapMax; |
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
551 |
const size_t class_space = align_up(CompressedClassSpaceSize, alignment); |
28372
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
552 |
// For small heaps, save some space for compressed class pointer |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
553 |
// space so it can be decoded with no base. |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
554 |
if (UseCompressedClassPointers && !UseSharedSpaces && |
28946
24261e03ba4c
8072434: 8064457: introduces performance regressions in 9-b47
goetz
parents:
28631
diff
changeset
|
555 |
OopEncodingHeapMax <= KlassEncodingMetaspaceMax && |
24261e03ba4c
8072434: 8064457: introduces performance regressions in 9-b47
goetz
parents:
28631
diff
changeset
|
556 |
(uint64_t)(aligned_heap_base_min_address + size + class_space) <= KlassEncodingMetaspaceMax) { |
28372
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
557 |
zerobased_max = (char *)OopEncodingHeapMax - class_space; |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
558 |
} |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
559 |
|
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
560 |
// Give it several tries from top of range to bottom. |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
561 |
if (aligned_heap_base_min_address + size <= zerobased_max && // Zerobased theoretical possible. |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
562 |
((_base == NULL) || // No previous try succeeded. |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
563 |
(_base + size > zerobased_max))) { // Unscaled delivered an arbitrary address. |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
564 |
|
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
565 |
// Calc address range within we try to attach (range of possible start addresses). |
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
566 |
char *const highest_start = align_down(zerobased_max - size, attach_point_alignment); |
29580
a67a581cfe11
8073315: Enable gcc -Wtype-limits and fix upcoming issues.
goetz
parents:
28946
diff
changeset
|
567 |
// Need to be careful about size being guaranteed to be less |
a67a581cfe11
8073315: Enable gcc -Wtype-limits and fix upcoming issues.
goetz
parents:
28946
diff
changeset
|
568 |
// than UnscaledOopHeapMax due to type constraints. |
a67a581cfe11
8073315: Enable gcc -Wtype-limits and fix upcoming issues.
goetz
parents:
28946
diff
changeset
|
569 |
char *lowest_start = aligned_heap_base_min_address; |
a67a581cfe11
8073315: Enable gcc -Wtype-limits and fix upcoming issues.
goetz
parents:
28946
diff
changeset
|
570 |
uint64_t unscaled_end = UnscaledOopHeapMax - size; |
a67a581cfe11
8073315: Enable gcc -Wtype-limits and fix upcoming issues.
goetz
parents:
28946
diff
changeset
|
571 |
if (unscaled_end < UnscaledOopHeapMax) { // unscaled_end wrapped if size is large |
a67a581cfe11
8073315: Enable gcc -Wtype-limits and fix upcoming issues.
goetz
parents:
28946
diff
changeset
|
572 |
lowest_start = MAX2(lowest_start, (char*)unscaled_end); |
a67a581cfe11
8073315: Enable gcc -Wtype-limits and fix upcoming issues.
goetz
parents:
28946
diff
changeset
|
573 |
} |
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
574 |
lowest_start = align_up(lowest_start, attach_point_alignment); |
28372
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
575 |
try_reserve_range(highest_start, lowest_start, attach_point_alignment, |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
576 |
aligned_heap_base_min_address, zerobased_max, size, alignment, large); |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
577 |
} |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
578 |
|
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
579 |
// Now we go for heaps with base != 0. We need a noaccess prefix to efficiently |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
580 |
// implement null checks. |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
581 |
noaccess_prefix = noaccess_prefix_size(alignment); |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
582 |
|
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
583 |
// Try to attach at addresses that are aligned to OopEncodingHeapMax. Disjointbase mode. |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
584 |
char** addresses = get_attach_addresses_for_disjoint_mode(); |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
585 |
int i = 0; |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
586 |
while (addresses[i] && // End of array not yet reached. |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
587 |
((_base == NULL) || // No previous try succeeded. |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
588 |
(_base + size > (char *)OopEncodingHeapMax && // Not zerobased or unscaled address. |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
589 |
!Universe::is_disjoint_heap_base_address((address)_base)))) { // Not disjoint address. |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
590 |
char* const attach_point = addresses[i]; |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
591 |
assert(attach_point >= aligned_heap_base_min_address, "Flag support broken"); |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
592 |
try_reserve_heap(size + noaccess_prefix, alignment, large, attach_point); |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
593 |
i++; |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
594 |
} |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
595 |
|
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
596 |
// Last, desperate try without any placement. |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
597 |
if (_base == NULL) { |
37428
6e724f3d488b
8152896: Convert PrintCompressedOopsMode to Unified Logging
rprotacio
parents:
35898
diff
changeset
|
598 |
log_trace(gc, heap, coops)("Trying to allocate at address NULL heap of size " SIZE_FORMAT_HEX, size + noaccess_prefix); |
28372
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
599 |
initialize(size + noaccess_prefix, alignment, large, NULL, false); |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
600 |
} |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
601 |
} |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
602 |
} |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
603 |
|
48153
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
604 |
ReservedHeapSpace::ReservedHeapSpace(size_t size, size_t alignment, bool large, const char* heap_allocation_directory) : ReservedSpace() { |
28372
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
605 |
|
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
606 |
if (size == 0) { |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
607 |
return; |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
608 |
} |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
609 |
|
48153
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
610 |
if (heap_allocation_directory != NULL) { |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
611 |
_fd_for_heap = os::create_file_for_heap(heap_allocation_directory); |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
612 |
if (_fd_for_heap == -1) { |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
613 |
vm_exit_during_initialization( |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
614 |
err_msg("Could not create file for Heap at location %s", heap_allocation_directory)); |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
615 |
} |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
616 |
} |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
617 |
|
28372
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
618 |
// Heap size should be aligned to alignment, too. |
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
619 |
guarantee(is_aligned(size, alignment), "set by caller"); |
28372
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
620 |
|
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
621 |
if (UseCompressedOops) { |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
622 |
initialize_compressed_heap(size, alignment, large); |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
623 |
if (_size > size) { |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
624 |
// We allocated heap with noaccess prefix. |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
625 |
// It can happen we get a zerobased/unscaled heap with noaccess prefix, |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
626 |
// if we had to try at arbitrary address. |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
627 |
establish_noaccess_prefix(); |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
628 |
} |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
629 |
} else { |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
630 |
initialize(size, alignment, large, NULL, false); |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
631 |
} |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
632 |
|
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
633 |
assert(markOopDesc::encode_pointer_as_mark(_base)->decode_pointer() == _base, |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
634 |
"area must be distinguishable from marks for mark-sweep"); |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
635 |
assert(markOopDesc::encode_pointer_as_mark(&_base[size])->decode_pointer() == &_base[size], |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
636 |
"area must be distinguishable from marks for mark-sweep"); |
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
637 |
|
46983 | 638 |
if (base() != NULL) { |
13195 | 639 |
MemTracker::record_virtual_memory_type((address)base(), mtJavaHeap); |
640 |
} |
|
48153
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
641 |
|
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
642 |
if (_fd_for_heap != -1) { |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
643 |
os::close(_fd_for_heap); |
cfa2c43e58c2
8190308: Implementation: JEP 316: Heap Allocation on Alternative Memory Devices
kkharbas
parents:
47216
diff
changeset
|
644 |
} |
823
9a5271881bc0
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
1
diff
changeset
|
645 |
} |
9a5271881bc0
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
1
diff
changeset
|
646 |
|
2268 | 647 |
// Reserve space for code segment. Same as Java heap only we mark this as |
648 |
// executable. |
|
649 |
ReservedCodeSpace::ReservedCodeSpace(size_t r_size, |
|
650 |
size_t rs_align, |
|
651 |
bool large) : |
|
42664 | 652 |
ReservedSpace(r_size, rs_align, large, /*executable*/ true) { |
13195 | 653 |
MemTracker::record_virtual_memory_type((address)base(), mtCode); |
2268 | 654 |
} |
655 |
||
1 | 656 |
// VirtualSpace |
657 |
||
658 |
VirtualSpace::VirtualSpace() { |
|
659 |
_low_boundary = NULL; |
|
660 |
_high_boundary = NULL; |
|
661 |
_low = NULL; |
|
662 |
_high = NULL; |
|
663 |
_lower_high = NULL; |
|
664 |
_middle_high = NULL; |
|
665 |
_upper_high = NULL; |
|
666 |
_lower_high_boundary = NULL; |
|
667 |
_middle_high_boundary = NULL; |
|
668 |
_upper_high_boundary = NULL; |
|
669 |
_lower_alignment = 0; |
|
670 |
_middle_alignment = 0; |
|
671 |
_upper_alignment = 0; |
|
823
9a5271881bc0
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
1
diff
changeset
|
672 |
_special = false; |
2268 | 673 |
_executable = false; |
1 | 674 |
} |
675 |
||
676 |
||
677 |
bool VirtualSpace::initialize(ReservedSpace rs, size_t committed_size) { |
|
28631 | 678 |
const size_t max_commit_granularity = os::page_size_for_region_unaligned(rs.size(), 1); |
20402
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
679 |
return initialize_with_granularity(rs, committed_size, max_commit_granularity); |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
680 |
} |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
681 |
|
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
682 |
bool VirtualSpace::initialize_with_granularity(ReservedSpace rs, size_t committed_size, size_t max_commit_granularity) { |
1 | 683 |
if(!rs.is_reserved()) return false; // allocation failed. |
684 |
assert(_low_boundary == NULL, "VirtualSpace already initialized"); |
|
20402
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
685 |
assert(max_commit_granularity > 0, "Granularity must be non-zero."); |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
686 |
|
1 | 687 |
_low_boundary = rs.base(); |
688 |
_high_boundary = low_boundary() + rs.size(); |
|
689 |
||
690 |
_low = low_boundary(); |
|
691 |
_high = low(); |
|
692 |
||
693 |
_special = rs.special(); |
|
2268 | 694 |
_executable = rs.executable(); |
1 | 695 |
|
696 |
// When a VirtualSpace begins life at a large size, make all future expansion |
|
697 |
// and shrinking occur aligned to a granularity of large pages. This avoids |
|
698 |
// fragmentation of physical addresses that inhibits the use of large pages |
|
699 |
// by the OS virtual memory system. Empirically, we see that with a 4MB |
|
700 |
// page size, the only spaces that get handled this way are codecache and |
|
701 |
// the heap itself, both of which provide a substantial performance |
|
702 |
// boost in many benchmarks when covered by large pages. |
|
703 |
// |
|
704 |
// No attempt is made to force large page alignment at the very top and |
|
705 |
// bottom of the space if they are not aligned so already. |
|
706 |
_lower_alignment = os::vm_page_size(); |
|
20402
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
707 |
_middle_alignment = max_commit_granularity; |
1 | 708 |
_upper_alignment = os::vm_page_size(); |
709 |
||
710 |
// End of each region |
|
46620
750c6edff33b
8178500: Replace usages of round_to and round_down with align_up and align_down
stefank
parents:
46619
diff
changeset
|
711 |
_lower_high_boundary = align_up(low_boundary(), middle_alignment()); |
750c6edff33b
8178500: Replace usages of round_to and round_down with align_up and align_down
stefank
parents:
46619
diff
changeset
|
712 |
_middle_high_boundary = align_down(high_boundary(), middle_alignment()); |
1 | 713 |
_upper_high_boundary = high_boundary(); |
714 |
||
715 |
// High address of each region |
|
716 |
_lower_high = low_boundary(); |
|
717 |
_middle_high = lower_high_boundary(); |
|
718 |
_upper_high = middle_high_boundary(); |
|
719 |
||
720 |
// commit to initial size |
|
721 |
if (committed_size > 0) { |
|
722 |
if (!expand_by(committed_size)) { |
|
723 |
return false; |
|
724 |
} |
|
725 |
} |
|
726 |
return true; |
|
727 |
} |
|
728 |
||
729 |
||
730 |
VirtualSpace::~VirtualSpace() { |
|
731 |
release(); |
|
732 |
} |
|
733 |
||
734 |
||
735 |
void VirtualSpace::release() { |
|
39966
43c7f35b800e
8160897: Concurrent mark mark stack memory allocation leaks memory
tschatzl
parents:
38009
diff
changeset
|
736 |
// This does not release memory it reserved. |
823
9a5271881bc0
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
1
diff
changeset
|
737 |
// Caller must release via rs.release(); |
1 | 738 |
_low_boundary = NULL; |
739 |
_high_boundary = NULL; |
|
740 |
_low = NULL; |
|
741 |
_high = NULL; |
|
742 |
_lower_high = NULL; |
|
743 |
_middle_high = NULL; |
|
744 |
_upper_high = NULL; |
|
745 |
_lower_high_boundary = NULL; |
|
746 |
_middle_high_boundary = NULL; |
|
747 |
_upper_high_boundary = NULL; |
|
748 |
_lower_alignment = 0; |
|
749 |
_middle_alignment = 0; |
|
750 |
_upper_alignment = 0; |
|
751 |
_special = false; |
|
2268 | 752 |
_executable = false; |
1 | 753 |
} |
754 |
||
755 |
||
756 |
size_t VirtualSpace::committed_size() const { |
|
757 |
return pointer_delta(high(), low(), sizeof(char)); |
|
758 |
} |
|
759 |
||
760 |
||
761 |
size_t VirtualSpace::reserved_size() const { |
|
762 |
return pointer_delta(high_boundary(), low_boundary(), sizeof(char)); |
|
763 |
} |
|
764 |
||
765 |
||
766 |
size_t VirtualSpace::uncommitted_size() const { |
|
767 |
return reserved_size() - committed_size(); |
|
768 |
} |
|
769 |
||
19989
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
770 |
size_t VirtualSpace::actual_committed_size() const { |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
771 |
// Special VirtualSpaces commit all reserved space up front. |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
772 |
if (special()) { |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
773 |
return reserved_size(); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
774 |
} |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
775 |
|
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
776 |
size_t committed_low = pointer_delta(_lower_high, _low_boundary, sizeof(char)); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
777 |
size_t committed_middle = pointer_delta(_middle_high, _lower_high_boundary, sizeof(char)); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
778 |
size_t committed_high = pointer_delta(_upper_high, _middle_high_boundary, sizeof(char)); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
779 |
|
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
780 |
#ifdef ASSERT |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
781 |
size_t lower = pointer_delta(_lower_high_boundary, _low_boundary, sizeof(char)); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
782 |
size_t middle = pointer_delta(_middle_high_boundary, _lower_high_boundary, sizeof(char)); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
783 |
size_t upper = pointer_delta(_upper_high_boundary, _middle_high_boundary, sizeof(char)); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
784 |
|
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
785 |
if (committed_high > 0) { |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
786 |
assert(committed_low == lower, "Must be"); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
787 |
assert(committed_middle == middle, "Must be"); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
788 |
} |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
789 |
|
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
790 |
if (committed_middle > 0) { |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
791 |
assert(committed_low == lower, "Must be"); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
792 |
} |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
793 |
if (committed_middle < middle) { |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
794 |
assert(committed_high == 0, "Must be"); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
795 |
} |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
796 |
|
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
797 |
if (committed_low < lower) { |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
798 |
assert(committed_high == 0, "Must be"); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
799 |
assert(committed_middle == 0, "Must be"); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
800 |
} |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
801 |
#endif |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
802 |
|
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
803 |
return committed_low + committed_middle + committed_high; |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
804 |
} |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
805 |
|
1 | 806 |
|
807 |
bool VirtualSpace::contains(const void* p) const { |
|
808 |
return low() <= (const char*) p && (const char*) p < high(); |
|
809 |
} |
|
810 |
||
37984
5e9b81de0fce
8067785: Using AlwaysPreTouch does not always touch all pages
stefank
parents:
37428
diff
changeset
|
811 |
static void pretouch_expanded_memory(void* start, void* end) { |
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
812 |
assert(is_aligned(start, os::vm_page_size()), "Unexpected alignment"); |
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
813 |
assert(is_aligned(end, os::vm_page_size()), "Unexpected alignment"); |
37984
5e9b81de0fce
8067785: Using AlwaysPreTouch does not always touch all pages
stefank
parents:
37428
diff
changeset
|
814 |
|
5e9b81de0fce
8067785: Using AlwaysPreTouch does not always touch all pages
stefank
parents:
37428
diff
changeset
|
815 |
os::pretouch_memory(start, end); |
5e9b81de0fce
8067785: Using AlwaysPreTouch does not always touch all pages
stefank
parents:
37428
diff
changeset
|
816 |
} |
5e9b81de0fce
8067785: Using AlwaysPreTouch does not always touch all pages
stefank
parents:
37428
diff
changeset
|
817 |
|
5e9b81de0fce
8067785: Using AlwaysPreTouch does not always touch all pages
stefank
parents:
37428
diff
changeset
|
818 |
static bool commit_expanded(char* start, size_t size, size_t alignment, bool pre_touch, bool executable) { |
5e9b81de0fce
8067785: Using AlwaysPreTouch does not always touch all pages
stefank
parents:
37428
diff
changeset
|
819 |
if (os::commit_memory(start, size, alignment, executable)) { |
5e9b81de0fce
8067785: Using AlwaysPreTouch does not always touch all pages
stefank
parents:
37428
diff
changeset
|
820 |
if (pre_touch || AlwaysPreTouch) { |
5e9b81de0fce
8067785: Using AlwaysPreTouch does not always touch all pages
stefank
parents:
37428
diff
changeset
|
821 |
pretouch_expanded_memory(start, start + size); |
5e9b81de0fce
8067785: Using AlwaysPreTouch does not always touch all pages
stefank
parents:
37428
diff
changeset
|
822 |
} |
5e9b81de0fce
8067785: Using AlwaysPreTouch does not always touch all pages
stefank
parents:
37428
diff
changeset
|
823 |
return true; |
5e9b81de0fce
8067785: Using AlwaysPreTouch does not always touch all pages
stefank
parents:
37428
diff
changeset
|
824 |
} |
5e9b81de0fce
8067785: Using AlwaysPreTouch does not always touch all pages
stefank
parents:
37428
diff
changeset
|
825 |
|
5e9b81de0fce
8067785: Using AlwaysPreTouch does not always touch all pages
stefank
parents:
37428
diff
changeset
|
826 |
debug_only(warning( |
5e9b81de0fce
8067785: Using AlwaysPreTouch does not always touch all pages
stefank
parents:
37428
diff
changeset
|
827 |
"INFO: os::commit_memory(" PTR_FORMAT ", " PTR_FORMAT |
5e9b81de0fce
8067785: Using AlwaysPreTouch does not always touch all pages
stefank
parents:
37428
diff
changeset
|
828 |
" size=" SIZE_FORMAT ", executable=%d) failed", |
5e9b81de0fce
8067785: Using AlwaysPreTouch does not always touch all pages
stefank
parents:
37428
diff
changeset
|
829 |
p2i(start), p2i(start + size), size, executable);) |
5e9b81de0fce
8067785: Using AlwaysPreTouch does not always touch all pages
stefank
parents:
37428
diff
changeset
|
830 |
|
5e9b81de0fce
8067785: Using AlwaysPreTouch does not always touch all pages
stefank
parents:
37428
diff
changeset
|
831 |
return false; |
5e9b81de0fce
8067785: Using AlwaysPreTouch does not always touch all pages
stefank
parents:
37428
diff
changeset
|
832 |
} |
5e9b81de0fce
8067785: Using AlwaysPreTouch does not always touch all pages
stefank
parents:
37428
diff
changeset
|
833 |
|
1 | 834 |
/* |
835 |
First we need to determine if a particular virtual space is using large |
|
836 |
pages. This is done at the initialize function and only virtual spaces |
|
837 |
that are larger than LargePageSizeInBytes use large pages. Once we |
|
838 |
have determined this, all expand_by and shrink_by calls must grow and |
|
839 |
shrink by large page size chunks. If a particular request |
|
840 |
is within the current large page, the call to commit and uncommit memory |
|
841 |
can be ignored. In the case that the low and high boundaries of this |
|
842 |
space is not large page aligned, the pages leading to the first large |
|
843 |
page address and the pages after the last large page address must be |
|
844 |
allocated with default pages. |
|
845 |
*/ |
|
846 |
bool VirtualSpace::expand_by(size_t bytes, bool pre_touch) { |
|
37984
5e9b81de0fce
8067785: Using AlwaysPreTouch does not always touch all pages
stefank
parents:
37428
diff
changeset
|
847 |
if (uncommitted_size() < bytes) { |
5e9b81de0fce
8067785: Using AlwaysPreTouch does not always touch all pages
stefank
parents:
37428
diff
changeset
|
848 |
return false; |
5e9b81de0fce
8067785: Using AlwaysPreTouch does not always touch all pages
stefank
parents:
37428
diff
changeset
|
849 |
} |
1 | 850 |
|
851 |
if (special()) { |
|
852 |
// don't commit memory if the entire space is pinned in memory |
|
853 |
_high += bytes; |
|
854 |
return true; |
|
855 |
} |
|
856 |
||
857 |
char* previous_high = high(); |
|
858 |
char* unaligned_new_high = high() + bytes; |
|
37984
5e9b81de0fce
8067785: Using AlwaysPreTouch does not always touch all pages
stefank
parents:
37428
diff
changeset
|
859 |
assert(unaligned_new_high <= high_boundary(), "cannot expand by more than upper boundary"); |
1 | 860 |
|
861 |
// Calculate where the new high for each of the regions should be. If |
|
862 |
// the low_boundary() and high_boundary() are LargePageSizeInBytes aligned |
|
863 |
// then the unaligned lower and upper new highs would be the |
|
864 |
// lower_high() and upper_high() respectively. |
|
37984
5e9b81de0fce
8067785: Using AlwaysPreTouch does not always touch all pages
stefank
parents:
37428
diff
changeset
|
865 |
char* unaligned_lower_new_high = MIN2(unaligned_new_high, lower_high_boundary()); |
5e9b81de0fce
8067785: Using AlwaysPreTouch does not always touch all pages
stefank
parents:
37428
diff
changeset
|
866 |
char* unaligned_middle_new_high = MIN2(unaligned_new_high, middle_high_boundary()); |
5e9b81de0fce
8067785: Using AlwaysPreTouch does not always touch all pages
stefank
parents:
37428
diff
changeset
|
867 |
char* unaligned_upper_new_high = MIN2(unaligned_new_high, upper_high_boundary()); |
1 | 868 |
|
869 |
// Align the new highs based on the regions alignment. lower and upper |
|
870 |
// alignment will always be default page size. middle alignment will be |
|
871 |
// LargePageSizeInBytes if the actual size of the virtual space is in |
|
872 |
// fact larger than LargePageSizeInBytes. |
|
46620
750c6edff33b
8178500: Replace usages of round_to and round_down with align_up and align_down
stefank
parents:
46619
diff
changeset
|
873 |
char* aligned_lower_new_high = align_up(unaligned_lower_new_high, lower_alignment()); |
750c6edff33b
8178500: Replace usages of round_to and round_down with align_up and align_down
stefank
parents:
46619
diff
changeset
|
874 |
char* aligned_middle_new_high = align_up(unaligned_middle_new_high, middle_alignment()); |
750c6edff33b
8178500: Replace usages of round_to and round_down with align_up and align_down
stefank
parents:
46619
diff
changeset
|
875 |
char* aligned_upper_new_high = align_up(unaligned_upper_new_high, upper_alignment()); |
1 | 876 |
|
877 |
// Determine which regions need to grow in this expand_by call. |
|
878 |
// If you are growing in the lower region, high() must be in that |
|
22551 | 879 |
// region so calculate the size based on high(). For the middle and |
1 | 880 |
// upper regions, determine the starting point of growth based on the |
881 |
// location of high(). By getting the MAX of the region's low address |
|
22551 | 882 |
// (or the previous region's high address) and high(), we can tell if it |
1 | 883 |
// is an intra or inter region growth. |
884 |
size_t lower_needs = 0; |
|
885 |
if (aligned_lower_new_high > lower_high()) { |
|
37984
5e9b81de0fce
8067785: Using AlwaysPreTouch does not always touch all pages
stefank
parents:
37428
diff
changeset
|
886 |
lower_needs = pointer_delta(aligned_lower_new_high, lower_high(), sizeof(char)); |
1 | 887 |
} |
888 |
size_t middle_needs = 0; |
|
889 |
if (aligned_middle_new_high > middle_high()) { |
|
37984
5e9b81de0fce
8067785: Using AlwaysPreTouch does not always touch all pages
stefank
parents:
37428
diff
changeset
|
890 |
middle_needs = pointer_delta(aligned_middle_new_high, middle_high(), sizeof(char)); |
1 | 891 |
} |
892 |
size_t upper_needs = 0; |
|
893 |
if (aligned_upper_new_high > upper_high()) { |
|
37984
5e9b81de0fce
8067785: Using AlwaysPreTouch does not always touch all pages
stefank
parents:
37428
diff
changeset
|
894 |
upper_needs = pointer_delta(aligned_upper_new_high, upper_high(), sizeof(char)); |
1 | 895 |
} |
896 |
||
897 |
// Check contiguity. |
|
37984
5e9b81de0fce
8067785: Using AlwaysPreTouch does not always touch all pages
stefank
parents:
37428
diff
changeset
|
898 |
assert(low_boundary() <= lower_high() && lower_high() <= lower_high_boundary(), |
1 | 899 |
"high address must be contained within the region"); |
37984
5e9b81de0fce
8067785: Using AlwaysPreTouch does not always touch all pages
stefank
parents:
37428
diff
changeset
|
900 |
assert(lower_high_boundary() <= middle_high() && middle_high() <= middle_high_boundary(), |
1 | 901 |
"high address must be contained within the region"); |
37984
5e9b81de0fce
8067785: Using AlwaysPreTouch does not always touch all pages
stefank
parents:
37428
diff
changeset
|
902 |
assert(middle_high_boundary() <= upper_high() && upper_high() <= upper_high_boundary(), |
1 | 903 |
"high address must be contained within the region"); |
904 |
||
905 |
// Commit regions |
|
906 |
if (lower_needs > 0) { |
|
37984
5e9b81de0fce
8067785: Using AlwaysPreTouch does not always touch all pages
stefank
parents:
37428
diff
changeset
|
907 |
assert(lower_high() + lower_needs <= lower_high_boundary(), "must not expand beyond region"); |
5e9b81de0fce
8067785: Using AlwaysPreTouch does not always touch all pages
stefank
parents:
37428
diff
changeset
|
908 |
if (!commit_expanded(lower_high(), lower_needs, _lower_alignment, pre_touch, _executable)) { |
1 | 909 |
return false; |
18069
e6d4971c8650
8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents:
17113
diff
changeset
|
910 |
} |
37984
5e9b81de0fce
8067785: Using AlwaysPreTouch does not always touch all pages
stefank
parents:
37428
diff
changeset
|
911 |
_lower_high += lower_needs; |
1 | 912 |
} |
37984
5e9b81de0fce
8067785: Using AlwaysPreTouch does not always touch all pages
stefank
parents:
37428
diff
changeset
|
913 |
|
1 | 914 |
if (middle_needs > 0) { |
37984
5e9b81de0fce
8067785: Using AlwaysPreTouch does not always touch all pages
stefank
parents:
37428
diff
changeset
|
915 |
assert(middle_high() + middle_needs <= middle_high_boundary(), "must not expand beyond region"); |
5e9b81de0fce
8067785: Using AlwaysPreTouch does not always touch all pages
stefank
parents:
37428
diff
changeset
|
916 |
if (!commit_expanded(middle_high(), middle_needs, _middle_alignment, pre_touch, _executable)) { |
1 | 917 |
return false; |
918 |
} |
|
919 |
_middle_high += middle_needs; |
|
920 |
} |
|
37984
5e9b81de0fce
8067785: Using AlwaysPreTouch does not always touch all pages
stefank
parents:
37428
diff
changeset
|
921 |
|
1 | 922 |
if (upper_needs > 0) { |
37984
5e9b81de0fce
8067785: Using AlwaysPreTouch does not always touch all pages
stefank
parents:
37428
diff
changeset
|
923 |
assert(upper_high() + upper_needs <= upper_high_boundary(), "must not expand beyond region"); |
5e9b81de0fce
8067785: Using AlwaysPreTouch does not always touch all pages
stefank
parents:
37428
diff
changeset
|
924 |
if (!commit_expanded(upper_high(), upper_needs, _upper_alignment, pre_touch, _executable)) { |
1 | 925 |
return false; |
926 |
} |
|
37984
5e9b81de0fce
8067785: Using AlwaysPreTouch does not always touch all pages
stefank
parents:
37428
diff
changeset
|
927 |
_upper_high += upper_needs; |
1 | 928 |
} |
929 |
||
930 |
_high += bytes; |
|
931 |
return true; |
|
932 |
} |
|
933 |
||
934 |
// A page is uncommitted if the contents of the entire page is deemed unusable. |
|
935 |
// Continue to decrement the high() pointer until it reaches a page boundary |
|
936 |
// in which case that particular page can now be uncommitted. |
|
937 |
void VirtualSpace::shrink_by(size_t size) { |
|
938 |
if (committed_size() < size) |
|
939 |
fatal("Cannot shrink virtual space to negative size"); |
|
940 |
||
941 |
if (special()) { |
|
942 |
// don't uncommit if the entire space is pinned in memory |
|
943 |
_high -= size; |
|
944 |
return; |
|
945 |
} |
|
946 |
||
947 |
char* unaligned_new_high = high() - size; |
|
948 |
assert(unaligned_new_high >= low_boundary(), "cannot shrink past lower boundary"); |
|
949 |
||
950 |
// Calculate new unaligned address |
|
951 |
char* unaligned_upper_new_high = |
|
952 |
MAX2(unaligned_new_high, middle_high_boundary()); |
|
953 |
char* unaligned_middle_new_high = |
|
954 |
MAX2(unaligned_new_high, lower_high_boundary()); |
|
955 |
char* unaligned_lower_new_high = |
|
956 |
MAX2(unaligned_new_high, low_boundary()); |
|
957 |
||
958 |
// Align address to region's alignment |
|
46620
750c6edff33b
8178500: Replace usages of round_to and round_down with align_up and align_down
stefank
parents:
46619
diff
changeset
|
959 |
char* aligned_upper_new_high = align_up(unaligned_upper_new_high, upper_alignment()); |
750c6edff33b
8178500: Replace usages of round_to and round_down with align_up and align_down
stefank
parents:
46619
diff
changeset
|
960 |
char* aligned_middle_new_high = align_up(unaligned_middle_new_high, middle_alignment()); |
750c6edff33b
8178500: Replace usages of round_to and round_down with align_up and align_down
stefank
parents:
46619
diff
changeset
|
961 |
char* aligned_lower_new_high = align_up(unaligned_lower_new_high, lower_alignment()); |
1 | 962 |
|
963 |
// Determine which regions need to shrink |
|
964 |
size_t upper_needs = 0; |
|
965 |
if (aligned_upper_new_high < upper_high()) { |
|
966 |
upper_needs = |
|
967 |
pointer_delta(upper_high(), aligned_upper_new_high, sizeof(char)); |
|
968 |
} |
|
969 |
size_t middle_needs = 0; |
|
970 |
if (aligned_middle_new_high < middle_high()) { |
|
971 |
middle_needs = |
|
972 |
pointer_delta(middle_high(), aligned_middle_new_high, sizeof(char)); |
|
973 |
} |
|
974 |
size_t lower_needs = 0; |
|
975 |
if (aligned_lower_new_high < lower_high()) { |
|
976 |
lower_needs = |
|
977 |
pointer_delta(lower_high(), aligned_lower_new_high, sizeof(char)); |
|
978 |
} |
|
979 |
||
980 |
// Check contiguity. |
|
981 |
assert(middle_high_boundary() <= upper_high() && |
|
982 |
upper_high() <= upper_high_boundary(), |
|
983 |
"high address must be contained within the region"); |
|
984 |
assert(lower_high_boundary() <= middle_high() && |
|
985 |
middle_high() <= middle_high_boundary(), |
|
986 |
"high address must be contained within the region"); |
|
987 |
assert(low_boundary() <= lower_high() && |
|
988 |
lower_high() <= lower_high_boundary(), |
|
989 |
"high address must be contained within the region"); |
|
990 |
||
991 |
// Uncommit |
|
992 |
if (upper_needs > 0) { |
|
993 |
assert(middle_high_boundary() <= aligned_upper_new_high && |
|
994 |
aligned_upper_new_high + upper_needs <= upper_high_boundary(), |
|
995 |
"must not shrink beyond region"); |
|
996 |
if (!os::uncommit_memory(aligned_upper_new_high, upper_needs)) { |
|
997 |
debug_only(warning("os::uncommit_memory failed")); |
|
998 |
return; |
|
999 |
} else { |
|
1000 |
_upper_high -= upper_needs; |
|
1001 |
} |
|
1002 |
} |
|
1003 |
if (middle_needs > 0) { |
|
1004 |
assert(lower_high_boundary() <= aligned_middle_new_high && |
|
1005 |
aligned_middle_new_high + middle_needs <= middle_high_boundary(), |
|
1006 |
"must not shrink beyond region"); |
|
1007 |
if (!os::uncommit_memory(aligned_middle_new_high, middle_needs)) { |
|
1008 |
debug_only(warning("os::uncommit_memory failed")); |
|
1009 |
return; |
|
1010 |
} else { |
|
1011 |
_middle_high -= middle_needs; |
|
1012 |
} |
|
1013 |
} |
|
1014 |
if (lower_needs > 0) { |
|
1015 |
assert(low_boundary() <= aligned_lower_new_high && |
|
1016 |
aligned_lower_new_high + lower_needs <= lower_high_boundary(), |
|
1017 |
"must not shrink beyond region"); |
|
1018 |
if (!os::uncommit_memory(aligned_lower_new_high, lower_needs)) { |
|
1019 |
debug_only(warning("os::uncommit_memory failed")); |
|
1020 |
return; |
|
1021 |
} else { |
|
1022 |
_lower_high -= lower_needs; |
|
1023 |
} |
|
1024 |
} |
|
1025 |
||
1026 |
_high -= size; |
|
1027 |
} |
|
1028 |
||
1029 |
#ifndef PRODUCT |
|
1030 |
void VirtualSpace::check_for_contiguity() { |
|
1031 |
// Check contiguity. |
|
1032 |
assert(low_boundary() <= lower_high() && |
|
1033 |
lower_high() <= lower_high_boundary(), |
|
1034 |
"high address must be contained within the region"); |
|
1035 |
assert(lower_high_boundary() <= middle_high() && |
|
1036 |
middle_high() <= middle_high_boundary(), |
|
1037 |
"high address must be contained within the region"); |
|
1038 |
assert(middle_high_boundary() <= upper_high() && |
|
1039 |
upper_high() <= upper_high_boundary(), |
|
1040 |
"high address must be contained within the region"); |
|
1041 |
assert(low() >= low_boundary(), "low"); |
|
1042 |
assert(low_boundary() <= lower_high_boundary(), "lower high boundary"); |
|
1043 |
assert(upper_high_boundary() <= high_boundary(), "upper high boundary"); |
|
1044 |
assert(high() <= upper_high(), "upper high"); |
|
1045 |
} |
|
1046 |
||
19993
b1d392324718
8024752: Log TraceMetadata* output to gclog_or_tty instead of tty
stefank
parents:
19989
diff
changeset
|
1047 |
void VirtualSpace::print_on(outputStream* out) { |
b1d392324718
8024752: Log TraceMetadata* output to gclog_or_tty instead of tty
stefank
parents:
19989
diff
changeset
|
1048 |
out->print ("Virtual space:"); |
b1d392324718
8024752: Log TraceMetadata* output to gclog_or_tty instead of tty
stefank
parents:
19989
diff
changeset
|
1049 |
if (special()) out->print(" (pinned in memory)"); |
b1d392324718
8024752: Log TraceMetadata* output to gclog_or_tty instead of tty
stefank
parents:
19989
diff
changeset
|
1050 |
out->cr(); |
b1d392324718
8024752: Log TraceMetadata* output to gclog_or_tty instead of tty
stefank
parents:
19989
diff
changeset
|
1051 |
out->print_cr(" - committed: " SIZE_FORMAT, committed_size()); |
b1d392324718
8024752: Log TraceMetadata* output to gclog_or_tty instead of tty
stefank
parents:
19989
diff
changeset
|
1052 |
out->print_cr(" - reserved: " SIZE_FORMAT, reserved_size()); |
33148
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
33105
diff
changeset
|
1053 |
out->print_cr(" - [low, high]: [" INTPTR_FORMAT ", " INTPTR_FORMAT "]", p2i(low()), p2i(high())); |
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
33105
diff
changeset
|
1054 |
out->print_cr(" - [low_b, high_b]: [" INTPTR_FORMAT ", " INTPTR_FORMAT "]", p2i(low_boundary()), p2i(high_boundary())); |
1 | 1055 |
} |
1056 |
||
19993
b1d392324718
8024752: Log TraceMetadata* output to gclog_or_tty instead of tty
stefank
parents:
19989
diff
changeset
|
1057 |
void VirtualSpace::print() { |
b1d392324718
8024752: Log TraceMetadata* output to gclog_or_tty instead of tty
stefank
parents:
19989
diff
changeset
|
1058 |
print_on(tty); |
b1d392324718
8024752: Log TraceMetadata* output to gclog_or_tty instead of tty
stefank
parents:
19989
diff
changeset
|
1059 |
} |
19546
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1060 |
|
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1061 |
/////////////// Unit tests /////////////// |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1062 |
|
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1063 |
#ifndef PRODUCT |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1064 |
|
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1065 |
#define test_log(...) \ |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1066 |
do {\ |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1067 |
if (VerboseInternalVMTests) { \ |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1068 |
tty->print_cr(__VA_ARGS__); \ |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1069 |
tty->flush(); \ |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1070 |
}\ |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1071 |
} while (false) |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1072 |
|
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1073 |
class TestReservedSpace : AllStatic { |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1074 |
public: |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1075 |
static void small_page_write(void* addr, size_t size) { |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1076 |
size_t page_size = os::vm_page_size(); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1077 |
|
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1078 |
char* end = (char*)addr + size; |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1079 |
for (char* p = (char*)addr; p < end; p += page_size) { |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1080 |
*p = 1; |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1081 |
} |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1082 |
} |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1083 |
|
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1084 |
static void release_memory_for_test(ReservedSpace rs) { |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1085 |
if (rs.special()) { |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1086 |
guarantee(os::release_memory_special(rs.base(), rs.size()), "Shouldn't fail"); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1087 |
} else { |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1088 |
guarantee(os::release_memory(rs.base(), rs.size()), "Shouldn't fail"); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1089 |
} |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1090 |
} |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1091 |
|
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1092 |
static void test_reserved_space1(size_t size, size_t alignment) { |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1093 |
test_log("test_reserved_space1(%p)", (void*) (uintptr_t) size); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1094 |
|
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
1095 |
assert(is_aligned(size, alignment), "Incorrect input parameters"); |
19546
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1096 |
|
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1097 |
ReservedSpace rs(size, // size |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1098 |
alignment, // alignment |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1099 |
UseLargePages, // large |
28372
ce0aad4b8c44
8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents:
28208
diff
changeset
|
1100 |
(char *)NULL); // requested_address |
19546
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1101 |
|
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1102 |
test_log(" rs.special() == %d", rs.special()); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1103 |
|
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1104 |
assert(rs.base() != NULL, "Must be"); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1105 |
assert(rs.size() == size, "Must be"); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1106 |
|
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
1107 |
assert(is_aligned(rs.base(), alignment), "aligned sizes should always give aligned addresses"); |
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
1108 |
assert(is_aligned(rs.size(), alignment), "aligned sizes should always give aligned addresses"); |
19546
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1109 |
|
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1110 |
if (rs.special()) { |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1111 |
small_page_write(rs.base(), size); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1112 |
} |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1113 |
|
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1114 |
release_memory_for_test(rs); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1115 |
} |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1116 |
|
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1117 |
static void test_reserved_space2(size_t size) { |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1118 |
test_log("test_reserved_space2(%p)", (void*)(uintptr_t)size); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1119 |
|
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
1120 |
assert(is_aligned(size, os::vm_allocation_granularity()), "Must be at least AG aligned"); |
19546
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1121 |
|
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1122 |
ReservedSpace rs(size); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1123 |
|
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1124 |
test_log(" rs.special() == %d", rs.special()); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1125 |
|
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1126 |
assert(rs.base() != NULL, "Must be"); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1127 |
assert(rs.size() == size, "Must be"); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1128 |
|
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1129 |
if (rs.special()) { |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1130 |
small_page_write(rs.base(), size); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1131 |
} |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1132 |
|
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1133 |
release_memory_for_test(rs); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1134 |
} |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1135 |
|
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1136 |
static void test_reserved_space3(size_t size, size_t alignment, bool maybe_large) { |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1137 |
test_log("test_reserved_space3(%p, %p, %d)", |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1138 |
(void*)(uintptr_t)size, (void*)(uintptr_t)alignment, maybe_large); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1139 |
|
38009
290ae73980f7
8053885: test/runtime/memory/RunUnitTestsConcurrently.java fails on solaris with largepage options
stefank
parents:
37984
diff
changeset
|
1140 |
if (size < alignment) { |
290ae73980f7
8053885: test/runtime/memory/RunUnitTestsConcurrently.java fails on solaris with largepage options
stefank
parents:
37984
diff
changeset
|
1141 |
// Tests might set -XX:LargePageSizeInBytes=<small pages> and cause unexpected input arguments for this test. |
290ae73980f7
8053885: test/runtime/memory/RunUnitTestsConcurrently.java fails on solaris with largepage options
stefank
parents:
37984
diff
changeset
|
1142 |
assert((size_t)os::vm_page_size() == os::large_page_size(), "Test needs further refinement"); |
290ae73980f7
8053885: test/runtime/memory/RunUnitTestsConcurrently.java fails on solaris with largepage options
stefank
parents:
37984
diff
changeset
|
1143 |
return; |
290ae73980f7
8053885: test/runtime/memory/RunUnitTestsConcurrently.java fails on solaris with largepage options
stefank
parents:
37984
diff
changeset
|
1144 |
} |
290ae73980f7
8053885: test/runtime/memory/RunUnitTestsConcurrently.java fails on solaris with largepage options
stefank
parents:
37984
diff
changeset
|
1145 |
|
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
1146 |
assert(is_aligned(size, os::vm_allocation_granularity()), "Must be at least AG aligned"); |
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
1147 |
assert(is_aligned(size, alignment), "Must be at least aligned against alignment"); |
19546
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1148 |
|
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1149 |
bool large = maybe_large && UseLargePages && size >= os::large_page_size(); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1150 |
|
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1151 |
ReservedSpace rs(size, alignment, large, false); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1152 |
|
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1153 |
test_log(" rs.special() == %d", rs.special()); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1154 |
|
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1155 |
assert(rs.base() != NULL, "Must be"); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1156 |
assert(rs.size() == size, "Must be"); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1157 |
|
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1158 |
if (rs.special()) { |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1159 |
small_page_write(rs.base(), size); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1160 |
} |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1161 |
|
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1162 |
release_memory_for_test(rs); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1163 |
} |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1164 |
|
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1165 |
|
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1166 |
static void test_reserved_space1() { |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1167 |
size_t size = 2 * 1024 * 1024; |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1168 |
size_t ag = os::vm_allocation_granularity(); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1169 |
|
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1170 |
test_reserved_space1(size, ag); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1171 |
test_reserved_space1(size * 2, ag); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1172 |
test_reserved_space1(size * 10, ag); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1173 |
} |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1174 |
|
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1175 |
static void test_reserved_space2() { |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1176 |
size_t size = 2 * 1024 * 1024; |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1177 |
size_t ag = os::vm_allocation_granularity(); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1178 |
|
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1179 |
test_reserved_space2(size * 1); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1180 |
test_reserved_space2(size * 2); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1181 |
test_reserved_space2(size * 10); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1182 |
test_reserved_space2(ag); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1183 |
test_reserved_space2(size - ag); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1184 |
test_reserved_space2(size); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1185 |
test_reserved_space2(size + ag); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1186 |
test_reserved_space2(size * 2); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1187 |
test_reserved_space2(size * 2 - ag); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1188 |
test_reserved_space2(size * 2 + ag); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1189 |
test_reserved_space2(size * 3); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1190 |
test_reserved_space2(size * 3 - ag); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1191 |
test_reserved_space2(size * 3 + ag); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1192 |
test_reserved_space2(size * 10); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1193 |
test_reserved_space2(size * 10 + size / 2); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1194 |
} |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1195 |
|
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1196 |
static void test_reserved_space3() { |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1197 |
size_t ag = os::vm_allocation_granularity(); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1198 |
|
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1199 |
test_reserved_space3(ag, ag , false); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1200 |
test_reserved_space3(ag * 2, ag , false); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1201 |
test_reserved_space3(ag * 3, ag , false); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1202 |
test_reserved_space3(ag * 2, ag * 2, false); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1203 |
test_reserved_space3(ag * 4, ag * 2, false); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1204 |
test_reserved_space3(ag * 8, ag * 2, false); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1205 |
test_reserved_space3(ag * 4, ag * 4, false); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1206 |
test_reserved_space3(ag * 8, ag * 4, false); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1207 |
test_reserved_space3(ag * 16, ag * 4, false); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1208 |
|
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1209 |
if (UseLargePages) { |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1210 |
size_t lp = os::large_page_size(); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1211 |
|
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1212 |
// Without large pages |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1213 |
test_reserved_space3(lp, ag * 4, false); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1214 |
test_reserved_space3(lp * 2, ag * 4, false); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1215 |
test_reserved_space3(lp * 4, ag * 4, false); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1216 |
test_reserved_space3(lp, lp , false); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1217 |
test_reserved_space3(lp * 2, lp , false); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1218 |
test_reserved_space3(lp * 3, lp , false); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1219 |
test_reserved_space3(lp * 2, lp * 2, false); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1220 |
test_reserved_space3(lp * 4, lp * 2, false); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1221 |
test_reserved_space3(lp * 8, lp * 2, false); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1222 |
|
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1223 |
// With large pages |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1224 |
test_reserved_space3(lp, ag * 4 , true); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1225 |
test_reserved_space3(lp * 2, ag * 4, true); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1226 |
test_reserved_space3(lp * 4, ag * 4, true); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1227 |
test_reserved_space3(lp, lp , true); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1228 |
test_reserved_space3(lp * 2, lp , true); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1229 |
test_reserved_space3(lp * 3, lp , true); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1230 |
test_reserved_space3(lp * 2, lp * 2, true); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1231 |
test_reserved_space3(lp * 4, lp * 2, true); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1232 |
test_reserved_space3(lp * 8, lp * 2, true); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1233 |
} |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1234 |
} |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1235 |
|
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1236 |
static void test_reserved_space() { |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1237 |
test_reserved_space1(); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1238 |
test_reserved_space2(); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1239 |
test_reserved_space3(); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1240 |
} |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1241 |
}; |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1242 |
|
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1243 |
void TestReservedSpace_test() { |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1244 |
TestReservedSpace::test_reserved_space(); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1245 |
} |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1246 |
|
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31620
diff
changeset
|
1247 |
#define assert_equals(actual, expected) \ |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31620
diff
changeset
|
1248 |
assert(actual == expected, \ |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31620
diff
changeset
|
1249 |
"Got " SIZE_FORMAT " expected " \ |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31620
diff
changeset
|
1250 |
SIZE_FORMAT, actual, expected); |
19989
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1251 |
|
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1252 |
#define assert_ge(value1, value2) \ |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1253 |
assert(value1 >= value2, \ |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31620
diff
changeset
|
1254 |
"'" #value1 "': " SIZE_FORMAT " '" \ |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31620
diff
changeset
|
1255 |
#value2 "': " SIZE_FORMAT, value1, value2); |
19989
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1256 |
|
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1257 |
#define assert_lt(value1, value2) \ |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1258 |
assert(value1 < value2, \ |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31620
diff
changeset
|
1259 |
"'" #value1 "': " SIZE_FORMAT " '" \ |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31620
diff
changeset
|
1260 |
#value2 "': " SIZE_FORMAT, value1, value2); |
19989
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1261 |
|
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1262 |
|
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1263 |
class TestVirtualSpace : AllStatic { |
20402
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1264 |
enum TestLargePages { |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1265 |
Default, |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1266 |
Disable, |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1267 |
Reserve, |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1268 |
Commit |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1269 |
}; |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1270 |
|
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1271 |
static ReservedSpace reserve_memory(size_t reserve_size_aligned, TestLargePages mode) { |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1272 |
switch(mode) { |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1273 |
default: |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1274 |
case Default: |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1275 |
case Reserve: |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1276 |
return ReservedSpace(reserve_size_aligned); |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1277 |
case Disable: |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1278 |
case Commit: |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1279 |
return ReservedSpace(reserve_size_aligned, |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1280 |
os::vm_allocation_granularity(), |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1281 |
/* large */ false, /* exec */ false); |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1282 |
} |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1283 |
} |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1284 |
|
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1285 |
static bool initialize_virtual_space(VirtualSpace& vs, ReservedSpace rs, TestLargePages mode) { |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1286 |
switch(mode) { |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1287 |
default: |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1288 |
case Default: |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1289 |
case Reserve: |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1290 |
return vs.initialize(rs, 0); |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1291 |
case Disable: |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1292 |
return vs.initialize_with_granularity(rs, 0, os::vm_page_size()); |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1293 |
case Commit: |
28631 | 1294 |
return vs.initialize_with_granularity(rs, 0, os::page_size_for_region_unaligned(rs.size(), 1)); |
20402
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1295 |
} |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1296 |
} |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1297 |
|
19989
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1298 |
public: |
20402
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1299 |
static void test_virtual_space_actual_committed_space(size_t reserve_size, size_t commit_size, |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1300 |
TestLargePages mode = Default) { |
19989
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1301 |
size_t granularity = os::vm_allocation_granularity(); |
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
1302 |
size_t reserve_size_aligned = align_up(reserve_size, granularity); |
19989
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1303 |
|
20402
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1304 |
ReservedSpace reserved = reserve_memory(reserve_size_aligned, mode); |
19989
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1305 |
|
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1306 |
assert(reserved.is_reserved(), "Must be"); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1307 |
|
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1308 |
VirtualSpace vs; |
20402
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1309 |
bool initialized = initialize_virtual_space(vs, reserved, mode); |
19989
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1310 |
assert(initialized, "Failed to initialize VirtualSpace"); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1311 |
|
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1312 |
vs.expand_by(commit_size, false); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1313 |
|
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1314 |
if (vs.special()) { |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1315 |
assert_equals(vs.actual_committed_size(), reserve_size_aligned); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1316 |
} else { |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1317 |
assert_ge(vs.actual_committed_size(), commit_size); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1318 |
// Approximate the commit granularity. |
20402
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1319 |
// Make sure that we don't commit using large pages |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1320 |
// if large pages has been disabled for this VirtualSpace. |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1321 |
size_t commit_granularity = (mode == Disable || !UseLargePages) ? |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1322 |
os::vm_page_size() : os::large_page_size(); |
19989
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1323 |
assert_lt(vs.actual_committed_size(), commit_size + commit_granularity); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1324 |
} |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1325 |
|
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1326 |
reserved.release(); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1327 |
} |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1328 |
|
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1329 |
static void test_virtual_space_actual_committed_space_one_large_page() { |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1330 |
if (!UseLargePages) { |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1331 |
return; |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1332 |
} |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1333 |
|
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1334 |
size_t large_page_size = os::large_page_size(); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1335 |
|
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1336 |
ReservedSpace reserved(large_page_size, large_page_size, true, false); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1337 |
|
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1338 |
assert(reserved.is_reserved(), "Must be"); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1339 |
|
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1340 |
VirtualSpace vs; |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1341 |
bool initialized = vs.initialize(reserved, 0); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1342 |
assert(initialized, "Failed to initialize VirtualSpace"); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1343 |
|
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1344 |
vs.expand_by(large_page_size, false); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1345 |
|
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1346 |
assert_equals(vs.actual_committed_size(), large_page_size); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1347 |
|
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1348 |
reserved.release(); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1349 |
} |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1350 |
|
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1351 |
static void test_virtual_space_actual_committed_space() { |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1352 |
test_virtual_space_actual_committed_space(4 * K, 0); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1353 |
test_virtual_space_actual_committed_space(4 * K, 4 * K); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1354 |
test_virtual_space_actual_committed_space(8 * K, 0); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1355 |
test_virtual_space_actual_committed_space(8 * K, 4 * K); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1356 |
test_virtual_space_actual_committed_space(8 * K, 8 * K); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1357 |
test_virtual_space_actual_committed_space(12 * K, 0); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1358 |
test_virtual_space_actual_committed_space(12 * K, 4 * K); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1359 |
test_virtual_space_actual_committed_space(12 * K, 8 * K); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1360 |
test_virtual_space_actual_committed_space(12 * K, 12 * K); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1361 |
test_virtual_space_actual_committed_space(64 * K, 0); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1362 |
test_virtual_space_actual_committed_space(64 * K, 32 * K); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1363 |
test_virtual_space_actual_committed_space(64 * K, 64 * K); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1364 |
test_virtual_space_actual_committed_space(2 * M, 0); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1365 |
test_virtual_space_actual_committed_space(2 * M, 4 * K); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1366 |
test_virtual_space_actual_committed_space(2 * M, 64 * K); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1367 |
test_virtual_space_actual_committed_space(2 * M, 1 * M); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1368 |
test_virtual_space_actual_committed_space(2 * M, 2 * M); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1369 |
test_virtual_space_actual_committed_space(10 * M, 0); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1370 |
test_virtual_space_actual_committed_space(10 * M, 4 * K); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1371 |
test_virtual_space_actual_committed_space(10 * M, 8 * K); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1372 |
test_virtual_space_actual_committed_space(10 * M, 1 * M); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1373 |
test_virtual_space_actual_committed_space(10 * M, 2 * M); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1374 |
test_virtual_space_actual_committed_space(10 * M, 5 * M); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1375 |
test_virtual_space_actual_committed_space(10 * M, 10 * M); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1376 |
} |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1377 |
|
20402
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1378 |
static void test_virtual_space_disable_large_pages() { |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1379 |
if (!UseLargePages) { |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1380 |
return; |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1381 |
} |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1382 |
// These test cases verify that if we force VirtualSpace to disable large pages |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1383 |
test_virtual_space_actual_committed_space(10 * M, 0, Disable); |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1384 |
test_virtual_space_actual_committed_space(10 * M, 4 * K, Disable); |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1385 |
test_virtual_space_actual_committed_space(10 * M, 8 * K, Disable); |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1386 |
test_virtual_space_actual_committed_space(10 * M, 1 * M, Disable); |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1387 |
test_virtual_space_actual_committed_space(10 * M, 2 * M, Disable); |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1388 |
test_virtual_space_actual_committed_space(10 * M, 5 * M, Disable); |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1389 |
test_virtual_space_actual_committed_space(10 * M, 10 * M, Disable); |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1390 |
|
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1391 |
test_virtual_space_actual_committed_space(10 * M, 0, Reserve); |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1392 |
test_virtual_space_actual_committed_space(10 * M, 4 * K, Reserve); |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1393 |
test_virtual_space_actual_committed_space(10 * M, 8 * K, Reserve); |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1394 |
test_virtual_space_actual_committed_space(10 * M, 1 * M, Reserve); |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1395 |
test_virtual_space_actual_committed_space(10 * M, 2 * M, Reserve); |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1396 |
test_virtual_space_actual_committed_space(10 * M, 5 * M, Reserve); |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1397 |
test_virtual_space_actual_committed_space(10 * M, 10 * M, Reserve); |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1398 |
|
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1399 |
test_virtual_space_actual_committed_space(10 * M, 0, Commit); |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1400 |
test_virtual_space_actual_committed_space(10 * M, 4 * K, Commit); |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1401 |
test_virtual_space_actual_committed_space(10 * M, 8 * K, Commit); |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1402 |
test_virtual_space_actual_committed_space(10 * M, 1 * M, Commit); |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1403 |
test_virtual_space_actual_committed_space(10 * M, 2 * M, Commit); |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1404 |
test_virtual_space_actual_committed_space(10 * M, 5 * M, Commit); |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1405 |
test_virtual_space_actual_committed_space(10 * M, 10 * M, Commit); |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1406 |
} |
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1407 |
|
19989
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1408 |
static void test_virtual_space() { |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1409 |
test_virtual_space_actual_committed_space(); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1410 |
test_virtual_space_actual_committed_space_one_large_page(); |
20402
9def9d6d969a
8025526: VirtualSpace should support per-instance disabling of large pages
mgerdin
parents:
19993
diff
changeset
|
1411 |
test_virtual_space_disable_large_pages(); |
19989
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1412 |
} |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1413 |
}; |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1414 |
|
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1415 |
void TestVirtualSpace_test() { |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1416 |
TestVirtualSpace::test_virtual_space(); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1417 |
} |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19546
diff
changeset
|
1418 |
|
19546
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1419 |
#endif // PRODUCT |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
18069
diff
changeset
|
1420 |
|
1 | 1421 |
#endif |