< prev index next >

src/hotspot/share/gc/g1/g1FullGCOopClosures.cpp

Print this page




  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  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 #include "precompiled.hpp"
  26 #include "gc/g1/g1CollectedHeap.hpp"
  27 #include "gc/g1/g1FullGCMarker.inline.hpp"
  28 #include "gc/g1/g1FullGCOopClosures.inline.hpp"
  29 #include "gc/g1/g1_specialized_oop_closures.hpp"
  30 #include "logging/logStream.hpp"


  31 
  32 void G1MarkAndPushClosure::do_oop(oop* p) {
  33   do_oop_nv(p);
  34 }
  35 
  36 void G1MarkAndPushClosure::do_oop(narrowOop* p) {
  37   do_oop_nv(p);
  38 }
  39 
  40 bool G1MarkAndPushClosure::do_metadata() {
  41   return do_metadata_nv();
  42 }
  43 
  44 void G1MarkAndPushClosure::do_klass(Klass* k) {
  45   do_klass_nv(k);
  46 }
  47 
  48 void G1MarkAndPushClosure::do_cld(ClassLoaderData* cld) {
  49   do_cld_nv(cld);
  50 }


  82 
  83 G1VerifyOopClosure::G1VerifyOopClosure(VerifyOption option) :
  84    _g1h(G1CollectedHeap::heap()),
  85    _containing_obj(NULL),
  86    _verify_option(option),
  87    _cc(0),
  88    _failures(false) {
  89 }
  90 
  91 void G1VerifyOopClosure::print_object(outputStream* out, oop obj) {
  92 #ifdef PRODUCT
  93   Klass* k = obj->klass();
  94   const char* class_name = InstanceKlass::cast(k)->external_name();
  95   out->print_cr("class name %s", class_name);
  96 #else // PRODUCT
  97   obj->print_on(out);
  98 #endif // PRODUCT
  99 }
 100 
 101 template <class T> void G1VerifyOopClosure::do_oop_nv(T* p) {
 102   T heap_oop = oopDesc::load_heap_oop(p);
 103   if (!oopDesc::is_null(heap_oop)) {
 104     _cc++;
 105     oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
 106     bool failed = false;
 107     if (!_g1h->is_in_closed_subset(obj) || _g1h->is_obj_dead_cond(obj, _verify_option)) {
 108       MutexLockerEx x(ParGCRareEvent_lock,
 109           Mutex::_no_safepoint_check_flag);
 110       LogStreamHandle(Error, gc, verify) yy;
 111       if (!_failures) {
 112         yy.cr();
 113         yy.print_cr("----------");
 114       }
 115       if (!_g1h->is_in_closed_subset(obj)) {
 116         HeapRegion* from = _g1h->heap_region_containing((HeapWord*)p);
 117         yy.print_cr("Field " PTR_FORMAT
 118             " of live obj " PTR_FORMAT " in region "
 119             "[" PTR_FORMAT ", " PTR_FORMAT ")",
 120             p2i(p), p2i(_containing_obj),
 121             p2i(from->bottom()), p2i(from->end()));
 122         print_object(&yy, _containing_obj);
 123         yy.print_cr("points to obj " PTR_FORMAT " not in the heap",
 124             p2i(obj));
 125       } else {




  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  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 #include "precompiled.hpp"
  26 #include "gc/g1/g1CollectedHeap.hpp"
  27 #include "gc/g1/g1FullGCMarker.inline.hpp"
  28 #include "gc/g1/g1FullGCOopClosures.inline.hpp"
  29 #include "gc/g1/g1_specialized_oop_closures.hpp"
  30 #include "logging/logStream.hpp"
  31 #include "oops/access.inline.hpp"
  32 #include "oops/compressedOops.inline.hpp"
  33 
  34 void G1MarkAndPushClosure::do_oop(oop* p) {
  35   do_oop_nv(p);
  36 }
  37 
  38 void G1MarkAndPushClosure::do_oop(narrowOop* p) {
  39   do_oop_nv(p);
  40 }
  41 
  42 bool G1MarkAndPushClosure::do_metadata() {
  43   return do_metadata_nv();
  44 }
  45 
  46 void G1MarkAndPushClosure::do_klass(Klass* k) {
  47   do_klass_nv(k);
  48 }
  49 
  50 void G1MarkAndPushClosure::do_cld(ClassLoaderData* cld) {
  51   do_cld_nv(cld);
  52 }


  84 
  85 G1VerifyOopClosure::G1VerifyOopClosure(VerifyOption option) :
  86    _g1h(G1CollectedHeap::heap()),
  87    _containing_obj(NULL),
  88    _verify_option(option),
  89    _cc(0),
  90    _failures(false) {
  91 }
  92 
  93 void G1VerifyOopClosure::print_object(outputStream* out, oop obj) {
  94 #ifdef PRODUCT
  95   Klass* k = obj->klass();
  96   const char* class_name = InstanceKlass::cast(k)->external_name();
  97   out->print_cr("class name %s", class_name);
  98 #else // PRODUCT
  99   obj->print_on(out);
 100 #endif // PRODUCT
 101 }
 102 
 103 template <class T> void G1VerifyOopClosure::do_oop_nv(T* p) {
 104   T heap_oop = RawAccess<>::oop_load(p);
 105   if (!CompressedOops::is_null(heap_oop)) {
 106     _cc++;
 107     oop obj = CompressedOops::decode_not_null(heap_oop);
 108     bool failed = false;
 109     if (!_g1h->is_in_closed_subset(obj) || _g1h->is_obj_dead_cond(obj, _verify_option)) {
 110       MutexLockerEx x(ParGCRareEvent_lock,
 111           Mutex::_no_safepoint_check_flag);
 112       LogStreamHandle(Error, gc, verify) yy;
 113       if (!_failures) {
 114         yy.cr();
 115         yy.print_cr("----------");
 116       }
 117       if (!_g1h->is_in_closed_subset(obj)) {
 118         HeapRegion* from = _g1h->heap_region_containing((HeapWord*)p);
 119         yy.print_cr("Field " PTR_FORMAT
 120             " of live obj " PTR_FORMAT " in region "
 121             "[" PTR_FORMAT ", " PTR_FORMAT ")",
 122             p2i(p), p2i(_containing_obj),
 123             p2i(from->bottom()), p2i(from->end()));
 124         print_object(&yy, _containing_obj);
 125         yy.print_cr("points to obj " PTR_FORMAT " not in the heap",
 126             p2i(obj));
 127       } else {


< prev index next >