src/share/vm/memory/genOopClosures.hpp

changeset 4037
da91efe96a93
parent 3900
d2a62e0f25eb
child 6680
78bbf4d43a14
     1.1 --- a/src/share/vm/memory/genOopClosures.hpp	Fri Aug 31 16:39:35 2012 -0700
     1.2 +++ b/src/share/vm/memory/genOopClosures.hpp	Sat Sep 01 13:25:18 2012 -0400
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -33,6 +33,7 @@
    1.11  class CardTableRS;
    1.12  class CardTableModRefBS;
    1.13  class DefNewGeneration;
    1.14 +class KlassRemSet;
    1.15  
    1.16  template<class E, MEMFLAGS F, unsigned int N> class GenericTaskQueue;
    1.17  typedef GenericTaskQueue<oop, mtGC, TASKQUEUE_SIZE> OopTaskQueue;
    1.18 @@ -44,7 +45,7 @@
    1.19  // method at the end of their own do_oop method!
    1.20  // Note: no do_oop defined, this is an abstract class.
    1.21  
    1.22 -class OopsInGenClosure : public OopClosure {
    1.23 +class OopsInGenClosure : public ExtendedOopClosure {
    1.24   private:
    1.25    Generation*  _orig_gen;     // generation originally set in ctor
    1.26    Generation*  _gen;          // generation being scanned
    1.27 @@ -66,7 +67,7 @@
    1.28    template <class T> void par_do_barrier(T* p);
    1.29  
    1.30   public:
    1.31 -  OopsInGenClosure() : OopClosure(NULL),
    1.32 +  OopsInGenClosure() : ExtendedOopClosure(NULL),
    1.33      _orig_gen(NULL), _gen(NULL), _gen_boundary(NULL), _rs(NULL) {};
    1.34  
    1.35    OopsInGenClosure(Generation* gen);
    1.36 @@ -82,13 +83,27 @@
    1.37    }
    1.38  
    1.39    HeapWord* gen_boundary() { return _gen_boundary; }
    1.40 +
    1.41 +};
    1.42 +
    1.43 +// Super class for scan closures. It contains code to dirty scanned Klasses.
    1.44 +class OopsInKlassOrGenClosure: public OopsInGenClosure {
    1.45 +  Klass* _scanned_klass;
    1.46 + public:
    1.47 +  OopsInKlassOrGenClosure(Generation* g) : OopsInGenClosure(g), _scanned_klass(NULL) {}
    1.48 +  void set_scanned_klass(Klass* k) {
    1.49 +    assert(k == NULL || _scanned_klass == NULL, "Must be");
    1.50 +    _scanned_klass = k;
    1.51 +  }
    1.52 +  bool is_scanning_a_klass() { return _scanned_klass != NULL; }
    1.53 +  void do_klass_barrier();
    1.54  };
    1.55  
    1.56  // Closure for scanning DefNewGeneration.
    1.57  //
    1.58  // This closure will perform barrier store calls for ALL
    1.59  // pointers in scanned oops.
    1.60 -class ScanClosure: public OopsInGenClosure {
    1.61 +class ScanClosure: public OopsInKlassOrGenClosure {
    1.62   protected:
    1.63    DefNewGeneration* _g;
    1.64    HeapWord*         _boundary;
    1.65 @@ -100,7 +115,6 @@
    1.66    virtual void do_oop(narrowOop* p);
    1.67    inline void do_oop_nv(oop* p);
    1.68    inline void do_oop_nv(narrowOop* p);
    1.69 -  bool do_header() { return false; }
    1.70    Prefetch::style prefetch_style() {
    1.71      return Prefetch::do_write;
    1.72    }
    1.73 @@ -111,7 +125,7 @@
    1.74  // This closure only performs barrier store calls on
    1.75  // pointers into the DefNewGeneration. This is less
    1.76  // precise, but faster, than a ScanClosure
    1.77 -class FastScanClosure: public OopsInGenClosure {
    1.78 +class FastScanClosure: public OopsInKlassOrGenClosure {
    1.79   protected:
    1.80    DefNewGeneration* _g;
    1.81    HeapWord*         _boundary;
    1.82 @@ -123,16 +137,25 @@
    1.83    virtual void do_oop(narrowOop* p);
    1.84    inline void do_oop_nv(oop* p);
    1.85    inline void do_oop_nv(narrowOop* p);
    1.86 -  bool do_header() { return false; }
    1.87    Prefetch::style prefetch_style() {
    1.88      return Prefetch::do_write;
    1.89    }
    1.90  };
    1.91  
    1.92 -class FilteringClosure: public OopClosure {
    1.93 +class KlassScanClosure: public KlassClosure {
    1.94 +  OopsInKlassOrGenClosure* _scavenge_closure;
    1.95 +  // true if the the modified oops state should be saved.
    1.96 +  bool                     _accumulate_modified_oops;
    1.97 + public:
    1.98 +  KlassScanClosure(OopsInKlassOrGenClosure* scavenge_closure,
    1.99 +                   KlassRemSet* klass_rem_set_policy);
   1.100 +  void do_klass(Klass* k);
   1.101 +};
   1.102 +
   1.103 +class FilteringClosure: public ExtendedOopClosure {
   1.104   private:
   1.105    HeapWord*   _boundary;
   1.106 -  OopClosure* _cl;
   1.107 +  ExtendedOopClosure* _cl;
   1.108   protected:
   1.109    template <class T> inline void do_oop_work(T* p) {
   1.110      T heap_oop = oopDesc::load_heap_oop(p);
   1.111 @@ -144,14 +167,15 @@
   1.112      }
   1.113    }
   1.114   public:
   1.115 -  FilteringClosure(HeapWord* boundary, OopClosure* cl) :
   1.116 -    OopClosure(cl->_ref_processor), _boundary(boundary),
   1.117 +  FilteringClosure(HeapWord* boundary, ExtendedOopClosure* cl) :
   1.118 +    ExtendedOopClosure(cl->_ref_processor), _boundary(boundary),
   1.119      _cl(cl) {}
   1.120    virtual void do_oop(oop* p);
   1.121    virtual void do_oop(narrowOop* p);
   1.122    inline void do_oop_nv(oop* p)       { FilteringClosure::do_oop_work(p); }
   1.123    inline void do_oop_nv(narrowOop* p) { FilteringClosure::do_oop_work(p); }
   1.124 -  bool do_header() { return false; }
   1.125 +  virtual bool do_metadata()          { return do_metadata_nv(); }
   1.126 +  inline bool do_metadata_nv()        { assert(!_cl->do_metadata(), "assumption broken, must change to 'return _cl->do_metadata()'"); return false; }
   1.127  };
   1.128  
   1.129  // Closure for scanning DefNewGeneration's weak references.

mercurial