hotspot/src/share/vm/memory/iterator.hpp
changeset 25491 70fb742e40aa
parent 25490 59f226da8d81
child 25492 d27050bdfb04
equal deleted inserted replaced
25490:59f226da8d81 25491:70fb742e40aa
    68   // The virtual (without suffix) and the non-virtual (with _nv suffix) need
    68   // The virtual (without suffix) and the non-virtual (with _nv suffix) need
    69   // to be updated together, or else the devirtualization will break.
    69   // to be updated together, or else the devirtualization will break.
    70   //
    70   //
    71   // Providing default implementations of the _nv functions unfortunately
    71   // Providing default implementations of the _nv functions unfortunately
    72   // removes the compile-time safeness, but reduces the clutter for the
    72   // removes the compile-time safeness, but reduces the clutter for the
    73   // ExtendedOopClosures that don't need to walk the metadata.
    73   // ExtendedOopClosures that don't need to walk the metadata. Currently,
    74   // Currently, only CMS and G1 need these.
    74   // only CMS needs these.
    75 
    75 
    76   virtual bool do_metadata() { return do_metadata_nv(); }
    76   virtual bool do_metadata() { return do_metadata_nv(); }
    77   bool do_metadata_v()       { return do_metadata(); }
    77   bool do_metadata_v()       { return do_metadata(); }
    78   bool do_metadata_nv()      { return false; }
    78   bool do_metadata_nv()      { return false; }
    79 
    79 
   124   void initialize(OopClosure* oop_closure) {
   124   void initialize(OopClosure* oop_closure) {
   125     assert(_oop_closure == NULL, "Should only be called once");
   125     assert(_oop_closure == NULL, "Should only be called once");
   126     _oop_closure = oop_closure;
   126     _oop_closure = oop_closure;
   127   }
   127   }
   128 
   128 
   129  public:
   129 public:
   130   KlassToOopClosure(OopClosure* oop_closure = NULL) : _oop_closure(oop_closure) {}
   130   KlassToOopClosure(OopClosure* oop_closure = NULL) : _oop_closure(oop_closure) {}
   131 
       
   132   virtual void do_klass(Klass* k);
   131   virtual void do_klass(Klass* k);
   133 };
   132 };
   134 
   133 
   135 class CLDToOopClosure : public CLDClosure {
   134 class CLDToOopClosure : public CLDClosure {
   136   OopClosure*       _oop_closure;
   135   OopClosure* _oop_closure;
   137   KlassToOopClosure _klass_closure;
   136   KlassToOopClosure _klass_closure;
   138   bool              _must_claim_cld;
   137   bool _must_claim_cld;
   139 
   138 
   140  public:
   139  public:
   141   CLDToOopClosure(OopClosure* oop_closure, bool must_claim_cld = true) :
   140   CLDToOopClosure(OopClosure* oop_closure, bool must_claim_cld = true) :
   142       _oop_closure(oop_closure),
   141       _oop_closure(oop_closure),
   143       _klass_closure(oop_closure),
   142       _klass_closure(oop_closure),
   144       _must_claim_cld(must_claim_cld) {}
   143       _must_claim_cld(must_claim_cld) {}
   145 
   144 
   146   void do_cld(ClassLoaderData* cld);
       
   147 };
       
   148 
       
   149 class CLDToKlassAndOopClosure : public CLDClosure {
       
   150   friend class SharedHeap;
       
   151   friend class G1CollectedHeap;
       
   152  protected:
       
   153   OopClosure*   _oop_closure;
       
   154   KlassClosure* _klass_closure;
       
   155   bool          _must_claim_cld;
       
   156  public:
       
   157   CLDToKlassAndOopClosure(KlassClosure* klass_closure,
       
   158                           OopClosure* oop_closure,
       
   159                           bool must_claim_cld) :
       
   160                               _oop_closure(oop_closure),
       
   161                               _klass_closure(klass_closure),
       
   162                               _must_claim_cld(must_claim_cld) {}
       
   163   void do_cld(ClassLoaderData* cld);
   145   void do_cld(ClassLoaderData* cld);
   164 };
   146 };
   165 
   147 
   166 // The base class for all concurrent marking closures,
   148 // The base class for all concurrent marking closures,
   167 // that participates in class unloading.
   149 // that participates in class unloading.
   262  public:
   244  public:
   263   // Called for each code blob.
   245   // Called for each code blob.
   264   virtual void do_code_blob(CodeBlob* cb) = 0;
   246   virtual void do_code_blob(CodeBlob* cb) = 0;
   265 };
   247 };
   266 
   248 
   267 // Applies an oop closure to all ref fields in code blobs
   249 
   268 // iterated over in an object iteration.
   250 class MarkingCodeBlobClosure : public CodeBlobClosure {
   269 class CodeBlobToOopClosure : public CodeBlobClosure {
   251  public:
   270   OopClosure* _cl;
   252   // Called for each code blob, but at most once per unique blob.
   271   bool _fix_relocations;
   253   virtual void do_newly_marked_nmethod(nmethod* nm) = 0;
   272  protected:
   254 
   273   void do_nmethod(nmethod* nm);
       
   274  public:
       
   275   CodeBlobToOopClosure(OopClosure* cl, bool fix_relocations) : _cl(cl), _fix_relocations(fix_relocations) {}
       
   276   virtual void do_code_blob(CodeBlob* cb);
   255   virtual void do_code_blob(CodeBlob* cb);
   277 
   256     // = { if (!nmethod(cb)->test_set_oops_do_mark())  do_newly_marked_nmethod(cb); }
   278   const static bool FixRelocations = true;
       
   279 };
       
   280 
       
   281 class MarkingCodeBlobClosure : public CodeBlobToOopClosure {
       
   282  public:
       
   283   MarkingCodeBlobClosure(OopClosure* cl, bool fix_relocations) : CodeBlobToOopClosure(cl, fix_relocations) {}
       
   284   // Called for each code blob, but at most once per unique blob.
       
   285 
       
   286   virtual void do_code_blob(CodeBlob* cb);
       
   287 
   257 
   288   class MarkScope : public StackObj {
   258   class MarkScope : public StackObj {
   289   protected:
   259   protected:
   290     bool _active;
   260     bool _active;
   291   public:
   261   public:
   293       // = { if (active) nmethod::oops_do_marking_prologue(); }
   263       // = { if (active) nmethod::oops_do_marking_prologue(); }
   294     ~MarkScope();
   264     ~MarkScope();
   295       // = { if (active) nmethod::oops_do_marking_epilogue(); }
   265       // = { if (active) nmethod::oops_do_marking_epilogue(); }
   296   };
   266   };
   297 };
   267 };
       
   268 
       
   269 
       
   270 // Applies an oop closure to all ref fields in code blobs
       
   271 // iterated over in an object iteration.
       
   272 class CodeBlobToOopClosure: public MarkingCodeBlobClosure {
       
   273   OopClosure* _cl;
       
   274   bool _do_marking;
       
   275 public:
       
   276   virtual void do_newly_marked_nmethod(nmethod* cb);
       
   277     // = { cb->oops_do(_cl); }
       
   278   virtual void do_code_blob(CodeBlob* cb);
       
   279     // = { if (_do_marking)  super::do_code_blob(cb); else cb->oops_do(_cl); }
       
   280   CodeBlobToOopClosure(OopClosure* cl, bool do_marking)
       
   281     : _cl(cl), _do_marking(do_marking) {}
       
   282 };
       
   283 
       
   284 
   298 
   285 
   299 // MonitorClosure is used for iterating over monitors in the monitors cache
   286 // MonitorClosure is used for iterating over monitors in the monitors cache
   300 
   287 
   301 class ObjectMonitor;
   288 class ObjectMonitor;
   302 
   289