7191124: Optimized build is broken due to inconsistent use of DEBUG_ONLY and NOT_PRODUCT macros in NMT
authorzgu
Tue, 14 Aug 2012 13:56:46 -0400
changeset 13478 85fe611440e5
parent 13477 2ac00cd97cf6
child 13479 a378c53b46f0
7191124: Optimized build is broken due to inconsistent use of DEBUG_ONLY and NOT_PRODUCT macros in NMT Summary: Updated all related variables and methods to use NOT_PRODUCT macros Reviewed-by: coleenp, acorn, kvn
hotspot/src/share/vm/services/memPtr.cpp
hotspot/src/share/vm/services/memPtr.hpp
hotspot/src/share/vm/services/memPtrArray.hpp
hotspot/src/share/vm/services/memRecorder.hpp
hotspot/src/share/vm/services/memSnapshot.cpp
hotspot/src/share/vm/services/memTracker.cpp
--- a/hotspot/src/share/vm/services/memPtr.cpp	Fri Aug 10 23:16:52 2012 -0700
+++ b/hotspot/src/share/vm/services/memPtr.cpp	Tue Aug 14 13:56:46 2012 -0400
@@ -27,7 +27,7 @@
 #include "services/memTracker.hpp"
 
 volatile jint SequenceGenerator::_seq_number = 1;
-DEBUG_ONLY(jint SequenceGenerator::_max_seq_number = 1;)
+NOT_PRODUCT(jint SequenceGenerator::_max_seq_number = 1;)
 DEBUG_ONLY(volatile unsigned long SequenceGenerator::_generation = 0;)
 
 jint SequenceGenerator::next() {
@@ -36,7 +36,7 @@
     MemTracker::shutdown(MemTracker::NMT_sequence_overflow);
   }
   assert(seq > 0, "counter overflow");
-  DEBUG_ONLY(_max_seq_number = (seq > _max_seq_number) ? seq : _max_seq_number;)
+  NOT_PRODUCT(_max_seq_number = (seq > _max_seq_number) ? seq : _max_seq_number;)
   return seq;
 }
 
--- a/hotspot/src/share/vm/services/memPtr.hpp	Fri Aug 10 23:16:52 2012 -0700
+++ b/hotspot/src/share/vm/services/memPtr.hpp	Tue Aug 14 13:56:46 2012 -0400
@@ -51,11 +51,11 @@
   };
 
   DEBUG_ONLY(static unsigned long current_generation() { return (unsigned long)_generation; })
-  DEBUG_ONLY(static jint max_seq_num() { return _max_seq_number; })
+  NOT_PRODUCT(static jint max_seq_num() { return _max_seq_number; })
 
  private:
   static volatile jint _seq_number;
-  DEBUG_ONLY(static jint _max_seq_number; )
+  NOT_PRODUCT(static jint _max_seq_number; )
   DEBUG_ONLY(static volatile unsigned long _generation; )
 };
 
--- a/hotspot/src/share/vm/services/memPtrArray.hpp	Fri Aug 10 23:16:52 2012 -0700
+++ b/hotspot/src/share/vm/services/memPtrArray.hpp	Tue Aug 14 13:56:46 2012 -0400
@@ -59,7 +59,7 @@
   virtual size_t instance_size() const = 0;
   virtual bool shrink() = 0;
 
-  debug_only(virtual int capacity() const = 0;)
+  NOT_PRODUCT(virtual int capacity() const = 0;)
 };
 
 // Iterator interface
@@ -205,7 +205,7 @@
     return _size;
   }
 
-  debug_only(int capacity() const { return _max_size; })
+  NOT_PRODUCT(int capacity() const { return _max_size; })
 
   void clear() {
     assert(_data != NULL, "Just check");
--- a/hotspot/src/share/vm/services/memRecorder.hpp	Fri Aug 10 23:16:52 2012 -0700
+++ b/hotspot/src/share/vm/services/memRecorder.hpp	Tue Aug 14 13:56:46 2012 -0400
@@ -73,7 +73,7 @@
     return sizeof(FixedSizeMemPointerArray<E, SIZE>);
   }
 
-  debug_only(int capacity() const { return SIZE; })
+  NOT_PRODUCT(int capacity() const { return SIZE; })
 
  public:
   // implementation of public interface
--- a/hotspot/src/share/vm/services/memSnapshot.cpp	Fri Aug 10 23:16:52 2012 -0700
+++ b/hotspot/src/share/vm/services/memSnapshot.cpp	Tue Aug 14 13:56:46 2012 -0400
@@ -338,15 +338,13 @@
             vm_itr.insert_after(cur_vm);
           }
         } else {
-#ifdef ASSERT
           // In theory, we should assert without conditions. However, in case of native
           // thread stack, NMT explicitly releases the thread stack in Thread's destructor,
           // due to platform dependent behaviors. On some platforms, we see uncommit/release
           // native thread stack, but some, we don't.
-          if (!cur_vm->is_uncommit_record() && !cur_vm->is_deallocation_record()) {
-            fatal(err_msg("Should not reach here, pointer flags = [%x]", cur_vm->flags()));
-          }
-#endif
+          assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record(),
+            err_msg("Should not reach here, pointer addr = [" INTPTR_FORMAT "], flags = [%x]",
+               cur_vm->addr(), cur_vm->flags()));
         }
       }
     } else {
@@ -406,7 +404,7 @@
 }
 
 
-#ifdef ASSERT
+#ifndef PRODUCT
 void MemSnapshot::print_snapshot_stats(outputStream* st) {
   st->print_cr("Snapshot:");
   st->print_cr("\tMalloced: %d/%d [%5.2f%%]  %dKB", _alloc_ptrs->length(), _alloc_ptrs->capacity(),
@@ -434,6 +432,20 @@
   }
 }
 
+bool MemSnapshot::has_allocation_record(address addr) {
+  MemPointerArrayIteratorImpl itr(_staging_area);
+  MemPointerRecord* cur = (MemPointerRecord*)itr.current();
+  while (cur != NULL) {
+    if (cur->addr() == addr && cur->is_allocation_record()) {
+      return true;
+    }
+    cur = (MemPointerRecord*)itr.next();
+  }
+  return false;
+}
+#endif // PRODUCT
+
+#ifdef ASSERT
 void MemSnapshot::check_staging_data() {
   MemPointerArrayIteratorImpl itr(_staging_area);
   MemPointerRecord* cur = (MemPointerRecord*)itr.current();
@@ -447,17 +459,5 @@
     next = (MemPointerRecord*)itr.next();
   }
 }
+#endif // ASSERT
 
-bool MemSnapshot::has_allocation_record(address addr) {
-  MemPointerArrayIteratorImpl itr(_staging_area);
-  MemPointerRecord* cur = (MemPointerRecord*)itr.current();
-  while (cur != NULL) {
-    if (cur->addr() == addr && cur->is_allocation_record()) {
-      return true;
-    }
-    cur = (MemPointerRecord*)itr.next();
-  }
-  return false;
-}
-
-#endif
--- a/hotspot/src/share/vm/services/memTracker.cpp	Fri Aug 10 23:16:52 2012 -0700
+++ b/hotspot/src/share/vm/services/memTracker.cpp	Tue Aug 14 13:56:46 2012 -0400
@@ -65,7 +65,7 @@
 int                             MemTracker::_thread_count = 255;
 volatile jint                   MemTracker::_pooled_recorder_count = 0;
 debug_only(intx                 MemTracker::_main_thread_tid = 0;)
-debug_only(volatile jint        MemTracker::_pending_recorder_count = 0;)
+NOT_PRODUCT(volatile jint       MemTracker::_pending_recorder_count = 0;)
 
 void MemTracker::init_tracking_options(const char* option_line) {
   _tracking_level = NMT_off;
@@ -291,7 +291,7 @@
     (void*)cur_head)) {
     cur_head = const_cast<MemRecorder*>(_merge_pending_queue);
   }
-  debug_only(Atomic::store(0, &_pending_recorder_count));
+  NOT_PRODUCT(Atomic::store(0, &_pending_recorder_count));
   return cur_head;
 }
 
@@ -420,7 +420,7 @@
     cur_head = const_cast<MemRecorder*>(_merge_pending_queue);
     rec->set_next(cur_head);
   }
-  debug_only(Atomic::inc(&_pending_recorder_count);)
+  NOT_PRODUCT(Atomic::inc(&_pending_recorder_count);)
 }
 
 /*