hotspot/src/share/vm/gc/cms/cmsOopClosures.inline.hpp
changeset 35862 411842d0c882
parent 35492 c8c0273e6b91
child 46968 9119841280f4
--- a/hotspot/src/share/vm/gc/cms/cmsOopClosures.inline.hpp	Wed Jan 27 11:41:44 2016 +0100
+++ b/hotspot/src/share/vm/gc/cms/cmsOopClosures.inline.hpp	Mon Jan 18 10:25:41 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,21 +30,6 @@
 #include "gc/shared/taskqueue.inline.hpp"
 #include "oops/oop.inline.hpp"
 
-// Trim our work_queue so its length is below max at return
-inline void ParMarkRefsIntoAndScanClosure::trim_queue(uint max) {
-  while (_work_queue->size() > max) {
-    oop newOop;
-    if (_work_queue->pop_local(newOop)) {
-      assert(newOop->is_oop(), "Expected an oop");
-      assert(_bit_map->isMarked((HeapWord*)newOop),
-             "only grey objects on this stack");
-      // iterate over the oops in this oop, marking and pushing
-      // the ones in CMS heap (i.e. in _span).
-      newOop->oop_iterate(&_parPushAndMarkClosure);
-    }
-  }
-}
-
 // MetadataAwareOopClosure and MetadataAwareOopsInGenClosure are duplicated,
 // until we get rid of OopsInGenClosure.
 
@@ -61,4 +46,48 @@
   cld->oops_do(_klass_closure._oop_closure, &_klass_closure, claim);
 }
 
+// Decode the oop and call do_oop on it.
+#define DO_OOP_WORK_IMPL(cls)                                 \
+  template <class T> void cls::do_oop_work(T* p) {            \
+    T heap_oop = oopDesc::load_heap_oop(p);                   \
+    if (!oopDesc::is_null(heap_oop)) {                        \
+      oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);  \
+      do_oop(obj);                                            \
+    }                                                         \
+  }
+
+#define DO_OOP_WORK_NV_IMPL(cls)                              \
+  DO_OOP_WORK_IMPL(cls)                                       \
+  void cls::do_oop_nv(oop* p)       { cls::do_oop_work(p); }  \
+  void cls::do_oop_nv(narrowOop* p) { cls::do_oop_work(p); }
+
+DO_OOP_WORK_IMPL(MarkRefsIntoClosure)
+DO_OOP_WORK_IMPL(ParMarkRefsIntoClosure)
+DO_OOP_WORK_IMPL(MarkRefsIntoVerifyClosure)
+DO_OOP_WORK_NV_IMPL(PushAndMarkClosure)
+DO_OOP_WORK_NV_IMPL(ParPushAndMarkClosure)
+DO_OOP_WORK_NV_IMPL(MarkRefsIntoAndScanClosure)
+DO_OOP_WORK_NV_IMPL(ParMarkRefsIntoAndScanClosure)
+
+// Trim our work_queue so its length is below max at return
+inline void ParMarkRefsIntoAndScanClosure::trim_queue(uint max) {
+  while (_work_queue->size() > max) {
+    oop newOop;
+    if (_work_queue->pop_local(newOop)) {
+      assert(newOop->is_oop(), "Expected an oop");
+      assert(_bit_map->isMarked((HeapWord*)newOop),
+             "only grey objects on this stack");
+      // iterate over the oops in this oop, marking and pushing
+      // the ones in CMS heap (i.e. in _span).
+      newOop->oop_iterate(&_parPushAndMarkClosure);
+    }
+  }
+}
+
+DO_OOP_WORK_NV_IMPL(PushOrMarkClosure)
+DO_OOP_WORK_NV_IMPL(ParPushOrMarkClosure)
+DO_OOP_WORK_NV_IMPL(CMSKeepAliveClosure)
+DO_OOP_WORK_NV_IMPL(CMSInnerParMarkAndPushClosure)
+DO_OOP_WORK_IMPL(CMSParKeepAliveClosure)
+
 #endif // SHARE_VM_GC_CMS_CMSOOPCLOSURES_INLINE_HPP