comparison src/share/vm/memory/genOopClosures.inline.hpp @ 0:a61af66fc99e jdk7-b24

Initial load
author duke
date Sat, 01 Dec 2007 00:00:00 +0000
parents
children ba764ed4b6f2
comparison
equal deleted inserted replaced
-1:000000000000 0:a61af66fc99e
1 /*
2 * Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
22 *
23 */
24
25 inline OopsInGenClosure::OopsInGenClosure(Generation* gen) :
26 OopClosure(gen->ref_processor()), _orig_gen(gen), _rs(NULL) {
27 set_generation(gen);
28 }
29
30 inline void OopsInGenClosure::set_generation(Generation* gen) {
31 _gen = gen;
32 _gen_boundary = _gen->reserved().start();
33 // Barrier set for the heap, must be set after heap is initialized
34 if (_rs == NULL) {
35 GenRemSet* rs = SharedHeap::heap()->rem_set();
36 assert(rs->rs_kind() == GenRemSet::CardTable, "Wrong rem set kind");
37 _rs = (CardTableRS*)rs;
38 }
39 }
40
41 inline void OopsInGenClosure::do_barrier(oop* p) {
42 assert(generation()->is_in_reserved(p), "expected ref in generation");
43 oop obj = *p;
44 assert(obj != NULL, "expected non-null object");
45 // If p points to a younger generation, mark the card.
46 if ((HeapWord*)obj < _gen_boundary) {
47 _rs->inline_write_ref_field_gc(p, obj);
48 }
49 }
50
51 // NOTE! Any changes made here should also be made
52 // in FastScanClosure::do_oop();
53 inline void ScanClosure::do_oop(oop* p) {
54 oop obj = *p;
55 // Should we copy the obj?
56 if (obj != NULL) {
57 if ((HeapWord*)obj < _boundary) {
58 assert(!_g->to()->is_in_reserved(obj), "Scanning field twice?");
59 if (obj->is_forwarded()) {
60 *p = obj->forwardee();
61 } else {
62 *p = _g->copy_to_survivor_space(obj, p);
63 }
64 }
65 if (_gc_barrier) {
66 // Now call parent closure
67 do_barrier(p);
68 }
69 }
70 }
71
72 inline void ScanClosure::do_oop_nv(oop* p) {
73 ScanClosure::do_oop(p);
74 }
75
76 // NOTE! Any changes made here should also be made
77 // in ScanClosure::do_oop();
78 inline void FastScanClosure::do_oop(oop* p) {
79 oop obj = *p;
80 // Should we copy the obj?
81 if (obj != NULL) {
82 if ((HeapWord*)obj < _boundary) {
83 assert(!_g->to()->is_in_reserved(obj), "Scanning field twice?");
84 if (obj->is_forwarded()) {
85 *p = obj->forwardee();
86 } else {
87 *p = _g->copy_to_survivor_space(obj, p);
88 }
89 if (_gc_barrier) {
90 // Now call parent closure
91 do_barrier(p);
92 }
93 }
94 }
95 }
96
97 inline void FastScanClosure::do_oop_nv(oop* p) {
98 FastScanClosure::do_oop(p);
99 }
100
101 // Note similarity to ScanClosure; the difference is that
102 // the barrier set is taken care of outside this closure.
103 inline void ScanWeakRefClosure::do_oop(oop* p) {
104 oop obj = *p;
105 assert (obj != NULL, "null weak reference?");
106 // weak references are sometimes scanned twice; must check
107 // that to-space doesn't already contain this object
108 if ((HeapWord*)obj < _boundary && !_g->to()->is_in_reserved(obj)) {
109 if (obj->is_forwarded()) {
110 *p = obj->forwardee();
111 } else {
112 *p = _g->copy_to_survivor_space(obj, p);
113 }
114 }
115 }
116
117 inline void ScanWeakRefClosure::do_oop_nv(oop* p) {
118 ScanWeakRefClosure::do_oop(p);
119 }