--- a/hotspot/src/share/vm/gc_implementation/parNew/parOopClosures.inline.hpp Fri Apr 11 09:56:35 2008 -0400
+++ b/hotspot/src/share/vm/gc_implementation/parNew/parOopClosures.inline.hpp Sun Apr 13 17:43:42 2008 -0400
@@ -22,10 +22,9 @@
*
*/
-inline void ParScanWeakRefClosure::do_oop(oop* p)
-{
- oop obj = *p;
- assert (obj != NULL, "null weak reference?");
+template <class T> inline void ParScanWeakRefClosure::do_oop_work(T* p) {
+ assert (!oopDesc::is_null(*p), "null weak reference?");
+ oop obj = oopDesc::load_decode_heap_oop_not_null(p);
// weak references are sometimes scanned twice; must check
// that to-space doesn't already contain this object
if ((HeapWord*)obj < _boundary && !_g->to()->is_in_reserved(obj)) {
@@ -33,41 +32,43 @@
// ParScanClosure::do_oop_work).
klassOop objK = obj->klass();
markOop m = obj->mark();
+ oop new_obj;
if (m->is_marked()) { // Contains forwarding pointer.
- *p = ParNewGeneration::real_forwardee(obj);
+ new_obj = ParNewGeneration::real_forwardee(obj);
} else {
size_t obj_sz = obj->size_given_klass(objK->klass_part());
- *p = ((ParNewGeneration*)_g)->copy_to_survivor_space(_par_scan_state,
- obj, obj_sz, m);
+ new_obj = ((ParNewGeneration*)_g)->copy_to_survivor_space(_par_scan_state,
+ obj, obj_sz, m);
}
+ oopDesc::encode_store_heap_oop_not_null(p, new_obj);
}
}
-inline void ParScanWeakRefClosure::do_oop_nv(oop* p)
-{
- ParScanWeakRefClosure::do_oop(p);
-}
+inline void ParScanWeakRefClosure::do_oop_nv(oop* p) { ParScanWeakRefClosure::do_oop_work(p); }
+inline void ParScanWeakRefClosure::do_oop_nv(narrowOop* p) { ParScanWeakRefClosure::do_oop_work(p); }
-inline void ParScanClosure::par_do_barrier(oop* p) {
+template <class T> inline void ParScanClosure::par_do_barrier(T* p) {
assert(generation()->is_in_reserved(p), "expected ref in generation");
- oop obj = *p;
- assert(obj != NULL, "expected non-null object");
+ assert(!oopDesc::is_null(*p), "expected non-null object");
+ oop obj = oopDesc::load_decode_heap_oop_not_null(p);
// If p points to a younger generation, mark the card.
if ((HeapWord*)obj < gen_boundary()) {
rs()->write_ref_field_gc_par(p, obj);
}
}
-inline void ParScanClosure::do_oop_work(oop* p,
+template <class T>
+inline void ParScanClosure::do_oop_work(T* p,
bool gc_barrier,
bool root_scan) {
- oop obj = *p;
assert((!Universe::heap()->is_in_reserved(p) ||
generation()->is_in_reserved(p))
&& (generation()->level() == 0 || gc_barrier),
"The gen must be right, and we must be doing the barrier "
"in older generations.");
- if (obj != NULL) {
+ T heap_oop = oopDesc::load_heap_oop(p);
+ if (!oopDesc::is_null(heap_oop)) {
+ oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
if ((HeapWord*)obj < _boundary) {
assert(!_g->to()->is_in_reserved(obj), "Scanning field twice?");
// OK, we need to ensure that it is copied.
@@ -78,11 +79,14 @@
// forwarded.
klassOop objK = obj->klass();
markOop m = obj->mark();
+ oop new_obj;
if (m->is_marked()) { // Contains forwarding pointer.
- *p = ParNewGeneration::real_forwardee(obj);
+ new_obj = ParNewGeneration::real_forwardee(obj);
+ oopDesc::encode_store_heap_oop_not_null(p, new_obj);
} else {
size_t obj_sz = obj->size_given_klass(objK->klass_part());
- *p = _g->copy_to_survivor_space(_par_scan_state, obj, obj_sz, m);
+ new_obj = _g->copy_to_survivor_space(_par_scan_state, obj, obj_sz, m);
+ oopDesc::encode_store_heap_oop_not_null(p, new_obj);
if (root_scan) {
// This may have pushed an object. If we have a root
// category with a lot of roots, can't let the queue get too
@@ -97,3 +101,9 @@
}
}
}
+
+inline void ParScanWithBarrierClosure::do_oop_nv(oop* p) { ParScanClosure::do_oop_work(p, true, false); }
+inline void ParScanWithBarrierClosure::do_oop_nv(narrowOop* p) { ParScanClosure::do_oop_work(p, true, false); }
+
+inline void ParScanWithoutBarrierClosure::do_oop_nv(oop* p) { ParScanClosure::do_oop_work(p, false, false); }
+inline void ParScanWithoutBarrierClosure::do_oop_nv(narrowOop* p) { ParScanClosure::do_oop_work(p, false, false); }