src/hotspot/share/gc/g1/g1CodeBlobClosure.cpp
changeset 58777 18c246ad2ff9
parent 49592 77fb0be7d19f
equal deleted inserted replaced
58776:ea153023d832 58777:18c246ad2ff9
    24 
    24 
    25 #include "precompiled.hpp"
    25 #include "precompiled.hpp"
    26 #include "code/nmethod.hpp"
    26 #include "code/nmethod.hpp"
    27 #include "gc/g1/g1CodeBlobClosure.hpp"
    27 #include "gc/g1/g1CodeBlobClosure.hpp"
    28 #include "gc/g1/g1CollectedHeap.inline.hpp"
    28 #include "gc/g1/g1CollectedHeap.inline.hpp"
       
    29 #include "gc/g1/g1ConcurrentMark.inline.hpp"
    29 #include "gc/g1/heapRegion.hpp"
    30 #include "gc/g1/heapRegion.hpp"
    30 #include "gc/g1/heapRegionRemSet.hpp"
    31 #include "gc/g1/heapRegionRemSet.hpp"
    31 #include "oops/access.inline.hpp"
    32 #include "oops/access.inline.hpp"
    32 #include "oops/compressedOops.inline.hpp"
    33 #include "oops/compressedOops.inline.hpp"
    33 #include "oops/oop.inline.hpp"
    34 #include "oops/oop.inline.hpp"
    50 
    51 
    51 void G1CodeBlobClosure::HeapRegionGatheringOopClosure::do_oop(narrowOop* o) {
    52 void G1CodeBlobClosure::HeapRegionGatheringOopClosure::do_oop(narrowOop* o) {
    52   do_oop_work(o);
    53   do_oop_work(o);
    53 }
    54 }
    54 
    55 
    55 void G1CodeBlobClosure::do_code_blob(CodeBlob* cb) {
    56 template<typename T>
    56   nmethod* nm = cb->as_nmethod_or_null();
    57 void G1CodeBlobClosure::MarkingOopClosure::do_oop_work(T* p) {
    57   if (nm != NULL) {
    58   T oop_or_narrowoop = RawAccess<>::oop_load(p);
    58     if (!nm->test_set_oops_do_mark()) {
    59   if (!CompressedOops::is_null(oop_or_narrowoop)) {
    59       _oc.set_nm(nm);
    60     oop o = CompressedOops::decode_not_null(oop_or_narrowoop);
    60       nm->oops_do(&_oc);
    61     _cm->mark_in_next_bitmap(_worker_id, o);
    61       nm->fix_oop_relocations();
       
    62     }
       
    63   }
    62   }
    64 }
    63 }
    65 
    64 
       
    65 G1CodeBlobClosure::MarkingOopClosure::MarkingOopClosure(uint worker_id) :
       
    66   _cm(G1CollectedHeap::heap()->concurrent_mark()), _worker_id(worker_id) { }
       
    67 
       
    68 void G1CodeBlobClosure::MarkingOopClosure::do_oop(oop* o) {
       
    69   do_oop_work(o);
       
    70 }
       
    71 
       
    72 void G1CodeBlobClosure::MarkingOopClosure::do_oop(narrowOop* o) {
       
    73   do_oop_work(o);
       
    74 }
       
    75 
       
    76 void G1CodeBlobClosure::do_evacuation_and_fixup(nmethod* nm) {
       
    77   _oc.set_nm(nm);
       
    78   nm->oops_do(&_oc);
       
    79   nm->fix_oop_relocations();
       
    80 }
       
    81 
       
    82 void G1CodeBlobClosure::do_marking(nmethod* nm) {
       
    83   nm->oops_do(&_marking_oc);
       
    84 }
       
    85 
       
    86 class G1NmethodProcessor : public nmethod::OopsDoProcessor {
       
    87   G1CodeBlobClosure* _cl;
       
    88 
       
    89 public:
       
    90   G1NmethodProcessor(G1CodeBlobClosure* cl) : _cl(cl) { }
       
    91 
       
    92   void do_regular_processing(nmethod* nm) {
       
    93     _cl->do_evacuation_and_fixup(nm);
       
    94   }
       
    95 
       
    96   void do_remaining_strong_processing(nmethod* nm) {
       
    97     _cl->do_marking(nm);
       
    98   }
       
    99 };
       
   100 
       
   101 void G1CodeBlobClosure::do_code_blob(CodeBlob* cb) {
       
   102   nmethod* nm = cb->as_nmethod_or_null();
       
   103   if (nm == NULL) {
       
   104     return;
       
   105   }
       
   106 
       
   107   G1NmethodProcessor cl(this);
       
   108 
       
   109   if (_strong) {
       
   110     nm->oops_do_process_strong(&cl);
       
   111   } else {
       
   112     nm->oops_do_process_weak(&cl);
       
   113   }
       
   114 }