< prev index next >

src/hotspot/share/services/memTracker.hpp

Print this page




  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 #ifndef SHARE_VM_SERVICES_MEM_TRACKER_HPP
  26 #define SHARE_VM_SERVICES_MEM_TRACKER_HPP
  27 
  28 #include "services/nmtCommon.hpp"
  29 #include "utilities/nativeCallStack.hpp"
  30 
  31 
  32 #if !INCLUDE_NMT
  33 
  34 #define CURRENT_PC   NativeCallStack::EMPTY_STACK
  35 #define CALLER_PC    NativeCallStack::EMPTY_STACK
  36 
  37 class Tracker : public StackObj {
  38  public:
  39   enum TrackerType {
  40      uncommit,
  41      release
  42   };
  43   Tracker(enum TrackerType type) : _type(type) { }
  44   void record(address addr, size_t size) { }
  45  private:
  46   enum TrackerType  _type;
  47 };
  48 
  49 class MemTracker : AllStatic {
  50  public:
  51   static inline NMT_TrackingLevel tracking_level() { return NMT_off; }
  52   static inline void shutdown() { }
  53   static inline void init() { }
  54   static bool check_launcher_nmt_support(const char* value) { return true; }
  55   static bool verify_nmt_option() { return true; }


  69   static inline void record_virtual_memory_reserve_and_commit(void* addr, size_t size,
  70     const NativeCallStack& stack, MEMFLAGS flag = mtNone) { }
  71   static inline void record_virtual_memory_commit(void* addr, size_t size, const NativeCallStack& stack) { }
  72   static inline void record_virtual_memory_type(void* addr, MEMFLAGS flag) { }
  73   static inline void record_thread_stack(void* addr, size_t size) { }
  74   static inline void release_thread_stack(void* addr, size_t size) { }
  75 
  76   static void final_report(outputStream*) { }
  77   static void error_report(outputStream*) { }
  78 };
  79 
  80 #else
  81 
  82 #include "runtime/threadCritical.hpp"
  83 #include "services/mallocTracker.hpp"
  84 #include "services/virtualMemoryTracker.hpp"
  85 
  86 extern volatile bool NMT_stack_walkable;
  87 
  88 #define CURRENT_PC ((MemTracker::tracking_level() == NMT_detail && NMT_stack_walkable) ? \
  89                     NativeCallStack(0, true) : NativeCallStack::EMPTY_STACK)
  90 #define CALLER_PC  ((MemTracker::tracking_level() == NMT_detail && NMT_stack_walkable) ?  \
  91                     NativeCallStack(1, true) : NativeCallStack::EMPTY_STACK)
  92 
  93 class MemBaseline;
  94 class Mutex;
  95 
  96 // Tracker is used for guarding 'release' semantics of virtual memory operation, to avoid
  97 // the other thread obtains and records the same region that is just 'released' by current
  98 // thread but before it can record the operation.
  99 class Tracker : public StackObj {
 100  public:
 101   enum TrackerType {
 102      uncommit,
 103      release
 104   };
 105 
 106  public:
 107   Tracker(enum TrackerType type) : _type(type) { }
 108   void record(address addr, size_t size);
 109  private:
 110   enum TrackerType  _type;
 111   // Virtual memory tracking data structures are protected by ThreadCritical lock.




  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 #ifndef SHARE_VM_SERVICES_MEM_TRACKER_HPP
  26 #define SHARE_VM_SERVICES_MEM_TRACKER_HPP
  27 
  28 #include "services/nmtCommon.hpp"
  29 #include "utilities/nativeCallStack.hpp"
  30 
  31 
  32 #if !INCLUDE_NMT
  33 
  34 #define CURRENT_PC   NativeCallStack::empty_stack()
  35 #define CALLER_PC    NativeCallStack::empty_stack()
  36 
  37 class Tracker : public StackObj {
  38  public:
  39   enum TrackerType {
  40      uncommit,
  41      release
  42   };
  43   Tracker(enum TrackerType type) : _type(type) { }
  44   void record(address addr, size_t size) { }
  45  private:
  46   enum TrackerType  _type;
  47 };
  48 
  49 class MemTracker : AllStatic {
  50  public:
  51   static inline NMT_TrackingLevel tracking_level() { return NMT_off; }
  52   static inline void shutdown() { }
  53   static inline void init() { }
  54   static bool check_launcher_nmt_support(const char* value) { return true; }
  55   static bool verify_nmt_option() { return true; }


  69   static inline void record_virtual_memory_reserve_and_commit(void* addr, size_t size,
  70     const NativeCallStack& stack, MEMFLAGS flag = mtNone) { }
  71   static inline void record_virtual_memory_commit(void* addr, size_t size, const NativeCallStack& stack) { }
  72   static inline void record_virtual_memory_type(void* addr, MEMFLAGS flag) { }
  73   static inline void record_thread_stack(void* addr, size_t size) { }
  74   static inline void release_thread_stack(void* addr, size_t size) { }
  75 
  76   static void final_report(outputStream*) { }
  77   static void error_report(outputStream*) { }
  78 };
  79 
  80 #else
  81 
  82 #include "runtime/threadCritical.hpp"
  83 #include "services/mallocTracker.hpp"
  84 #include "services/virtualMemoryTracker.hpp"
  85 
  86 extern volatile bool NMT_stack_walkable;
  87 
  88 #define CURRENT_PC ((MemTracker::tracking_level() == NMT_detail && NMT_stack_walkable) ? \
  89                     NativeCallStack(0, true) : NativeCallStack::empty_stack())
  90 #define CALLER_PC  ((MemTracker::tracking_level() == NMT_detail && NMT_stack_walkable) ?  \
  91                     NativeCallStack(1, true) : NativeCallStack::empty_stack())
  92 
  93 class MemBaseline;
  94 class Mutex;
  95 
  96 // Tracker is used for guarding 'release' semantics of virtual memory operation, to avoid
  97 // the other thread obtains and records the same region that is just 'released' by current
  98 // thread but before it can record the operation.
  99 class Tracker : public StackObj {
 100  public:
 101   enum TrackerType {
 102      uncommit,
 103      release
 104   };
 105 
 106  public:
 107   Tracker(enum TrackerType type) : _type(type) { }
 108   void record(address addr, size_t size);
 109  private:
 110   enum TrackerType  _type;
 111   // Virtual memory tracking data structures are protected by ThreadCritical lock.


< prev index next >