hotspot/src/share/vm/oops/instanceRefKlass.cpp
changeset 360 21d113ecbf6a
parent 1 489c9b5090e2
child 670 ddf3e9583f2f
child 1374 4c24294029a9
--- a/hotspot/src/share/vm/oops/instanceRefKlass.cpp	Fri Apr 11 09:56:35 2008 -0400
+++ b/hotspot/src/share/vm/oops/instanceRefKlass.cpp	Sun Apr 13 17:43:42 2008 -0400
@@ -25,23 +25,77 @@
 # include "incls/_precompiled.incl"
 # include "incls/_instanceRefKlass.cpp.incl"
 
-void instanceRefKlass::oop_follow_contents(oop obj) {
-  oop* referent_addr = java_lang_ref_Reference::referent_addr(obj);
-  oop referent = *referent_addr;
+template <class T>
+static void specialized_oop_follow_contents(instanceRefKlass* ref, oop obj) {
+  T* referent_addr = (T*)java_lang_ref_Reference::referent_addr(obj);
+  oop referent = oopDesc::load_decode_heap_oop(referent_addr);
   debug_only(
     if(TraceReferenceGC && PrintGCDetails) {
-      gclog_or_tty->print_cr("instanceRefKlass::oop_follow_contents " INTPTR_FORMAT, (address)obj);
+      gclog_or_tty->print_cr("instanceRefKlass::oop_follow_contents " INTPTR_FORMAT, obj);
     }
   )
   if (referent != NULL) {
     if (!referent->is_gc_marked() &&
         MarkSweep::ref_processor()->
-          discover_reference(obj, reference_type())) {
+          discover_reference(obj, ref->reference_type())) {
       // reference already enqueued, referent will be traversed later
-      instanceKlass::oop_follow_contents(obj);
+      ref->instanceKlass::oop_follow_contents(obj);
+      debug_only(
+        if(TraceReferenceGC && PrintGCDetails) {
+          gclog_or_tty->print_cr("       Non NULL enqueued " INTPTR_FORMAT, obj);
+        }
+      )
+      return;
+    } else {
+      // treat referent as normal oop
       debug_only(
         if(TraceReferenceGC && PrintGCDetails) {
-          gclog_or_tty->print_cr("       Non NULL enqueued " INTPTR_FORMAT, (address)obj);
+          gclog_or_tty->print_cr("       Non NULL normal " INTPTR_FORMAT, obj);
+        }
+      )
+      MarkSweep::mark_and_push(referent_addr);
+    }
+  }
+  // treat next as normal oop.  next is a link in the pending list.
+  T* next_addr = (T*)java_lang_ref_Reference::next_addr(obj);
+  debug_only(
+    if(TraceReferenceGC && PrintGCDetails) {
+      gclog_or_tty->print_cr("   Process next as normal " INTPTR_FORMAT, next_addr);
+    }
+  )
+  MarkSweep::mark_and_push(next_addr);
+  ref->instanceKlass::oop_follow_contents(obj);
+}
+
+void instanceRefKlass::oop_follow_contents(oop obj) {
+  if (UseCompressedOops) {
+    specialized_oop_follow_contents<narrowOop>(this, obj);
+  } else {
+    specialized_oop_follow_contents<oop>(this, obj);
+  }
+}
+
+#ifndef SERIALGC
+template <class T>
+static void specialized_oop_follow_contents(instanceRefKlass* ref,
+                                            ParCompactionManager* cm,
+                                            oop obj) {
+  T* referent_addr = (T*)java_lang_ref_Reference::referent_addr(obj);
+  oop referent = oopDesc::load_decode_heap_oop(referent_addr);
+  debug_only(
+    if(TraceReferenceGC && PrintGCDetails) {
+      gclog_or_tty->print_cr("instanceRefKlass::oop_follow_contents " INTPTR_FORMAT, obj);
+    }
+  )
+  if (referent != NULL) {
+    if (PSParallelCompact::mark_bitmap()->is_unmarked(referent) &&
+        PSParallelCompact::ref_processor()->
+          discover_reference(obj, ref->reference_type())) {
+      // reference already enqueued, referent will be traversed later
+      ref->instanceKlass::oop_follow_contents(cm, obj);
+      debug_only(
+        if(TraceReferenceGC && PrintGCDetails) {
+          gclog_or_tty->print_cr("       Non NULL enqueued " INTPTR_FORMAT, obj);
         }
       )
       return;
@@ -49,98 +103,106 @@
       // treat referent as normal oop
       debug_only(
         if(TraceReferenceGC && PrintGCDetails) {
-          gclog_or_tty->print_cr("       Non NULL normal " INTPTR_FORMAT, (address)obj);
-        }
-      )
-      MarkSweep::mark_and_push(referent_addr);
-    }
-  }
-  // treat next as normal oop.  next is a link in the pending list.
-  oop* next_addr = java_lang_ref_Reference::next_addr(obj);
-  debug_only(
-    if(TraceReferenceGC && PrintGCDetails) {
-      gclog_or_tty->print_cr("   Process next as normal " INTPTR_FORMAT, next_addr);
-    }
-  )
-  MarkSweep::mark_and_push(next_addr);
-  instanceKlass::oop_follow_contents(obj);
-}
-
-#ifndef SERIALGC
-void instanceRefKlass::oop_follow_contents(ParCompactionManager* cm,
-                                           oop obj) {
-  oop* referent_addr = java_lang_ref_Reference::referent_addr(obj);
-  oop referent = *referent_addr;
-  debug_only(
-    if(TraceReferenceGC && PrintGCDetails) {
-      gclog_or_tty->print_cr("instanceRefKlass::oop_follow_contents " INTPTR_FORMAT, (address)obj);
-    }
-  )
-  if (referent != NULL) {
-    if (PSParallelCompact::mark_bitmap()->is_unmarked(referent) &&
-        PSParallelCompact::ref_processor()->
-          discover_reference(obj, reference_type())) {
-      // reference already enqueued, referent will be traversed later
-      instanceKlass::oop_follow_contents(cm, obj);
-      debug_only(
-        if(TraceReferenceGC && PrintGCDetails) {
-          gclog_or_tty->print_cr("       Non NULL enqueued " INTPTR_FORMAT, (address)obj);
-        }
-      )
-      return;
-    } else {
-      // treat referent as normal oop
-      debug_only(
-        if(TraceReferenceGC && PrintGCDetails) {
-          gclog_or_tty->print_cr("       Non NULL normal " INTPTR_FORMAT, (address)obj);
+          gclog_or_tty->print_cr("       Non NULL normal " INTPTR_FORMAT, obj);
         }
       )
       PSParallelCompact::mark_and_push(cm, referent_addr);
     }
   }
   // treat next as normal oop.  next is a link in the pending list.
-  oop* next_addr = java_lang_ref_Reference::next_addr(obj);
+  T* next_addr = (T*)java_lang_ref_Reference::next_addr(obj);
   debug_only(
     if(TraceReferenceGC && PrintGCDetails) {
       gclog_or_tty->print_cr("   Process next as normal " INTPTR_FORMAT, next_addr);
     }
   )
   PSParallelCompact::mark_and_push(cm, next_addr);
-  instanceKlass::oop_follow_contents(cm, obj);
+  ref->instanceKlass::oop_follow_contents(cm, obj);
+}
+
+void instanceRefKlass::oop_follow_contents(ParCompactionManager* cm,
+                                           oop obj) {
+  if (UseCompressedOops) {
+    specialized_oop_follow_contents<narrowOop>(this, cm, obj);
+  } else {
+    specialized_oop_follow_contents<oop>(this, cm, obj);
+  }
 }
 #endif // SERIALGC
 
+#ifdef ASSERT
+template <class T> void trace_reference_gc(const char *s, oop obj,
+                                           T* referent_addr,
+                                           T* next_addr,
+                                           T* discovered_addr) {
+  if(TraceReferenceGC && PrintGCDetails) {
+    gclog_or_tty->print_cr("%s obj " INTPTR_FORMAT, s, (address)obj);
+    gclog_or_tty->print_cr("     referent_addr/* " INTPTR_FORMAT " / "
+         INTPTR_FORMAT, referent_addr,
+         referent_addr ?
+           (address)oopDesc::load_decode_heap_oop(referent_addr) : NULL);
+    gclog_or_tty->print_cr("     next_addr/* " INTPTR_FORMAT " / "
+         INTPTR_FORMAT, next_addr,
+         next_addr ? (address)oopDesc::load_decode_heap_oop(next_addr) : NULL);
+    gclog_or_tty->print_cr("     discovered_addr/* " INTPTR_FORMAT " / "
+         INTPTR_FORMAT, discovered_addr,
+         discovered_addr ?
+           (address)oopDesc::load_decode_heap_oop(discovered_addr) : NULL);
+  }
+}
+#endif
+
+template <class T> void specialized_oop_adjust_pointers(instanceRefKlass *ref, oop obj) {
+  T* referent_addr = (T*)java_lang_ref_Reference::referent_addr(obj);
+  MarkSweep::adjust_pointer(referent_addr);
+  T* next_addr = (T*)java_lang_ref_Reference::next_addr(obj);
+  MarkSweep::adjust_pointer(next_addr);
+  T* discovered_addr = (T*)java_lang_ref_Reference::discovered_addr(obj);
+  MarkSweep::adjust_pointer(discovered_addr);
+  debug_only(trace_reference_gc("instanceRefKlass::oop_adjust_pointers", obj,
+                                referent_addr, next_addr, discovered_addr);)
+}
 
 int instanceRefKlass::oop_adjust_pointers(oop obj) {
   int size = size_helper();
   instanceKlass::oop_adjust_pointers(obj);
 
-  oop* referent_addr = java_lang_ref_Reference::referent_addr(obj);
-  MarkSweep::adjust_pointer(referent_addr);
-  oop* next_addr = java_lang_ref_Reference::next_addr(obj);
-  MarkSweep::adjust_pointer(next_addr);
-  oop* discovered_addr = java_lang_ref_Reference::discovered_addr(obj);
-  MarkSweep::adjust_pointer(discovered_addr);
-
-#ifdef ASSERT
-  if(TraceReferenceGC && PrintGCDetails) {
-    gclog_or_tty->print_cr("instanceRefKlass::oop_adjust_pointers obj "
-                           INTPTR_FORMAT, (address)obj);
-    gclog_or_tty->print_cr("     referent_addr/* " INTPTR_FORMAT " / "
-                           INTPTR_FORMAT, referent_addr,
-                           referent_addr ? (address)*referent_addr : NULL);
-    gclog_or_tty->print_cr("     next_addr/* " INTPTR_FORMAT " / "
-                           INTPTR_FORMAT, next_addr,
-                           next_addr ? (address)*next_addr : NULL);
-    gclog_or_tty->print_cr("     discovered_addr/* " INTPTR_FORMAT " / "
-                           INTPTR_FORMAT, discovered_addr,
-                           discovered_addr ? (address)*discovered_addr : NULL);
+  if (UseCompressedOops) {
+    specialized_oop_adjust_pointers<narrowOop>(this, obj);
+  } else {
+    specialized_oop_adjust_pointers<oop>(this, obj);
   }
-#endif
-
   return size;
 }
 
+#define InstanceRefKlass_SPECIALIZED_OOP_ITERATE(T, nv_suffix, contains)        \
+  T* referent_addr = (T*)java_lang_ref_Reference::referent_addr(obj);           \
+  oop referent = oopDesc::load_decode_heap_oop(referent_addr);                  \
+  if (referent != NULL && contains(referent_addr)) {                            \
+    ReferenceProcessor* rp = closure->_ref_processor;                           \
+    if (!referent->is_gc_marked() && (rp != NULL) &&                            \
+        rp->discover_reference(obj, reference_type())) {                        \
+      return size;                                                              \
+    } else {                                                                    \
+      /* treat referent as normal oop */                                        \
+      SpecializationStats::record_do_oop_call##nv_suffix(SpecializationStats::irk);\
+      closure->do_oop##nv_suffix(referent_addr);                                \
+    }                                                                           \
+  }                                                                             \
+  /* treat next as normal oop */                                                \
+  T* next_addr = (T*)java_lang_ref_Reference::next_addr(obj);                   \
+  if (contains(next_addr)) {                                                    \
+    SpecializationStats::record_do_oop_call##nv_suffix(SpecializationStats::irk); \
+    closure->do_oop##nv_suffix(next_addr);                                      \
+  }                                                                             \
+  return size;                                                                  \
+
+
+template <class T> bool contains(T *t) { return true; }
+
+// Macro to define instanceRefKlass::oop_oop_iterate for virtual/nonvirtual for
+// all closures.  Macros calling macros above for each oop size.
+
 #define InstanceRefKlass_OOP_OOP_ITERATE_DEFN(OopClosureType, nv_suffix)        \
                                                                                 \
 int instanceRefKlass::                                                          \
@@ -150,25 +212,11 @@
                                                                                 \
   int size = instanceKlass::oop_oop_iterate##nv_suffix(obj, closure);           \
                                                                                 \
-  oop* referent_addr = java_lang_ref_Reference::referent_addr(obj);             \
-  oop referent = *referent_addr;                                                \
-  if (referent != NULL) {                                                       \
-    ReferenceProcessor* rp = closure->_ref_processor;                           \
-    if (!referent->is_gc_marked() && (rp != NULL) &&                            \
-        rp->discover_reference(obj, reference_type())) {              \
-      return size;                                                              \
-    } else {                                                                    \
-      /* treat referent as normal oop */                                        \
-      SpecializationStats::record_do_oop_call##nv_suffix(SpecializationStats::irk);\
-      closure->do_oop##nv_suffix(referent_addr);                                \
-    }                                                                           \
+  if (UseCompressedOops) {                                                      \
+    InstanceRefKlass_SPECIALIZED_OOP_ITERATE(narrowOop, nv_suffix, contains);   \
+  } else {                                                                      \
+    InstanceRefKlass_SPECIALIZED_OOP_ITERATE(oop, nv_suffix, contains);         \
   }                                                                             \
-                                                                                \
-  /* treat next as normal oop */                                                \
-  oop* next_addr = java_lang_ref_Reference::next_addr(obj);                     \
-  SpecializationStats::record_do_oop_call##nv_suffix(SpecializationStats::irk); \
-  closure->do_oop##nv_suffix(next_addr);                                        \
-  return size;                                                                  \
 }
 
 #define InstanceRefKlass_OOP_OOP_ITERATE_DEFN_m(OopClosureType, nv_suffix)      \
@@ -180,28 +228,11 @@
   SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::irk);\
                                                                                 \
   int size = instanceKlass::oop_oop_iterate##nv_suffix##_m(obj, closure, mr);   \
-                                                                                \
-  oop* referent_addr = java_lang_ref_Reference::referent_addr(obj);             \
-  oop referent = *referent_addr;                                                \
-  if (referent != NULL && mr.contains(referent_addr)) {                         \
-    ReferenceProcessor* rp = closure->_ref_processor;                           \
-    if (!referent->is_gc_marked() && (rp != NULL) &&                            \
-        rp->discover_reference(obj, reference_type())) {              \
-      return size;                                                              \
-    } else {                                                                    \
-      /* treat referent as normal oop */                                        \
-      SpecializationStats::record_do_oop_call##nv_suffix(SpecializationStats::irk);\
-      closure->do_oop##nv_suffix(referent_addr);                                \
-    }                                                                           \
+  if (UseCompressedOops) {                                                      \
+    InstanceRefKlass_SPECIALIZED_OOP_ITERATE(narrowOop, nv_suffix, mr.contains); \
+  } else {                                                                      \
+    InstanceRefKlass_SPECIALIZED_OOP_ITERATE(oop, nv_suffix, mr.contains);      \
   }                                                                             \
-                                                                                \
-  /* treat next as normal oop */                                                \
-  oop* next_addr = java_lang_ref_Reference::next_addr(obj);                     \
-  if (mr.contains(next_addr)) {                                                 \
-    SpecializationStats::record_do_oop_call##nv_suffix(SpecializationStats::irk);\
-    closure->do_oop##nv_suffix(next_addr);                                      \
-  }                                                                             \
-  return size;                                                                  \
 }
 
 ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceRefKlass_OOP_OOP_ITERATE_DEFN)
