1 /*
2 * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
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 *
4347 return survivor_attempt_allocation(word_size);
4348 }
4349 }
4350
4351 ShouldNotReachHere();
4352 // Trying to keep some compilers happy.
4353 return NULL;
4354 }
4355
4356 G1ParGCAllocBuffer::G1ParGCAllocBuffer(size_t gclab_word_size) :
4357 ParGCAllocBuffer(gclab_word_size), _retired(false) { }
4358
4359 G1ParScanThreadState::G1ParScanThreadState(G1CollectedHeap* g1h, uint queue_num)
4360 : _g1h(g1h),
4361 _refs(g1h->task_queue(queue_num)),
4362 _dcq(&g1h->dirty_card_queue_set()),
4363 _ct_bs((CardTableModRefBS*)_g1h->barrier_set()),
4364 _g1_rem(g1h->g1_rem_set()),
4365 _hash_seed(17), _queue_num(queue_num),
4366 _term_attempts(0),
4367 _surviving_alloc_buffer(g1h->desired_plab_sz(GCAllocForSurvived)),
4368 _tenured_alloc_buffer(g1h->desired_plab_sz(GCAllocForTenured)),
4369 _age_table(false),
4370 _strong_roots_time(0), _term_time(0),
4371 _alloc_buffer_waste(0), _undo_waste(0) {
4372 // we allocate G1YoungSurvRateNumRegions plus one entries, since
4373 // we "sacrifice" entry 0 to keep track of surviving bytes for
4374 // non-young regions (where the age is -1)
4375 // We also add a few elements at the beginning and at the end in
4376 // an attempt to eliminate cache contention
4377 uint real_length = 1 + _g1h->g1_policy()->young_cset_region_length();
4378 uint array_length = PADDING_ELEM_NUM +
4379 real_length +
4380 PADDING_ELEM_NUM;
4381 _surviving_young_words_base = NEW_C_HEAP_ARRAY(size_t, array_length, mtGC);
4382 if (_surviving_young_words_base == NULL)
4383 vm_exit_out_of_memory(array_length * sizeof(size_t),
4384 "Not enough space for young surv histo.");
4385 _surviving_young_words = _surviving_young_words_base + PADDING_ELEM_NUM;
4386 memset(_surviving_young_words, 0, (size_t) real_length * sizeof(size_t));
4387
4388 _alloc_buffers[GCAllocForSurvived] = &_surviving_alloc_buffer;
4389 _alloc_buffers[GCAllocForTenured] = &_tenured_alloc_buffer;
4390
4391 _start = os::elapsedTime();
4392 }
4393
4394 void
4395 G1ParScanThreadState::print_termination_stats_hdr(outputStream* const st)
4396 {
4397 st->print_raw_cr("GC Termination Stats");
4398 st->print_raw_cr(" elapsed --strong roots-- -------termination-------"
4399 " ------waste (KiB)------");
4400 st->print_raw_cr("thr ms ms % ms % attempts"
4401 " total alloc undo");
4402 st->print_raw_cr("--- --------- --------- ------ --------- ------ --------"
4403 " ------- ------- -------");
4404 }
4405
4406 void
4407 G1ParScanThreadState::print_termination_stats(int i,
4408 outputStream* const st) const
4409 {
|
1 /*
2 * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
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 *
4347 return survivor_attempt_allocation(word_size);
4348 }
4349 }
4350
4351 ShouldNotReachHere();
4352 // Trying to keep some compilers happy.
4353 return NULL;
4354 }
4355
4356 G1ParGCAllocBuffer::G1ParGCAllocBuffer(size_t gclab_word_size) :
4357 ParGCAllocBuffer(gclab_word_size), _retired(false) { }
4358
4359 G1ParScanThreadState::G1ParScanThreadState(G1CollectedHeap* g1h, uint queue_num)
4360 : _g1h(g1h),
4361 _refs(g1h->task_queue(queue_num)),
4362 _dcq(&g1h->dirty_card_queue_set()),
4363 _ct_bs((CardTableModRefBS*)_g1h->barrier_set()),
4364 _g1_rem(g1h->g1_rem_set()),
4365 _hash_seed(17), _queue_num(queue_num),
4366 _term_attempts(0),
4367 _age_table(false),
4368 _strong_roots_time(0), _term_time(0),
4369 _alloc_buffer_waste(0), _undo_waste(0) {
4370 // we allocate G1YoungSurvRateNumRegions plus one entries, since
4371 // we "sacrifice" entry 0 to keep track of surviving bytes for
4372 // non-young regions (where the age is -1)
4373 // We also add a few elements at the beginning and at the end in
4374 // an attempt to eliminate cache contention
4375 uint real_length = 1 + _g1h->g1_policy()->young_cset_region_length();
4376 uint array_length = PADDING_ELEM_NUM +
4377 real_length +
4378 PADDING_ELEM_NUM;
4379 _surviving_young_words_base = NEW_C_HEAP_ARRAY(size_t, array_length, mtGC);
4380 if (_surviving_young_words_base == NULL)
4381 vm_exit_out_of_memory(array_length * sizeof(size_t),
4382 "Not enough space for young surv histo.");
4383 _surviving_young_words = _surviving_young_words_base + PADDING_ELEM_NUM;
4384 memset(_surviving_young_words, 0, (size_t) real_length * sizeof(size_t));
4385
4386 for (int ap = GCAllocPurposeStart; ap < GCAllocPurposeCount; ++ap) {
4387 for (int pr = GCAllocPriorityStart; pr < GCAllocPriorityCount; ++pr) {
4388 _alloc_buffers[ap][pr] =
4389 new G1ParGCAllocBuffer(g1h->desired_plab_sz((GCAllocPurpose)ap));
4390 }
4391 }
4392
4393 _start = os::elapsedTime();
4394 }
4395
4396 void
4397 G1ParScanThreadState::print_termination_stats_hdr(outputStream* const st)
4398 {
4399 st->print_raw_cr("GC Termination Stats");
4400 st->print_raw_cr(" elapsed --strong roots-- -------termination-------"
4401 " ------waste (KiB)------");
4402 st->print_raw_cr("thr ms ms % ms % attempts"
4403 " total alloc undo");
4404 st->print_raw_cr("--- --------- --------- ------ --------- ------ --------"
4405 " ------- ------- -------");
4406 }
4407
4408 void
4409 G1ParScanThreadState::print_termination_stats(int i,
4410 outputStream* const st) const
4411 {
|