annotate src/share/vm/memory/genOopClosures.inline.hpp @ 5264:24e87613ee58

8009561: NPG: Metaspace fragmentation when retiring a Metachunk Summary: Use best-fit block-splitting freelist allocation from the block freelist. Reviewed-by: jmasa, stefank
author mgerdin
date Wed, 11 Sep 2013 09:37:14 +0200
parents f95d63e2154a
children
rev   line source
duke@0 1 /*
coleenp@3602 2 * Copyright (c) 2001, 2012, 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
stefank@1879 25 #ifndef SHARE_VM_MEMORY_GENOOPCLOSURES_INLINE_HPP
stefank@1879 26 #define SHARE_VM_MEMORY_GENOOPCLOSURES_INLINE_HPP
stefank@1879 27
stefank@1879 28 #include "memory/cardTableRS.hpp"
stefank@1879 29 #include "memory/defNewGeneration.hpp"
stefank@1879 30 #include "memory/genCollectedHeap.hpp"
stefank@1879 31 #include "memory/genOopClosures.hpp"
stefank@1879 32 #include "memory/genRemSet.hpp"
stefank@1879 33 #include "memory/generation.hpp"
stefank@1879 34 #include "memory/sharedHeap.hpp"
stefank@1879 35 #include "memory/space.hpp"
stefank@1879 36
duke@0 37 inline OopsInGenClosure::OopsInGenClosure(Generation* gen) :
coleenp@3602 38 ExtendedOopClosure(gen->ref_processor()), _orig_gen(gen), _rs(NULL) {
duke@0 39 set_generation(gen);
duke@0 40 }
duke@0 41
duke@0 42 inline void OopsInGenClosure::set_generation(Generation* gen) {
duke@0 43 _gen = gen;
duke@0 44 _gen_boundary = _gen->reserved().start();
duke@0 45 // Barrier set for the heap, must be set after heap is initialized
duke@0 46 if (_rs == NULL) {
duke@0 47 GenRemSet* rs = SharedHeap::heap()->rem_set();
duke@0 48 assert(rs->rs_kind() == GenRemSet::CardTable, "Wrong rem set kind");
duke@0 49 _rs = (CardTableRS*)rs;
duke@0 50 }
duke@0 51 }
duke@0 52
coleenp@113 53 template <class T> inline void OopsInGenClosure::do_barrier(T* p) {
duke@0 54 assert(generation()->is_in_reserved(p), "expected ref in generation");
ysr@845 55 T heap_oop = oopDesc::load_heap_oop(p);
ysr@845 56 assert(!oopDesc::is_null(heap_oop), "expected non-null oop");
ysr@845 57 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
duke@0 58 // If p points to a younger generation, mark the card.
duke@0 59 if ((HeapWord*)obj < _gen_boundary) {
duke@0 60 _rs->inline_write_ref_field_gc(p, obj);
duke@0 61 }
duke@0 62 }
duke@0 63
ysr@845 64 template <class T> inline void OopsInGenClosure::par_do_barrier(T* p) {
ysr@342 65 assert(generation()->is_in_reserved(p), "expected ref in generation");
ysr@845 66 T heap_oop = oopDesc::load_heap_oop(p);
ysr@845 67 assert(!oopDesc::is_null(heap_oop), "expected non-null oop");
ysr@845 68 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
ysr@342 69 // If p points to a younger generation, mark the card.
ysr@342 70 if ((HeapWord*)obj < gen_boundary()) {
ysr@342 71 rs()->write_ref_field_gc_par(p, obj);
ysr@342 72 }
ysr@342 73 }
ysr@342 74
coleenp@3602 75 inline void OopsInKlassOrGenClosure::do_klass_barrier() {
coleenp@3602 76 assert(_scanned_klass != NULL, "Must be");
coleenp@3602 77 _scanned_klass->record_modified_oops();
coleenp@3602 78 }
coleenp@3602 79
duke@0 80 // NOTE! Any changes made here should also be made
coleenp@113 81 // in FastScanClosure::do_oop_work()
coleenp@113 82 template <class T> inline void ScanClosure::do_oop_work(T* p) {
coleenp@113 83 T heap_oop = oopDesc::load_heap_oop(p);
duke@0 84 // Should we copy the obj?
coleenp@113 85 if (!oopDesc::is_null(heap_oop)) {
coleenp@113 86 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
duke@0 87 if ((HeapWord*)obj < _boundary) {
duke@0 88 assert(!_g->to()->is_in_reserved(obj), "Scanning field twice?");
coleenp@113 89 oop new_obj = obj->is_forwarded() ? obj->forwardee()
coleenp@113 90 : _g->copy_to_survivor_space(obj);
coleenp@113 91 oopDesc::encode_store_heap_oop_not_null(p, new_obj);
duke@0 92 }
coleenp@3602 93
coleenp@3602 94 if (is_scanning_a_klass()) {
coleenp@3602 95 do_klass_barrier();
coleenp@3602 96 } else if (_gc_barrier) {
duke@0 97 // Now call parent closure
duke@0 98 do_barrier(p);
duke@0 99 }
duke@0 100 }
duke@0 101 }
duke@0 102
coleenp@113 103 inline void ScanClosure::do_oop_nv(oop* p) { ScanClosure::do_oop_work(p); }
coleenp@113 104 inline void ScanClosure::do_oop_nv(narrowOop* p) { ScanClosure::do_oop_work(p); }
duke@0 105
duke@0 106 // NOTE! Any changes made here should also be made
coleenp@113 107 // in ScanClosure::do_oop_work()
coleenp@113 108 template <class T> inline void FastScanClosure::do_oop_work(T* p) {
coleenp@113 109 T heap_oop = oopDesc::load_heap_oop(p);
duke@0 110 // Should we copy the obj?
coleenp@113 111 if (!oopDesc::is_null(heap_oop)) {
coleenp@113 112 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
duke@0 113 if ((HeapWord*)obj < _boundary) {
duke@0 114 assert(!_g->to()->is_in_reserved(obj), "Scanning field twice?");
coleenp@113 115 oop new_obj = obj->is_forwarded() ? obj->forwardee()
coleenp@113 116 : _g->copy_to_survivor_space(obj);
coleenp@113 117 oopDesc::encode_store_heap_oop_not_null(p, new_obj);
coleenp@3602 118 if (is_scanning_a_klass()) {
coleenp@3602 119 do_klass_barrier();
coleenp@3602 120 } else if (_gc_barrier) {
duke@0 121 // Now call parent closure
duke@0 122 do_barrier(p);
duke@0 123 }
duke@0 124 }
duke@0 125 }
duke@0 126 }
duke@0 127
coleenp@113 128 inline void FastScanClosure::do_oop_nv(oop* p) { FastScanClosure::do_oop_work(p); }
coleenp@113 129 inline void FastScanClosure::do_oop_nv(narrowOop* p) { FastScanClosure::do_oop_work(p); }
duke@0 130
duke@0 131 // Note similarity to ScanClosure; the difference is that
duke@0 132 // the barrier set is taken care of outside this closure.
coleenp@113 133 template <class T> inline void ScanWeakRefClosure::do_oop_work(T* p) {
coleenp@113 134 assert(!oopDesc::is_null(*p), "null weak reference?");
coleenp@113 135 oop obj = oopDesc::load_decode_heap_oop_not_null(p);
duke@0 136 // weak references are sometimes scanned twice; must check
duke@0 137 // that to-space doesn't already contain this object
duke@0 138 if ((HeapWord*)obj < _boundary && !_g->to()->is_in_reserved(obj)) {
coleenp@113 139 oop new_obj = obj->is_forwarded() ? obj->forwardee()
coleenp@113 140 : _g->copy_to_survivor_space(obj);
coleenp@113 141 oopDesc::encode_store_heap_oop_not_null(p, new_obj);
duke@0 142 }
duke@0 143 }
duke@0 144
coleenp@113 145 inline void ScanWeakRefClosure::do_oop_nv(oop* p) { ScanWeakRefClosure::do_oop_work(p); }
coleenp@113 146 inline void ScanWeakRefClosure::do_oop_nv(narrowOop* p) { ScanWeakRefClosure::do_oop_work(p); }
stefank@1879 147
stefank@1879 148 #endif // SHARE_VM_MEMORY_GENOOPCLOSURES_INLINE_HPP