src/hotspot/os/aix/os_perf_aix.cpp
changeset 58282 03fce7b04b42
parent 58083 9046db64ca39
child 58679 9c3209ff7550
equal deleted inserted replaced
58281:49836127542b 58282:03fce7b04b42
   443 }
   443 }
   444 
   444 
   445 bool CPUPerformanceInterface::CPUPerformance::initialize() {
   445 bool CPUPerformanceInterface::CPUPerformance::initialize() {
   446   size_t array_entry_count = _counters.nProcs + 1;
   446   size_t array_entry_count = _counters.nProcs + 1;
   447   _counters.cpus = NEW_C_HEAP_ARRAY(CPUPerfTicks, array_entry_count, mtInternal);
   447   _counters.cpus = NEW_C_HEAP_ARRAY(CPUPerfTicks, array_entry_count, mtInternal);
   448   if (NULL == _counters.cpus) {
       
   449     return false;
       
   450   }
       
   451   memset(_counters.cpus, 0, array_entry_count * sizeof(*_counters.cpus));
   448   memset(_counters.cpus, 0, array_entry_count * sizeof(*_counters.cpus));
   452 
   449 
   453   // For the CPU load total
   450   // For the CPU load total
   454   get_total_ticks(-1, &_counters.cpus[_counters.nProcs]);
   451   get_total_ticks(-1, &_counters.cpus[_counters.nProcs]);
   455 
   452 
   533   _impl = NULL;
   530   _impl = NULL;
   534 }
   531 }
   535 
   532 
   536 bool CPUPerformanceInterface::initialize() {
   533 bool CPUPerformanceInterface::initialize() {
   537   _impl = new CPUPerformanceInterface::CPUPerformance();
   534   _impl = new CPUPerformanceInterface::CPUPerformance();
   538   return NULL == _impl ? false : _impl->initialize();
   535   return _impl->initialize();
   539 }
   536 }
   540 
   537 
   541 CPUPerformanceInterface::~CPUPerformanceInterface() {
   538 CPUPerformanceInterface::~CPUPerformanceInterface() {
   542   if (_impl != NULL) {
   539   if (_impl != NULL) {
   543     delete _impl;
   540     delete _impl;
   686     while (fread(&dummy, 1, 1, fp) == 1) {
   683     while (fread(&dummy, 1, 1, fp) == 1) {
   687       size++;
   684       size++;
   688     }
   685     }
   689     if (size > 0) {
   686     if (size > 0) {
   690       cmdline = NEW_C_HEAP_ARRAY(char, size + 1, mtInternal);
   687       cmdline = NEW_C_HEAP_ARRAY(char, size + 1, mtInternal);
   691       if (cmdline != NULL) {
   688       cmdline[0] = '\0';
   692         cmdline[0] = '\0';
   689       if (fseek(fp, 0, SEEK_SET) == 0) {
   693         if (fseek(fp, 0, SEEK_SET) == 0) {
   690         if (fread(cmdline, 1, size, fp) == size) {
   694           if (fread(cmdline, 1, size, fp) == size) {
   691           // the file has the arguments separated by '\0',
   695             // the file has the arguments separated by '\0',
   692           // so we translate '\0' to ' '
   696             // so we translate '\0' to ' '
   693           for (size_t i = 0; i < size; i++) {
   697             for (size_t i = 0; i < size; i++) {
   694             if (cmdline[i] == '\0') {
   698               if (cmdline[i] == '\0') {
   695               cmdline[i] = ' ';
   699                 cmdline[i] = ' ';
       
   700               }
       
   701             }
   696             }
   702             cmdline[size] = '\0';
       
   703           }
   697           }
       
   698           cmdline[size] = '\0';
   704         }
   699         }
   705       }
   700       }
   706     }
   701     }
   707     fclose(fp);
   702     fclose(fp);
   708   }
   703   }
   788   _iterator = NULL;
   783   _iterator = NULL;
   789 }
   784 }
   790 
   785 
   791 bool SystemProcessInterface::SystemProcesses::initialize() {
   786 bool SystemProcessInterface::SystemProcesses::initialize() {
   792   _iterator = new SystemProcessInterface::SystemProcesses::ProcessIterator();
   787   _iterator = new SystemProcessInterface::SystemProcesses::ProcessIterator();
   793   return NULL == _iterator ? false : _iterator->initialize();
   788   return _iterator->initialize();
   794 }
   789 }
   795 
   790 
   796 SystemProcessInterface::SystemProcesses::~SystemProcesses() {
   791 SystemProcessInterface::SystemProcesses::~SystemProcesses() {
   797   if (_iterator != NULL) {
   792   if (_iterator != NULL) {
   798     delete _iterator;
   793     delete _iterator;
   835   _impl = NULL;
   830   _impl = NULL;
   836 }
   831 }
   837 
   832 
   838 bool SystemProcessInterface::initialize() {
   833 bool SystemProcessInterface::initialize() {
   839   _impl = new SystemProcessInterface::SystemProcesses();
   834   _impl = new SystemProcessInterface::SystemProcesses();
   840   return NULL == _impl ? false : _impl->initialize();
   835   return _impl->initialize();
   841 }
   836 }
   842 
   837 
   843 SystemProcessInterface::~SystemProcessInterface() {
   838 SystemProcessInterface::~SystemProcessInterface() {
   844   if (_impl != NULL) {
   839   if (_impl != NULL) {
   845     delete _impl;
   840     delete _impl;
   850   _cpu_info = NULL;
   845   _cpu_info = NULL;
   851 }
   846 }
   852 
   847 
   853 bool CPUInformationInterface::initialize() {
   848 bool CPUInformationInterface::initialize() {
   854   _cpu_info = new CPUInformation();
   849   _cpu_info = new CPUInformation();
   855   if (NULL == _cpu_info) {
       
   856     return false;
       
   857   }
       
   858   _cpu_info->set_number_of_hardware_threads(VM_Version_Ext::number_of_threads());
   850   _cpu_info->set_number_of_hardware_threads(VM_Version_Ext::number_of_threads());
   859   _cpu_info->set_number_of_cores(VM_Version_Ext::number_of_cores());
   851   _cpu_info->set_number_of_cores(VM_Version_Ext::number_of_cores());
   860   _cpu_info->set_number_of_sockets(VM_Version_Ext::number_of_sockets());
   852   _cpu_info->set_number_of_sockets(VM_Version_Ext::number_of_sockets());
   861   _cpu_info->set_cpu_name(VM_Version_Ext::cpu_name());
   853   _cpu_info->set_cpu_name(VM_Version_Ext::cpu_name());
   862   _cpu_info->set_cpu_description(VM_Version_Ext::cpu_description());
   854   _cpu_info->set_cpu_description(VM_Version_Ext::cpu_description());
   863 
       
   864   return true;
   855   return true;
   865 }
   856 }
   866 
   857 
   867 CPUInformationInterface::~CPUInformationInterface() {
   858 CPUInformationInterface::~CPUInformationInterface() {
   868   if (_cpu_info != NULL) {
   859   if (_cpu_info != NULL) {
   926   }
   917   }
   927 }
   918 }
   928 
   919 
   929 bool NetworkPerformanceInterface::initialize() {
   920 bool NetworkPerformanceInterface::initialize() {
   930   _impl = new NetworkPerformanceInterface::NetworkPerformance();
   921   _impl = new NetworkPerformanceInterface::NetworkPerformance();
   931   return _impl != NULL && _impl->initialize();
   922   return _impl->initialize();
   932 }
   923 }
   933 
   924 
   934 int NetworkPerformanceInterface::network_utilization(NetworkInterface** network_interfaces) const {
   925 int NetworkPerformanceInterface::network_utilization(NetworkInterface** network_interfaces) const {
   935   return _impl->network_utilization(network_interfaces);
   926   return _impl->network_utilization(network_interfaces);
   936 }
   927 }