8206408: Add missing CPU/system info to vm_version_ext on PPC64
authorghaug
Mon, 09 Jul 2018 12:51:58 +0200
changeset 51011 c9bf46f4d555
parent 51010 29be48779807
child 51012 cd557cad6e0a
8206408: Add missing CPU/system info to vm_version_ext on PPC64 Reviewed-by: mdoerr, simonis
src/hotspot/cpu/ppc/vm_version_ext_ppc.cpp
src/hotspot/cpu/ppc/vm_version_ext_ppc.hpp
--- a/src/hotspot/cpu/ppc/vm_version_ext_ppc.cpp	Mon Jul 09 16:36:05 2018 +0300
+++ b/src/hotspot/cpu/ppc/vm_version_ext_ppc.cpp	Mon Jul 09 12:51:58 2018 +0200
@@ -25,19 +25,30 @@
 #include "jvm.h"
 #include "memory/allocation.hpp"
 #include "memory/allocation.inline.hpp"
+#include "runtime/vm_version.hpp"
 #include "vm_version_ext_ppc.hpp"
 
 // VM_Version_Ext statics
 int   VM_Version_Ext::_no_of_threads = 0;
 int   VM_Version_Ext::_no_of_cores = 0;
 int   VM_Version_Ext::_no_of_sockets = 0;
+bool  VM_Version_Ext::_initialized = false;
 char  VM_Version_Ext::_cpu_name[CPU_TYPE_DESC_BUF_SIZE] = {0};
 char  VM_Version_Ext::_cpu_desc[CPU_DETAILED_DESC_BUF_SIZE] = {0};
 
 // get cpu information.
-bool VM_Version_Ext::initialize_cpu_information(void) {
-  // Not yet implemented.
-  return false;
+void VM_Version_Ext::initialize_cpu_information(void) {
+  // do nothing if cpu info has been initialized
+  if (_initialized) {
+    return;
+  }
+
+  _no_of_cores  = os::processor_count();
+  _no_of_threads = _no_of_cores;
+  _no_of_sockets = _no_of_cores;
+  snprintf(_cpu_name, CPU_TYPE_DESC_BUF_SIZE, "PowerPC POWER%lu", PowerArchitecturePPC64);
+  snprintf(_cpu_desc, CPU_DETAILED_DESC_BUF_SIZE, "PPC %s", features_string());
+  _initialized = true;
 }
 
 int VM_Version_Ext::number_of_threads(void) {
@@ -56,9 +67,7 @@
 }
 
 const char* VM_Version_Ext::cpu_name(void) {
-  if (!initialize_cpu_information()) {
-    return NULL;
-  }
+  initialize_cpu_information();
   char* tmp = NEW_C_HEAP_ARRAY_RETURN_NULL(char, CPU_TYPE_DESC_BUF_SIZE, mtTracing);
   if (NULL == tmp) {
     return NULL;
@@ -68,9 +77,7 @@
 }
 
 const char* VM_Version_Ext::cpu_description(void) {
-  if (!initialize_cpu_information()) {
-    return NULL;
-  }
+  initialize_cpu_information();
   char* tmp = NEW_C_HEAP_ARRAY_RETURN_NULL(char, CPU_DETAILED_DESC_BUF_SIZE, mtTracing);
   if (NULL == tmp) {
     return NULL;
--- a/src/hotspot/cpu/ppc/vm_version_ext_ppc.hpp	Mon Jul 09 16:36:05 2018 +0300
+++ b/src/hotspot/cpu/ppc/vm_version_ext_ppc.hpp	Mon Jul 09 12:51:58 2018 +0200
@@ -43,10 +43,11 @@
   static int               _no_of_threads;
   static int               _no_of_cores;
   static int               _no_of_sockets;
+  static bool              _initialized;
   static char              _cpu_name[CPU_TYPE_DESC_BUF_SIZE];
   static char              _cpu_desc[CPU_DETAILED_DESC_BUF_SIZE];
 
-  static bool initialize_cpu_information(void);
+  static void initialize_cpu_information(void);
 
  public: