< prev index next >

src/share/vm/gc/g1/heapRegion.cpp

Print this page

        

@@ -32,10 +32,11 @@
 #include "gc/g1/heapRegionManager.inline.hpp"
 #include "gc/g1/heapRegionRemSet.hpp"
 #include "gc/shared/genOopClosures.inline.hpp"
 #include "gc/shared/liveRange.hpp"
 #include "gc/shared/space.inline.hpp"
+#include "logging/log.hpp"
 #include "memory/iterator.hpp"
 #include "oops/oop.inline.hpp"
 #include "runtime/atomic.inline.hpp"
 #include "runtime/orderAccess.inline.hpp"
 

@@ -477,13 +478,11 @@
       // current region. We only look at those which are.
       if (_hr->is_in(obj)) {
         // Object is in the region. Check that its less than top
         if (_hr->top() <= (HeapWord*)obj) {
           // Object is above top
-          gclog_or_tty->print_cr("Object " PTR_FORMAT " in region "
-                                 "[" PTR_FORMAT ", " PTR_FORMAT ") is above "
-                                 "top " PTR_FORMAT,
+          log_info(gc, verify)("Object " PTR_FORMAT " in region [" PTR_FORMAT ", " PTR_FORMAT ") is above top " PTR_FORMAT,
                                  p2i(obj), p2i(_hr->bottom()), p2i(_hr->end()), p2i(_hr->top()));
           _failures = true;
           return;
         }
         // Nmethod has at least one oop in the current region

@@ -513,26 +512,22 @@
   void do_code_blob(CodeBlob* cb) {
     nmethod* nm = (cb == NULL) ? NULL : cb->as_nmethod_or_null();
     if (nm != NULL) {
       // Verify that the nemthod is live
       if (!nm->is_alive()) {
-        gclog_or_tty->print_cr("region [" PTR_FORMAT "," PTR_FORMAT "] has dead nmethod "
-                               PTR_FORMAT " in its strong code roots",
+        log_info(gc, verify)("region [" PTR_FORMAT "," PTR_FORMAT "] has dead nmethod " PTR_FORMAT " in its strong code roots",
                                p2i(_hr->bottom()), p2i(_hr->end()), p2i(nm));
         _failures = true;
       } else {
         VerifyStrongCodeRootOopClosure oop_cl(_hr, nm);
         nm->oops_do(&oop_cl);
         if (!oop_cl.has_oops_in_region()) {
-          gclog_or_tty->print_cr("region [" PTR_FORMAT "," PTR_FORMAT "] has nmethod "
-                                 PTR_FORMAT " in its strong code roots "
-                                 "with no pointers into region",
+          log_info(gc, verify)("region [" PTR_FORMAT "," PTR_FORMAT "] has nmethod " PTR_FORMAT " in its strong code roots with no pointers into region",
                                  p2i(_hr->bottom()), p2i(_hr->end()), p2i(nm));
           _failures = true;
         } else if (oop_cl.failures()) {
-          gclog_or_tty->print_cr("region [" PTR_FORMAT "," PTR_FORMAT "] has other "
-                                 "failures for nmethod " PTR_FORMAT,
+          log_info(gc, verify)("region [" PTR_FORMAT "," PTR_FORMAT "] has other failures for nmethod " PTR_FORMAT,
                                  p2i(_hr->bottom()), p2i(_hr->end()), p2i(nm));
           _failures = true;
         }
       }
     }

@@ -562,22 +557,20 @@
 
   // if this region is empty then there should be no entries
   // on its strong code root list
   if (is_empty()) {
     if (strong_code_roots_length > 0) {
-      gclog_or_tty->print_cr("region [" PTR_FORMAT "," PTR_FORMAT "] is empty "
-                             "but has " SIZE_FORMAT " code root entries",
+      log_info(gc, verify)("region [" PTR_FORMAT "," PTR_FORMAT "] is empty but has " SIZE_FORMAT " code root entries",
                              p2i(bottom()), p2i(end()), strong_code_roots_length);
       *failures = true;
     }
     return;
   }
 
   if (is_continues_humongous()) {
     if (strong_code_roots_length > 0) {
-      gclog_or_tty->print_cr("region " HR_FORMAT " is a continuation of a humongous "
-                             "region but has " SIZE_FORMAT " code root entries",
+      log_info(gc, verify)("region " HR_FORMAT " is a continuation of a humongous region but has " SIZE_FORMAT " code root entries",
                              HR_FORMAT_PARAMS(this), strong_code_roots_length);
       *failures = true;
     }
     return;
   }

@@ -588,11 +581,11 @@
   if (cb_cl.failures()) {
     *failures = true;
   }
 }
 
-void HeapRegion::print() const { print_on(gclog_or_tty); }
+void HeapRegion::print() const { print_on(tty); }
 void HeapRegion::print_on(outputStream* st) const {
   st->print("AC%4u", allocation_context());
 
   st->print(" %2s", get_short_type_str());
   if (in_collection_set())

@@ -646,47 +639,39 @@
   void do_oop_work(T* p) {
     assert(_containing_obj != NULL, "Precondition");
     assert(!_g1h->is_obj_dead_cond(_containing_obj, _vo),
            "Precondition");
     T heap_oop = oopDesc::load_heap_oop(p);
+    LogHandle(gc, verify) log;
     if (!oopDesc::is_null(heap_oop)) {
       oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
       bool failed = false;
       if (!_g1h->is_in_closed_subset(obj) || _g1h->is_obj_dead_cond(obj, _vo)) {
         MutexLockerEx x(ParGCRareEvent_lock,
                         Mutex::_no_safepoint_check_flag);
 
         if (!_failures) {
-          gclog_or_tty->cr();
-          gclog_or_tty->print_cr("----------");
+          log.info("----------");
         }
+        ResourceMark rm;
         if (!_g1h->is_in_closed_subset(obj)) {
           HeapRegion* from = _g1h->heap_region_containing((HeapWord*)p);
-          gclog_or_tty->print_cr("Field " PTR_FORMAT
-                                 " of live obj " PTR_FORMAT " in region "
-                                 "[" PTR_FORMAT ", " PTR_FORMAT ")",
-                                 p2i(p), p2i(_containing_obj),
-                                 p2i(from->bottom()), p2i(from->end()));
-          print_object(gclog_or_tty, _containing_obj);
-          gclog_or_tty->print_cr("points to obj " PTR_FORMAT " not in the heap",
-                                 p2i(obj));
+          log.info("Field " PTR_FORMAT " of live obj " PTR_FORMAT " in region [" PTR_FORMAT ", " PTR_FORMAT ")",
+                   p2i(p), p2i(_containing_obj), p2i(from->bottom()), p2i(from->end()));
+          print_object(log.info_stream(), _containing_obj);
+          log.info("points to obj " PTR_FORMAT " not in the heap", p2i(obj));
         } else {
           HeapRegion* from = _g1h->heap_region_containing((HeapWord*)p);
           HeapRegion* to   = _g1h->heap_region_containing((HeapWord*)obj);
-          gclog_or_tty->print_cr("Field " PTR_FORMAT
-                                 " of live obj " PTR_FORMAT " in region "
-                                 "[" PTR_FORMAT ", " PTR_FORMAT ")",
-                                 p2i(p), p2i(_containing_obj),
-                                 p2i(from->bottom()), p2i(from->end()));
-          print_object(gclog_or_tty, _containing_obj);
-          gclog_or_tty->print_cr("points to dead obj " PTR_FORMAT " in region "
-                                 "[" PTR_FORMAT ", " PTR_FORMAT ")",
+          log.info("Field " PTR_FORMAT " of live obj " PTR_FORMAT " in region [" PTR_FORMAT ", " PTR_FORMAT ")",
+                   p2i(p), p2i(_containing_obj), p2i(from->bottom()), p2i(from->end()));
+          print_object(log.info_stream(), _containing_obj);
+          log.info("points to dead obj " PTR_FORMAT " in region [" PTR_FORMAT ", " PTR_FORMAT ")",
                                  p2i(obj), p2i(to->bottom()), p2i(to->end()));
-          print_object(gclog_or_tty, obj);
+          print_object(log.info_stream(), obj);
         }
-        gclog_or_tty->print_cr("----------");
-        gclog_or_tty->flush();
+        log.info("----------");
         _failures = true;
         failed = true;
         _n_failures++;
       }
 

@@ -709,29 +694,21 @@
           if (is_bad) {
             MutexLockerEx x(ParGCRareEvent_lock,
                             Mutex::_no_safepoint_check_flag);
 
             if (!_failures) {
-              gclog_or_tty->cr();
-              gclog_or_tty->print_cr("----------");
+              log.info("----------");
             }
-            gclog_or_tty->print_cr("Missing rem set entry:");
-            gclog_or_tty->print_cr("Field " PTR_FORMAT " "
-                                   "of obj " PTR_FORMAT ", "
-                                   "in region " HR_FORMAT,
-                                   p2i(p), p2i(_containing_obj),
-                                   HR_FORMAT_PARAMS(from));
-            _containing_obj->print_on(gclog_or_tty);
-            gclog_or_tty->print_cr("points to obj " PTR_FORMAT " "
-                                   "in region " HR_FORMAT,
-                                   p2i(obj),
-                                   HR_FORMAT_PARAMS(to));
-            obj->print_on(gclog_or_tty);
-            gclog_or_tty->print_cr("Obj head CTE = %d, field CTE = %d.",
-                          cv_obj, cv_field);
-            gclog_or_tty->print_cr("----------");
-            gclog_or_tty->flush();
+            log.info("Missing rem set entry:");
+            log.info("Field " PTR_FORMAT " of obj " PTR_FORMAT ", in region " HR_FORMAT,
+                     p2i(p), p2i(_containing_obj), HR_FORMAT_PARAMS(from));
+            ResourceMark rm;
+            _containing_obj->print_on(log.info_stream());
+            log.info("points to obj " PTR_FORMAT " in region " HR_FORMAT, p2i(obj), HR_FORMAT_PARAMS(to));
+            obj->print_on(log.info_stream());
+            log.info("Obj head CTE = %d, field CTE = %d.", cv_obj, cv_field);
+            log.info("----------");
             _failures = true;
             if (!failed) _n_failures++;
           }
         }
       }

@@ -756,11 +733,11 @@
     size_t obj_size = block_size(p);
     object_num += 1;
 
     if (is_region_humongous != g1->is_humongous(obj_size) &&
         !g1->is_obj_dead(obj, this)) { // Dead objects may have bigger block_size since they span several objects.
-      gclog_or_tty->print_cr("obj " PTR_FORMAT " is of %shumongous size ("
+      log_info(gc, verify)("obj " PTR_FORMAT " is of %shumongous size ("
                              SIZE_FORMAT " words) in a %shumongous region",
                              p2i(p), g1->is_humongous(obj_size) ? "" : "non-",
                              obj_size, is_region_humongous ? "" : "non-");
        *failures = true;
        return;

@@ -771,16 +748,16 @@
         Klass* klass = obj->klass();
         bool is_metaspace_object = Metaspace::contains(klass) ||
                                    (vo == VerifyOption_G1UsePrevMarking &&
                                    ClassLoaderDataGraph::unload_list_contains(klass));
         if (!is_metaspace_object) {
-          gclog_or_tty->print_cr("klass " PTR_FORMAT " of object " PTR_FORMAT " "
+          log_info(gc, verify)("klass " PTR_FORMAT " of object " PTR_FORMAT " "
                                  "not metadata", p2i(klass), p2i(obj));
           *failures = true;
           return;
         } else if (!klass->is_klass()) {
-          gclog_or_tty->print_cr("klass " PTR_FORMAT " of object " PTR_FORMAT " "
+          log_info(gc, verify)("klass " PTR_FORMAT " of object " PTR_FORMAT " "
                                  "not a klass", p2i(klass), p2i(obj));
           *failures = true;
           return;
         } else {
           vl_cl.set_containing_obj(obj);

@@ -792,11 +769,11 @@
               vl_cl.n_failures() >= G1MaxVerifyFailures) {
             return;
           }
         }
       } else {
-        gclog_or_tty->print_cr(PTR_FORMAT " no an oop", p2i(obj));
+        log_info(gc, verify)(PTR_FORMAT " no an oop", p2i(obj));
         *failures = true;
         return;
       }
     }
     prev_p = p;

@@ -808,16 +785,16 @@
   }
 
   if (is_region_humongous) {
     oop obj = oop(this->humongous_start_region()->bottom());
     if ((HeapWord*)obj > bottom() || (HeapWord*)obj + obj->size() < bottom()) {
-      gclog_or_tty->print_cr("this humongous region is not part of its' humongous object " PTR_FORMAT, p2i(obj));
+      log_info(gc, verify)("this humongous region is not part of its' humongous object " PTR_FORMAT, p2i(obj));
     }
   }
 
   if (!is_region_humongous && p != top()) {
-    gclog_or_tty->print_cr("end of last object " PTR_FORMAT " "
+    log_info(gc, verify)("end of last object " PTR_FORMAT " "
                            "does not match top " PTR_FORMAT, p2i(p), p2i(top()));
     *failures = true;
     return;
   }
 

@@ -828,11 +805,11 @@
   if (p < the_end) {
     // Look up top
     HeapWord* addr_1 = p;
     HeapWord* b_start_1 = _offsets.block_start_const(addr_1);
     if (b_start_1 != p) {
-      gclog_or_tty->print_cr("BOT look up for top: " PTR_FORMAT " "
+      log_info(gc, verify)("BOT look up for top: " PTR_FORMAT " "
                              " yielded " PTR_FORMAT ", expecting " PTR_FORMAT,
                              p2i(addr_1), p2i(b_start_1), p2i(p));
       *failures = true;
       return;
     }

@@ -840,11 +817,11 @@
     // Look up top + 1
     HeapWord* addr_2 = p + 1;
     if (addr_2 < the_end) {
       HeapWord* b_start_2 = _offsets.block_start_const(addr_2);
       if (b_start_2 != p) {
-        gclog_or_tty->print_cr("BOT look up for top + 1: " PTR_FORMAT " "
+        log_info(gc, verify)("BOT look up for top + 1: " PTR_FORMAT " "
                                " yielded " PTR_FORMAT ", expecting " PTR_FORMAT,
                                p2i(addr_2), p2i(b_start_2), p2i(p));
         *failures = true;
         return;
       }

@@ -854,11 +831,11 @@
     size_t diff = pointer_delta(the_end, p) / 2;
     HeapWord* addr_3 = p + diff;
     if (addr_3 < the_end) {
       HeapWord* b_start_3 = _offsets.block_start_const(addr_3);
       if (b_start_3 != p) {
-        gclog_or_tty->print_cr("BOT look up for top + diff: " PTR_FORMAT " "
+        log_info(gc, verify)("BOT look up for top + diff: " PTR_FORMAT " "
                                " yielded " PTR_FORMAT ", expecting " PTR_FORMAT,
                                p2i(addr_3), p2i(b_start_3), p2i(p));
         *failures = true;
         return;
       }

@@ -866,20 +843,20 @@
 
     // Look up end - 1
     HeapWord* addr_4 = the_end - 1;
     HeapWord* b_start_4 = _offsets.block_start_const(addr_4);
     if (b_start_4 != p) {
-      gclog_or_tty->print_cr("BOT look up for end - 1: " PTR_FORMAT " "
+      log_info(gc, verify)("BOT look up for end - 1: " PTR_FORMAT " "
                              " yielded " PTR_FORMAT ", expecting " PTR_FORMAT,
                              p2i(addr_4), p2i(b_start_4), p2i(p));
       *failures = true;
       return;
     }
   }
 
   if (is_region_humongous && object_num > 1) {
-    gclog_or_tty->print_cr("region [" PTR_FORMAT "," PTR_FORMAT "] is humongous "
+    log_info(gc, verify)("region [" PTR_FORMAT "," PTR_FORMAT "] is humongous "
                            "but has " SIZE_FORMAT ", objects",
                            p2i(bottom()), p2i(end()), object_num);
     *failures = true;
     return;
   }

@@ -927,11 +904,11 @@
 }
 #endif
 
 void G1OffsetTableContigSpace::print() const {
   print_short();
-  gclog_or_tty->print_cr(" [" INTPTR_FORMAT ", " INTPTR_FORMAT ", "
+  tty->print_cr(" [" INTPTR_FORMAT ", " INTPTR_FORMAT ", "
                 INTPTR_FORMAT ", " INTPTR_FORMAT ")",
                 p2i(bottom()), p2i(top()), p2i(_offsets.threshold()), p2i(end()));
 }
 
 HeapWord* G1OffsetTableContigSpace::initialize_threshold() {
< prev index next >