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

Thu, 26 Sep 2013 10:25:02 -0400

author
hseigel
date
Thu, 26 Sep 2013 10:25:02 -0400
changeset 5784
190899198332
parent 5341
b30744960351
child 5820
798522662fcd
permissions
-rw-r--r--

7195622: CheckUnhandledOops has limited usefulness now
Summary: Enable CHECK_UNHANDLED_OOPS in fastdebug builds across all supported platforms.
Reviewed-by: coleenp, hseigel, dholmes, stefank, twisti, ihse, rdurbin
Contributed-by: lois.foltan@oracle.com

ysr@777 1 /*
hseigel@5784 2 * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
ysr@777 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ysr@777 4 *
ysr@777 5 * This code is free software; you can redistribute it and/or modify it
ysr@777 6 * under the terms of the GNU General Public License version 2 only, as
ysr@777 7 * published by the Free Software Foundation.
ysr@777 8 *
ysr@777 9 * This code is distributed in the hope that it will be useful, but WITHOUT
ysr@777 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ysr@777 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
ysr@777 12 * version 2 for more details (a copy is included in the LICENSE file that
ysr@777 13 * accompanied this code).
ysr@777 14 *
ysr@777 15 * You should have received a copy of the GNU General Public License version
ysr@777 16 * 2 along with this work; if not, write to the Free Software Foundation,
ysr@777 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ysr@777 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
ysr@777 22 *
ysr@777 23 */
ysr@777 24
stefank@2314 25 #include "precompiled.hpp"
stefank@2314 26 #include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp"
stefank@2314 27 #include "gc_implementation/g1/heapRegion.hpp"
stefank@2314 28 #include "gc_implementation/g1/satbQueue.hpp"
stefank@2314 29 #include "runtime/mutexLocker.hpp"
stefank@4299 30 #include "runtime/thread.inline.hpp"
ysr@777 31
ysr@777 32 G1SATBCardTableModRefBS::G1SATBCardTableModRefBS(MemRegion whole_heap,
ysr@777 33 int max_covered_regions) :
ysr@777 34 CardTableModRefBSForCTRS(whole_heap, max_covered_regions)
ysr@777 35 {
ysr@777 36 _kind = G1SATBCT;
ysr@777 37 }
ysr@777 38
ysr@777 39
ysr@777 40 void G1SATBCardTableModRefBS::enqueue(oop pre_val) {
johnc@2781 41 // Nulls should have been already filtered.
johnc@2781 42 assert(pre_val->is_oop(true), "Error");
johnc@2781 43
tonyp@1752 44 if (!JavaThread::satb_mark_queue_set().is_active()) return;
ysr@777 45 Thread* thr = Thread::current();
ysr@777 46 if (thr->is_Java_thread()) {
ysr@777 47 JavaThread* jt = (JavaThread*)thr;
ysr@777 48 jt->satb_mark_queue().enqueue(pre_val);
ysr@777 49 } else {
brutisso@5341 50 MutexLockerEx x(Shared_SATB_Q_lock, Mutex::_no_safepoint_check_flag);
ysr@777 51 JavaThread::satb_mark_queue_set().shared_satb_queue()->enqueue(pre_val);
ysr@777 52 }
ysr@777 53 }
ysr@777 54
ysr@1280 55 template <class T> void
ysr@1280 56 G1SATBCardTableModRefBS::write_ref_array_pre_work(T* dst, int count) {
tonyp@1752 57 if (!JavaThread::satb_mark_queue_set().is_active()) return;
ysr@1280 58 T* elem_ptr = dst;
ysr@1280 59 for (int i = 0; i < count; i++, elem_ptr++) {
ysr@1280 60 T heap_oop = oopDesc::load_heap_oop(elem_ptr);
ysr@1280 61 if (!oopDesc::is_null(heap_oop)) {
ysr@1280 62 enqueue(oopDesc::decode_heap_oop_not_null(heap_oop));
ysr@1280 63 }
ysr@777 64 }
ysr@777 65 }
ysr@777 66
ysr@777 67 G1SATBCardTableLoggingModRefBS::
ysr@777 68 G1SATBCardTableLoggingModRefBS(MemRegion whole_heap,
ysr@777 69 int max_covered_regions) :
ysr@777 70 G1SATBCardTableModRefBS(whole_heap, max_covered_regions),
ysr@777 71 _dcqs(JavaThread::dirty_card_queue_set())
ysr@777 72 {
ysr@777 73 _kind = G1SATBCTLogging;
ysr@777 74 }
ysr@777 75
ysr@777 76 void
ysr@777 77 G1SATBCardTableLoggingModRefBS::write_ref_field_work(void* field,
ysr@777 78 oop new_val) {
ysr@777 79 jbyte* byte = byte_for(field);
ysr@777 80 if (*byte != dirty_card) {
ysr@777 81 *byte = dirty_card;
ysr@777 82 Thread* thr = Thread::current();
ysr@777 83 if (thr->is_Java_thread()) {
ysr@777 84 JavaThread* jt = (JavaThread*)thr;
ysr@777 85 jt->dirty_card_queue().enqueue(byte);
ysr@777 86 } else {
ysr@777 87 MutexLockerEx x(Shared_DirtyCardQ_lock,
ysr@777 88 Mutex::_no_safepoint_check_flag);
ysr@777 89 _dcqs.shared_dirty_card_queue()->enqueue(byte);
ysr@777 90 }
ysr@777 91 }
ysr@777 92 }
ysr@777 93
ysr@777 94 void
ysr@777 95 G1SATBCardTableLoggingModRefBS::write_ref_field_static(void* field,
ysr@777 96 oop new_val) {
ysr@777 97 uintptr_t field_uint = (uintptr_t)field;
hseigel@5784 98 uintptr_t new_val_uint = cast_from_oop<uintptr_t>(new_val);
ysr@777 99 uintptr_t comb = field_uint ^ new_val_uint;
ysr@777 100 comb = comb >> HeapRegion::LogOfHRGrainBytes;
ysr@777 101 if (comb == 0) return;
ysr@777 102 if (new_val == NULL) return;
ysr@777 103 // Otherwise, log it.
ysr@777 104 G1SATBCardTableLoggingModRefBS* g1_bs =
ysr@777 105 (G1SATBCardTableLoggingModRefBS*)Universe::heap()->barrier_set();
ysr@777 106 g1_bs->write_ref_field_work(field, new_val);
ysr@777 107 }
ysr@777 108
ysr@777 109 void
ysr@777 110 G1SATBCardTableLoggingModRefBS::invalidate(MemRegion mr, bool whole_heap) {
ysr@777 111 jbyte* byte = byte_for(mr.start());
ysr@777 112 jbyte* last_byte = byte_for(mr.last());
ysr@777 113 Thread* thr = Thread::current();
ysr@777 114 if (whole_heap) {
ysr@777 115 while (byte <= last_byte) {
ysr@777 116 *byte = dirty_card;
ysr@777 117 byte++;
ysr@777 118 }
ysr@777 119 } else {
ysr@777 120 // Enqueue if necessary.
ysr@777 121 if (thr->is_Java_thread()) {
ysr@777 122 JavaThread* jt = (JavaThread*)thr;
ysr@777 123 while (byte <= last_byte) {
ysr@777 124 if (*byte != dirty_card) {
ysr@777 125 *byte = dirty_card;
ysr@777 126 jt->dirty_card_queue().enqueue(byte);
ysr@777 127 }
ysr@777 128 byte++;
ysr@777 129 }
ysr@777 130 } else {
ysr@777 131 MutexLockerEx x(Shared_DirtyCardQ_lock,
ysr@777 132 Mutex::_no_safepoint_check_flag);
ysr@777 133 while (byte <= last_byte) {
ysr@777 134 if (*byte != dirty_card) {
ysr@777 135 *byte = dirty_card;
ysr@777 136 _dcqs.shared_dirty_card_queue()->enqueue(byte);
ysr@777 137 }
ysr@777 138 byte++;
ysr@777 139 }
ysr@777 140 }
ysr@777 141 }
ysr@777 142 }

mercurial