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 "classfile/symbolTable.hpp"
27 #include "gc_implementation/parallelScavenge/cardTableExtension.hpp"
28 #include "gc_implementation/parallelScavenge/gcTaskManager.hpp"
29 #include "gc_implementation/parallelScavenge/generationSizer.hpp"
30 #include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp"
31 #include "gc_implementation/parallelScavenge/psAdaptiveSizePolicy.hpp"
32 #include "gc_implementation/parallelScavenge/psMarkSweep.hpp"
33 #include "gc_implementation/parallelScavenge/psParallelCompact.hpp"
34 #include "gc_implementation/parallelScavenge/psScavenge.inline.hpp"
35 #include "gc_implementation/parallelScavenge/psTasks.hpp"
36 #include "gc_implementation/shared/isGCActiveMark.hpp"
37 #include "gc_implementation/shared/spaceDecorator.hpp"
38 #include "gc_interface/gcCause.hpp"
39 #include "memory/collectorPolicy.hpp"
40 #include "memory/gcLocker.inline.hpp"
41 #include "memory/referencePolicy.hpp"
42 #include "memory/referenceProcessor.hpp"
43 #include "memory/resourceArea.hpp"
44 #include "oops/oop.inline.hpp"
45 #include "oops/oop.psgc.inline.hpp"
46 #include "runtime/biasedLocking.hpp"
83 protected:
84 MutableSpace* _to_space;
85 PSPromotionManager* _promotion_manager;
86
87 public:
88 PSKeepAliveClosure(PSPromotionManager* pm) : _promotion_manager(pm) {
89 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
90 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
91 _to_space = heap->young_gen()->to_space();
92
93 assert(_promotion_manager != NULL, "Sanity");
94 }
95
96 template <class T> void do_oop_work(T* p) {
97 assert (!oopDesc::is_null(*p), "expected non-null ref");
98 assert ((oopDesc::load_decode_heap_oop_not_null(p))->is_oop(),
99 "expected an oop while scanning weak refs");
100
101 // Weak refs may be visited more than once.
102 if (PSScavenge::should_scavenge(p, _to_space)) {
103 PSScavenge::copy_and_push_safe_barrier(_promotion_manager, p);
104 }
105 }
106 virtual void do_oop(oop* p) { PSKeepAliveClosure::do_oop_work(p); }
107 virtual void do_oop(narrowOop* p) { PSKeepAliveClosure::do_oop_work(p); }
108 };
109
110 class PSEvacuateFollowersClosure: public VoidClosure {
111 private:
112 PSPromotionManager* _promotion_manager;
113 public:
114 PSEvacuateFollowersClosure(PSPromotionManager* pm) : _promotion_manager(pm) {}
115
116 virtual void do_void() {
117 assert(_promotion_manager != NULL, "Sanity");
118 _promotion_manager->drain_stacks(true);
119 guarantee(_promotion_manager->stacks_empty(),
120 "stacks should be empty at this point");
121 }
122 };
123
585 }
586 }
587
588 // Update the structure of the eden. With NUMA-eden CPU hotplugging or offlining can
589 // cause the change of the heap layout. Make sure eden is reshaped if that's the case.
590 // Also update() will case adaptive NUMA chunk resizing.
591 assert(young_gen->eden_space()->is_empty(), "eden space should be empty now");
592 young_gen->eden_space()->update();
593
594 heap->gc_policy_counters()->update_counters();
595
596 heap->resize_all_tlabs();
597
598 assert(young_gen->to_space()->is_empty(), "to space should be empty now");
599 }
600
601 COMPILER2_PRESENT(DerivedPointerTable::update_pointers());
602
603 NOT_PRODUCT(reference_processor()->verify_no_references_recorded());
604
605 // Re-verify object start arrays
606 if (VerifyObjectStartArray &&
607 VerifyAfterGC) {
608 old_gen->verify_object_start_array();
609 perm_gen->verify_object_start_array();
610 }
611
612 // Verify all old -> young cards are now precise
613 if (VerifyRememberedSets) {
614 // Precise verification will give false positives. Until this is fixed,
615 // use imprecise verification.
616 // CardTableExtension::verify_all_young_refs_precise();
617 CardTableExtension::verify_all_young_refs_imprecise();
618 }
619
620 if (TraceGen0Time) accumulated_time()->stop();
621
622 if (PrintGC) {
623 if (PrintGCDetails) {
624 // Don't print a GC timestamp here. This is after the GC so
|
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 "classfile/symbolTable.hpp"
27 #include "code/codeCache.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.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/psScavenge.inline.hpp"
36 #include "gc_implementation/parallelScavenge/psTasks.hpp"
37 #include "gc_implementation/shared/isGCActiveMark.hpp"
38 #include "gc_implementation/shared/spaceDecorator.hpp"
39 #include "gc_interface/gcCause.hpp"
40 #include "memory/collectorPolicy.hpp"
41 #include "memory/gcLocker.inline.hpp"
42 #include "memory/referencePolicy.hpp"
43 #include "memory/referenceProcessor.hpp"
44 #include "memory/resourceArea.hpp"
45 #include "oops/oop.inline.hpp"
46 #include "oops/oop.psgc.inline.hpp"
47 #include "runtime/biasedLocking.hpp"
84 protected:
85 MutableSpace* _to_space;
86 PSPromotionManager* _promotion_manager;
87
88 public:
89 PSKeepAliveClosure(PSPromotionManager* pm) : _promotion_manager(pm) {
90 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
91 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
92 _to_space = heap->young_gen()->to_space();
93
94 assert(_promotion_manager != NULL, "Sanity");
95 }
96
97 template <class T> void do_oop_work(T* p) {
98 assert (!oopDesc::is_null(*p), "expected non-null ref");
99 assert ((oopDesc::load_decode_heap_oop_not_null(p))->is_oop(),
100 "expected an oop while scanning weak refs");
101
102 // Weak refs may be visited more than once.
103 if (PSScavenge::should_scavenge(p, _to_space)) {
104 PSScavenge::copy_and_push_safe_barrier<T, /*promote_immediately=*/false>(_promotion_manager, p);
105 }
106 }
107 virtual void do_oop(oop* p) { PSKeepAliveClosure::do_oop_work(p); }
108 virtual void do_oop(narrowOop* p) { PSKeepAliveClosure::do_oop_work(p); }
109 };
110
111 class PSEvacuateFollowersClosure: public VoidClosure {
112 private:
113 PSPromotionManager* _promotion_manager;
114 public:
115 PSEvacuateFollowersClosure(PSPromotionManager* pm) : _promotion_manager(pm) {}
116
117 virtual void do_void() {
118 assert(_promotion_manager != NULL, "Sanity");
119 _promotion_manager->drain_stacks(true);
120 guarantee(_promotion_manager->stacks_empty(),
121 "stacks should be empty at this point");
122 }
123 };
124
586 }
587 }
588
589 // Update the structure of the eden. With NUMA-eden CPU hotplugging or offlining can
590 // cause the change of the heap layout. Make sure eden is reshaped if that's the case.
591 // Also update() will case adaptive NUMA chunk resizing.
592 assert(young_gen->eden_space()->is_empty(), "eden space should be empty now");
593 young_gen->eden_space()->update();
594
595 heap->gc_policy_counters()->update_counters();
596
597 heap->resize_all_tlabs();
598
599 assert(young_gen->to_space()->is_empty(), "to space should be empty now");
600 }
601
602 COMPILER2_PRESENT(DerivedPointerTable::update_pointers());
603
604 NOT_PRODUCT(reference_processor()->verify_no_references_recorded());
605
606 CodeCache::prune_scavenge_root_nmethods();
607
608 // Re-verify object start arrays
609 if (VerifyObjectStartArray &&
610 VerifyAfterGC) {
611 old_gen->verify_object_start_array();
612 perm_gen->verify_object_start_array();
613 }
614
615 // Verify all old -> young cards are now precise
616 if (VerifyRememberedSets) {
617 // Precise verification will give false positives. Until this is fixed,
618 // use imprecise verification.
619 // CardTableExtension::verify_all_young_refs_precise();
620 CardTableExtension::verify_all_young_refs_imprecise();
621 }
622
623 if (TraceGen0Time) accumulated_time()->stop();
624
625 if (PrintGC) {
626 if (PrintGCDetails) {
627 // Don't print a GC timestamp here. This is after the GC so
|