author | tschatzl |
Wed, 25 Nov 2015 14:43:29 +0100 | |
changeset 34300 | 6075c1e0e913 |
parent 33105 | 294e48b4f704 |
child 38177 | b0c9cb06506b |
permissions | -rw-r--r-- |
26160 | 1 |
/* |
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
2 |
* Copyright (c) 2001, 2015, 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/g1BiasedArray.hpp" |
27 |
#include "gc/g1/g1RegionToSpaceMapper.hpp" |
|
26163
89f44df5b438
8055635: Missing include in g1RegionToSpaceMapper.hpp results in unresolved symbol of fastdebug build without precompiled headers
tschatzl
parents:
26160
diff
changeset
|
28 |
#include "memory/allocation.inline.hpp" |
30291
54cdc5c1a9cb
8068352: Move virtualspace.* out of src/share/vm/runtime to memory directory
coleenp
parents:
30158
diff
changeset
|
29 |
#include "memory/virtualspace.hpp" |
26160 | 30 |
#include "services/memTracker.hpp" |
31 |
#include "utilities/bitMap.inline.hpp" |
|
32 |
||
33 |
G1RegionToSpaceMapper::G1RegionToSpaceMapper(ReservedSpace rs, |
|
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
34 |
size_t used_size, |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
35 |
size_t page_size, |
26160 | 36 |
size_t region_granularity, |
37 |
MemoryType type) : |
|
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
38 |
_storage(rs, used_size, page_size), |
26160 | 39 |
_region_granularity(region_granularity), |
40 |
_listener(NULL), |
|
41 |
_commit_map() { |
|
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
42 |
guarantee(is_power_of_2(page_size), "must be"); |
26160 | 43 |
guarantee(is_power_of_2(region_granularity), "must be"); |
44 |
||
45 |
MemTracker::record_virtual_memory_type((address)rs.base(), type); |
|
46 |
} |
|
47 |
||
48 |
// G1RegionToSpaceMapper implementation where the region granularity is larger than |
|
49 |
// or the same as the commit granularity. |
|
50 |
// Basically, the space corresponding to one region region spans several OS pages. |
|
51 |
class G1RegionsLargerThanCommitSizeMapper : public G1RegionToSpaceMapper { |
|
52 |
private: |
|
53 |
size_t _pages_per_region; |
|
54 |
||
55 |
public: |
|
56 |
G1RegionsLargerThanCommitSizeMapper(ReservedSpace rs, |
|
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
57 |
size_t actual_size, |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
58 |
size_t page_size, |
26160 | 59 |
size_t alloc_granularity, |
60 |
size_t commit_factor, |
|
61 |
MemoryType type) : |
|
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
62 |
G1RegionToSpaceMapper(rs, actual_size, page_size, alloc_granularity, type), |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
63 |
_pages_per_region(alloc_granularity / (page_size * commit_factor)) { |
26160 | 64 |
|
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
65 |
guarantee(alloc_granularity >= page_size, "allocation granularity smaller than commit granularity"); |
26160 | 66 |
_commit_map.resize(rs.size() * commit_factor / alloc_granularity, /* in_resource_area */ false); |
67 |
} |
|
68 |
||
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
69 |
virtual void commit_regions(uint start_idx, size_t num_regions) { |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
70 |
bool zero_filled = _storage.commit((size_t)start_idx * _pages_per_region, num_regions * _pages_per_region); |
26160 | 71 |
_commit_map.set_range(start_idx, start_idx + num_regions); |
28482
e1a8d03c342f
8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
sjohanss
parents:
27149
diff
changeset
|
72 |
fire_on_commit(start_idx, num_regions, zero_filled); |
26160 | 73 |
} |
74 |
||
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
75 |
virtual void uncommit_regions(uint start_idx, size_t num_regions) { |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
76 |
_storage.uncommit((size_t)start_idx * _pages_per_region, num_regions * _pages_per_region); |
26160 | 77 |
_commit_map.clear_range(start_idx, start_idx + num_regions); |
78 |
} |
|
79 |
}; |
|
80 |
||
81 |
// G1RegionToSpaceMapper implementation where the region granularity is smaller |
|
82 |
// than the commit granularity. |
|
83 |
// Basically, the contents of one OS page span several regions. |
|
84 |
class G1RegionsSmallerThanCommitSizeMapper : public G1RegionToSpaceMapper { |
|
85 |
private: |
|
86 |
class CommitRefcountArray : public G1BiasedMappedArray<uint> { |
|
87 |
protected: |
|
88 |
virtual uint default_value() const { return 0; } |
|
89 |
}; |
|
90 |
||
91 |
size_t _regions_per_page; |
|
92 |
||
93 |
CommitRefcountArray _refcounts; |
|
94 |
||
95 |
uintptr_t region_idx_to_page_idx(uint region) const { |
|
96 |
return region / _regions_per_page; |
|
97 |
} |
|
98 |
||
99 |
public: |
|
100 |
G1RegionsSmallerThanCommitSizeMapper(ReservedSpace rs, |
|
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
101 |
size_t actual_size, |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
102 |
size_t page_size, |
26160 | 103 |
size_t alloc_granularity, |
104 |
size_t commit_factor, |
|
105 |
MemoryType type) : |
|
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
106 |
G1RegionToSpaceMapper(rs, actual_size, page_size, alloc_granularity, type), |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
107 |
_regions_per_page((page_size * commit_factor) / alloc_granularity), _refcounts() { |
26160 | 108 |
|
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
109 |
guarantee((page_size * commit_factor) >= alloc_granularity, "allocation granularity smaller than commit granularity"); |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
110 |
_refcounts.initialize((HeapWord*)rs.base(), (HeapWord*)(rs.base() + align_size_up(rs.size(), page_size)), page_size); |
26160 | 111 |
_commit_map.resize(rs.size() * commit_factor / alloc_granularity, /* in_resource_area */ false); |
112 |
} |
|
113 |
||
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
114 |
virtual void commit_regions(uint start_idx, size_t num_regions) { |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
115 |
for (uint i = start_idx; i < start_idx + num_regions; i++) { |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
30764
diff
changeset
|
116 |
assert(!_commit_map.at(i), "Trying to commit storage at region %u that is already committed", i); |
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
117 |
size_t idx = region_idx_to_page_idx(i); |
26160 | 118 |
uint old_refcount = _refcounts.get_by_index(idx); |
27149 | 119 |
bool zero_filled = false; |
26160 | 120 |
if (old_refcount == 0) { |
28482
e1a8d03c342f
8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
sjohanss
parents:
27149
diff
changeset
|
121 |
zero_filled = _storage.commit(idx, 1); |
26160 | 122 |
} |
123 |
_refcounts.set_by_index(idx, old_refcount + 1); |
|
124 |
_commit_map.set_bit(i); |
|
27149 | 125 |
fire_on_commit(i, 1, zero_filled); |
26160 | 126 |
} |
127 |
} |
|
128 |
||
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
129 |
virtual void uncommit_regions(uint start_idx, size_t num_regions) { |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
130 |
for (uint i = start_idx; i < start_idx + num_regions; i++) { |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
30764
diff
changeset
|
131 |
assert(_commit_map.at(i), "Trying to uncommit storage at region %u that is not committed", i); |
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
132 |
size_t idx = region_idx_to_page_idx(i); |
26160 | 133 |
uint old_refcount = _refcounts.get_by_index(idx); |
134 |
assert(old_refcount > 0, "must be"); |
|
135 |
if (old_refcount == 1) { |
|
136 |
_storage.uncommit(idx, 1); |
|
137 |
} |
|
138 |
_refcounts.set_by_index(idx, old_refcount - 1); |
|
139 |
_commit_map.clear_bit(i); |
|
140 |
} |
|
141 |
} |
|
142 |
}; |
|
143 |
||
27149 | 144 |
void G1RegionToSpaceMapper::fire_on_commit(uint start_idx, size_t num_regions, bool zero_filled) { |
26160 | 145 |
if (_listener != NULL) { |
27149 | 146 |
_listener->on_commit(start_idx, num_regions, zero_filled); |
26160 | 147 |
} |
148 |
} |
|
149 |
||
150 |
G1RegionToSpaceMapper* G1RegionToSpaceMapper::create_mapper(ReservedSpace rs, |
|
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
151 |
size_t actual_size, |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
152 |
size_t page_size, |
26160 | 153 |
size_t region_granularity, |
154 |
size_t commit_factor, |
|
155 |
MemoryType type) { |
|
156 |
||
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
157 |
if (region_granularity >= (page_size * commit_factor)) { |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
158 |
return new G1RegionsLargerThanCommitSizeMapper(rs, actual_size, page_size, region_granularity, commit_factor, type); |
26160 | 159 |
} else { |
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
160 |
return new G1RegionsSmallerThanCommitSizeMapper(rs, actual_size, page_size, region_granularity, commit_factor, type); |
26160 | 161 |
} |
162 |
} |