src/share/vm/memory/genOopClosures.inline.hpp

Wed, 27 Apr 2016 01:25:04 +0800

author
aoqi
date
Wed, 27 Apr 2016 01:25:04 +0800
changeset 0
f90c822e73f8
child 6876
710a3c8b516e
permissions
-rw-r--r--

Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/hotspot/
changeset: 6782:28b50d07f6f8
tag: jdk8u25-b17

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation.
aoqi@0 8 *
aoqi@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 12 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 13 * accompanied this code).
aoqi@0 14 *
aoqi@0 15 * You should have received a copy of the GNU General Public License version
aoqi@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 18 *
aoqi@0 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 20 * or visit www.oracle.com if you need additional information or have any
aoqi@0 21 * questions.
aoqi@0 22 *
aoqi@0 23 */
aoqi@0 24
aoqi@0 25 #ifndef SHARE_VM_MEMORY_GENOOPCLOSURES_INLINE_HPP
aoqi@0 26 #define SHARE_VM_MEMORY_GENOOPCLOSURES_INLINE_HPP
aoqi@0 27
aoqi@0 28 #include "memory/cardTableRS.hpp"
aoqi@0 29 #include "memory/defNewGeneration.hpp"
aoqi@0 30 #include "memory/genCollectedHeap.hpp"
aoqi@0 31 #include "memory/genOopClosures.hpp"
aoqi@0 32 #include "memory/genRemSet.hpp"
aoqi@0 33 #include "memory/generation.hpp"
aoqi@0 34 #include "memory/sharedHeap.hpp"
aoqi@0 35 #include "memory/space.hpp"
aoqi@0 36
aoqi@0 37 inline OopsInGenClosure::OopsInGenClosure(Generation* gen) :
aoqi@0 38 ExtendedOopClosure(gen->ref_processor()), _orig_gen(gen), _rs(NULL) {
aoqi@0 39 set_generation(gen);
aoqi@0 40 }
aoqi@0 41
aoqi@0 42 inline void OopsInGenClosure::set_generation(Generation* gen) {
aoqi@0 43 _gen = gen;
aoqi@0 44 _gen_boundary = _gen->reserved().start();
aoqi@0 45 // Barrier set for the heap, must be set after heap is initialized
aoqi@0 46 if (_rs == NULL) {
aoqi@0 47 GenRemSet* rs = SharedHeap::heap()->rem_set();
aoqi@0 48 assert(rs->rs_kind() == GenRemSet::CardTable, "Wrong rem set kind");
aoqi@0 49 _rs = (CardTableRS*)rs;
aoqi@0 50 }
aoqi@0 51 }
aoqi@0 52
aoqi@0 53 template <class T> inline void OopsInGenClosure::do_barrier(T* p) {
aoqi@0 54 assert(generation()->is_in_reserved(p), "expected ref in generation");
aoqi@0 55 T heap_oop = oopDesc::load_heap_oop(p);
aoqi@0 56 assert(!oopDesc::is_null(heap_oop), "expected non-null oop");
aoqi@0 57 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
aoqi@0 58 // If p points to a younger generation, mark the card.
aoqi@0 59 if ((HeapWord*)obj < _gen_boundary) {
aoqi@0 60 _rs->inline_write_ref_field_gc(p, obj);
aoqi@0 61 }
aoqi@0 62 }
aoqi@0 63
aoqi@0 64 template <class T> inline void OopsInGenClosure::par_do_barrier(T* p) {
aoqi@0 65 assert(generation()->is_in_reserved(p), "expected ref in generation");
aoqi@0 66 T heap_oop = oopDesc::load_heap_oop(p);
aoqi@0 67 assert(!oopDesc::is_null(heap_oop), "expected non-null oop");
aoqi@0 68 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
aoqi@0 69 // If p points to a younger generation, mark the card.
aoqi@0 70 if ((HeapWord*)obj < gen_boundary()) {
aoqi@0 71 rs()->write_ref_field_gc_par(p, obj);
aoqi@0 72 }
aoqi@0 73 }
aoqi@0 74
aoqi@0 75 inline void OopsInKlassOrGenClosure::do_klass_barrier() {
aoqi@0 76 assert(_scanned_klass != NULL, "Must be");
aoqi@0 77 _scanned_klass->record_modified_oops();
aoqi@0 78 }
aoqi@0 79
aoqi@0 80 // NOTE! Any changes made here should also be made
aoqi@0 81 // in FastScanClosure::do_oop_work()
aoqi@0 82 template <class T> inline void ScanClosure::do_oop_work(T* p) {
aoqi@0 83 T heap_oop = oopDesc::load_heap_oop(p);
aoqi@0 84 // Should we copy the obj?
aoqi@0 85 if (!oopDesc::is_null(heap_oop)) {
aoqi@0 86 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
aoqi@0 87 if ((HeapWord*)obj < _boundary) {
aoqi@0 88 assert(!_g->to()->is_in_reserved(obj), "Scanning field twice?");
aoqi@0 89 oop new_obj = obj->is_forwarded() ? obj->forwardee()
aoqi@0 90 : _g->copy_to_survivor_space(obj);
aoqi@0 91 oopDesc::encode_store_heap_oop_not_null(p, new_obj);
aoqi@0 92 }
aoqi@0 93
aoqi@0 94 if (is_scanning_a_klass()) {
aoqi@0 95 do_klass_barrier();
aoqi@0 96 } else if (_gc_barrier) {
aoqi@0 97 // Now call parent closure
aoqi@0 98 do_barrier(p);
aoqi@0 99 }
aoqi@0 100 }
aoqi@0 101 }
aoqi@0 102
aoqi@0 103 inline void ScanClosure::do_oop_nv(oop* p) { ScanClosure::do_oop_work(p); }
aoqi@0 104 inline void ScanClosure::do_oop_nv(narrowOop* p) { ScanClosure::do_oop_work(p); }
aoqi@0 105
aoqi@0 106 // NOTE! Any changes made here should also be made
aoqi@0 107 // in ScanClosure::do_oop_work()
aoqi@0 108 template <class T> inline void FastScanClosure::do_oop_work(T* p) {
aoqi@0 109 T heap_oop = oopDesc::load_heap_oop(p);
aoqi@0 110 // Should we copy the obj?
aoqi@0 111 if (!oopDesc::is_null(heap_oop)) {
aoqi@0 112 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
aoqi@0 113 if ((HeapWord*)obj < _boundary) {
aoqi@0 114 assert(!_g->to()->is_in_reserved(obj), "Scanning field twice?");
aoqi@0 115 oop new_obj = obj->is_forwarded() ? obj->forwardee()
aoqi@0 116 : _g->copy_to_survivor_space(obj);
aoqi@0 117 oopDesc::encode_store_heap_oop_not_null(p, new_obj);
aoqi@0 118 if (is_scanning_a_klass()) {
aoqi@0 119 do_klass_barrier();
aoqi@0 120 } else if (_gc_barrier) {
aoqi@0 121 // Now call parent closure
aoqi@0 122 do_barrier(p);
aoqi@0 123 }
aoqi@0 124 }
aoqi@0 125 }
aoqi@0 126 }
aoqi@0 127
aoqi@0 128 inline void FastScanClosure::do_oop_nv(oop* p) { FastScanClosure::do_oop_work(p); }
aoqi@0 129 inline void FastScanClosure::do_oop_nv(narrowOop* p) { FastScanClosure::do_oop_work(p); }
aoqi@0 130
aoqi@0 131 // Note similarity to ScanClosure; the difference is that
aoqi@0 132 // the barrier set is taken care of outside this closure.
aoqi@0 133 template <class T> inline void ScanWeakRefClosure::do_oop_work(T* p) {
aoqi@0 134 assert(!oopDesc::is_null(*p), "null weak reference?");
aoqi@0 135 oop obj = oopDesc::load_decode_heap_oop_not_null(p);
aoqi@0 136 // weak references are sometimes scanned twice; must check
aoqi@0 137 // that to-space doesn't already contain this object
aoqi@0 138 if ((HeapWord*)obj < _boundary && !_g->to()->is_in_reserved(obj)) {
aoqi@0 139 oop new_obj = obj->is_forwarded() ? obj->forwardee()
aoqi@0 140 : _g->copy_to_survivor_space(obj);
aoqi@0 141 oopDesc::encode_store_heap_oop_not_null(p, new_obj);
aoqi@0 142 }
aoqi@0 143 }
aoqi@0 144
aoqi@0 145 inline void ScanWeakRefClosure::do_oop_nv(oop* p) { ScanWeakRefClosure::do_oop_work(p); }
aoqi@0 146 inline void ScanWeakRefClosure::do_oop_nv(narrowOop* p) { ScanWeakRefClosure::do_oop_work(p); }
aoqi@0 147
aoqi@0 148 #endif // SHARE_VM_MEMORY_GENOOPCLOSURES_INLINE_HPP

mercurial