< prev index next >

src/hotspot/share/jfr/utilities/jfrAllocation.cpp

Print this page




  24 
  25 #include "precompiled.hpp"
  26 #include "jfr/recorder/jfrRecorder.hpp"
  27 #include "jfr/utilities/jfrAllocation.hpp"
  28 #include "logging/log.hpp"
  29 #include "memory/allocation.inline.hpp"
  30 #include "runtime/atomic.hpp"
  31 #include "runtime/vm_version.hpp"
  32 #include "utilities/debug.hpp"
  33 #include "utilities/macros.hpp"
  34 #include "utilities/nativeCallStack.hpp"
  35 
  36 #ifdef ASSERT
  37 static jlong atomic_add_jlong(jlong value, jlong volatile* const dest) {
  38   assert(VM_Version::supports_cx8(), "unsupported");
  39   jlong compare_value;
  40   jlong exchange_value;
  41   do {
  42     compare_value = *dest;
  43     exchange_value = compare_value + value;
  44   } while (Atomic::cmpxchg(exchange_value, dest, compare_value) != compare_value);
  45   return exchange_value;
  46 }
  47 
  48 // debug statistics
  49 static volatile jlong _allocated_bytes = 0;
  50 static volatile jlong _deallocated_bytes = 0;
  51 static volatile jlong _live_set_bytes = 0;
  52 
  53 static void add(size_t alloc_size) {
  54   if (!JfrRecorder::is_created()) {
  55     const jlong total_allocated = atomic_add_jlong((jlong)alloc_size, &_allocated_bytes);
  56     const jlong current_live_set = atomic_add_jlong((jlong)alloc_size, &_live_set_bytes);
  57     log_trace(jfr, system)("Allocation: [" SIZE_FORMAT "] bytes", alloc_size);
  58     log_trace(jfr, system)("Total alloc [" JLONG_FORMAT "] bytes", total_allocated);
  59     log_trace(jfr, system)("Liveset:    [" JLONG_FORMAT "] bytes", current_live_set);
  60   }
  61 }
  62 
  63 static void subtract(size_t dealloc_size) {
  64   if (!JfrRecorder::is_created()) {




  24 
  25 #include "precompiled.hpp"
  26 #include "jfr/recorder/jfrRecorder.hpp"
  27 #include "jfr/utilities/jfrAllocation.hpp"
  28 #include "logging/log.hpp"
  29 #include "memory/allocation.inline.hpp"
  30 #include "runtime/atomic.hpp"
  31 #include "runtime/vm_version.hpp"
  32 #include "utilities/debug.hpp"
  33 #include "utilities/macros.hpp"
  34 #include "utilities/nativeCallStack.hpp"
  35 
  36 #ifdef ASSERT
  37 static jlong atomic_add_jlong(jlong value, jlong volatile* const dest) {
  38   assert(VM_Version::supports_cx8(), "unsupported");
  39   jlong compare_value;
  40   jlong exchange_value;
  41   do {
  42     compare_value = *dest;
  43     exchange_value = compare_value + value;
  44   } while (Atomic::cmpxchg(dest, compare_value, exchange_value) != compare_value);
  45   return exchange_value;
  46 }
  47 
  48 // debug statistics
  49 static volatile jlong _allocated_bytes = 0;
  50 static volatile jlong _deallocated_bytes = 0;
  51 static volatile jlong _live_set_bytes = 0;
  52 
  53 static void add(size_t alloc_size) {
  54   if (!JfrRecorder::is_created()) {
  55     const jlong total_allocated = atomic_add_jlong((jlong)alloc_size, &_allocated_bytes);
  56     const jlong current_live_set = atomic_add_jlong((jlong)alloc_size, &_live_set_bytes);
  57     log_trace(jfr, system)("Allocation: [" SIZE_FORMAT "] bytes", alloc_size);
  58     log_trace(jfr, system)("Total alloc [" JLONG_FORMAT "] bytes", total_allocated);
  59     log_trace(jfr, system)("Liveset:    [" JLONG_FORMAT "] bytes", current_live_set);
  60   }
  61 }
  62 
  63 static void subtract(size_t dealloc_size) {
  64   if (!JfrRecorder::is_created()) {


< prev index next >