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