annotate src/share/vm/gc/cms/parOopClosures.inline.hpp @ 10585:d5e9c320ac68

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