src/share/vm/gc_implementation/g1/g1OopClosures.hpp

Tue, 19 May 2009 04:05:31 -0700

author
apetrusenko
date
Tue, 19 May 2009 04:05:31 -0700
changeset 1231
29e7d79232b9
parent 1014
0fbdb4381b99
child 1280
df6caf649ff7
permissions
-rw-r--r--

6819065: G1: eliminate high serial card table clearing time
Reviewed-by: iveresov, tonyp

     1 /*
     2  * Copyright 2001-2009 Sun Microsystems, Inc.  All Rights Reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    20  * CA 95054 USA or visit www.sun.com if you need additional information or
    21  * have any questions.
    22  *
    23  */
    25 class HeapRegion;
    26 class G1CollectedHeap;
    27 class G1RemSet;
    28 class HRInto_G1RemSet;
    29 class G1RemSet;
    30 class ConcurrentMark;
    31 class DirtyCardToOopClosure;
    32 class CMBitMap;
    33 class CMMarkStack;
    34 class G1ParScanThreadState;
    36 // A class that scans oops in a given heap region (much as OopsInGenClosure
    37 // scans oops in a generation.)
    38 class OopsInHeapRegionClosure: public OopsInGenClosure {
    39 protected:
    40   HeapRegion* _from;
    41 public:
    42   virtual void set_region(HeapRegion* from) { _from = from; }
    43 };
    46 class G1ScanAndBalanceClosure : public OopClosure {
    47   G1CollectedHeap* _g1;
    48   static int _nq;
    49 public:
    50   G1ScanAndBalanceClosure(G1CollectedHeap* g1) : _g1(g1) { }
    51   inline  void do_oop_nv(oop* p);
    52   inline  void do_oop_nv(narrowOop* p) { guarantee(false, "NYI"); }
    53   virtual void do_oop(oop* p);
    54   virtual void do_oop(narrowOop* p)    { guarantee(false, "NYI"); }
    55 };
    57 class G1ParClosureSuper : public OopsInHeapRegionClosure {
    58 protected:
    59   G1CollectedHeap* _g1;
    60   G1RemSet* _g1_rem;
    61   ConcurrentMark* _cm;
    62   G1ParScanThreadState* _par_scan_state;
    63 public:
    64   G1ParClosureSuper(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state);
    65   bool apply_to_weak_ref_discovered_field() { return true; }
    66 };
    68 class G1ParScanClosure : public G1ParClosureSuper {
    69 public:
    70   G1ParScanClosure(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state) :
    71     G1ParClosureSuper(g1, par_scan_state) { }
    72   void do_oop_nv(oop* p);   // should be made inline
    73   inline  void do_oop_nv(narrowOop* p) { guarantee(false, "NYI"); }
    74   virtual void do_oop(oop* p)          { do_oop_nv(p); }
    75   virtual void do_oop(narrowOop* p)    { do_oop_nv(p); }
    76 };
    78 #define G1_PARTIAL_ARRAY_MASK 1
    80 inline bool has_partial_array_mask(oop* ref) {
    81   return (intptr_t) ref & G1_PARTIAL_ARRAY_MASK;
    82 }
    84 inline oop* set_partial_array_mask(oop obj) {
    85   return (oop*) ((intptr_t) obj | G1_PARTIAL_ARRAY_MASK);
    86 }
    88 inline oop clear_partial_array_mask(oop* ref) {
    89   return oop((intptr_t) ref & ~G1_PARTIAL_ARRAY_MASK);
    90 }
    92 class G1ParScanPartialArrayClosure : public G1ParClosureSuper {
    93   G1ParScanClosure _scanner;
    94   template <class T> void process_array_chunk(oop obj, int start, int end);
    95 public:
    96   G1ParScanPartialArrayClosure(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state) :
    97     G1ParClosureSuper(g1, par_scan_state), _scanner(g1, par_scan_state) { }
    98   void do_oop_nv(oop* p);
    99   void do_oop_nv(narrowOop* p)      { guarantee(false, "NYI"); }
   100   virtual void do_oop(oop* p)       { do_oop_nv(p); }
   101   virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
   102 };
   105 class G1ParCopyHelper : public G1ParClosureSuper {
   106   G1ParScanClosure *_scanner;
   107 protected:
   108   void mark_forwardee(oop* p);
   109   oop copy_to_survivor_space(oop obj);
   110 public:
   111   G1ParCopyHelper(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state,
   112                   G1ParScanClosure *scanner) :
   113     G1ParClosureSuper(g1, par_scan_state), _scanner(scanner) { }
   114 };
   116 template<bool do_gen_barrier, G1Barrier barrier,
   117          bool do_mark_forwardee, bool skip_cset_test>
   118 class G1ParCopyClosure : public G1ParCopyHelper {
   119   G1ParScanClosure _scanner;
   120   void do_oop_work(oop* p);
   121   void do_oop_work(narrowOop* p) { guarantee(false, "NYI"); }
   122 public:
   123   G1ParCopyClosure(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state) :
   124     _scanner(g1, par_scan_state), G1ParCopyHelper(g1, par_scan_state, &_scanner) { }
   125   inline void do_oop_nv(oop* p) {
   126     do_oop_work(p);
   127     if (do_mark_forwardee)
   128       mark_forwardee(p);
   129   }
   130   inline void do_oop_nv(narrowOop* p) { guarantee(false, "NYI"); }
   131   virtual void do_oop(oop* p)       { do_oop_nv(p); }
   132   virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
   133 };
   135 typedef G1ParCopyClosure<false, G1BarrierNone, false, false> G1ParScanExtRootClosure;
   136 typedef G1ParCopyClosure<true,  G1BarrierNone, false, false> G1ParScanPermClosure;
   137 typedef G1ParCopyClosure<false, G1BarrierNone, true,  false> G1ParScanAndMarkExtRootClosure;
   138 typedef G1ParCopyClosure<true,  G1BarrierNone, true,  false> G1ParScanAndMarkPermClosure;
   139 typedef G1ParCopyClosure<false, G1BarrierRS,   false, false> G1ParScanHeapRSClosure;
   140 typedef G1ParCopyClosure<false, G1BarrierRS,   true,  false> G1ParScanAndMarkHeapRSClosure;
   141 // This is the only case when we set skip_cset_test. Basically, this
   142 // closure is (should?) only be called directly while we're draining
   143 // the overflow and task queues. In that case we know that the
   144 // reference in question points into the collection set, otherwise we
   145 // would not have pushed it on the queue.
   146 typedef G1ParCopyClosure<false, G1BarrierEvac, false, true> G1ParScanHeapEvacClosure;
   147 // We need a separate closure to handle references during evacuation
   148 // failure processing, as it cannot asume that the reference already
   149  // points to the collection set (like G1ParScanHeapEvacClosure does).
   150 typedef G1ParCopyClosure<false, G1BarrierEvac, false, false> G1ParScanHeapEvacFailureClosure;
   152 class FilterIntoCSClosure: public OopClosure {
   153   G1CollectedHeap* _g1;
   154   OopClosure* _oc;
   155   DirtyCardToOopClosure* _dcto_cl;
   156 public:
   157   FilterIntoCSClosure(  DirtyCardToOopClosure* dcto_cl,
   158                         G1CollectedHeap* g1, OopClosure* oc) :
   159     _dcto_cl(dcto_cl), _g1(g1), _oc(oc)
   160   {}
   161   inline void do_oop_nv(oop* p);
   162   inline void do_oop_nv(narrowOop* p) { guarantee(false, "NYI"); }
   163   virtual void do_oop(oop* p);
   164   virtual void do_oop(narrowOop* p)   { guarantee(false, "NYI"); }
   165   bool apply_to_weak_ref_discovered_field() { return true; }
   166   bool do_header() { return false; }
   167 };
   169 class FilterInHeapRegionAndIntoCSClosure : public OopsInHeapRegionClosure {
   170   G1CollectedHeap* _g1;
   171   OopsInHeapRegionClosure* _oc;
   172 public:
   173   FilterInHeapRegionAndIntoCSClosure(G1CollectedHeap* g1,
   174                                      OopsInHeapRegionClosure* oc) :
   175     _g1(g1), _oc(oc)
   176   {}
   177   inline  void do_oop_nv(oop* p);
   178   inline  void do_oop_nv(narrowOop* p) { guarantee(false, "NYI"); }
   179   virtual void do_oop(oop* p);
   180   virtual void do_oop(narrowOop* p)    { guarantee(false, "NYI"); }
   181   bool apply_to_weak_ref_discovered_field() { return true; }
   182   bool do_header() { return false; }
   183   void set_region(HeapRegion* from) {
   184     _oc->set_region(from);
   185   }
   186 };
   188 class FilterAndMarkInHeapRegionAndIntoCSClosure : public OopsInHeapRegionClosure {
   189   G1CollectedHeap* _g1;
   190   ConcurrentMark* _cm;
   191   OopsInHeapRegionClosure* _oc;
   192 public:
   193   FilterAndMarkInHeapRegionAndIntoCSClosure(G1CollectedHeap* g1,
   194                                             OopsInHeapRegionClosure* oc,
   195                                             ConcurrentMark* cm)
   196   : _g1(g1), _oc(oc), _cm(cm) { }
   198   inline  void do_oop_nv(oop* p);
   199   inline  void do_oop_nv(narrowOop* p) { guarantee(false, "NYI"); }
   200   virtual void do_oop(oop* p);
   201   virtual void do_oop(narrowOop* p)    { guarantee(false, "NYI"); }
   202   bool apply_to_weak_ref_discovered_field() { return true; }
   203   bool do_header() { return false; }
   204   void set_region(HeapRegion* from) {
   205     _oc->set_region(from);
   206   }
   207 };
   209 class FilterOutOfRegionClosure: public OopClosure {
   210   HeapWord* _r_bottom;
   211   HeapWord* _r_end;
   212   OopClosure* _oc;
   213   int _out_of_region;
   214 public:
   215   FilterOutOfRegionClosure(HeapRegion* r, OopClosure* oc);
   216   inline  void do_oop_nv(oop* p);
   217   inline  void do_oop_nv(narrowOop* p) { guarantee(false, "NYI"); }
   218   virtual void do_oop(oop* p);
   219   virtual void do_oop(narrowOop* p)   { guarantee(false, "NYI"); }
   220   bool apply_to_weak_ref_discovered_field() { return true; }
   221   bool do_header() { return false; }
   222   int out_of_region() { return _out_of_region; }
   223 };

mercurial