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);
73 bool root_scan) {
74 assert((!GenCollectedHeap::heap()->is_in_reserved(p) ||
75 generation()->is_in_reserved(p))
76 && (GenCollectedHeap::heap()->is_young_gen(generation()) || gc_barrier),
77 "The gen must be right, and we must be doing the barrier "
78 "in older generations.");
79 T heap_oop = oopDesc::load_heap_oop(p);
80 if (!oopDesc::is_null(heap_oop)) {
81 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
82 if ((HeapWord*)obj < _boundary) {
83 #ifndef PRODUCT
84 if (_g->to()->is_in_reserved(obj)) {
85 Log(gc) log;
86 log.error("Scanning field (" PTR_FORMAT ") twice?", p2i(p));
87 GenCollectedHeap* gch = GenCollectedHeap::heap();
88 Space* sp = gch->space_containing(p);
89 oop obj = oop(sp->block_start(p));
90 assert((HeapWord*)obj < (HeapWord*)p, "Error");
91 log.error("Object: " PTR_FORMAT, p2i((void *)obj));
92 log.error("-------");
93 obj->print_on(log.error_stream());
94 log.error("-----");
95 log.error("Heap:");
96 log.error("-----");
97 gch->print_on(log.error_stream());
98 ShouldNotReachHere();
99 }
100 #endif
101 // OK, we need to ensure that it is copied.
102 // We read the klass and mark in this order, so that we can reliably
103 // get the size of the object: if the mark we read is not a
104 // forwarding pointer, then the klass is valid: the klass is only
105 // overwritten with an overflow next pointer after the object is
106 // forwarded.
107 Klass* objK = obj->klass();
108 markOop m = obj->mark();
109 oop new_obj;
110 if (m->is_marked()) { // Contains forwarding pointer.
111 new_obj = ParNewGeneration::real_forwardee(obj);
112 oopDesc::encode_store_heap_oop_not_null(p, new_obj);
113 log_develop_trace(gc, scavenge)("{%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 } else {
117 size_t obj_sz = obj->size_given_klass(objK);
|
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 #include "logging/logStream.hpp"
35
36
37 template <class T> inline void ParScanWeakRefClosure::do_oop_work(T* p) {
38 assert (!oopDesc::is_null(*p), "null weak reference?");
39 oop obj = oopDesc::load_decode_heap_oop_not_null(p);
40 // weak references are sometimes scanned twice; must check
41 // that to-space doesn't already contain this object
42 if ((HeapWord*)obj < _boundary && !_g->to()->is_in_reserved(obj)) {
43 // we need to ensure that it is copied (see comment in
44 // ParScanClosure::do_oop_work).
45 Klass* objK = obj->klass();
46 markOop m = obj->mark();
47 oop new_obj;
48 if (m->is_marked()) { // Contains forwarding pointer.
49 new_obj = ParNewGeneration::real_forwardee(obj);
50 } else {
51 size_t obj_sz = obj->size_given_klass(objK);
52 new_obj = ((ParNewGeneration*)_g)->copy_to_survivor_space(_par_scan_state,
53 obj, obj_sz, m);
54 }
55 oopDesc::encode_store_heap_oop_not_null(p, new_obj);
75 bool root_scan) {
76 assert((!GenCollectedHeap::heap()->is_in_reserved(p) ||
77 generation()->is_in_reserved(p))
78 && (GenCollectedHeap::heap()->is_young_gen(generation()) || gc_barrier),
79 "The gen must be right, and we must be doing the barrier "
80 "in older generations.");
81 T heap_oop = oopDesc::load_heap_oop(p);
82 if (!oopDesc::is_null(heap_oop)) {
83 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
84 if ((HeapWord*)obj < _boundary) {
85 #ifndef PRODUCT
86 if (_g->to()->is_in_reserved(obj)) {
87 Log(gc) log;
88 log.error("Scanning field (" PTR_FORMAT ") twice?", p2i(p));
89 GenCollectedHeap* gch = GenCollectedHeap::heap();
90 Space* sp = gch->space_containing(p);
91 oop obj = oop(sp->block_start(p));
92 assert((HeapWord*)obj < (HeapWord*)p, "Error");
93 log.error("Object: " PTR_FORMAT, p2i((void *)obj));
94 log.error("-------");
95 LogStream ls(log.error());
96 obj->print_on(&ls);
97 log.error("-----");
98 log.error("Heap:");
99 log.error("-----");
100 gch->print_on(&ls);
101 ShouldNotReachHere();
102 }
103 #endif
104 // OK, we need to ensure that it is copied.
105 // We read the klass and mark in this order, so that we can reliably
106 // get the size of the object: if the mark we read is not a
107 // forwarding pointer, then the klass is valid: the klass is only
108 // overwritten with an overflow next pointer after the object is
109 // forwarded.
110 Klass* objK = obj->klass();
111 markOop m = obj->mark();
112 oop new_obj;
113 if (m->is_marked()) { // Contains forwarding pointer.
114 new_obj = ParNewGeneration::real_forwardee(obj);
115 oopDesc::encode_store_heap_oop_not_null(p, new_obj);
116 log_develop_trace(gc, scavenge)("{%s %s ( " PTR_FORMAT " ) " PTR_FORMAT " -> " PTR_FORMAT " (%d)}",
117 "forwarded ",
118 new_obj->klass()->internal_name(), p2i(p), p2i((void *)obj), p2i((void *)new_obj), new_obj->size());
119 } else {
120 size_t obj_sz = obj->size_given_klass(objK);
|