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 "classfile/stringTable.hpp"
27 #include "classfile/symbolTable.hpp"
28 #include "classfile/systemDictionary.hpp"
29 #include "code/codeCache.hpp"
30 #include "gc/parallel/parallelScavengeHeap.hpp"
31 #include "gc/parallel/psAdaptiveSizePolicy.hpp"
32 #include "gc/parallel/psMarkSweep.hpp"
33 #include "gc/parallel/psMarkSweepDecorator.hpp"
34 #include "gc/parallel/psOldGen.hpp"
35 #include "gc/parallel/psScavenge.hpp"
36 #include "gc/parallel/psYoungGen.hpp"
37 #include "gc/serial/markSweep.hpp"
38 #include "gc/shared/gcCause.hpp"
39 #include "gc/shared/gcHeapSummary.hpp"
40 #include "gc/shared/gcId.hpp"
41 #include "gc/shared/gcLocker.inline.hpp"
42 #include "gc/shared/gcTimer.hpp"
43 #include "gc/shared/gcTrace.hpp"
44 #include "gc/shared/gcTraceTime.inline.hpp"
45 #include "gc/shared/isGCActiveMark.hpp"
498 ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
499
500 // Need to clear claim bits before the tracing starts.
501 ClassLoaderDataGraph::clear_claimed_marks();
502
503 // General strong roots.
504 {
505 ParallelScavengeHeap::ParStrongRootsScope psrs;
506 Universe::oops_do(mark_and_push_closure());
507 JNIHandles::oops_do(mark_and_push_closure()); // Global (strong) JNI handles
508 MarkingCodeBlobClosure each_active_code_blob(mark_and_push_closure(), !CodeBlobToOopClosure::FixRelocations);
509 Threads::oops_do(mark_and_push_closure(), &each_active_code_blob);
510 ObjectSynchronizer::oops_do(mark_and_push_closure());
511 FlatProfiler::oops_do(mark_and_push_closure());
512 Management::oops_do(mark_and_push_closure());
513 JvmtiExport::oops_do(mark_and_push_closure());
514 SystemDictionary::always_strong_oops_do(mark_and_push_closure());
515 ClassLoaderDataGraph::always_strong_cld_do(follow_cld_closure());
516 // Do not treat nmethods as strong roots for mark/sweep, since we can unload them.
517 //CodeCache::scavenge_root_nmethods_do(CodeBlobToOopClosure(mark_and_push_closure()));
518 }
519
520 // Flush marking stack.
521 follow_stack();
522
523 // Process reference objects found during marking
524 {
525 GCTraceTime(Debug, gc, phases) t("Reference Processing", _gc_timer);
526
527 ref_processor()->setup_policy(clear_all_softrefs);
528 const ReferenceProcessorStats& stats =
529 ref_processor()->process_discovered_references(
530 is_alive_closure(), mark_and_push_closure(), follow_stack_closure(), NULL, _gc_timer);
531 gc_tracer()->report_gc_reference_stats(stats);
532 }
533
534 // This is the point where the entire marking should have completed.
535 assert(_marking_stack.is_empty(), "Marking should have completed");
536
537 {
594 ClassLoaderDataGraph::clear_claimed_marks();
595
596 // General strong roots.
597 Universe::oops_do(adjust_pointer_closure());
598 JNIHandles::oops_do(adjust_pointer_closure()); // Global (strong) JNI handles
599 Threads::oops_do(adjust_pointer_closure(), NULL);
600 ObjectSynchronizer::oops_do(adjust_pointer_closure());
601 FlatProfiler::oops_do(adjust_pointer_closure());
602 Management::oops_do(adjust_pointer_closure());
603 JvmtiExport::oops_do(adjust_pointer_closure());
604 SystemDictionary::oops_do(adjust_pointer_closure());
605 ClassLoaderDataGraph::cld_do(adjust_cld_closure());
606
607 // Now adjust pointers in remaining weak roots. (All of which should
608 // have been cleared if they pointed to non-surviving objects.)
609 // Global (weak) JNI handles
610 JNIHandles::weak_oops_do(adjust_pointer_closure());
611
612 CodeBlobToOopClosure adjust_from_blobs(adjust_pointer_closure(), CodeBlobToOopClosure::FixRelocations);
613 CodeCache::blobs_do(&adjust_from_blobs);
614 StringTable::oops_do(adjust_pointer_closure());
615 ref_processor()->weak_oops_do(adjust_pointer_closure());
616 PSScavenge::reference_processor()->weak_oops_do(adjust_pointer_closure());
617
618 adjust_marks();
619
620 young_gen->adjust_pointers();
621 old_gen->adjust_pointers();
622 }
623
624 void PSMarkSweep::mark_sweep_phase4() {
625 EventMark m("4 compact heap");
626 GCTraceTime(Info, gc, phases) tm("Phase 4: Move objects", _gc_timer);
627
628 // All pointers are now adjusted, move objects accordingly
629
630 ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
631 PSYoungGen* young_gen = heap->young_gen();
632 PSOldGen* old_gen = heap->old_gen();
633
|
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 "aot/aotLoader.hpp"
27 #include "classfile/stringTable.hpp"
28 #include "classfile/symbolTable.hpp"
29 #include "classfile/systemDictionary.hpp"
30 #include "code/codeCache.hpp"
31 #include "gc/parallel/parallelScavengeHeap.hpp"
32 #include "gc/parallel/psAdaptiveSizePolicy.hpp"
33 #include "gc/parallel/psMarkSweep.hpp"
34 #include "gc/parallel/psMarkSweepDecorator.hpp"
35 #include "gc/parallel/psOldGen.hpp"
36 #include "gc/parallel/psScavenge.hpp"
37 #include "gc/parallel/psYoungGen.hpp"
38 #include "gc/serial/markSweep.hpp"
39 #include "gc/shared/gcCause.hpp"
40 #include "gc/shared/gcHeapSummary.hpp"
41 #include "gc/shared/gcId.hpp"
42 #include "gc/shared/gcLocker.inline.hpp"
43 #include "gc/shared/gcTimer.hpp"
44 #include "gc/shared/gcTrace.hpp"
45 #include "gc/shared/gcTraceTime.inline.hpp"
46 #include "gc/shared/isGCActiveMark.hpp"
499 ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
500
501 // Need to clear claim bits before the tracing starts.
502 ClassLoaderDataGraph::clear_claimed_marks();
503
504 // General strong roots.
505 {
506 ParallelScavengeHeap::ParStrongRootsScope psrs;
507 Universe::oops_do(mark_and_push_closure());
508 JNIHandles::oops_do(mark_and_push_closure()); // Global (strong) JNI handles
509 MarkingCodeBlobClosure each_active_code_blob(mark_and_push_closure(), !CodeBlobToOopClosure::FixRelocations);
510 Threads::oops_do(mark_and_push_closure(), &each_active_code_blob);
511 ObjectSynchronizer::oops_do(mark_and_push_closure());
512 FlatProfiler::oops_do(mark_and_push_closure());
513 Management::oops_do(mark_and_push_closure());
514 JvmtiExport::oops_do(mark_and_push_closure());
515 SystemDictionary::always_strong_oops_do(mark_and_push_closure());
516 ClassLoaderDataGraph::always_strong_cld_do(follow_cld_closure());
517 // Do not treat nmethods as strong roots for mark/sweep, since we can unload them.
518 //CodeCache::scavenge_root_nmethods_do(CodeBlobToOopClosure(mark_and_push_closure()));
519 AOTLoader::oops_do(mark_and_push_closure());
520 }
521
522 // Flush marking stack.
523 follow_stack();
524
525 // Process reference objects found during marking
526 {
527 GCTraceTime(Debug, gc, phases) t("Reference Processing", _gc_timer);
528
529 ref_processor()->setup_policy(clear_all_softrefs);
530 const ReferenceProcessorStats& stats =
531 ref_processor()->process_discovered_references(
532 is_alive_closure(), mark_and_push_closure(), follow_stack_closure(), NULL, _gc_timer);
533 gc_tracer()->report_gc_reference_stats(stats);
534 }
535
536 // This is the point where the entire marking should have completed.
537 assert(_marking_stack.is_empty(), "Marking should have completed");
538
539 {
596 ClassLoaderDataGraph::clear_claimed_marks();
597
598 // General strong roots.
599 Universe::oops_do(adjust_pointer_closure());
600 JNIHandles::oops_do(adjust_pointer_closure()); // Global (strong) JNI handles
601 Threads::oops_do(adjust_pointer_closure(), NULL);
602 ObjectSynchronizer::oops_do(adjust_pointer_closure());
603 FlatProfiler::oops_do(adjust_pointer_closure());
604 Management::oops_do(adjust_pointer_closure());
605 JvmtiExport::oops_do(adjust_pointer_closure());
606 SystemDictionary::oops_do(adjust_pointer_closure());
607 ClassLoaderDataGraph::cld_do(adjust_cld_closure());
608
609 // Now adjust pointers in remaining weak roots. (All of which should
610 // have been cleared if they pointed to non-surviving objects.)
611 // Global (weak) JNI handles
612 JNIHandles::weak_oops_do(adjust_pointer_closure());
613
614 CodeBlobToOopClosure adjust_from_blobs(adjust_pointer_closure(), CodeBlobToOopClosure::FixRelocations);
615 CodeCache::blobs_do(&adjust_from_blobs);
616 AOTLoader::oops_do(adjust_pointer_closure());
617 StringTable::oops_do(adjust_pointer_closure());
618 ref_processor()->weak_oops_do(adjust_pointer_closure());
619 PSScavenge::reference_processor()->weak_oops_do(adjust_pointer_closure());
620
621 adjust_marks();
622
623 young_gen->adjust_pointers();
624 old_gen->adjust_pointers();
625 }
626
627 void PSMarkSweep::mark_sweep_phase4() {
628 EventMark m("4 compact heap");
629 GCTraceTime(Info, gc, phases) tm("Phase 4: Move objects", _gc_timer);
630
631 // All pointers are now adjusted, move objects accordingly
632
633 ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
634 PSYoungGen* young_gen = heap->young_gen();
635 PSOldGen* old_gen = heap->old_gen();
636
|