< prev index next >

src/hotspot/share/gc/shared/weakProcessor.inline.hpp

Print this page




  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 #ifndef SHARE_GC_SHARED_WEAKPROCESSOR_INLINE_HPP
  26 #define SHARE_GC_SHARED_WEAKPROCESSOR_INLINE_HPP
  27 
  28 #include "classfile/stringTable.hpp"
  29 #include "gc/shared/oopStorage.inline.hpp"
  30 #include "gc/shared/oopStorageParState.inline.hpp"
  31 #include "gc/shared/weakProcessor.hpp"
  32 #include "gc/shared/weakProcessorPhases.hpp"
  33 #include "gc/shared/weakProcessorPhaseTimes.hpp"
  34 #include "gc/shared/workgroup.hpp"
  35 #include "prims/resolvedMethodTable.hpp"
  36 #include "utilities/debug.hpp"
  37 
  38 class BoolObjectClosure;
  39 class OopClosure;
  40 
  41 template<typename IsAlive>
  42 class CountingIsAliveClosure : public BoolObjectClosure {
  43   IsAlive* _inner;
  44 
  45   size_t _num_dead;
  46   size_t _num_total;
  47 
  48 public:
  49   CountingIsAliveClosure(IsAlive* cl) : _inner(cl), _num_dead(0), _num_total(0) { }
  50 
  51   virtual bool do_object_b(oop obj) {
  52     bool result = _inner->do_object_b(obj);
  53     _num_dead += !result;
  54     _num_total++;
  55     return result;


  98     if (WeakProcessorPhases::is_serial(phase)) {
  99       CountingIsAliveClosure<IsAlive> cl(is_alive);
 100       uint serial_index = WeakProcessorPhases::serial_index(phase);
 101       if (_serial_phases_done.try_claim_task(serial_index)) {
 102         WeakProcessorPhaseTimeTracker pt(_phase_times, phase);
 103         WeakProcessorPhases::processor(phase)(&cl, keep_alive);
 104         if (_phase_times != NULL) {
 105           _phase_times->record_phase_items(phase, cl.num_dead(), cl.num_total());
 106         }
 107       }
 108     } else {
 109       CountingSkippedIsAliveClosure<IsAlive, KeepAlive> cl(is_alive, keep_alive);
 110       WeakProcessorPhaseTimeTracker pt(_phase_times, phase, worker_id);
 111       uint storage_index = WeakProcessorPhases::oop_storage_index(phase);
 112       _storage_states[storage_index].oops_do(&cl);
 113       if (_phase_times != NULL) {
 114         _phase_times->record_worker_items(worker_id, phase, cl.num_dead(), cl.num_total());
 115       }
 116       if (WeakProcessorPhases::is_stringtable(phase)) {
 117         StringTable::inc_dead_counter(cl.num_dead() + cl.num_skipped());
 118       }
 119       if (WeakProcessorPhases::is_resolved_method_table(phase)) {
 120         ResolvedMethodTable::inc_dead_counter(cl.num_dead() + cl.num_skipped());
 121       }
 122     }
 123   }
 124 
 125   _serial_phases_done.all_tasks_completed(_nworkers);
 126 }
 127 
 128 class WeakProcessor::GangTask : public AbstractGangTask {
 129   Task _task;
 130   BoolObjectClosure* _is_alive;
 131   OopClosure* _keep_alive;
 132   void (*_erased_do_work)(GangTask* task, uint worker_id);
 133 
 134   template<typename IsAlive, typename KeepAlive>
 135   static void erased_do_work(GangTask* task, uint worker_id) {
 136     task->_task.work(worker_id,
 137                      static_cast<IsAlive*>(task->_is_alive),
 138                      static_cast<KeepAlive*>(task->_keep_alive));
 139   }
 140 




  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 #ifndef SHARE_GC_SHARED_WEAKPROCESSOR_INLINE_HPP
  26 #define SHARE_GC_SHARED_WEAKPROCESSOR_INLINE_HPP
  27 
  28 #include "classfile/stringTable.hpp"
  29 #include "gc/shared/oopStorage.inline.hpp"
  30 #include "gc/shared/oopStorageParState.inline.hpp"
  31 #include "gc/shared/weakProcessor.hpp"
  32 #include "gc/shared/weakProcessorPhases.hpp"
  33 #include "gc/shared/weakProcessorPhaseTimes.hpp"
  34 #include "gc/shared/workgroup.hpp"

  35 #include "utilities/debug.hpp"
  36 
  37 class BoolObjectClosure;
  38 class OopClosure;
  39 
  40 template<typename IsAlive>
  41 class CountingIsAliveClosure : public BoolObjectClosure {
  42   IsAlive* _inner;
  43 
  44   size_t _num_dead;
  45   size_t _num_total;
  46 
  47 public:
  48   CountingIsAliveClosure(IsAlive* cl) : _inner(cl), _num_dead(0), _num_total(0) { }
  49 
  50   virtual bool do_object_b(oop obj) {
  51     bool result = _inner->do_object_b(obj);
  52     _num_dead += !result;
  53     _num_total++;
  54     return result;


  97     if (WeakProcessorPhases::is_serial(phase)) {
  98       CountingIsAliveClosure<IsAlive> cl(is_alive);
  99       uint serial_index = WeakProcessorPhases::serial_index(phase);
 100       if (_serial_phases_done.try_claim_task(serial_index)) {
 101         WeakProcessorPhaseTimeTracker pt(_phase_times, phase);
 102         WeakProcessorPhases::processor(phase)(&cl, keep_alive);
 103         if (_phase_times != NULL) {
 104           _phase_times->record_phase_items(phase, cl.num_dead(), cl.num_total());
 105         }
 106       }
 107     } else {
 108       CountingSkippedIsAliveClosure<IsAlive, KeepAlive> cl(is_alive, keep_alive);
 109       WeakProcessorPhaseTimeTracker pt(_phase_times, phase, worker_id);
 110       uint storage_index = WeakProcessorPhases::oop_storage_index(phase);
 111       _storage_states[storage_index].oops_do(&cl);
 112       if (_phase_times != NULL) {
 113         _phase_times->record_worker_items(worker_id, phase, cl.num_dead(), cl.num_total());
 114       }
 115       if (WeakProcessorPhases::is_stringtable(phase)) {
 116         StringTable::inc_dead_counter(cl.num_dead() + cl.num_skipped());



 117       }
 118     }
 119   }
 120 
 121   _serial_phases_done.all_tasks_completed(_nworkers);
 122 }
 123 
 124 class WeakProcessor::GangTask : public AbstractGangTask {
 125   Task _task;
 126   BoolObjectClosure* _is_alive;
 127   OopClosure* _keep_alive;
 128   void (*_erased_do_work)(GangTask* task, uint worker_id);
 129 
 130   template<typename IsAlive, typename KeepAlive>
 131   static void erased_do_work(GangTask* task, uint worker_id) {
 132     task->_task.work(worker_id,
 133                      static_cast<IsAlive*>(task->_is_alive),
 134                      static_cast<KeepAlive*>(task->_keep_alive));
 135   }
 136 


< prev index next >