@@ -209,16 +240,17 @@
 ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceRefKlass_OOP_OOP_ITERATE_DEFN_m)
 ALL_OOP_OOP_ITERATE_CLOSURES_3(InstanceRefKlass_OOP_OOP_ITERATE_DEFN_m)
 
-
 #ifndef SERIALGC
-void instanceRefKlass::oop_copy_contents(PSPromotionManager* pm, oop obj) {
+template <class T>
+void specialized_oop_copy_contents(instanceRefKlass *ref,
+                                   PSPromotionManager* pm, oop obj) {
   assert(!pm->depth_first(), "invariant");
-  oop* referent_addr = java_lang_ref_Reference::referent_addr(obj);
-  if (PSScavenge::should_scavenge(*referent_addr)) {
+  T* referent_addr = (T*)java_lang_ref_Reference::referent_addr(obj);
+  if (PSScavenge::should_scavenge(referent_addr)) {
     ReferenceProcessor* rp = PSScavenge::reference_processor();
-    if (rp->discover_reference(obj, reference_type())) {
+    if (rp->discover_reference(obj, ref->reference_type())) {
       // reference already enqueued, referent and next will be traversed later
-      instanceKlass::oop_copy_contents(pm, obj);
+      ref->instanceKlass::oop_copy_contents(pm, obj);
       return;
     } else {
       // treat referent as normal oop
@@ -226,21 +258,31 @@
     }
   }
   // treat next as normal oop
-  oop* next_addr = java_lang_ref_Reference::next_addr(obj);
-  if (PSScavenge::should_scavenge(*next_addr)) {
+  T* next_addr = (T*)java_lang_ref_Reference::next_addr(obj);
+  if (PSScavenge::should_scavenge(next_addr)) {
     pm->claim_or_forward_breadth(next_addr);
   }
-  instanceKlass::oop_copy_contents(pm, obj);
+  ref->instanceKlass::oop_copy_contents(pm, obj);
 }
 
-void instanceRefKlass::oop_push_contents(PSPromotionManager* pm, oop obj) {
+void instanceRefKlass::oop_copy_contents(PSPromotionManager* pm, oop obj) {
+  if (UseCompressedOops) {
+    specialized_oop_copy_contents<narrowOop>(this, pm, obj);
+  } else {
+    specialized_oop_copy_contents<oop>(this, pm, obj);
+  }
+}
+
+template <class T>
+void specialized_oop_push_contents(instanceRefKlass *ref,
+                                   PSPromotionManager* pm, oop obj) {
   assert(pm->depth_first(), "invariant");
-  oop* referent_addr = java_lang_ref_Reference::referent_addr(obj);
-  if (PSScavenge::should_scavenge(*referent_addr)) {
+  T* referent_addr = (T*)java_lang_ref_Reference::referent_addr(obj);
+  if (PSScavenge::should_scavenge(referent_addr)) {
     ReferenceProcessor* rp = PSScavenge::reference_processor();
-    if (rp->discover_reference(obj, reference_type())) {
+    if (rp->discover_reference(obj, ref->reference_type())) {
       // reference already enqueued, referent and next will be traversed later
-      instanceKlass::oop_push_contents(pm, obj);
+      ref->instanceKlass::oop_push_contents(pm, obj);
       return;
     } else {
       // treat referent as normal oop
@@ -248,71 +290,68 @@
     }
   }
   // treat next as normal oop
-  oop* next_addr = java_lang_ref_Reference::next_addr(obj);
-  if (PSScavenge::should_scavenge(*next_addr)) {
+  T* next_addr = (T*)java_lang_ref_Reference::next_addr(obj);
+  if (PSScavenge::should_scavenge(next_addr)) {
     pm->claim_or_forward_depth(next_addr);
   }
-  instanceKlass::oop_push_contents(pm, obj);
+  ref->instanceKlass::oop_push_contents(pm, obj);
+}
+
+void instanceRefKlass::oop_push_contents(PSPromotionManager* pm, oop obj) {
+  if (UseCompressedOops) {
+    specialized_oop_push_contents<narrowOop>(this, pm, obj);
+  } else {
+    specialized_oop_push_contents<oop>(this, pm, obj);
+  }
+}
+
+template <class T>
+void specialized_oop_update_pointers(instanceRefKlass *ref,
+                                    ParCompactionManager* cm, oop obj) {
+  T* referent_addr = (T*)java_lang_ref_Reference::referent_addr(obj);
+  PSParallelCompact::adjust_pointer(referent_addr);
+  T* next_addr = (T*)java_lang_ref_Reference::next_addr(obj);
+  PSParallelCompact::adjust_pointer(next_addr);
+  T* discovered_addr = (T*)java_lang_ref_Reference::discovered_addr(obj);
+  PSParallelCompact::adjust_pointer(discovered_addr);
+  debug_only(trace_reference_gc("instanceRefKlass::oop_update_ptrs", obj,
+                                referent_addr, next_addr, discovered_addr);)
 }
 
 int instanceRefKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) {
   instanceKlass::oop_update_pointers(cm, obj);
+  if (UseCompressedOops) {
+    specialized_oop_update_pointers<narrowOop>(this, cm, obj);
+  } else {
+    specialized_oop_update_pointers<oop>(this, cm, obj);
+  }
+  return size_helper();
+}
 
-  oop* referent_addr = java_lang_ref_Reference::referent_addr(obj);
-  PSParallelCompact::adjust_pointer(referent_addr);
-  oop* next_addr = java_lang_ref_Reference::next_addr(obj);
-  PSParallelCompact::adjust_pointer(next_addr);
-  oop* discovered_addr = java_lang_ref_Reference::discovered_addr(obj);
-  PSParallelCompact::adjust_pointer(discovered_addr);
 
-#ifdef ASSERT
-  if(TraceReferenceGC && PrintGCDetails) {
-    gclog_or_tty->print_cr("instanceRefKlass::oop_update_pointers obj "
-                           INTPTR_FORMAT, (oopDesc*) obj);
-    gclog_or_tty->print_cr("     referent_addr/* " INTPTR_FORMAT " / "
-                           INTPTR_FORMAT, referent_addr,
-                           referent_addr ? (oopDesc*) *referent_addr : NULL);
-    gclog_or_tty->print_cr("     next_addr/* " INTPTR_FORMAT " / "
-                           INTPTR_FORMAT, next_addr,
-                           next_addr ? (oopDesc*) *next_addr : NULL);
-    gclog_or_tty->print_cr("     discovered_addr/* " INTPTR_FORMAT " / "
-                   INTPTR_FORMAT, discovered_addr,
-                   discovered_addr ? (oopDesc*) *discovered_addr : NULL);
-  }
-#endif
-
-  return size_helper();
+template <class T> void
+specialized_oop_update_pointers(ParCompactionManager* cm, oop obj,
+                                HeapWord* beg_addr, HeapWord* end_addr) {
+  T* p;
+  T* referent_addr = p = (T*)java_lang_ref_Reference::referent_addr(obj);
+  PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
+  T* next_addr = p = (T*)java_lang_ref_Reference::next_addr(obj);
+  PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
+  T* discovered_addr = p = (T*)java_lang_ref_Reference::discovered_addr(obj);
+  PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
+  debug_only(trace_reference_gc("instanceRefKlass::oop_update_ptrs", obj,
+                                referent_addr, next_addr, discovered_addr);)
 }
 
 int
 instanceRefKlass::oop_update_pointers(ParCompactionManager* cm, oop obj,
                                       HeapWord* beg_addr, HeapWord* end_addr) {
   instanceKlass::oop_update_pointers(cm, obj, beg_addr, end_addr);
-
-  oop* p;
-  oop* referent_addr = p = java_lang_ref_Reference::referent_addr(obj);
-  PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
-  oop* next_addr = p = java_lang_ref_Reference::next_addr(obj);
-  PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
-  oop* discovered_addr = p = java_lang_ref_Reference::discovered_addr(obj);
-  PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
-
-#ifdef ASSERT
-  if(TraceReferenceGC && PrintGCDetails) {
-    gclog_or_tty->print_cr("instanceRefKlass::oop_update_pointers obj "
-                           INTPTR_FORMAT, (oopDesc*) obj);
-    gclog_or_tty->print_cr("     referent_addr/* " INTPTR_FORMAT " / "
-                           INTPTR_FORMAT, referent_addr,
-                           referent_addr ? (oopDesc*) *referent_addr : NULL);
-    gclog_or_tty->print_cr("     next_addr/* " INTPTR_FORMAT " / "
-                           INTPTR_FORMAT, next_addr,
-                           next_addr ? (oopDesc*) *next_addr : NULL);
-    gclog_or_tty->print_cr("     discovered_addr/* " INTPTR_FORMAT " / "
-                   INTPTR_FORMAT, discovered_addr,
-                   discovered_addr ? (oopDesc*) *discovered_addr : NULL);
+  if (UseCompressedOops) {
+    specialized_oop_update_pointers<narrowOop>(cm, obj, beg_addr, end_addr);
+  } else {
+    specialized_oop_update_pointers<oop>(cm, obj, beg_addr, end_addr);
   }
-#endif
-
   return size_helper();
 }
 #endif // SERIALGC
@@ -338,7 +377,7 @@
   // offset 2 (words) and has 4 map entries.
   debug_only(int offset = java_lang_ref_Reference::referent_offset);
   debug_only(int length = ((java_lang_ref_Reference::discovered_offset -
-    java_lang_ref_Reference::referent_offset)/wordSize) + 1);
+    java_lang_ref_Reference::referent_offset)/heapOopSize) + 1);
 
   if (UseSharedSpaces) {
     assert(map->offset() == java_lang_ref_Reference::queue_offset &&
@@ -368,22 +407,35 @@
 
   if (referent != NULL) {
     guarantee(referent->is_oop(), "referent field heap failed");
-    if (gch != NULL && !gch->is_in_youngest(obj))
+    if (gch != NULL && !gch->is_in_youngest(obj)) {
       // We do a specific remembered set check here since the referent
       // field is not part of the oop mask and therefore skipped by the
       // regular verify code.
-      obj->verify_old_oop(java_lang_ref_Reference::referent_addr(obj), true);
+      if (UseCompressedOops) {
+        narrowOop* referent_addr = (narrowOop*)java_lang_ref_Reference::referent_addr(obj);
+        obj->verify_old_oop(referent_addr, true);
+      } else {
+        oop* referent_addr = (oop*)java_lang_ref_Reference::referent_addr(obj);
+        obj->verify_old_oop(referent_addr, true);
+      }
+    }
   }
   // Verify next field
   oop next = java_lang_ref_Reference::next(obj);
   if (next != NULL) {
-    guarantee(next->is_oop(), "next field verify failed");
+    guarantee(next->is_oop(), "next field verify fa iled");
     guarantee(next->is_instanceRef(), "next field verify failed");
     if (gch != NULL && !gch->is_in_youngest(obj)) {
       // We do a specific remembered set check here since the next field is
       // not part of the oop mask and therefore skipped by the regular
       // verify code.
-      obj->verify_old_oop(java_lang_ref_Reference::next_addr(obj), true);
+      if (UseCompressedOops) {
+        narrowOop* next_addr = (narrowOop*)java_lang_ref_Reference::next_addr(obj);
+        obj->verify_old_oop(next_addr, true);
+      } else {
+        oop* next_addr = (oop*)java_lang_ref_Reference::next_addr(obj);
+        obj->verify_old_oop(next_addr, true);
+      }
     }
   }
 }