Mercurial > hg > graal-jvmci-8
comparison src/share/vm/gc_implementation/g1/g1RegionToSpaceMapper.cpp @ 22977:33e421924c67
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
Summary: Allow use of large pages for auxiliary data structures in G1. Clean up existing interfaces.
Reviewed-by: jmasa, pliden, stefank
author | tschatzl |
---|---|
date | Tue, 07 Apr 2015 10:53:51 +0200 |
parents | ae52ee069062 |
children |
comparison
equal
deleted
inserted
replaced
22976:5788dbd1f2d6 | 22977:33e421924c67 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 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 | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
29 #include "runtime/virtualspace.hpp" | 29 #include "runtime/virtualspace.hpp" |
30 #include "services/memTracker.hpp" | 30 #include "services/memTracker.hpp" |
31 #include "utilities/bitMap.inline.hpp" | 31 #include "utilities/bitMap.inline.hpp" |
32 | 32 |
33 G1RegionToSpaceMapper::G1RegionToSpaceMapper(ReservedSpace rs, | 33 G1RegionToSpaceMapper::G1RegionToSpaceMapper(ReservedSpace rs, |
34 size_t commit_granularity, | 34 size_t used_size, |
35 size_t page_size, | |
35 size_t region_granularity, | 36 size_t region_granularity, |
36 MemoryType type) : | 37 MemoryType type) : |
37 _storage(), | 38 _storage(rs, used_size, page_size), |
38 _commit_granularity(commit_granularity), | |
39 _region_granularity(region_granularity), | 39 _region_granularity(region_granularity), |
40 _listener(NULL), | 40 _listener(NULL), |
41 _commit_map() { | 41 _commit_map() { |
42 guarantee(is_power_of_2(commit_granularity), "must be"); | 42 guarantee(is_power_of_2(page_size), "must be"); |
43 guarantee(is_power_of_2(region_granularity), "must be"); | 43 guarantee(is_power_of_2(region_granularity), "must be"); |
44 _storage.initialize_with_granularity(rs, commit_granularity); | |
45 | 44 |
46 MemTracker::record_virtual_memory_type((address)rs.base(), type); | 45 MemTracker::record_virtual_memory_type((address)rs.base(), type); |
47 } | 46 } |
48 | 47 |
49 // G1RegionToSpaceMapper implementation where the region granularity is larger than | 48 // G1RegionToSpaceMapper implementation where the region granularity is larger than |
53 private: | 52 private: |
54 size_t _pages_per_region; | 53 size_t _pages_per_region; |
55 | 54 |
56 public: | 55 public: |
57 G1RegionsLargerThanCommitSizeMapper(ReservedSpace rs, | 56 G1RegionsLargerThanCommitSizeMapper(ReservedSpace rs, |
58 size_t os_commit_granularity, | 57 size_t actual_size, |
58 size_t page_size, | |
59 size_t alloc_granularity, | 59 size_t alloc_granularity, |
60 size_t commit_factor, | 60 size_t commit_factor, |
61 MemoryType type) : | 61 MemoryType type) : |
62 G1RegionToSpaceMapper(rs, os_commit_granularity, alloc_granularity, type), | 62 G1RegionToSpaceMapper(rs, actual_size, page_size, alloc_granularity, type), |
63 _pages_per_region(alloc_granularity / (os_commit_granularity * commit_factor)) { | 63 _pages_per_region(alloc_granularity / (page_size * commit_factor)) { |
64 | 64 |
65 guarantee(alloc_granularity >= os_commit_granularity, "allocation granularity smaller than commit granularity"); | 65 guarantee(alloc_granularity >= page_size, "allocation granularity smaller than commit granularity"); |
66 _commit_map.resize(rs.size() * commit_factor / alloc_granularity, /* in_resource_area */ false); | 66 _commit_map.resize(rs.size() * commit_factor / alloc_granularity, /* in_resource_area */ false); |
67 } | 67 } |
68 | 68 |
69 virtual void commit_regions(uintptr_t start_idx, size_t num_regions) { | 69 virtual void commit_regions(uint start_idx, size_t num_regions) { |
70 bool zero_filled = _storage.commit(start_idx * _pages_per_region, num_regions * _pages_per_region); | 70 bool zero_filled = _storage.commit((size_t)start_idx * _pages_per_region, num_regions * _pages_per_region); |
71 _commit_map.set_range(start_idx, start_idx + num_regions); | 71 _commit_map.set_range(start_idx, start_idx + num_regions); |
72 fire_on_commit(start_idx, num_regions, zero_filled); | 72 fire_on_commit(start_idx, num_regions, zero_filled); |
73 } | 73 } |
74 | 74 |
75 virtual void uncommit_regions(uintptr_t start_idx, size_t num_regions) { | 75 virtual void uncommit_regions(uint start_idx, size_t num_regions) { |
76 _storage.uncommit(start_idx * _pages_per_region, num_regions * _pages_per_region); | 76 _storage.uncommit((size_t)start_idx * _pages_per_region, num_regions * _pages_per_region); |
77 _commit_map.clear_range(start_idx, start_idx + num_regions); | 77 _commit_map.clear_range(start_idx, start_idx + num_regions); |
78 } | 78 } |
79 }; | 79 }; |
80 | 80 |
81 // G1RegionToSpaceMapper implementation where the region granularity is smaller | 81 // G1RegionToSpaceMapper implementation where the region granularity is smaller |
96 return region / _regions_per_page; | 96 return region / _regions_per_page; |
97 } | 97 } |
98 | 98 |
99 public: | 99 public: |
100 G1RegionsSmallerThanCommitSizeMapper(ReservedSpace rs, | 100 G1RegionsSmallerThanCommitSizeMapper(ReservedSpace rs, |
101 size_t os_commit_granularity, | 101 size_t actual_size, |
102 size_t page_size, | |
102 size_t alloc_granularity, | 103 size_t alloc_granularity, |
103 size_t commit_factor, | 104 size_t commit_factor, |
104 MemoryType type) : | 105 MemoryType type) : |
105 G1RegionToSpaceMapper(rs, os_commit_granularity, alloc_granularity, type), | 106 G1RegionToSpaceMapper(rs, actual_size, page_size, alloc_granularity, type), |
106 _regions_per_page((os_commit_granularity * commit_factor) / alloc_granularity), _refcounts() { | 107 _regions_per_page((page_size * commit_factor) / alloc_granularity), _refcounts() { |
107 | 108 |
108 guarantee((os_commit_granularity * commit_factor) >= alloc_granularity, "allocation granularity smaller than commit granularity"); | 109 guarantee((page_size * commit_factor) >= alloc_granularity, "allocation granularity smaller than commit granularity"); |
109 _refcounts.initialize((HeapWord*)rs.base(), (HeapWord*)(rs.base() + rs.size()), os_commit_granularity); | 110 _refcounts.initialize((HeapWord*)rs.base(), (HeapWord*)(rs.base() + align_size_up(rs.size(), page_size)), page_size); |
110 _commit_map.resize(rs.size() * commit_factor / alloc_granularity, /* in_resource_area */ false); | 111 _commit_map.resize(rs.size() * commit_factor / alloc_granularity, /* in_resource_area */ false); |
111 } | 112 } |
112 | 113 |
113 virtual void commit_regions(uintptr_t start_idx, size_t num_regions) { | 114 virtual void commit_regions(uint start_idx, size_t num_regions) { |
114 for (uintptr_t i = start_idx; i < start_idx + num_regions; i++) { | 115 for (uint i = start_idx; i < start_idx + num_regions; i++) { |
115 assert(!_commit_map.at(i), err_msg("Trying to commit storage at region "INTPTR_FORMAT" that is already committed", i)); | 116 assert(!_commit_map.at(i), err_msg("Trying to commit storage at region %u that is already committed", i)); |
116 uintptr_t idx = region_idx_to_page_idx(i); | 117 size_t idx = region_idx_to_page_idx(i); |
117 uint old_refcount = _refcounts.get_by_index(idx); | 118 uint old_refcount = _refcounts.get_by_index(idx); |
118 bool zero_filled = false; | 119 bool zero_filled = false; |
119 if (old_refcount == 0) { | 120 if (old_refcount == 0) { |
120 zero_filled = _storage.commit(idx, 1); | 121 zero_filled = _storage.commit(idx, 1); |
121 } | 122 } |
123 _commit_map.set_bit(i); | 124 _commit_map.set_bit(i); |
124 fire_on_commit(i, 1, zero_filled); | 125 fire_on_commit(i, 1, zero_filled); |
125 } | 126 } |
126 } | 127 } |
127 | 128 |
128 virtual void uncommit_regions(uintptr_t start_idx, size_t num_regions) { | 129 virtual void uncommit_regions(uint start_idx, size_t num_regions) { |
129 for (uintptr_t i = start_idx; i < start_idx + num_regions; i++) { | 130 for (uint i = start_idx; i < start_idx + num_regions; i++) { |
130 assert(_commit_map.at(i), err_msg("Trying to uncommit storage at region "INTPTR_FORMAT" that is not committed", i)); | 131 assert(_commit_map.at(i), err_msg("Trying to uncommit storage at region %u that is not committed", i)); |
131 uintptr_t idx = region_idx_to_page_idx(i); | 132 size_t idx = region_idx_to_page_idx(i); |
132 uint old_refcount = _refcounts.get_by_index(idx); | 133 uint old_refcount = _refcounts.get_by_index(idx); |
133 assert(old_refcount > 0, "must be"); | 134 assert(old_refcount > 0, "must be"); |
134 if (old_refcount == 1) { | 135 if (old_refcount == 1) { |
135 _storage.uncommit(idx, 1); | 136 _storage.uncommit(idx, 1); |
136 } | 137 } |
145 _listener->on_commit(start_idx, num_regions, zero_filled); | 146 _listener->on_commit(start_idx, num_regions, zero_filled); |
146 } | 147 } |
147 } | 148 } |
148 | 149 |
149 G1RegionToSpaceMapper* G1RegionToSpaceMapper::create_mapper(ReservedSpace rs, | 150 G1RegionToSpaceMapper* G1RegionToSpaceMapper::create_mapper(ReservedSpace rs, |
150 size_t os_commit_granularity, | 151 size_t actual_size, |
152 size_t page_size, | |
151 size_t region_granularity, | 153 size_t region_granularity, |
152 size_t commit_factor, | 154 size_t commit_factor, |
153 MemoryType type) { | 155 MemoryType type) { |
154 | 156 |
155 if (region_granularity >= (os_commit_granularity * commit_factor)) { | 157 if (region_granularity >= (page_size * commit_factor)) { |
156 return new G1RegionsLargerThanCommitSizeMapper(rs, os_commit_granularity, region_granularity, commit_factor, type); | 158 return new G1RegionsLargerThanCommitSizeMapper(rs, actual_size, page_size, region_granularity, commit_factor, type); |
157 } else { | 159 } else { |
158 return new G1RegionsSmallerThanCommitSizeMapper(rs, os_commit_granularity, region_granularity, commit_factor, type); | 160 return new G1RegionsSmallerThanCommitSizeMapper(rs, actual_size, page_size, region_granularity, commit_factor, type); |
159 } | 161 } |
160 } | 162 } |