src/share/vm/gc_implementation/parNew/parOopClosures.inline.hpp

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

author
hseigel
date
Thu, 26 Sep 2013 10:25:02 -0400
changeset 5784
190899198332
parent 4037
da91efe96a93
child 6680
78bbf4d43a14
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

duke@435 1 /*
hseigel@5784 2 * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 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.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #ifndef SHARE_VM_GC_IMPLEMENTATION_PARNEW_PAROOPCLOSURES_INLINE_HPP
stefank@2314 26 #define SHARE_VM_GC_IMPLEMENTATION_PARNEW_PAROOPCLOSURES_INLINE_HPP
stefank@2314 27
stefank@2314 28 #include "gc_implementation/parNew/parNewGeneration.hpp"
stefank@2314 29 #include "gc_implementation/parNew/parOopClosures.hpp"
stefank@2314 30 #include "memory/cardTableRS.hpp"
stefank@2314 31
coleenp@548 32 template <class T> inline void ParScanWeakRefClosure::do_oop_work(T* p) {
coleenp@548 33 assert (!oopDesc::is_null(*p), "null weak reference?");
coleenp@548 34 oop obj = oopDesc::load_decode_heap_oop_not_null(p);
duke@435 35 // weak references are sometimes scanned twice; must check
duke@435 36 // that to-space doesn't already contain this object
duke@435 37 if ((HeapWord*)obj < _boundary && !_g->to()->is_in_reserved(obj)) {
duke@435 38 // we need to ensure that it is copied (see comment in
duke@435 39 // ParScanClosure::do_oop_work).
coleenp@4037 40 Klass* objK = obj->klass();
duke@435 41 markOop m = obj->mark();
coleenp@548 42 oop new_obj;
duke@435 43 if (m->is_marked()) { // Contains forwarding pointer.
coleenp@548 44 new_obj = ParNewGeneration::real_forwardee(obj);
duke@435 45 } else {
coleenp@4037 46 size_t obj_sz = obj->size_given_klass(objK);
coleenp@548 47 new_obj = ((ParNewGeneration*)_g)->copy_to_survivor_space(_par_scan_state,
coleenp@548 48 obj, obj_sz, m);
duke@435 49 }
coleenp@548 50 oopDesc::encode_store_heap_oop_not_null(p, new_obj);
duke@435 51 }
duke@435 52 }
duke@435 53
coleenp@548 54 inline void ParScanWeakRefClosure::do_oop_nv(oop* p) { ParScanWeakRefClosure::do_oop_work(p); }
coleenp@548 55 inline void ParScanWeakRefClosure::do_oop_nv(narrowOop* p) { ParScanWeakRefClosure::do_oop_work(p); }
duke@435 56
coleenp@548 57 template <class T> inline void ParScanClosure::par_do_barrier(T* p) {
duke@435 58 assert(generation()->is_in_reserved(p), "expected ref in generation");
coleenp@548 59 assert(!oopDesc::is_null(*p), "expected non-null object");
coleenp@548 60 oop obj = oopDesc::load_decode_heap_oop_not_null(p);
duke@435 61 // If p points to a younger generation, mark the card.
duke@435 62 if ((HeapWord*)obj < gen_boundary()) {
duke@435 63 rs()->write_ref_field_gc_par(p, obj);
duke@435 64 }
duke@435 65 }
duke@435 66
coleenp@548 67 template <class T>
coleenp@548 68 inline void ParScanClosure::do_oop_work(T* p,
duke@435 69 bool gc_barrier,
duke@435 70 bool root_scan) {
duke@435 71 assert((!Universe::heap()->is_in_reserved(p) ||
duke@435 72 generation()->is_in_reserved(p))
duke@435 73 && (generation()->level() == 0 || gc_barrier),
duke@435 74 "The gen must be right, and we must be doing the barrier "
duke@435 75 "in older generations.");
coleenp@548 76 T heap_oop = oopDesc::load_heap_oop(p);
coleenp@548 77 if (!oopDesc::is_null(heap_oop)) {
coleenp@548 78 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
duke@435 79 if ((HeapWord*)obj < _boundary) {
ysr@2889 80 #ifndef PRODUCT
ysr@2889 81 if (_g->to()->is_in_reserved(obj)) {
ysr@2889 82 tty->print_cr("Scanning field (" PTR_FORMAT ") twice?", p);
ysr@2889 83 GenCollectedHeap* gch = (GenCollectedHeap*)Universe::heap();
ysr@2889 84 Space* sp = gch->space_containing(p);
ysr@2889 85 oop obj = oop(sp->block_start(p));
ysr@2889 86 assert((HeapWord*)obj < (HeapWord*)p, "Error");
hseigel@5784 87 tty->print_cr("Object: " PTR_FORMAT, (void *)obj);
ysr@2889 88 tty->print_cr("-------");
ysr@2889 89 obj->print();
ysr@2889 90 tty->print_cr("-----");
ysr@2889 91 tty->print_cr("Heap:");
ysr@2889 92 tty->print_cr("-----");
ysr@2889 93 gch->print();
ysr@2889 94 ShouldNotReachHere();
ysr@2889 95 }
ysr@2889 96 #endif
duke@435 97 // OK, we need to ensure that it is copied.
duke@435 98 // We read the klass and mark in this order, so that we can reliably
duke@435 99 // get the size of the object: if the mark we read is not a
duke@435 100 // forwarding pointer, then the klass is valid: the klass is only
duke@435 101 // overwritten with an overflow next pointer after the object is
duke@435 102 // forwarded.
coleenp@4037 103 Klass* objK = obj->klass();
duke@435 104 markOop m = obj->mark();
coleenp@548 105 oop new_obj;
duke@435 106 if (m->is_marked()) { // Contains forwarding pointer.
coleenp@548 107 new_obj = ParNewGeneration::real_forwardee(obj);
coleenp@548 108 oopDesc::encode_store_heap_oop_not_null(p, new_obj);
coleenp@4037 109 #ifndef PRODUCT
coleenp@4037 110 if (TraceScavenge) {
coleenp@4037 111 gclog_or_tty->print_cr("{%s %s ( " PTR_FORMAT " ) " PTR_FORMAT " -> " PTR_FORMAT " (%d)}",
coleenp@4037 112 "forwarded ",
hseigel@5784 113 new_obj->klass()->internal_name(), p, (void *)obj, (void *)new_obj, new_obj->size());
coleenp@4037 114 }
coleenp@4037 115 #endif
coleenp@4037 116
duke@435 117 } else {
coleenp@4037 118 size_t obj_sz = obj->size_given_klass(objK);
coleenp@548 119 new_obj = _g->copy_to_survivor_space(_par_scan_state, obj, obj_sz, m);
coleenp@548 120 oopDesc::encode_store_heap_oop_not_null(p, new_obj);
duke@435 121 if (root_scan) {
duke@435 122 // This may have pushed an object. If we have a root
duke@435 123 // category with a lot of roots, can't let the queue get too
duke@435 124 // full:
duke@435 125 (void)_par_scan_state->trim_queues(10 * ParallelGCThreads);
duke@435 126 }
duke@435 127 }
coleenp@4037 128 if (is_scanning_a_klass()) {
coleenp@4037 129 do_klass_barrier();
coleenp@4037 130 } else if (gc_barrier) {
duke@435 131 // Now call parent closure
duke@435 132 par_do_barrier(p);
duke@435 133 }
duke@435 134 }
duke@435 135 }
duke@435 136 }
coleenp@548 137
coleenp@548 138 inline void ParScanWithBarrierClosure::do_oop_nv(oop* p) { ParScanClosure::do_oop_work(p, true, false); }
coleenp@548 139 inline void ParScanWithBarrierClosure::do_oop_nv(narrowOop* p) { ParScanClosure::do_oop_work(p, true, false); }
coleenp@548 140
coleenp@548 141 inline void ParScanWithoutBarrierClosure::do_oop_nv(oop* p) { ParScanClosure::do_oop_work(p, false, false); }
coleenp@548 142 inline void ParScanWithoutBarrierClosure::do_oop_nv(narrowOop* p) { ParScanClosure::do_oop_work(p, false, false); }
stefank@2314 143
stefank@2314 144 #endif // SHARE_VM_GC_IMPLEMENTATION_PARNEW_PAROOPCLOSURES_INLINE_HPP

mercurial