< prev index next >

src/hotspot/share/gc/parallel/psCardTable.cpp

Print this page


   1 /*
   2  * Copyright (c) 2001, 2019, Oracle and/or its affiliates. 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 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 #include "precompiled.hpp"

  26 #include "gc/parallel/objectStartArray.inline.hpp"
  27 #include "gc/parallel/parallelScavengeHeap.inline.hpp"
  28 #include "gc/parallel/psCardTable.hpp"
  29 #include "gc/parallel/psPromotionManager.inline.hpp"
  30 #include "gc/parallel/psScavenge.inline.hpp"

  31 #include "gc/parallel/psYoungGen.hpp"
  32 #include "memory/iterator.inline.hpp"
  33 #include "oops/access.inline.hpp"
  34 #include "oops/oop.inline.hpp"
  35 #include "runtime/prefetch.inline.hpp"
  36 #include "utilities/align.hpp"
  37 
  38 // Checks an individual oop for missing precise marks. Mark
  39 // may be either dirty or newgen.
  40 class CheckForUnmarkedOops : public BasicOopIterateClosure {
  41  private:
  42   PSYoungGen*  _young_gen;
  43   PSCardTable* _card_table;
  44   HeapWord*    _unmarked_addr;
  45 
  46  protected:
  47   template <class T> void do_oop_work(T* p) {
  48     oop obj = RawAccess<>::oop_load(p);
  49     if (_young_gen->is_in_reserved(obj) &&
  50         !_card_table->addr_is_marked_imprecise(p)) {


 108       _card_table->set_card_newgen(p);
 109     }
 110   }
 111 
 112  public:
 113   CheckForPreciseMarks(PSYoungGen* young_gen, PSCardTable* card_table) :
 114     _young_gen(young_gen), _card_table(card_table) { }
 115 
 116   virtual void do_oop(oop* p)       { CheckForPreciseMarks::do_oop_work(p); }
 117   virtual void do_oop(narrowOop* p) { CheckForPreciseMarks::do_oop_work(p); }
 118 };
 119 
 120 // We get passed the space_top value to prevent us from traversing into
 121 // the old_gen promotion labs, which cannot be safely parsed.
 122 
 123 // Do not call this method if the space is empty.
 124 // It is a waste to start tasks and get here only to
 125 // do no work.  If this method needs to be called
 126 // when the space is empty, fix the calculation of
 127 // end_card to allow sp_top == sp->bottom().
 128 
 129 // The generation (old gen) is divided into slices, which are further
 130 // subdivided into stripes, with one stripe per GC thread. The size of
 131 // a stripe is a constant, ssize.
 132 //
 133 //      +===============+        slice 0
 134 //      |  stripe 0     |
 135 //      +---------------+
 136 //      |  stripe 1     |
 137 //      +---------------+
 138 //      |  stripe 2     |
 139 //      +---------------+
 140 //      |  stripe 3     |
 141 //      +===============+        slice 1
 142 //      |  stripe 0     |
 143 //      +---------------+
 144 //      |  stripe 1     |
 145 //      +---------------+
 146 //      |  stripe 2     |
 147 //      +---------------+
 148 //      |  stripe 3     |
 149 //      +===============+        slice 2
 150 //      ...
 151 //
 152 // In this case there are 4 threads, so 4 stripes.  A GC thread first works on
 153 // its stripe within slice 0 and then moves to its stripe in the next slice
 154 // until it has exceeded the top of the generation.  The distance to stripe in
 155 // the next slice is calculated based on the number of stripes.  The next
 156 // stripe is at ssize * number_of_stripes (= slice_stride)..  So after
 157 // finishing stripe 0 in slice 0, the thread finds the stripe 0 in slice1 by
 158 // adding slice_stride to the start of stripe 0 in slice 0 to get to the start
 159 // of stride 0 in slice 1.
 160 
 161 void PSCardTable::scavenge_contents_parallel(ObjectStartArray* start_array,
 162                                              MutableSpace* sp,
 163                                              HeapWord* space_top,
 164                                              PSPromotionManager* pm,
 165                                              uint stripe_number,
 166                                              uint stripe_total) {
 167   int ssize = 128; // Naked constant!  Work unit = 64k.
 168   int dirty_card_count = 0;
 169 
 170   // It is a waste to get here if empty.
 171   assert(sp->bottom() < sp->top(), "Should not be called if empty");
 172   oop* sp_top = (oop*)space_top;
 173   CardValue* start_card = byte_for(sp->bottom());
 174   CardValue* end_card   = byte_for(sp_top - 1) + 1;
 175   oop* last_scanned = NULL; // Prevent scanning objects more than once
 176   // The width of the stripe ssize*stripe_total must be
 177   // consistent with the number of stripes so that the complete slice
 178   // is covered.
 179   size_t slice_width = ssize * stripe_total;


   1 /*
   2  * Copyright (c) 2001, 2018, Oracle and/or its affiliates. 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 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 #include "precompiled.hpp"
  26 #include "gc/parallel/gcTaskManager.hpp"
  27 #include "gc/parallel/objectStartArray.inline.hpp"
  28 #include "gc/parallel/parallelScavengeHeap.inline.hpp"
  29 #include "gc/parallel/psCardTable.hpp"
  30 #include "gc/parallel/psPromotionManager.inline.hpp"
  31 #include "gc/parallel/psScavenge.inline.hpp"
  32 #include "gc/parallel/psTasks.hpp"
  33 #include "gc/parallel/psYoungGen.hpp"
  34 #include "memory/iterator.inline.hpp"
  35 #include "oops/access.inline.hpp"
  36 #include "oops/oop.inline.hpp"
  37 #include "runtime/prefetch.inline.hpp"
  38 #include "utilities/align.hpp"
  39 
  40 // Checks an individual oop for missing precise marks. Mark
  41 // may be either dirty or newgen.
  42 class CheckForUnmarkedOops : public BasicOopIterateClosure {
  43  private:
  44   PSYoungGen*  _young_gen;
  45   PSCardTable* _card_table;
  46   HeapWord*    _unmarked_addr;
  47 
  48  protected:
  49   template <class T> void do_oop_work(T* p) {
  50     oop obj = RawAccess<>::oop_load(p);
  51     if (_young_gen->is_in_reserved(obj) &&
  52         !_card_table->addr_is_marked_imprecise(p)) {


 110       _card_table->set_card_newgen(p);
 111     }
 112   }
 113 
 114  public:
 115   CheckForPreciseMarks(PSYoungGen* young_gen, PSCardTable* card_table) :
 116     _young_gen(young_gen), _card_table(card_table) { }
 117 
 118   virtual void do_oop(oop* p)       { CheckForPreciseMarks::do_oop_work(p); }
 119   virtual void do_oop(narrowOop* p) { CheckForPreciseMarks::do_oop_work(p); }
 120 };
 121 
 122 // We get passed the space_top value to prevent us from traversing into
 123 // the old_gen promotion labs, which cannot be safely parsed.
 124 
 125 // Do not call this method if the space is empty.
 126 // It is a waste to start tasks and get here only to
 127 // do no work.  If this method needs to be called
 128 // when the space is empty, fix the calculation of
 129 // end_card to allow sp_top == sp->bottom().
































 130 
 131 void PSCardTable::scavenge_contents_parallel(ObjectStartArray* start_array,
 132                                              MutableSpace* sp,
 133                                              HeapWord* space_top,
 134                                              PSPromotionManager* pm,
 135                                              uint stripe_number,
 136                                              uint stripe_total) {
 137   int ssize = 128; // Naked constant!  Work unit = 64k.
 138   int dirty_card_count = 0;
 139 
 140   // It is a waste to get here if empty.
 141   assert(sp->bottom() < sp->top(), "Should not be called if empty");
 142   oop* sp_top = (oop*)space_top;
 143   CardValue* start_card = byte_for(sp->bottom());
 144   CardValue* end_card   = byte_for(sp_top - 1) + 1;
 145   oop* last_scanned = NULL; // Prevent scanning objects more than once
 146   // The width of the stripe ssize*stripe_total must be
 147   // consistent with the number of stripes so that the complete slice
 148   // is covered.
 149   size_t slice_width = ssize * stripe_total;


< prev index next >