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"
26 #include "gc/g1/g1AllocRegion.inline.hpp"
27 #include "gc/g1/g1EvacStats.inline.hpp"
28 #include "gc/g1/g1CollectedHeap.inline.hpp"
29 #include "memory/resourceArea.hpp"
30 #include "runtime/orderAccess.inline.hpp"
31 #include "utilities/align.hpp"
32
33 G1CollectedHeap* G1AllocRegion::_g1h = NULL;
34 HeapRegion* G1AllocRegion::_dummy_region = NULL;
35
36 void G1AllocRegion::setup(G1CollectedHeap* g1h, HeapRegion* dummy_region) {
37 assert(_dummy_region == NULL, "should be set once");
38 assert(dummy_region != NULL, "pre-condition");
39 assert(dummy_region->free() == 0, "pre-condition");
40
41 // Make sure that any allocation attempt on this region will fail
42 // and will not trigger any asserts.
43 assert(allocate(dummy_region, 1, false) == NULL, "should fail");
44 assert(par_allocate(dummy_region, 1, false) == NULL, "should fail");
45 assert(allocate(dummy_region, 1, true) == NULL, "should fail");
46 assert(par_allocate(dummy_region, 1, true) == NULL, "should fail");
47
48 _g1h = g1h;
195 trace("released");
196 return (alloc_region == _dummy_region) ? NULL : alloc_region;
197 }
198
199 #ifndef PRODUCT
200 void G1AllocRegion::trace(const char* str, size_t min_word_size, size_t desired_word_size, size_t actual_word_size, HeapWord* result) {
201 // All the calls to trace that set either just the size or the size
202 // and the result are considered part of detailed tracing and are
203 // skipped during other tracing.
204
205 Log(gc, alloc, region) log;
206
207 if (!log.is_debug()) {
208 return;
209 }
210
211 bool detailed_info = log.is_trace();
212
213 if ((actual_word_size == 0 && result == NULL) || detailed_info) {
214 ResourceMark rm;
215 outputStream* out;
216 if (detailed_info) {
217 out = log.trace_stream();
218 } else {
219 out = log.debug_stream();
220 }
221
222 out->print("%s: %u ", _name, _count);
223
224 if (_alloc_region == NULL) {
225 out->print("NULL");
226 } else if (_alloc_region == _dummy_region) {
227 out->print("DUMMY");
228 } else {
229 out->print(HR_FORMAT, HR_FORMAT_PARAMS(_alloc_region));
230 }
231
232 out->print(" : %s", str);
233
234 if (detailed_info) {
235 if (result != NULL) {
236 out->print(" min " SIZE_FORMAT " desired " SIZE_FORMAT " actual " SIZE_FORMAT " " PTR_FORMAT,
237 min_word_size, desired_word_size, actual_word_size, p2i(result));
238 } else if (min_word_size != 0) {
239 out->print(" min " SIZE_FORMAT " desired " SIZE_FORMAT, min_word_size, desired_word_size);
240 }
|
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"
26 #include "gc/g1/g1AllocRegion.inline.hpp"
27 #include "gc/g1/g1EvacStats.inline.hpp"
28 #include "gc/g1/g1CollectedHeap.inline.hpp"
29 #include "logging/log.hpp"
30 #include "logging/logStream.hpp"
31 #include "memory/resourceArea.hpp"
32 #include "runtime/orderAccess.inline.hpp"
33 #include "utilities/align.hpp"
34
35 G1CollectedHeap* G1AllocRegion::_g1h = NULL;
36 HeapRegion* G1AllocRegion::_dummy_region = NULL;
37
38 void G1AllocRegion::setup(G1CollectedHeap* g1h, HeapRegion* dummy_region) {
39 assert(_dummy_region == NULL, "should be set once");
40 assert(dummy_region != NULL, "pre-condition");
41 assert(dummy_region->free() == 0, "pre-condition");
42
43 // Make sure that any allocation attempt on this region will fail
44 // and will not trigger any asserts.
45 assert(allocate(dummy_region, 1, false) == NULL, "should fail");
46 assert(par_allocate(dummy_region, 1, false) == NULL, "should fail");
47 assert(allocate(dummy_region, 1, true) == NULL, "should fail");
48 assert(par_allocate(dummy_region, 1, true) == NULL, "should fail");
49
50 _g1h = g1h;
197 trace("released");
198 return (alloc_region == _dummy_region) ? NULL : alloc_region;
199 }
200
201 #ifndef PRODUCT
202 void G1AllocRegion::trace(const char* str, size_t min_word_size, size_t desired_word_size, size_t actual_word_size, HeapWord* result) {
203 // All the calls to trace that set either just the size or the size
204 // and the result are considered part of detailed tracing and are
205 // skipped during other tracing.
206
207 Log(gc, alloc, region) log;
208
209 if (!log.is_debug()) {
210 return;
211 }
212
213 bool detailed_info = log.is_trace();
214
215 if ((actual_word_size == 0 && result == NULL) || detailed_info) {
216 ResourceMark rm;
217 LogStream ls_trace(log.trace());
218 LogStream ls_debug(log.debug());
219 outputStream* out = detailed_info ? &ls_trace : &ls_debug;
220
221 out->print("%s: %u ", _name, _count);
222
223 if (_alloc_region == NULL) {
224 out->print("NULL");
225 } else if (_alloc_region == _dummy_region) {
226 out->print("DUMMY");
227 } else {
228 out->print(HR_FORMAT, HR_FORMAT_PARAMS(_alloc_region));
229 }
230
231 out->print(" : %s", str);
232
233 if (detailed_info) {
234 if (result != NULL) {
235 out->print(" min " SIZE_FORMAT " desired " SIZE_FORMAT " actual " SIZE_FORMAT " " PTR_FORMAT,
236 min_word_size, desired_word_size, actual_word_size, p2i(result));
237 } else if (min_word_size != 0) {
238 out->print(" min " SIZE_FORMAT " desired " SIZE_FORMAT, min_word_size, desired_word_size);
239 }
|