< prev index next >

src/share/vm/gc/g1/g1SATBCardTableModRefBS.cpp

Print this page




  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/g1/g1CollectedHeap.inline.hpp"
  27 #include "gc/g1/g1SATBCardTableModRefBS.hpp"
  28 #include "gc/g1/heapRegion.hpp"
  29 #include "gc/g1/satbQueue.hpp"
  30 #include "gc/shared/memset_with_concurrent_readers.hpp"

  31 #include "oops/oop.inline.hpp"
  32 #include "runtime/atomic.inline.hpp"
  33 #include "runtime/mutexLocker.hpp"
  34 #include "runtime/orderAccess.inline.hpp"
  35 #include "runtime/thread.inline.hpp"
  36 
  37 G1SATBCardTableModRefBS::G1SATBCardTableModRefBS(
  38   MemRegion whole_heap,
  39   const BarrierSet::FakeRtti& fake_rtti) :
  40   CardTableModRefBS(whole_heap, fake_rtti.add_tag(BarrierSet::G1SATBCT))
  41 { }
  42 
  43 void G1SATBCardTableModRefBS::enqueue(oop pre_val) {
  44   // Nulls should have been already filtered.
  45   assert(pre_val->is_oop(true), "Error");
  46 
  47   if (!JavaThread::satb_mark_queue_set().is_active()) return;
  48   Thread* thr = Thread::current();
  49   if (thr->is_Java_thread()) {
  50     JavaThread* jt = (JavaThread*)thr;


 135 
 136 void G1SATBCardTableLoggingModRefBS::initialize(G1RegionToSpaceMapper* mapper) {
 137   mapper->set_mapping_changed_listener(&_listener);
 138 
 139   _byte_map_size = mapper->reserved().byte_size();
 140 
 141   _guard_index = cards_required(_whole_heap.word_size()) - 1;
 142   _last_valid_index = _guard_index - 1;
 143 
 144   HeapWord* low_bound  = _whole_heap.start();
 145   HeapWord* high_bound = _whole_heap.end();
 146 
 147   _cur_covered_regions = 1;
 148   _covered[0] = _whole_heap;
 149 
 150   _byte_map = (jbyte*) mapper->reserved().start();
 151   byte_map_base = _byte_map - (uintptr_t(low_bound) >> card_shift);
 152   assert(byte_for(low_bound) == &_byte_map[0], "Checking start of map");
 153   assert(byte_for(high_bound-1) <= &_byte_map[_last_valid_index], "Checking end of map");
 154 
 155   if (TraceCardTableModRefBS) {
 156     gclog_or_tty->print_cr("G1SATBCardTableModRefBS::G1SATBCardTableModRefBS: ");
 157     gclog_or_tty->print_cr("  "
 158                   "  &_byte_map[0]: " INTPTR_FORMAT
 159                   "  &_byte_map[_last_valid_index]: " INTPTR_FORMAT,
 160                   p2i(&_byte_map[0]),
 161                   p2i(&_byte_map[_last_valid_index]));
 162     gclog_or_tty->print_cr("  "
 163                   "  byte_map_base: " INTPTR_FORMAT,
 164                   p2i(byte_map_base));
 165   }
 166 }
 167 
 168 void
 169 G1SATBCardTableLoggingModRefBS::write_ref_field_work(void* field,
 170                                                      oop new_val,
 171                                                      bool release) {
 172   volatile jbyte* byte = byte_for(field);
 173   if (*byte == g1_young_gen) {
 174     return;
 175   }
 176   OrderAccess::storeload();
 177   if (*byte != dirty_card) {
 178     *byte = dirty_card;
 179     Thread* thr = Thread::current();
 180     if (thr->is_Java_thread()) {
 181       JavaThread* jt = (JavaThread*)thr;
 182       jt->dirty_card_queue().enqueue(byte);
 183     } else {
 184       MutexLockerEx x(Shared_DirtyCardQ_lock,
 185                       Mutex::_no_safepoint_check_flag);




  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/g1/g1CollectedHeap.inline.hpp"
  27 #include "gc/g1/g1SATBCardTableModRefBS.hpp"
  28 #include "gc/g1/heapRegion.hpp"
  29 #include "gc/g1/satbQueue.hpp"
  30 #include "gc/shared/memset_with_concurrent_readers.hpp"
  31 #include "logging/log.hpp"
  32 #include "oops/oop.inline.hpp"
  33 #include "runtime/atomic.inline.hpp"
  34 #include "runtime/mutexLocker.hpp"
  35 #include "runtime/orderAccess.inline.hpp"
  36 #include "runtime/thread.inline.hpp"
  37 
  38 G1SATBCardTableModRefBS::G1SATBCardTableModRefBS(
  39   MemRegion whole_heap,
  40   const BarrierSet::FakeRtti& fake_rtti) :
  41   CardTableModRefBS(whole_heap, fake_rtti.add_tag(BarrierSet::G1SATBCT))
  42 { }
  43 
  44 void G1SATBCardTableModRefBS::enqueue(oop pre_val) {
  45   // Nulls should have been already filtered.
  46   assert(pre_val->is_oop(true), "Error");
  47 
  48   if (!JavaThread::satb_mark_queue_set().is_active()) return;
  49   Thread* thr = Thread::current();
  50   if (thr->is_Java_thread()) {
  51     JavaThread* jt = (JavaThread*)thr;


 136 
 137 void G1SATBCardTableLoggingModRefBS::initialize(G1RegionToSpaceMapper* mapper) {
 138   mapper->set_mapping_changed_listener(&_listener);
 139 
 140   _byte_map_size = mapper->reserved().byte_size();
 141 
 142   _guard_index = cards_required(_whole_heap.word_size()) - 1;
 143   _last_valid_index = _guard_index - 1;
 144 
 145   HeapWord* low_bound  = _whole_heap.start();
 146   HeapWord* high_bound = _whole_heap.end();
 147 
 148   _cur_covered_regions = 1;
 149   _covered[0] = _whole_heap;
 150 
 151   _byte_map = (jbyte*) mapper->reserved().start();
 152   byte_map_base = _byte_map - (uintptr_t(low_bound) >> card_shift);
 153   assert(byte_for(low_bound) == &_byte_map[0], "Checking start of map");
 154   assert(byte_for(high_bound-1) <= &_byte_map[_last_valid_index], "Checking end of map");
 155 
 156     log_trace(barrier)("G1SATBCardTableModRefBS::G1SATBCardTableModRefBS: ");
 157     log_trace(barrier)("    &_byte_map[0]: " INTPTR_FORMAT "  &_byte_map[_last_valid_index]: " INTPTR_FORMAT,
 158                   p2i(&_byte_map[0]), p2i(&_byte_map[_last_valid_index]));
 159     log_trace(barrier)("    byte_map_base: " INTPTR_FORMAT,  p2i(byte_map_base));







 160 }
 161 
 162 void
 163 G1SATBCardTableLoggingModRefBS::write_ref_field_work(void* field,
 164                                                      oop new_val,
 165                                                      bool release) {
 166   volatile jbyte* byte = byte_for(field);
 167   if (*byte == g1_young_gen) {
 168     return;
 169   }
 170   OrderAccess::storeload();
 171   if (*byte != dirty_card) {
 172     *byte = dirty_card;
 173     Thread* thr = Thread::current();
 174     if (thr->is_Java_thread()) {
 175       JavaThread* jt = (JavaThread*)thr;
 176       jt->dirty_card_queue().enqueue(byte);
 177     } else {
 178       MutexLockerEx x(Shared_DirtyCardQ_lock,
 179                       Mutex::_no_safepoint_check_flag);


< prev index next >