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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_VM_GC_CMS_PAROOPCLOSURES_INLINE_HPP
26 #define SHARE_VM_GC_CMS_PAROOPCLOSURES_INLINE_HPP
27
28 #include "gc/cms/parNewGeneration.hpp"
29 #include "gc/cms/parOopClosures.hpp"
30 #include "gc/shared/cardTableRS.hpp"
31 #include "gc/shared/genCollectedHeap.hpp"
32 #include "gc/shared/genOopClosures.inline.hpp"
33
34 template <class T> inline void ParScanWeakRefClosure::do_oop_work(T* p) {
35 assert (!oopDesc::is_null(*p), "null weak reference?");
36 oop obj = oopDesc::load_decode_heap_oop_not_null(p);
37 // weak references are sometimes scanned twice; must check
38 // that to-space doesn't already contain this object
39 if ((HeapWord*)obj < _boundary && !_g->to()->is_in_reserved(obj)) {
40 // we need to ensure that it is copied (see comment in
41 // ParScanClosure::do_oop_work).
42 Klass* objK = obj->klass();
43 markOop m = obj->mark();
44 oop new_obj;
45 if (m->is_marked()) { // Contains forwarding pointer.
46 new_obj = ParNewGeneration::real_forwardee(obj);
47 } else {
48 size_t obj_sz = obj->size_given_klass(objK);
49 new_obj = ((ParNewGeneration*)_g)->copy_to_survivor_space(_par_scan_state,
50 obj, obj_sz, m);
51 }
52 oopDesc::encode_store_heap_oop_not_null(p, new_obj);
91 obj->print();
92 tty->print_cr("-----");
93 tty->print_cr("Heap:");
94 tty->print_cr("-----");
95 gch->print();
96 ShouldNotReachHere();
97 }
98 #endif
99 // OK, we need to ensure that it is copied.
100 // We read the klass and mark in this order, so that we can reliably
101 // get the size of the object: if the mark we read is not a
102 // forwarding pointer, then the klass is valid: the klass is only
103 // overwritten with an overflow next pointer after the object is
104 // forwarded.
105 Klass* objK = obj->klass();
106 markOop m = obj->mark();
107 oop new_obj;
108 if (m->is_marked()) { // Contains forwarding pointer.
109 new_obj = ParNewGeneration::real_forwardee(obj);
110 oopDesc::encode_store_heap_oop_not_null(p, new_obj);
111 #ifndef PRODUCT
112 if (TraceScavenge) {
113 gclog_or_tty->print_cr("{%s %s ( " PTR_FORMAT " ) " PTR_FORMAT " -> " PTR_FORMAT " (%d)}",
114 "forwarded ",
115 new_obj->klass()->internal_name(), p2i(p), p2i((void *)obj), p2i((void *)new_obj), new_obj->size());
116 }
117 #endif
118
119 } else {
120 size_t obj_sz = obj->size_given_klass(objK);
121 new_obj = _g->copy_to_survivor_space(_par_scan_state, obj, obj_sz, m);
122 oopDesc::encode_store_heap_oop_not_null(p, new_obj);
123 if (root_scan) {
124 // This may have pushed an object. If we have a root
125 // category with a lot of roots, can't let the queue get too
126 // full:
127 (void)_par_scan_state->trim_queues(10 * ParallelGCThreads);
128 }
129 }
130 if (is_scanning_a_klass()) {
131 do_klass_barrier();
132 } else if (gc_barrier) {
133 // Now call parent closure
134 par_do_barrier(p);
135 }
136 }
137 }
138 }
|
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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_VM_GC_CMS_PAROOPCLOSURES_INLINE_HPP
26 #define SHARE_VM_GC_CMS_PAROOPCLOSURES_INLINE_HPP
27
28 #include "gc/cms/parNewGeneration.hpp"
29 #include "gc/cms/parOopClosures.hpp"
30 #include "gc/shared/cardTableRS.hpp"
31 #include "gc/shared/genCollectedHeap.hpp"
32 #include "gc/shared/genOopClosures.inline.hpp"
33 #include "logging/log.hpp"
34
35 template <class T> inline void ParScanWeakRefClosure::do_oop_work(T* p) {
36 assert (!oopDesc::is_null(*p), "null weak reference?");
37 oop obj = oopDesc::load_decode_heap_oop_not_null(p);
38 // weak references are sometimes scanned twice; must check
39 // that to-space doesn't already contain this object
40 if ((HeapWord*)obj < _boundary && !_g->to()->is_in_reserved(obj)) {
41 // we need to ensure that it is copied (see comment in
42 // ParScanClosure::do_oop_work).
43 Klass* objK = obj->klass();
44 markOop m = obj->mark();
45 oop new_obj;
46 if (m->is_marked()) { // Contains forwarding pointer.
47 new_obj = ParNewGeneration::real_forwardee(obj);
48 } else {
49 size_t obj_sz = obj->size_given_klass(objK);
50 new_obj = ((ParNewGeneration*)_g)->copy_to_survivor_space(_par_scan_state,
51 obj, obj_sz, m);
52 }
53 oopDesc::encode_store_heap_oop_not_null(p, new_obj);
92 obj->print();
93 tty->print_cr("-----");
94 tty->print_cr("Heap:");
95 tty->print_cr("-----");
96 gch->print();
97 ShouldNotReachHere();
98 }
99 #endif
100 // OK, we need to ensure that it is copied.
101 // We read the klass and mark in this order, so that we can reliably
102 // get the size of the object: if the mark we read is not a
103 // forwarding pointer, then the klass is valid: the klass is only
104 // overwritten with an overflow next pointer after the object is
105 // forwarded.
106 Klass* objK = obj->klass();
107 markOop m = obj->mark();
108 oop new_obj;
109 if (m->is_marked()) { // Contains forwarding pointer.
110 new_obj = ParNewGeneration::real_forwardee(obj);
111 oopDesc::encode_store_heap_oop_not_null(p, new_obj);
112 log_develop(gc, scavenge)("{forwarded %s ( " PTR_FORMAT " ) " PTR_FORMAT " -> " PTR_FORMAT " (%d)}",
113 new_obj->klass()->internal_name(), p2i(p), p2i((void *)obj), p2i((void *)new_obj), new_obj->size());
114 } else {
115 size_t obj_sz = obj->size_given_klass(objK);
116 new_obj = _g->copy_to_survivor_space(_par_scan_state, obj, obj_sz, m);
117 oopDesc::encode_store_heap_oop_not_null(p, new_obj);
118 if (root_scan) {
119 // This may have pushed an object. If we have a root
120 // category with a lot of roots, can't let the queue get too
121 // full:
122 (void)_par_scan_state->trim_queues(10 * ParallelGCThreads);
123 }
124 }
125 if (is_scanning_a_klass()) {
126 do_klass_barrier();
127 } else if (gc_barrier) {
128 // Now call parent closure
129 par_do_barrier(p);
130 }
131 }
132 }
133 }
|