Mercurial > hg > graal-jvmci-8
comparison src/share/vm/gc_implementation/g1/g1PageBasedVirtualSpace.cpp @ 22811:06face256a8c
8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
Summary: Making sure committed memory is cleared when re-committed, even if using large pages.
Reviewed-by: jwilhelm, tschatzl
author | sjohanss |
---|---|
date | Mon, 12 Jan 2015 15:24:29 +0100 |
parents | 8d5f66b42c53 |
children | 340ca8812af9 |
comparison
equal
deleted
inserted
replaced
22810:f7e9598536c1 | 22811:06face256a8c |
---|---|
43 # include "os_bsd.inline.hpp" | 43 # include "os_bsd.inline.hpp" |
44 #endif | 44 #endif |
45 #include "utilities/bitMap.inline.hpp" | 45 #include "utilities/bitMap.inline.hpp" |
46 | 46 |
47 G1PageBasedVirtualSpace::G1PageBasedVirtualSpace() : _low_boundary(NULL), | 47 G1PageBasedVirtualSpace::G1PageBasedVirtualSpace() : _low_boundary(NULL), |
48 _high_boundary(NULL), _committed(), _page_size(0), _special(false), _executable(false) { | 48 _high_boundary(NULL), _committed(), _page_size(0), _special(false), |
49 _dirty(), _executable(false) { | |
49 } | 50 } |
50 | 51 |
51 bool G1PageBasedVirtualSpace::initialize_with_granularity(ReservedSpace rs, size_t page_size) { | 52 bool G1PageBasedVirtualSpace::initialize_with_granularity(ReservedSpace rs, size_t page_size) { |
52 if (!rs.is_reserved()) { | 53 if (!rs.is_reserved()) { |
53 return false; // Allocation failed. | 54 return false; // Allocation failed. |
64 _page_size = page_size; | 65 _page_size = page_size; |
65 | 66 |
66 assert(_committed.size() == 0, "virtual space initialized more than once"); | 67 assert(_committed.size() == 0, "virtual space initialized more than once"); |
67 uintx size_in_bits = rs.size() / page_size; | 68 uintx size_in_bits = rs.size() / page_size; |
68 _committed.resize(size_in_bits, /* in_resource_area */ false); | 69 _committed.resize(size_in_bits, /* in_resource_area */ false); |
70 if (_special) { | |
71 _dirty.resize(size_in_bits, /* in_resource_area */ false); | |
72 } | |
69 | 73 |
70 return true; | 74 return true; |
71 } | 75 } |
72 | 76 |
73 | 77 |
82 _high_boundary = NULL; | 86 _high_boundary = NULL; |
83 _special = false; | 87 _special = false; |
84 _executable = false; | 88 _executable = false; |
85 _page_size = 0; | 89 _page_size = 0; |
86 _committed.resize(0, false); | 90 _committed.resize(0, false); |
91 _dirty.resize(0, false); | |
87 } | 92 } |
88 | 93 |
89 size_t G1PageBasedVirtualSpace::committed_size() const { | 94 size_t G1PageBasedVirtualSpace::committed_size() const { |
90 return _committed.count_one_bits() * _page_size; | 95 return _committed.count_one_bits() * _page_size; |
91 } | 96 } |
118 | 123 |
119 size_t G1PageBasedVirtualSpace::byte_size_for_pages(size_t num) { | 124 size_t G1PageBasedVirtualSpace::byte_size_for_pages(size_t num) { |
120 return num * _page_size; | 125 return num * _page_size; |
121 } | 126 } |
122 | 127 |
123 MemRegion G1PageBasedVirtualSpace::commit(uintptr_t start, size_t size_in_pages) { | 128 bool G1PageBasedVirtualSpace::commit(uintptr_t start, size_t size_in_pages) { |
124 // We need to make sure to commit all pages covered by the given area. | 129 // We need to make sure to commit all pages covered by the given area. |
125 guarantee(is_area_uncommitted(start, size_in_pages), "Specified area is not uncommitted"); | 130 guarantee(is_area_uncommitted(start, size_in_pages), "Specified area is not uncommitted"); |
126 | 131 |
127 if (!_special) { | 132 bool zero_filled = true; |
133 uintptr_t end = start + size_in_pages; | |
134 | |
135 if (_special) { | |
136 // Check for dirty pages and update zero_filled if any found. | |
137 if (_dirty.get_next_one_offset(start,end) < end) { | |
138 zero_filled = false; | |
139 _dirty.clear_range(start, end); | |
140 } | |
141 } else { | |
128 os::commit_memory_or_exit(page_start(start), byte_size_for_pages(size_in_pages), _executable, | 142 os::commit_memory_or_exit(page_start(start), byte_size_for_pages(size_in_pages), _executable, |
129 err_msg("Failed to commit pages from "SIZE_FORMAT" of length "SIZE_FORMAT, start, size_in_pages)); | 143 err_msg("Failed to commit pages from "SIZE_FORMAT" of length "SIZE_FORMAT, start, size_in_pages)); |
130 } | 144 } |
131 _committed.set_range(start, start + size_in_pages); | 145 _committed.set_range(start, end); |
132 | 146 |
133 MemRegion result((HeapWord*)page_start(start), byte_size_for_pages(size_in_pages) / HeapWordSize); | 147 return zero_filled; |
134 return result; | |
135 } | 148 } |
136 | 149 |
137 MemRegion G1PageBasedVirtualSpace::uncommit(uintptr_t start, size_t size_in_pages) { | 150 void G1PageBasedVirtualSpace::uncommit(uintptr_t start, size_t size_in_pages) { |
138 guarantee(is_area_committed(start, size_in_pages), "checking"); | 151 guarantee(is_area_committed(start, size_in_pages), "checking"); |
139 | 152 |
140 if (!_special) { | 153 if (_special) { |
154 // Mark that memory is dirty. If committed again the memory might | |
155 // need to be cleared explicitly. | |
156 _dirty.set_range(start, start + size_in_pages); | |
157 } else { | |
141 os::uncommit_memory(page_start(start), byte_size_for_pages(size_in_pages)); | 158 os::uncommit_memory(page_start(start), byte_size_for_pages(size_in_pages)); |
142 } | 159 } |
143 | 160 |
144 _committed.clear_range(start, start + size_in_pages); | 161 _committed.clear_range(start, start + size_in_pages); |
145 | |
146 MemRegion result((HeapWord*)page_start(start), byte_size_for_pages(size_in_pages) / HeapWordSize); | |
147 return result; | |
148 } | 162 } |
149 | 163 |
150 bool G1PageBasedVirtualSpace::contains(const void* p) const { | 164 bool G1PageBasedVirtualSpace::contains(const void* p) const { |
151 return _low_boundary <= (const char*) p && (const char*) p < _high_boundary; | 165 return _low_boundary <= (const char*) p && (const char*) p < _high_boundary; |
152 } | 166 } |
153 | 167 |
154 #ifndef PRODUCT | 168 #ifndef PRODUCT |
155 void G1PageBasedVirtualSpace::print_on(outputStream* out) { | 169 void G1PageBasedVirtualSpace::print_on(outputStream* out) { |
156 out->print ("Virtual space:"); | 170 out->print ("Virtual space:"); |
157 if (special()) out->print(" (pinned in memory)"); | 171 if (_special) out->print(" (pinned in memory)"); |
158 out->cr(); | 172 out->cr(); |
159 out->print_cr(" - committed: " SIZE_FORMAT, committed_size()); | 173 out->print_cr(" - committed: " SIZE_FORMAT, committed_size()); |
160 out->print_cr(" - reserved: " SIZE_FORMAT, reserved_size()); | 174 out->print_cr(" - reserved: " SIZE_FORMAT, reserved_size()); |
161 out->print_cr(" - [low_b, high_b]: [" INTPTR_FORMAT ", " INTPTR_FORMAT "]", p2i(_low_boundary), p2i(_high_boundary)); | 175 out->print_cr(" - [low_b, high_b]: [" INTPTR_FORMAT ", " INTPTR_FORMAT "]", p2i(_low_boundary), p2i(_high_boundary)); |
162 } | 176 } |