745 // separate thread causes wide variance in run times. We can't help this
746 // in the multi-threaded case, but we special-case n=1 here to get
747 // repeatable measurements of the 1-thread overhead of the parallel code.
748 if (n_workers > 1) {
749 workers->run_task(&tsk);
750 } else {
751 tsk.work(0);
752 }
753 thread_state_set.reset();
754
755 if (PAR_STATS_ENABLED && ParallelGCVerbose) {
756 gclog_or_tty->print("Thread totals:\n"
757 " Pushes: %7d Pops: %7d Steals %7d (sum = %7d).\n",
758 thread_state_set.pushes(), thread_state_set.pops(),
759 thread_state_set.steals(),
760 thread_state_set.pops()+thread_state_set.steals());
761 }
762 assert(thread_state_set.pushes() == thread_state_set.pops() + thread_state_set.steals(),
763 "Or else the queues are leaky.");
764
765 // For now, process discovered weak refs sequentially.
766 #ifdef COMPILER2
767 ReferencePolicy *soft_ref_policy = new LRUMaxHeapPolicy();
768 #else
769 ReferencePolicy *soft_ref_policy = new LRUCurrentHeapPolicy();
770 #endif // COMPILER2
771
772 // Process (weak) reference objects found during scavenge.
773 IsAliveClosure is_alive(this);
774 ScanWeakRefClosure scan_weak_ref(this);
775 KeepAliveClosure keep_alive(&scan_weak_ref);
776 ScanClosure scan_without_gc_barrier(this, false);
777 ScanClosureWithParBarrier scan_with_gc_barrier(this, true);
778 set_promo_failure_scan_stack_closure(&scan_without_gc_barrier);
779 EvacuateFollowersClosureGeneral evacuate_followers(gch, _level,
780 &scan_without_gc_barrier, &scan_with_gc_barrier);
781 if (ref_processor()->processing_is_mt()) {
782 ParNewRefProcTaskExecutor task_executor(*this, thread_state_set);
783 ref_processor()->process_discovered_references(
784 soft_ref_policy, &is_alive, &keep_alive, &evacuate_followers,
785 &task_executor);
786 } else {
787 thread_state_set.flush();
788 gch->set_par_threads(0); // 0 ==> non-parallel.
789 gch->save_marks();
790 ref_processor()->process_discovered_references(
791 soft_ref_policy, &is_alive, &keep_alive, &evacuate_followers,
792 NULL);
793 }
794 if (!promotion_failed()) {
795 // Swap the survivor spaces.
796 eden()->clear(SpaceDecorator::Mangle);
797 from()->clear(SpaceDecorator::Mangle);
798 if (ZapUnusedHeapArea) {
799 // This is now done here because of the piece-meal mangling which
800 // can check for valid mangling at intermediate points in the
801 // collection(s). When a minor collection fails to collect
802 // sufficient space resizing of the young generation can occur
803 // an redistribute the spaces in the young generation. Mangle
804 // here so that unzapped regions don't get distributed to
805 // other spaces.
806 to()->mangle_unused_area();
807 }
808 swap_spaces();
809
810 assert(to()->is_empty(), "to space should be empty now");
811 } else {
812 assert(HandlePromotionFailure,
834 to()->set_concurrent_iteration_safe_limit(to()->top());
835
836 adjust_desired_tenuring_threshold();
837 if (ResizePLAB) {
838 plab_stats()->adjust_desired_plab_sz();
839 }
840
841 if (PrintGC && !PrintGCDetails) {
842 gch->print_heap_change(gch_prev_used);
843 }
844
845 if (UseAdaptiveSizePolicy) {
846 size_policy->minor_collection_end(gch->gc_cause());
847 size_policy->avg_survived()->sample(from()->used());
848 }
849
850 update_time_of_last_gc(os::javaTimeMillis());
851
852 SpecializationStats::print();
853
854 ref_processor()->set_enqueuing_is_done(true);
855 if (ref_processor()->processing_is_mt()) {
856 ParNewRefProcTaskExecutor task_executor(*this, thread_state_set);
857 ref_processor()->enqueue_discovered_references(&task_executor);
858 } else {
859 ref_processor()->enqueue_discovered_references(NULL);
860 }
861 ref_processor()->verify_no_references_recorded();
862 }
863
864 static int sum;
865 void ParNewGeneration::waste_some_time() {
866 for (int i = 0; i < 100; i++) {
867 sum += i;
868 }
869 }
870
871 static const oop ClaimedForwardPtr = oop(0x4);
872
873 // Because of concurrency, there are times where an object for which
874 // "is_forwarded()" is true contains an "interim" forwarding pointer
875 // value. Such a value will soon be overwritten with a real value.
876 // This method requires "obj" to have a forwarding pointer, and waits, if
877 // necessary for a real one to be inserted, and returns it.
878
879 oop ParNewGeneration::real_forwardee(oop obj) {
880 oop forward_ptr = obj->forwardee();
881 if (forward_ptr != ClaimedForwardPtr) {
|
745 // separate thread causes wide variance in run times. We can't help this
746 // in the multi-threaded case, but we special-case n=1 here to get
747 // repeatable measurements of the 1-thread overhead of the parallel code.
748 if (n_workers > 1) {
749 workers->run_task(&tsk);
750 } else {
751 tsk.work(0);
752 }
753 thread_state_set.reset();
754
755 if (PAR_STATS_ENABLED && ParallelGCVerbose) {
756 gclog_or_tty->print("Thread totals:\n"
757 " Pushes: %7d Pops: %7d Steals %7d (sum = %7d).\n",
758 thread_state_set.pushes(), thread_state_set.pops(),
759 thread_state_set.steals(),
760 thread_state_set.pops()+thread_state_set.steals());
761 }
762 assert(thread_state_set.pushes() == thread_state_set.pops() + thread_state_set.steals(),
763 "Or else the queues are leaky.");
764
765 // Process (weak) reference objects found during scavenge.
766 ReferenceProcessor* rp = ref_processor();
767 IsAliveClosure is_alive(this);
768 ScanWeakRefClosure scan_weak_ref(this);
769 KeepAliveClosure keep_alive(&scan_weak_ref);
770 ScanClosure scan_without_gc_barrier(this, false);
771 ScanClosureWithParBarrier scan_with_gc_barrier(this, true);
772 set_promo_failure_scan_stack_closure(&scan_without_gc_barrier);
773 EvacuateFollowersClosureGeneral evacuate_followers(gch, _level,
774 &scan_without_gc_barrier, &scan_with_gc_barrier);
775 rp->snap_policy(clear_all_soft_refs);
776 if (rp->processing_is_mt()) {
777 ParNewRefProcTaskExecutor task_executor(*this, thread_state_set);
778 rp->process_discovered_references(&is_alive, &keep_alive, &evacuate_followers, &task_executor);
779 } else {
780 thread_state_set.flush();
781 gch->set_par_threads(0); // 0 ==> non-parallel.
782 gch->save_marks();
783 rp->process_discovered_references(&is_alive, &keep_alive, &evacuate_followers, NULL);
784 }
785 if (!promotion_failed()) {
786 // Swap the survivor spaces.
787 eden()->clear(SpaceDecorator::Mangle);
788 from()->clear(SpaceDecorator::Mangle);
789 if (ZapUnusedHeapArea) {
790 // This is now done here because of the piece-meal mangling which
791 // can check for valid mangling at intermediate points in the
792 // collection(s). When a minor collection fails to collect
793 // sufficient space resizing of the young generation can occur
794 // an redistribute the spaces in the young generation. Mangle
795 // here so that unzapped regions don't get distributed to
796 // other spaces.
797 to()->mangle_unused_area();
798 }
799 swap_spaces();
800
801 assert(to()->is_empty(), "to space should be empty now");
802 } else {
803 assert(HandlePromotionFailure,
825 to()->set_concurrent_iteration_safe_limit(to()->top());
826
827 adjust_desired_tenuring_threshold();
828 if (ResizePLAB) {
829 plab_stats()->adjust_desired_plab_sz();
830 }
831
832 if (PrintGC && !PrintGCDetails) {
833 gch->print_heap_change(gch_prev_used);
834 }
835
836 if (UseAdaptiveSizePolicy) {
837 size_policy->minor_collection_end(gch->gc_cause());
838 size_policy->avg_survived()->sample(from()->used());
839 }
840
841 update_time_of_last_gc(os::javaTimeMillis());
842
843 SpecializationStats::print();
844
845 rp->set_enqueuing_is_done(true);
846 if (rp->processing_is_mt()) {
847 ParNewRefProcTaskExecutor task_executor(*this, thread_state_set);
848 rp->enqueue_discovered_references(&task_executor);
849 } else {
850 rp->enqueue_discovered_references(NULL);
851 }
852 rp->verify_no_references_recorded();
853 }
854
855 static int sum;
856 void ParNewGeneration::waste_some_time() {
857 for (int i = 0; i < 100; i++) {
858 sum += i;
859 }
860 }
861
862 static const oop ClaimedForwardPtr = oop(0x4);
863
864 // Because of concurrency, there are times where an object for which
865 // "is_forwarded()" is true contains an "interim" forwarding pointer
866 // value. Such a value will soon be overwritten with a real value.
867 // This method requires "obj" to have a forwarding pointer, and waits, if
868 // necessary for a real one to be inserted, and returns it.
869
870 oop ParNewGeneration::real_forwardee(oop obj) {
871 oop forward_ptr = obj->forwardee();
872 if (forward_ptr != ClaimedForwardPtr) {
|