679 &is_alive, &keep_alive, &complete_gc);
680 }
681 private:
682 bool _clear_referent;
683 };
684
685 #ifndef PRODUCT
686 void ReferenceProcessor::log_reflist_counts(DiscoveredList ref_lists[], uint active_length, size_t total_refs) {
687 if (!log_is_enabled(Trace, gc, ref)) {
688 return;
689 }
690
691 stringStream st;
692 for (uint i = 0; i < active_length; ++i) {
693 st.print(SIZE_FORMAT " ", ref_lists[i].length());
694 }
695 log_develop_trace(gc, ref)("%s= " SIZE_FORMAT, st.as_string(), total_refs);
696 }
697 #endif
698
699 // Balances reference queues.
700 // Move entries from all queues[0, 1, ..., _max_num_q-1] to
701 // queues[0, 1, ..., _num_q-1] because only the first _num_q
702 // corresponding to the active workers will be processed.
703 void ReferenceProcessor::balance_queues(DiscoveredList ref_lists[])
704 {
705 // calculate total length
706 size_t total_refs = 0;
707 log_develop_trace(gc, ref)("Balance ref_lists ");
708
709 for (uint i = 0; i < _max_num_q; ++i) {
710 total_refs += ref_lists[i].length();
711 }
712 log_reflist_counts(ref_lists, _max_num_q, total_refs);
713 size_t avg_refs = total_refs / _num_q + 1;
714 uint to_idx = 0;
715 for (uint from_idx = 0; from_idx < _max_num_q; from_idx++) {
716 bool move_all = false;
717 if (from_idx >= _num_q) {
718 move_all = ref_lists[from_idx].length() > 0;
|
679 &is_alive, &keep_alive, &complete_gc);
680 }
681 private:
682 bool _clear_referent;
683 };
684
685 #ifndef PRODUCT
686 void ReferenceProcessor::log_reflist_counts(DiscoveredList ref_lists[], uint active_length, size_t total_refs) {
687 if (!log_is_enabled(Trace, gc, ref)) {
688 return;
689 }
690
691 stringStream st;
692 for (uint i = 0; i < active_length; ++i) {
693 st.print(SIZE_FORMAT " ", ref_lists[i].length());
694 }
695 log_develop_trace(gc, ref)("%s= " SIZE_FORMAT, st.as_string(), total_refs);
696 }
697 #endif
698
699 void ReferenceProcessor::set_active_mt_degree(uint v) {
700 _num_q = v;
701 _next_id = 0;
702 }
703
704 // Balances reference queues.
705 // Move entries from all queues[0, 1, ..., _max_num_q-1] to
706 // queues[0, 1, ..., _num_q-1] because only the first _num_q
707 // corresponding to the active workers will be processed.
708 void ReferenceProcessor::balance_queues(DiscoveredList ref_lists[])
709 {
710 // calculate total length
711 size_t total_refs = 0;
712 log_develop_trace(gc, ref)("Balance ref_lists ");
713
714 for (uint i = 0; i < _max_num_q; ++i) {
715 total_refs += ref_lists[i].length();
716 }
717 log_reflist_counts(ref_lists, _max_num_q, total_refs);
718 size_t avg_refs = total_refs / _num_q + 1;
719 uint to_idx = 0;
720 for (uint from_idx = 0; from_idx < _max_num_q; from_idx++) {
721 bool move_all = false;
722 if (from_idx >= _num_q) {
723 move_all = ref_lists[from_idx].length() > 0;
|