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