< prev index next >

src/hotspot/share/services/memTracker.hpp

Print this page
rev 59383 : [mq]: final
   1 /*
   2  * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  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  *


  68                        MEMFLAGS flag = mtNone) { }
  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/mutexLocker.hpp"
  83 #include "runtime/threadCritical.hpp"
  84 #include "services/mallocTracker.hpp"
  85 #include "services/threadStackTracker.hpp"
  86 #include "services/virtualMemoryTracker.hpp"
  87 
  88 extern volatile bool NMT_stack_walkable;
  89 
  90 #define CURRENT_PC ((MemTracker::tracking_level() == NMT_detail && NMT_stack_walkable) ? \
  91                     NativeCallStack(0, true) : NativeCallStack::empty_stack())
  92 #define CALLER_PC  ((MemTracker::tracking_level() == NMT_detail && NMT_stack_walkable) ?  \
  93                     NativeCallStack(1, true) : NativeCallStack::empty_stack())
  94 
  95 class MemBaseline;
  96 
  97 // Tracker is used for guarding 'release' semantics of virtual memory operation, to avoid
  98 // the other thread obtains and records the same region that is just 'released' by current
  99 // thread but before it can record the operation.
 100 class Tracker : public StackObj {
 101  public:
 102   enum TrackerType {
 103      uncommit,
 104      release
 105   };
 106 
 107  public:
 108   Tracker(enum TrackerType type) : _type(type) { }
 109   void record(address addr, size_t size);
 110  private:
 111   enum TrackerType  _type;
 112   // Virtual memory tracking data structures are protected by ThreadCritical lock.


   1 /*
   2  * Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  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  *


  68                        MEMFLAGS flag = mtNone) { }
  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/mutexLocker.hpp"
  83 #include "runtime/threadCritical.hpp"
  84 #include "services/mallocTracker.hpp"
  85 #include "services/threadStackTracker.hpp"
  86 #include "services/virtualMemoryTracker.hpp"
  87 
  88 #define CURRENT_PC ((MemTracker::tracking_level() == NMT_detail) ? \


  89                     NativeCallStack(0, true) : NativeCallStack::empty_stack())
  90 #define CALLER_PC  ((MemTracker::tracking_level() == NMT_detail) ?  \
  91                     NativeCallStack(1, true) : NativeCallStack::empty_stack())
  92 
  93 class MemBaseline;
  94 
  95 // Tracker is used for guarding 'release' semantics of virtual memory operation, to avoid
  96 // the other thread obtains and records the same region that is just 'released' by current
  97 // thread but before it can record the operation.
  98 class Tracker : public StackObj {
  99  public:
 100   enum TrackerType {
 101      uncommit,
 102      release
 103   };
 104 
 105  public:
 106   Tracker(enum TrackerType type) : _type(type) { }
 107   void record(address addr, size_t size);
 108  private:
 109   enum TrackerType  _type;
 110   // Virtual memory tracking data structures are protected by ThreadCritical lock.


< prev index next >