author | pliden |
Wed, 21 Feb 2018 07:46:40 +0100 | |
changeset 49030 | 1817d118ff66 |
parent 47634 | 6a0c42c40cd1 |
child 51332 | c25572739e7c |
permissions | -rw-r--r-- |
26160 | 1 |
/* |
49030
1817d118ff66
8198267: Allow GCId::current_raw() calls from non-NamedThreads
pliden
parents:
47634
diff
changeset
|
2 |
* Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved. |
26160 | 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 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
* |
|
23 |
*/ |
|
24 |
||
25 |
#include "precompiled.hpp" |
|
30764 | 26 |
#include "gc/g1/g1PageBasedVirtualSpace.hpp" |
41178 | 27 |
#include "gc/shared/workgroup.hpp" |
26160 | 28 |
#include "oops/markOop.hpp" |
29 |
#include "oops/oop.inline.hpp" |
|
41178 | 30 |
#include "runtime/atomic.hpp" |
40010 | 31 |
#include "runtime/os.inline.hpp" |
26160 | 32 |
#include "services/memTracker.hpp" |
46625 | 33 |
#include "utilities/align.hpp" |
26160 | 34 |
#include "utilities/bitMap.inline.hpp" |
35 |
||
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
36 |
G1PageBasedVirtualSpace::G1PageBasedVirtualSpace(ReservedSpace rs, size_t used_size, size_t page_size) : |
46745
f7b9bb98bb72
8176571: Fine bitmaps should be allocated as belonging to mtGC, not mtInternal
kbarrett
parents:
46625
diff
changeset
|
37 |
_low_boundary(NULL), _high_boundary(NULL), _committed(mtGC), _page_size(0), _special(false), |
f7b9bb98bb72
8176571: Fine bitmaps should be allocated as belonging to mtGC, not mtInternal
kbarrett
parents:
46625
diff
changeset
|
38 |
_dirty(mtGC), _executable(false) { |
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
39 |
initialize_with_page_size(rs, used_size, page_size); |
26160 | 40 |
} |
41 |
||
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
42 |
void G1PageBasedVirtualSpace::initialize_with_page_size(ReservedSpace rs, size_t used_size, size_t page_size) { |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
43 |
guarantee(rs.is_reserved(), "Given reserved space must have been reserved already."); |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
44 |
|
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
45 |
vmassert(_low_boundary == NULL, "VirtualSpace already initialized"); |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
46 |
vmassert(page_size > 0, "Page size must be non-zero."); |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
47 |
|
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
48 |
guarantee(is_aligned(rs.base(), page_size), |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
30764
diff
changeset
|
49 |
"Reserved space base " PTR_FORMAT " is not aligned to requested page size " SIZE_FORMAT, p2i(rs.base()), page_size); |
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
50 |
guarantee(is_aligned(used_size, os::vm_page_size()), |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
30764
diff
changeset
|
51 |
"Given used reserved space size needs to be OS page size aligned (%d bytes) but is " SIZE_FORMAT, os::vm_page_size(), used_size); |
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
52 |
guarantee(used_size <= rs.size(), |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
30764
diff
changeset
|
53 |
"Used size of reserved space " SIZE_FORMAT " bytes is smaller than reservation at " SIZE_FORMAT " bytes", used_size, rs.size()); |
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
54 |
guarantee(is_aligned(rs.size(), page_size), |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
30764
diff
changeset
|
55 |
"Expected that the virtual space is size aligned, but " SIZE_FORMAT " is not aligned to page size " SIZE_FORMAT, rs.size(), page_size); |
26160 | 56 |
|
57 |
_low_boundary = rs.base(); |
|
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
58 |
_high_boundary = _low_boundary + used_size; |
26160 | 59 |
|
60 |
_special = rs.special(); |
|
61 |
_executable = rs.executable(); |
|
62 |
||
63 |
_page_size = page_size; |
|
64 |
||
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
65 |
vmassert(_committed.size() == 0, "virtual space initialized more than once"); |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
66 |
BitMap::idx_t size_in_pages = rs.size() / page_size; |
38177 | 67 |
_committed.initialize(size_in_pages); |
28482
e1a8d03c342f
8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
sjohanss
parents:
28208
diff
changeset
|
68 |
if (_special) { |
38177 | 69 |
_dirty.initialize(size_in_pages); |
28482
e1a8d03c342f
8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
sjohanss
parents:
28208
diff
changeset
|
70 |
} |
26160 | 71 |
|
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
72 |
_tail_size = used_size % _page_size; |
26160 | 73 |
} |
74 |
||
75 |
G1PageBasedVirtualSpace::~G1PageBasedVirtualSpace() { |
|
76 |
// This does not release memory it never reserved. |
|
77 |
// Caller must release via rs.release(); |
|
78 |
_low_boundary = NULL; |
|
79 |
_high_boundary = NULL; |
|
80 |
_special = false; |
|
81 |
_executable = false; |
|
82 |
_page_size = 0; |
|
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
83 |
_tail_size = 0; |
26160 | 84 |
} |
85 |
||
86 |
size_t G1PageBasedVirtualSpace::committed_size() const { |
|
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
87 |
size_t result = _committed.count_one_bits() * _page_size; |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
88 |
// The last page might not be in full. |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
89 |
if (is_last_page_partial() && _committed.at(_committed.size() - 1)) { |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
90 |
result -= _page_size - _tail_size; |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
91 |
} |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
92 |
return result; |
26160 | 93 |
} |
94 |
||
95 |
size_t G1PageBasedVirtualSpace::reserved_size() const { |
|
96 |
return pointer_delta(_high_boundary, _low_boundary, sizeof(char)); |
|
97 |
} |
|
98 |
||
99 |
size_t G1PageBasedVirtualSpace::uncommitted_size() const { |
|
100 |
return reserved_size() - committed_size(); |
|
101 |
} |
|
102 |
||
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
103 |
size_t G1PageBasedVirtualSpace::addr_to_page_index(char* addr) const { |
26160 | 104 |
return (addr - _low_boundary) / _page_size; |
105 |
} |
|
106 |
||
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
107 |
bool G1PageBasedVirtualSpace::is_area_committed(size_t start_page, size_t size_in_pages) const { |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
108 |
size_t end_page = start_page + size_in_pages; |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
109 |
return _committed.get_next_zero_offset(start_page, end_page) >= end_page; |
26160 | 110 |
} |
111 |
||
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
112 |
bool G1PageBasedVirtualSpace::is_area_uncommitted(size_t start_page, size_t size_in_pages) const { |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
113 |
size_t end_page = start_page + size_in_pages; |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
114 |
return _committed.get_next_one_offset(start_page, end_page) >= end_page; |
26160 | 115 |
} |
116 |
||
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
117 |
char* G1PageBasedVirtualSpace::page_start(size_t index) const { |
26160 | 118 |
return _low_boundary + index * _page_size; |
119 |
} |
|
120 |
||
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
121 |
bool G1PageBasedVirtualSpace::is_after_last_page(size_t index) const { |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
122 |
guarantee(index <= _committed.size(), |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
30764
diff
changeset
|
123 |
"Given boundary page " SIZE_FORMAT " is beyond managed page count " SIZE_FORMAT, index, _committed.size()); |
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
124 |
return index == _committed.size(); |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
125 |
} |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
126 |
|
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
127 |
void G1PageBasedVirtualSpace::commit_preferred_pages(size_t start, size_t num_pages) { |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
128 |
vmassert(num_pages > 0, "No full pages to commit"); |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
129 |
vmassert(start + num_pages <= _committed.size(), |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
30764
diff
changeset
|
130 |
"Tried to commit area from page " SIZE_FORMAT " to page " SIZE_FORMAT " " |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
30764
diff
changeset
|
131 |
"that is outside of managed space of " SIZE_FORMAT " pages", |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
30764
diff
changeset
|
132 |
start, start + num_pages, _committed.size()); |
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
133 |
|
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
134 |
char* start_addr = page_start(start); |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
135 |
size_t size = num_pages * _page_size; |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
136 |
|
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
137 |
os::commit_memory_or_exit(start_addr, size, _page_size, _executable, |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
138 |
err_msg("Failed to commit area from " PTR_FORMAT " to " PTR_FORMAT " of length " SIZE_FORMAT ".", |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
30764
diff
changeset
|
139 |
p2i(start_addr), p2i(start_addr + size), size)); |
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
140 |
} |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
141 |
|
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
142 |
void G1PageBasedVirtualSpace::commit_tail() { |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
143 |
vmassert(_tail_size > 0, "The size of the tail area must be > 0 when reaching here"); |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
144 |
|
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
145 |
char* const aligned_end_address = align_down(_high_boundary, _page_size); |
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
146 |
os::commit_memory_or_exit(aligned_end_address, _tail_size, os::vm_page_size(), _executable, |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
147 |
err_msg("Failed to commit tail area from " PTR_FORMAT " to " PTR_FORMAT " of length " SIZE_FORMAT ".", |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
30764
diff
changeset
|
148 |
p2i(aligned_end_address), p2i(_high_boundary), _tail_size)); |
26160 | 149 |
} |
150 |
||
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
151 |
void G1PageBasedVirtualSpace::commit_internal(size_t start_page, size_t end_page) { |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
152 |
guarantee(start_page < end_page, |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
30764
diff
changeset
|
153 |
"Given start page " SIZE_FORMAT " is larger or equal to end page " SIZE_FORMAT, start_page, end_page); |
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
154 |
guarantee(end_page <= _committed.size(), |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
30764
diff
changeset
|
155 |
"Given end page " SIZE_FORMAT " is beyond end of managed page amount of " SIZE_FORMAT, end_page, _committed.size()); |
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
156 |
|
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
157 |
size_t pages = end_page - start_page; |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
158 |
bool need_to_commit_tail = is_after_last_page(end_page) && is_last_page_partial(); |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
159 |
|
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
160 |
// If we have to commit some (partial) tail area, decrease the amount of pages to avoid |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
161 |
// committing that in the full-page commit code. |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
162 |
if (need_to_commit_tail) { |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
163 |
pages--; |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
164 |
} |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
165 |
|
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
166 |
if (pages > 0) { |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
167 |
commit_preferred_pages(start_page, pages); |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
168 |
} |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
169 |
|
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
170 |
if (need_to_commit_tail) { |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
171 |
commit_tail(); |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
172 |
} |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
173 |
} |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
174 |
|
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
175 |
char* G1PageBasedVirtualSpace::bounded_end_addr(size_t end_page) const { |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
176 |
return MIN2(_high_boundary, page_start(end_page)); |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
177 |
} |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
178 |
|
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
179 |
void G1PageBasedVirtualSpace::pretouch_internal(size_t start_page, size_t end_page) { |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
180 |
guarantee(start_page < end_page, |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
30764
diff
changeset
|
181 |
"Given start page " SIZE_FORMAT " is larger or equal to end page " SIZE_FORMAT, start_page, end_page); |
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
182 |
|
41178 | 183 |
os::pretouch_memory(page_start(start_page), bounded_end_addr(end_page), _page_size); |
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
184 |
} |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
185 |
|
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
186 |
bool G1PageBasedVirtualSpace::commit(size_t start_page, size_t size_in_pages) { |
26160 | 187 |
// We need to make sure to commit all pages covered by the given area. |
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
188 |
guarantee(is_area_uncommitted(start_page, size_in_pages), "Specified area is not uncommitted"); |
26160 | 189 |
|
28482
e1a8d03c342f
8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
sjohanss
parents:
28208
diff
changeset
|
190 |
bool zero_filled = true; |
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
191 |
size_t end_page = start_page + size_in_pages; |
28482
e1a8d03c342f
8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
sjohanss
parents:
28208
diff
changeset
|
192 |
|
e1a8d03c342f
8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
sjohanss
parents:
28208
diff
changeset
|
193 |
if (_special) { |
e1a8d03c342f
8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
sjohanss
parents:
28208
diff
changeset
|
194 |
// Check for dirty pages and update zero_filled if any found. |
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
195 |
if (_dirty.get_next_one_offset(start_page, end_page) < end_page) { |
28482
e1a8d03c342f
8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
sjohanss
parents:
28208
diff
changeset
|
196 |
zero_filled = false; |
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
197 |
_dirty.clear_range(start_page, end_page); |
28482
e1a8d03c342f
8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
sjohanss
parents:
28208
diff
changeset
|
198 |
} |
e1a8d03c342f
8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
sjohanss
parents:
28208
diff
changeset
|
199 |
} else { |
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
200 |
commit_internal(start_page, end_page); |
26160 | 201 |
} |
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
202 |
_committed.set_range(start_page, end_page); |
26160 | 203 |
|
28482
e1a8d03c342f
8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
sjohanss
parents:
28208
diff
changeset
|
204 |
return zero_filled; |
26160 | 205 |
} |
206 |
||
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
207 |
void G1PageBasedVirtualSpace::uncommit_internal(size_t start_page, size_t end_page) { |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
208 |
guarantee(start_page < end_page, |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
30764
diff
changeset
|
209 |
"Given start page " SIZE_FORMAT " is larger or equal to end page " SIZE_FORMAT, start_page, end_page); |
26160 | 210 |
|
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
211 |
char* start_addr = page_start(start_page); |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
212 |
os::uncommit_memory(start_addr, pointer_delta(bounded_end_addr(end_page), start_addr, sizeof(char))); |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
213 |
} |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
214 |
|
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
215 |
void G1PageBasedVirtualSpace::uncommit(size_t start_page, size_t size_in_pages) { |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
216 |
guarantee(is_area_committed(start_page, size_in_pages), "checking"); |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
217 |
|
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
218 |
size_t end_page = start_page + size_in_pages; |
28482
e1a8d03c342f
8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
sjohanss
parents:
28208
diff
changeset
|
219 |
if (_special) { |
e1a8d03c342f
8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
sjohanss
parents:
28208
diff
changeset
|
220 |
// Mark that memory is dirty. If committed again the memory might |
e1a8d03c342f
8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
sjohanss
parents:
28208
diff
changeset
|
221 |
// need to be cleared explicitly. |
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
222 |
_dirty.set_range(start_page, end_page); |
28482
e1a8d03c342f
8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
sjohanss
parents:
28208
diff
changeset
|
223 |
} else { |
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
224 |
uncommit_internal(start_page, end_page); |
26160 | 225 |
} |
226 |
||
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
227 |
_committed.clear_range(start_page, end_page); |
26160 | 228 |
} |
229 |
||
41178 | 230 |
class G1PretouchTask : public AbstractGangTask { |
231 |
private: |
|
232 |
char* volatile _cur_addr; |
|
233 |
char* const _start_addr; |
|
234 |
char* const _end_addr; |
|
235 |
size_t const _page_size; |
|
236 |
public: |
|
237 |
G1PretouchTask(char* start_address, char* end_address, size_t page_size) : |
|
49030
1817d118ff66
8198267: Allow GCId::current_raw() calls from non-NamedThreads
pliden
parents:
47634
diff
changeset
|
238 |
AbstractGangTask("G1 PreTouch"), |
41178 | 239 |
_cur_addr(start_address), |
240 |
_start_addr(start_address), |
|
241 |
_end_addr(end_address), |
|
242 |
_page_size(page_size) { |
|
243 |
} |
|
244 |
||
245 |
virtual void work(uint worker_id) { |
|
246 |
size_t const actual_chunk_size = MAX2(chunk_size(), _page_size); |
|
247 |
while (true) { |
|
47634
6a0c42c40cd1
8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents:
47216
diff
changeset
|
248 |
char* touch_addr = Atomic::add(actual_chunk_size, &_cur_addr) - actual_chunk_size; |
41178 | 249 |
if (touch_addr < _start_addr || touch_addr >= _end_addr) { |
250 |
break; |
|
251 |
} |
|
252 |
char* end_addr = touch_addr + MIN2(actual_chunk_size, pointer_delta(_end_addr, touch_addr, sizeof(char))); |
|
253 |
os::pretouch_memory(touch_addr, end_addr, _page_size); |
|
254 |
} |
|
255 |
} |
|
256 |
||
257 |
static size_t chunk_size() { return PreTouchParallelChunkSize; } |
|
258 |
}; |
|
259 |
||
260 |
void G1PageBasedVirtualSpace::pretouch(size_t start_page, size_t size_in_pages, WorkGang* pretouch_gang) { |
|
42595
b1ae41a4eae9
8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
41178
diff
changeset
|
261 |
G1PretouchTask cl(page_start(start_page), bounded_end_addr(start_page + size_in_pages), _page_size); |
41178 | 262 |
|
42595
b1ae41a4eae9
8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
41178
diff
changeset
|
263 |
if (pretouch_gang != NULL) { |
b1ae41a4eae9
8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
41178
diff
changeset
|
264 |
size_t num_chunks = MAX2((size_t)1, size_in_pages * _page_size / MAX2(G1PretouchTask::chunk_size(), _page_size)); |
41178 | 265 |
|
42595
b1ae41a4eae9
8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
41178
diff
changeset
|
266 |
uint num_workers = MIN2((uint)num_chunks, pretouch_gang->active_workers()); |
b1ae41a4eae9
8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
41178
diff
changeset
|
267 |
log_debug(gc, heap)("Running %s with %u workers for " SIZE_FORMAT " work units pre-touching " SIZE_FORMAT "B.", |
b1ae41a4eae9
8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
41178
diff
changeset
|
268 |
cl.name(), num_workers, num_chunks, size_in_pages * _page_size); |
b1ae41a4eae9
8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
41178
diff
changeset
|
269 |
pretouch_gang->run_task(&cl, num_workers); |
b1ae41a4eae9
8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
41178
diff
changeset
|
270 |
} else { |
b1ae41a4eae9
8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
41178
diff
changeset
|
271 |
log_debug(gc, heap)("Running %s pre-touching " SIZE_FORMAT "B.", |
b1ae41a4eae9
8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
41178
diff
changeset
|
272 |
cl.name(), size_in_pages * _page_size); |
b1ae41a4eae9
8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
41178
diff
changeset
|
273 |
cl.work(0); |
b1ae41a4eae9
8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
41178
diff
changeset
|
274 |
} |
41178 | 275 |
} |
276 |
||
26160 | 277 |
bool G1PageBasedVirtualSpace::contains(const void* p) const { |
278 |
return _low_boundary <= (const char*) p && (const char*) p < _high_boundary; |
|
279 |
} |
|
280 |
||
281 |
#ifndef PRODUCT |
|
282 |
void G1PageBasedVirtualSpace::print_on(outputStream* out) { |
|
283 |
out->print ("Virtual space:"); |
|
28482
e1a8d03c342f
8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
sjohanss
parents:
28208
diff
changeset
|
284 |
if (_special) out->print(" (pinned in memory)"); |
26160 | 285 |
out->cr(); |
286 |
out->print_cr(" - committed: " SIZE_FORMAT, committed_size()); |
|
287 |
out->print_cr(" - reserved: " SIZE_FORMAT, reserved_size()); |
|
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
288 |
out->print_cr(" - preferred page size: " SIZE_FORMAT, _page_size); |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
289 |
out->print_cr(" - [low_b, high_b]: [" PTR_FORMAT ", " PTR_FORMAT "]", p2i(_low_boundary), p2i(_high_boundary)); |
26160 | 290 |
} |
291 |
||
292 |
void G1PageBasedVirtualSpace::print() { |
|
293 |
print_on(tty); |
|
294 |
} |
|
295 |
#endif |