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 void ParScanWeakRefClosure::do_oop(oop* p)
29 {
30 oop obj = *p;
31 assert (obj != NULL, "null weak reference?");
32 // weak references are sometimes scanned twice; must check
33 // that to-space doesn't already contain this object
34 if ((HeapWord*)obj < _boundary && !_g->to()->is_in_reserved(obj)) {
35 // we need to ensure that it is copied (see comment in
36 // ParScanClosure::do_oop_work).
37 klassOop objK = obj->klass();
38 markOop m = obj->mark();
39 if (m->is_marked()) { // Contains forwarding pointer.
40 *p = ParNewGeneration::real_forwardee(obj);
41 } else {
42 size_t obj_sz = obj->size_given_klass(objK->klass_part());
43 *p = ((ParNewGeneration*)_g)->copy_to_survivor_space(_par_scan_state,
44 obj, obj_sz, m);
45 }
46 }
47 }
48
49 inline void ParScanWeakRefClosure::do_oop_nv(oop* p)
50 {
51 ParScanWeakRefClosure::do_oop(p);
52 }
53
54 inline void ParScanClosure::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 inline void ParScanClosure::do_oop_work(oop* p,
65 bool gc_barrier,
66 bool root_scan) {
67 oop obj = *p;
68 assert((!Universe::heap()->is_in_reserved(p) ||
69 generation()->is_in_reserved(p))
70 && (generation()->level() == 0 || gc_barrier),
71 "The gen must be right, and we must be doing the barrier "
72 "in older generations.");
73 if (obj != NULL) {
74 if ((HeapWord*)obj < _boundary) {
75 assert(!_g->to()->is_in_reserved(obj), "Scanning field twice?");
76 // OK, we need to ensure that it is copied.
77 // We read the klass and mark in this order, so that we can reliably
78 // get the size of the object: if the mark we read is not a
79 // forwarding pointer, then the klass is valid: the klass is only
80 // overwritten with an overflow next pointer after the object is
81 // forwarded.
82 klassOop objK = obj->klass();
83 markOop m = obj->mark();
84 if (m->is_marked()) { // Contains forwarding pointer.
85 *p = ParNewGeneration::real_forwardee(obj);
86 } else {
87 size_t obj_sz = obj->size_given_klass(objK->klass_part());
88 *p = _g->copy_to_survivor_space(_par_scan_state, obj, obj_sz, m);
89 if (root_scan) {
90 // This may have pushed an object. If we have a root
91 // category with a lot of roots, can't let the queue get too
92 // full:
93 (void)_par_scan_state->trim_queues(10 * ParallelGCThreads);
94 }
95 }
96 if (gc_barrier) {
97 // Now call parent closure
98 par_do_barrier(p);
99 }
100 }
101 }
102 }
103
|
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 template <class T> inline void ParScanWeakRefClosure::do_oop_work(T* p) {
29 assert (!oopDesc::is_null(*p), "null weak reference?");
30 oop obj = oopDesc::load_decode_heap_oop_not_null(p);
31 // weak references are sometimes scanned twice; must check
32 // that to-space doesn't already contain this object
33 if ((HeapWord*)obj < _boundary && !_g->to()->is_in_reserved(obj)) {
34 // we need to ensure that it is copied (see comment in
35 // ParScanClosure::do_oop_work).
36 klassOop objK = obj->klass();
37 markOop m = obj->mark();
38 oop new_obj;
39 if (m->is_marked()) { // Contains forwarding pointer.
40 new_obj = ParNewGeneration::real_forwardee(obj);
41 } else {
42 size_t obj_sz = obj->size_given_klass(objK->klass_part());
43 new_obj = ((ParNewGeneration*)_g)->copy_to_survivor_space(_par_scan_state,
44 obj, obj_sz, m);
45 }
46 oopDesc::encode_store_heap_oop_not_null(p, new_obj);
47 }
48 }
49
50 inline void ParScanWeakRefClosure::do_oop_nv(oop* p) { ParScanWeakRefClosure::do_oop_work(p); }
51 inline void ParScanWeakRefClosure::do_oop_nv(narrowOop* p) { ParScanWeakRefClosure::do_oop_work(p); }
52
53 template <class T> inline void ParScanClosure::par_do_barrier(T* p) {
54 assert(generation()->is_in_reserved(p), "expected ref in generation");
55 assert(!oopDesc::is_null(*p), "expected non-null object");
56 oop obj = oopDesc::load_decode_heap_oop_not_null(p);
57 // If p points to a younger generation, mark the card.
58 if ((HeapWord*)obj < gen_boundary()) {
59 rs()->write_ref_field_gc_par(p, obj);
60 }
61 }
62
63 template <class T>
64 inline void ParScanClosure::do_oop_work(T* p,
65 bool gc_barrier,
66 bool root_scan) {
67 assert((!Universe::heap()->is_in_reserved(p) ||
68 generation()->is_in_reserved(p))
69 && (generation()->level() == 0 || gc_barrier),
70 "The gen must be right, and we must be doing the barrier "
71 "in older generations.");
72 T heap_oop = oopDesc::load_heap_oop(p);
73 if (!oopDesc::is_null(heap_oop)) {
74 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
75 if ((HeapWord*)obj < _boundary) {
76 assert(!_g->to()->is_in_reserved(obj), "Scanning field twice?");
77 // OK, we need to ensure that it is copied.
78 // We read the klass and mark in this order, so that we can reliably
79 // get the size of the object: if the mark we read is not a
80 // forwarding pointer, then the klass is valid: the klass is only
81 // overwritten with an overflow next pointer after the object is
82 // forwarded.
83 klassOop objK = obj->klass();
84 markOop m = obj->mark();
85 oop new_obj;
86 if (m->is_marked()) { // Contains forwarding pointer.
87 new_obj = ParNewGeneration::real_forwardee(obj);
88 oopDesc::encode_store_heap_oop_not_null(p, new_obj);
89 } else {
90 size_t obj_sz = obj->size_given_klass(objK->klass_part());
91 new_obj = _g->copy_to_survivor_space(_par_scan_state, obj, obj_sz, m);
92 oopDesc::encode_store_heap_oop_not_null(p, new_obj);
93 if (root_scan) {
94 // This may have pushed an object. If we have a root
95 // category with a lot of roots, can't let the queue get too
96 // full:
97 (void)_par_scan_state->trim_queues(10 * ParallelGCThreads);
98 }
99 }
100 if (gc_barrier) {
101 // Now call parent closure
102 par_do_barrier(p);
103 }
104 }
105 }
106 }
107
108 inline void ParScanWithBarrierClosure::do_oop_nv(oop* p) { ParScanClosure::do_oop_work(p, true, false); }
109 inline void ParScanWithBarrierClosure::do_oop_nv(narrowOop* p) { ParScanClosure::do_oop_work(p, true, false); }
110
111 inline void ParScanWithoutBarrierClosure::do_oop_nv(oop* p) { ParScanClosure::do_oop_work(p, false, false); }
112 inline void ParScanWithoutBarrierClosure::do_oop_nv(narrowOop* p) { ParScanClosure::do_oop_work(p, false, false); }
|