< prev index next >

src/share/vm/runtime/perfMemory.cpp

Print this page
rev 9019 : [mq]: format.patch


  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 #include "precompiled.hpp"
  26 #include "memory/allocation.inline.hpp"
  27 #include "runtime/arguments.hpp"
  28 #include "runtime/java.hpp"
  29 #include "runtime/mutex.hpp"
  30 #include "runtime/mutexLocker.hpp"
  31 #include "runtime/orderAccess.inline.hpp"
  32 #include "runtime/os.hpp"
  33 #include "runtime/perfData.hpp"
  34 #include "runtime/perfMemory.hpp"
  35 #include "runtime/safepoint.hpp"
  36 #include "runtime/statSampler.hpp"
  37 #include "utilities/globalDefinitions.hpp"
  38 
  39 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
  40 
  41 // Prefix of performance data file.
  42 const char               PERFDATA_NAME[] = "hsperfdata";
  43 
  44 // Add 1 for the '_' character between PERFDATA_NAME and pid. The '\0' terminating
  45 // character will be included in the sizeof(PERFDATA_NAME) operation.
  46 static const size_t PERFDATA_FILENAME_LEN = sizeof(PERFDATA_NAME) +
  47                                             UINT_CHARS + 1;
  48 
  49 char*                    PerfMemory::_start = NULL;
  50 char*                    PerfMemory::_end = NULL;
  51 char*                    PerfMemory::_top = NULL;
  52 size_t                   PerfMemory::_capacity = 0;
  53 jint                     PerfMemory::_initialized = false;
  54 PerfDataPrologue*        PerfMemory::_prologue = NULL;
  55 
  56 void perfMemory_init() {
  57 
  58   if (!UsePerfData) return;
  59 
  60   PerfMemory::initialize();


  78     PerfDataManager::destroy();
  79   }
  80 
  81   // Remove the persistent external resources, if any. This method
  82   // does not unmap or invalidate any virtual memory allocated during
  83   // initialization.
  84   //
  85   PerfMemory::destroy();
  86 }
  87 
  88 void PerfMemory::initialize() {
  89 
  90   if (_prologue != NULL)
  91     // initialization already performed
  92     return;
  93 
  94   size_t capacity = align_size_up(PerfDataMemorySize,
  95                                   os::vm_allocation_granularity());
  96 
  97   if (PerfTraceMemOps) {
  98     tty->print("PerfDataMemorySize = " SIZE_FORMAT ","
  99                " os::vm_allocation_granularity = " SIZE_FORMAT ","
 100                " adjusted size = " SIZE_FORMAT "\n",
 101                PerfDataMemorySize,
 102                os::vm_allocation_granularity(),
 103                capacity);
 104   }
 105 
 106   // allocate PerfData memory region
 107   create_memory_region(capacity);
 108 
 109   if (_start == NULL) {
 110 
 111     // the PerfMemory region could not be created as desired. Rather
 112     // than terminating the JVM, we revert to creating the instrumentation
 113     // on the C heap. When running in this mode, external monitoring
 114     // clients cannot attach to and monitor this JVM.
 115     //
 116     // the warning is issued only in debug mode in order to avoid
 117     // additional output to the stdout or stderr output streams.
 118     //
 119     if (PrintMiscellaneous && Verbose) {
 120       warning("Could not create PerfData Memory region, reverting to malloc");
 121     }
 122 
 123     _prologue = NEW_C_HEAP_OBJ(PerfDataPrologue, mtInternal);
 124   }
 125   else {
 126 
 127     // the PerfMemory region was created as expected.
 128 
 129     if (PerfTraceMemOps) {
 130       tty->print("PerfMemory created: address = " INTPTR_FORMAT ","
 131                  " size = " SIZE_FORMAT "\n",
 132                  (void*)_start,
 133                  _capacity);
 134     }
 135 
 136     _prologue = (PerfDataPrologue *)_start;
 137     _end = _start + _capacity;
 138     _top = _start + sizeof(PerfDataPrologue);
 139   }
 140 
 141   assert(_prologue != NULL, "prologue pointer must be initialized");
 142 
 143 #ifdef VM_LITTLE_ENDIAN
 144   _prologue->magic = (jint)0xc0c0feca;
 145   _prologue->byte_order = PERFDATA_LITTLE_ENDIAN;
 146 #else
 147   _prologue->magic = (jint)0xcafec0c0;
 148   _prologue->byte_order = PERFDATA_BIG_ENDIAN;
 149 #endif
 150 
 151   _prologue->major_version = PERFDATA_MAJOR_VERSION;
 152   _prologue->minor_version = PERFDATA_MINOR_VERSION;




  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 #include "precompiled.hpp"
  26 #include "memory/allocation.inline.hpp"
  27 #include "runtime/arguments.hpp"
  28 #include "runtime/java.hpp"
  29 #include "runtime/mutex.hpp"
  30 #include "runtime/mutexLocker.hpp"
  31 #include "runtime/orderAccess.inline.hpp"
  32 #include "runtime/os.hpp"
  33 #include "runtime/perfData.hpp"
  34 #include "runtime/perfMemory.hpp"
  35 #include "runtime/safepoint.hpp"
  36 #include "runtime/statSampler.hpp"
  37 #include "utilities/globalDefinitions.hpp"
  38 


  39 // Prefix of performance data file.
  40 const char               PERFDATA_NAME[] = "hsperfdata";
  41 
  42 // Add 1 for the '_' character between PERFDATA_NAME and pid. The '\0' terminating
  43 // character will be included in the sizeof(PERFDATA_NAME) operation.
  44 static const size_t PERFDATA_FILENAME_LEN = sizeof(PERFDATA_NAME) +
  45                                             UINT_CHARS + 1;
  46 
  47 char*                    PerfMemory::_start = NULL;
  48 char*                    PerfMemory::_end = NULL;
  49 char*                    PerfMemory::_top = NULL;
  50 size_t                   PerfMemory::_capacity = 0;
  51 jint                     PerfMemory::_initialized = false;
  52 PerfDataPrologue*        PerfMemory::_prologue = NULL;
  53 
  54 void perfMemory_init() {
  55 
  56   if (!UsePerfData) return;
  57 
  58   PerfMemory::initialize();


  76     PerfDataManager::destroy();
  77   }
  78 
  79   // Remove the persistent external resources, if any. This method
  80   // does not unmap or invalidate any virtual memory allocated during
  81   // initialization.
  82   //
  83   PerfMemory::destroy();
  84 }
  85 
  86 void PerfMemory::initialize() {
  87 
  88   if (_prologue != NULL)
  89     // initialization already performed
  90     return;
  91 
  92   size_t capacity = align_size_up(PerfDataMemorySize,
  93                                   os::vm_allocation_granularity());
  94 
  95   if (PerfTraceMemOps) {
  96     tty->print("PerfDataMemorySize = " INTX_FORMAT ","
  97                " os::vm_allocation_granularity = %d,"
  98                " adjusted size = " SIZE_FORMAT "\n",
  99                PerfDataMemorySize,
 100                os::vm_allocation_granularity(),
 101                capacity);
 102   }
 103 
 104   // allocate PerfData memory region
 105   create_memory_region(capacity);
 106 
 107   if (_start == NULL) {
 108 
 109     // the PerfMemory region could not be created as desired. Rather
 110     // than terminating the JVM, we revert to creating the instrumentation
 111     // on the C heap. When running in this mode, external monitoring
 112     // clients cannot attach to and monitor this JVM.
 113     //
 114     // the warning is issued only in debug mode in order to avoid
 115     // additional output to the stdout or stderr output streams.
 116     //
 117     if (PrintMiscellaneous && Verbose) {
 118       warning("Could not create PerfData Memory region, reverting to malloc");
 119     }
 120 
 121     _prologue = NEW_C_HEAP_OBJ(PerfDataPrologue, mtInternal);
 122   }
 123   else {
 124 
 125     // the PerfMemory region was created as expected.
 126 
 127     if (PerfTraceMemOps) {
 128       tty->print("PerfMemory created: address = " INTPTR_FORMAT ","
 129                  " size = " SIZE_FORMAT "\n",
 130                  p2i(_start),
 131                  _capacity);
 132     }
 133 
 134     _prologue = (PerfDataPrologue *)_start;
 135     _end = _start + _capacity;
 136     _top = _start + sizeof(PerfDataPrologue);
 137   }
 138 
 139   assert(_prologue != NULL, "prologue pointer must be initialized");
 140 
 141 #ifdef VM_LITTLE_ENDIAN
 142   _prologue->magic = (jint)0xc0c0feca;
 143   _prologue->byte_order = PERFDATA_LITTLE_ENDIAN;
 144 #else
 145   _prologue->magic = (jint)0xcafec0c0;
 146   _prologue->byte_order = PERFDATA_BIG_ENDIAN;
 147 #endif
 148 
 149   _prologue->major_version = PERFDATA_MAJOR_VERSION;
 150   _prologue->minor_version = PERFDATA_MINOR_VERSION;


< prev index next >