1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/gc_implementation/g1/g1RemSet.inline.hpp Thu Jun 05 15:57:56 2008 -0700 1.3 @@ -0,0 +1,104 @@ 1.4 +/* 1.5 + * Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 1.24 + * have any questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +inline size_t G1RemSet::n_workers() { 1.29 + if (_g1->workers() != NULL) { 1.30 + return _g1->workers()->total_workers(); 1.31 + } else { 1.32 + return 1; 1.33 + } 1.34 +} 1.35 + 1.36 +inline void HRInto_G1RemSet::write_ref_nv(HeapRegion* from, oop* p) { 1.37 + oop obj = *p; 1.38 + assert(from != NULL && from->is_in_reserved(p), 1.39 + "p is not in a from"); 1.40 + HeapRegion* to = _g1->heap_region_containing(obj); 1.41 + if (from != to && to != NULL) { 1.42 + if (!to->popular() && !from->is_survivor()) { 1.43 +#if G1_REM_SET_LOGGING 1.44 + gclog_or_tty->print_cr("Adding " PTR_FORMAT " (" PTR_FORMAT ") to RS" 1.45 + " for region [" PTR_FORMAT ", " PTR_FORMAT ")", 1.46 + p, obj, 1.47 + to->bottom(), to->end()); 1.48 +#endif 1.49 + assert(to->rem_set() != NULL, "Need per-region 'into' remsets."); 1.50 + if (to->rem_set()->add_reference(p)) { 1.51 + _g1->schedule_popular_region_evac(to); 1.52 + } 1.53 + } 1.54 + } 1.55 +} 1.56 + 1.57 +inline void HRInto_G1RemSet::write_ref(HeapRegion* from, oop* p) { 1.58 + write_ref_nv(from, p); 1.59 +} 1.60 + 1.61 +inline bool HRInto_G1RemSet::self_forwarded(oop obj) { 1.62 + bool result = (obj->is_forwarded() && (obj->forwardee()== obj)); 1.63 + return result; 1.64 +} 1.65 + 1.66 +inline void HRInto_G1RemSet::par_write_ref(HeapRegion* from, oop* p, int tid) { 1.67 + oop obj = *p; 1.68 +#ifdef ASSERT 1.69 + // can't do because of races 1.70 + // assert(obj == NULL || obj->is_oop(), "expected an oop"); 1.71 + 1.72 + // Do the safe subset of is_oop 1.73 + if (obj != NULL) { 1.74 +#ifdef CHECK_UNHANDLED_OOPS 1.75 + oopDesc* o = obj.obj(); 1.76 +#else 1.77 + oopDesc* o = obj; 1.78 +#endif // CHECK_UNHANDLED_OOPS 1.79 + assert((intptr_t)o % MinObjAlignmentInBytes == 0, "not oop aligned"); 1.80 + assert(Universe::heap()->is_in_reserved(obj), "must be in heap"); 1.81 + } 1.82 +#endif // ASSERT 1.83 + assert(from == NULL || from->is_in_reserved(p), 1.84 + "p is not in from"); 1.85 + HeapRegion* to = _g1->heap_region_containing(obj); 1.86 + // The test below could be optimized by applying a bit op to to and from. 1.87 + if (to != NULL && from != NULL && from != to) { 1.88 + if (!to->popular() && !from->is_survivor()) { 1.89 +#if G1_REM_SET_LOGGING 1.90 + gclog_or_tty->print_cr("Adding " PTR_FORMAT " (" PTR_FORMAT ") to RS" 1.91 + " for region [" PTR_FORMAT ", " PTR_FORMAT ")", 1.92 + p, obj, 1.93 + to->bottom(), to->end()); 1.94 +#endif 1.95 + assert(to->rem_set() != NULL, "Need per-region 'into' remsets."); 1.96 + if (to->rem_set()->add_reference(p, tid)) { 1.97 + _g1->schedule_popular_region_evac(to); 1.98 + } 1.99 + } 1.100 + // There is a tricky infinite loop if we keep pushing 1.101 + // self forwarding pointers onto our _new_refs list. 1.102 + if (_par_traversal_in_progress && 1.103 + to->in_collection_set() && !self_forwarded(obj)) { 1.104 + _new_refs[tid]->push(p); 1.105 + } 1.106 + } 1.107 +}