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 *
23 */
24
25 #include "precompiled.hpp"
26 #include "gc_implementation/parallelScavenge/adjoiningGenerations.hpp"
27 #include "gc_implementation/parallelScavenge/adjoiningVirtualSpaces.hpp"
28 #include "gc_implementation/parallelScavenge/cardTableExtension.hpp"
29 #include "gc_implementation/parallelScavenge/gcTaskManager.hpp"
30 #include "gc_implementation/parallelScavenge/generationSizer.hpp"
31 #include "gc_implementation/parallelScavenge/parallelScavengeHeap.inline.hpp"
32 #include "gc_implementation/parallelScavenge/psAdaptiveSizePolicy.hpp"
33 #include "gc_implementation/parallelScavenge/psMarkSweep.hpp"
34 #include "gc_implementation/parallelScavenge/psParallelCompact.hpp"
35 #include "gc_implementation/parallelScavenge/psPromotionManager.hpp"
36 #include "gc_implementation/parallelScavenge/psScavenge.hpp"
37 #include "gc_implementation/parallelScavenge/vmPSOperations.hpp"
38 #include "memory/gcLocker.inline.hpp"
39 #include "oops/oop.inline.hpp"
40 #include "runtime/handles.inline.hpp"
41 #include "runtime/java.hpp"
42 #include "runtime/vmThread.hpp"
43 #include "services/memTracker.hpp"
44 #include "utilities/vmError.hpp"
45
46 PSYoungGen* ParallelScavengeHeap::_young_gen = NULL;
47 PSOldGen* ParallelScavengeHeap::_old_gen = NULL;
48 PSAdaptiveSizePolicy* ParallelScavengeHeap::_size_policy = NULL;
49 PSGCAdaptivePolicyCounters* ParallelScavengeHeap::_gc_policy_counters = NULL;
50 ParallelScavengeHeap* ParallelScavengeHeap::_psh = NULL;
51 GCTaskManager* ParallelScavengeHeap::_gc_task_manager = NULL;
52
53 static void trace_gen_sizes(const char* const str,
54 size_t og_min, size_t og_max,
55 size_t yg_min, size_t yg_max)
56 {
57 if (TracePageSizes) {
625 }
626
627 size_t ParallelScavengeHeap::block_size(const HeapWord* addr) const {
628 return oop(addr)->size();
629 }
630
631 bool ParallelScavengeHeap::block_is_obj(const HeapWord* addr) const {
632 return block_start(addr) == addr;
633 }
634
635 jlong ParallelScavengeHeap::millis_since_last_gc() {
636 return UseParallelOldGC ?
637 PSParallelCompact::millis_since_last_gc() :
638 PSMarkSweep::millis_since_last_gc();
639 }
640
641 void ParallelScavengeHeap::prepare_for_verify() {
642 ensure_parsability(false); // no need to retire TLABs for verification
643 }
644
645 void ParallelScavengeHeap::print_on(outputStream* st) const {
646 young_gen()->print_on(st);
647 old_gen()->print_on(st);
648 MetaspaceAux::print_on(st);
649 }
650
651 void ParallelScavengeHeap::print_on_error(outputStream* st) const {
652 this->CollectedHeap::print_on_error(st);
653
654 if (UseParallelOldGC) {
655 st->cr();
656 PSParallelCompact::print_on_error(st);
657 }
658 }
659
660 void ParallelScavengeHeap::gc_threads_do(ThreadClosure* tc) const {
661 PSScavenge::gc_task_manager()->threads_do(tc);
662 }
663
664 void ParallelScavengeHeap::print_gc_threads_on(outputStream* st) const {
689 gclog_or_tty->print("eden ");
690 }
691 young_gen()->verify();
692 }
693 }
694
695 void ParallelScavengeHeap::print_heap_change(size_t prev_used) {
696 if (PrintGCDetails && Verbose) {
697 gclog_or_tty->print(" " SIZE_FORMAT
698 "->" SIZE_FORMAT
699 "(" SIZE_FORMAT ")",
700 prev_used, used(), capacity());
701 } else {
702 gclog_or_tty->print(" " SIZE_FORMAT "K"
703 "->" SIZE_FORMAT "K"
704 "(" SIZE_FORMAT "K)",
705 prev_used / K, used() / K, capacity() / K);
706 }
707 }
708
709 ParallelScavengeHeap* ParallelScavengeHeap::heap() {
710 assert(_psh != NULL, "Uninitialized access to ParallelScavengeHeap::heap()");
711 assert(_psh->kind() == CollectedHeap::ParallelScavengeHeap, "not a parallel scavenge heap");
712 return _psh;
713 }
714
715 // Before delegating the resize to the young generation,
716 // the reserved space for the young and old generations
717 // may be changed to accomodate the desired resize.
718 void ParallelScavengeHeap::resize_young_gen(size_t eden_size,
719 size_t survivor_size) {
720 if (UseAdaptiveGCBoundary) {
721 if (size_policy()->bytes_absorbed_from_eden() != 0) {
722 size_policy()->reset_bytes_absorbed_from_eden();
723 return; // The generation changed size already.
724 }
725 gens()->adjust_boundary_for_young_gen_needs(eden_size, survivor_size);
726 }
727
728 // Delegate the resize to the generation.
|
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 *
23 */
24
25 #include "precompiled.hpp"
26 #include "gc_implementation/parallelScavenge/adjoiningGenerations.hpp"
27 #include "gc_implementation/parallelScavenge/adjoiningVirtualSpaces.hpp"
28 #include "gc_implementation/parallelScavenge/cardTableExtension.hpp"
29 #include "gc_implementation/parallelScavenge/gcTaskManager.hpp"
30 #include "gc_implementation/parallelScavenge/generationSizer.hpp"
31 #include "gc_implementation/parallelScavenge/parallelScavengeHeap.inline.hpp"
32 #include "gc_implementation/parallelScavenge/psAdaptiveSizePolicy.hpp"
33 #include "gc_implementation/parallelScavenge/psMarkSweep.hpp"
34 #include "gc_implementation/parallelScavenge/psParallelCompact.hpp"
35 #include "gc_implementation/parallelScavenge/psPromotionManager.hpp"
36 #include "gc_implementation/parallelScavenge/psScavenge.hpp"
37 #include "gc_implementation/parallelScavenge/vmPSOperations.hpp"
38 #include "gc_implementation/shared/gcHeapSummary.hpp"
39 #include "gc_implementation/shared/gcWhen.hpp"
40 #include "memory/gcLocker.inline.hpp"
41 #include "oops/oop.inline.hpp"
42 #include "runtime/handles.inline.hpp"
43 #include "runtime/java.hpp"
44 #include "runtime/vmThread.hpp"
45 #include "services/memTracker.hpp"
46 #include "utilities/vmError.hpp"
47
48 PSYoungGen* ParallelScavengeHeap::_young_gen = NULL;
49 PSOldGen* ParallelScavengeHeap::_old_gen = NULL;
50 PSAdaptiveSizePolicy* ParallelScavengeHeap::_size_policy = NULL;
51 PSGCAdaptivePolicyCounters* ParallelScavengeHeap::_gc_policy_counters = NULL;
52 ParallelScavengeHeap* ParallelScavengeHeap::_psh = NULL;
53 GCTaskManager* ParallelScavengeHeap::_gc_task_manager = NULL;
54
55 static void trace_gen_sizes(const char* const str,
56 size_t og_min, size_t og_max,
57 size_t yg_min, size_t yg_max)
58 {
59 if (TracePageSizes) {
627 }
628
629 size_t ParallelScavengeHeap::block_size(const HeapWord* addr) const {
630 return oop(addr)->size();
631 }
632
633 bool ParallelScavengeHeap::block_is_obj(const HeapWord* addr) const {
634 return block_start(addr) == addr;
635 }
636
637 jlong ParallelScavengeHeap::millis_since_last_gc() {
638 return UseParallelOldGC ?
639 PSParallelCompact::millis_since_last_gc() :
640 PSMarkSweep::millis_since_last_gc();
641 }
642
643 void ParallelScavengeHeap::prepare_for_verify() {
644 ensure_parsability(false); // no need to retire TLABs for verification
645 }
646
647 PSHeapSummary ParallelScavengeHeap::create_ps_heap_summary() {
648 PSOldGen* old = old_gen();
649 HeapWord* old_committed_end = (HeapWord*)old->virtual_space()->committed_high_addr();
650 VirtualSpaceSummary old_summary(old->reserved().start(), old_committed_end, old->reserved().end());
651 SpaceSummary old_space(old->reserved().start(), old_committed_end, old->used_in_bytes());
652
653 PSYoungGen* young = young_gen();
654 VirtualSpaceSummary young_summary(young->reserved().start(),
655 (HeapWord*)young->virtual_space()->committed_high_addr(), young->reserved().end());
656
657 MutableSpace* eden = young_gen()->eden_space();
658 SpaceSummary eden_space(eden->bottom(), eden->end(), eden->used_in_bytes());
659
660 MutableSpace* from = young_gen()->from_space();
661 SpaceSummary from_space(from->bottom(), from->end(), from->used_in_bytes());
662
663 MutableSpace* to = young_gen()->to_space();
664 SpaceSummary to_space(to->bottom(), to->end(), to->used_in_bytes());
665
666 VirtualSpaceSummary heap_summary = create_heap_space_summary();
667 return PSHeapSummary(heap_summary, used(), old_summary, old_space, young_summary, eden_space, from_space, to_space);
668 }
669
670 void ParallelScavengeHeap::print_on(outputStream* st) const {
671 young_gen()->print_on(st);
672 old_gen()->print_on(st);
673 MetaspaceAux::print_on(st);
674 }
675
676 void ParallelScavengeHeap::print_on_error(outputStream* st) const {
677 this->CollectedHeap::print_on_error(st);
678
679 if (UseParallelOldGC) {
680 st->cr();
681 PSParallelCompact::print_on_error(st);
682 }
683 }
684
685 void ParallelScavengeHeap::gc_threads_do(ThreadClosure* tc) const {
686 PSScavenge::gc_task_manager()->threads_do(tc);
687 }
688
689 void ParallelScavengeHeap::print_gc_threads_on(outputStream* st) const {
714 gclog_or_tty->print("eden ");
715 }
716 young_gen()->verify();
717 }
718 }
719
720 void ParallelScavengeHeap::print_heap_change(size_t prev_used) {
721 if (PrintGCDetails && Verbose) {
722 gclog_or_tty->print(" " SIZE_FORMAT
723 "->" SIZE_FORMAT
724 "(" SIZE_FORMAT ")",
725 prev_used, used(), capacity());
726 } else {
727 gclog_or_tty->print(" " SIZE_FORMAT "K"
728 "->" SIZE_FORMAT "K"
729 "(" SIZE_FORMAT "K)",
730 prev_used / K, used() / K, capacity() / K);
731 }
732 }
733
734 void ParallelScavengeHeap::trace_heap(GCWhen::Type when, GCTracer* gc_tracer) {
735 const PSHeapSummary& heap_summary = create_ps_heap_summary();
736 const MetaspaceSummary& metaspace_summary = create_metaspace_summary();
737 gc_tracer->report_gc_heap_summary(when, heap_summary, metaspace_summary);
738 }
739
740 ParallelScavengeHeap* ParallelScavengeHeap::heap() {
741 assert(_psh != NULL, "Uninitialized access to ParallelScavengeHeap::heap()");
742 assert(_psh->kind() == CollectedHeap::ParallelScavengeHeap, "not a parallel scavenge heap");
743 return _psh;
744 }
745
746 // Before delegating the resize to the young generation,
747 // the reserved space for the young and old generations
748 // may be changed to accomodate the desired resize.
749 void ParallelScavengeHeap::resize_young_gen(size_t eden_size,
750 size_t survivor_size) {
751 if (UseAdaptiveGCBoundary) {
752 if (size_policy()->bytes_absorbed_from_eden() != 0) {
753 size_policy()->reset_bytes_absorbed_from_eden();
754 return; // The generation changed size already.
755 }
756 gens()->adjust_boundary_for_young_gen_needs(eden_size, survivor_size);
757 }
758
759 // Delegate the resize to the generation.
|