Fri, 06 Dec 2019 12:42:29 +0100
8235243: handle VS2017 15.9 and VS2019 in abstract_vm_version
8235325: build failure on Linux after 8235243
Reviewed-by: dholmes, mdoerr
apetushkov@9858 | 1 | /* |
apetushkov@9858 | 2 | * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. |
apetushkov@9858 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
apetushkov@9858 | 4 | * |
apetushkov@9858 | 5 | * This code is free software; you can redistribute it and/or modify it |
apetushkov@9858 | 6 | * under the terms of the GNU General Public License version 2 only, as |
apetushkov@9858 | 7 | * published by the Free Software Foundation. |
apetushkov@9858 | 8 | * |
apetushkov@9858 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
apetushkov@9858 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
apetushkov@9858 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
apetushkov@9858 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
apetushkov@9858 | 13 | * accompanied this code). |
apetushkov@9858 | 14 | * |
apetushkov@9858 | 15 | * You should have received a copy of the GNU General Public License version |
apetushkov@9858 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
apetushkov@9858 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
apetushkov@9858 | 18 | * |
apetushkov@9858 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
apetushkov@9858 | 20 | * or visit www.oracle.com if you need additional information or have any |
apetushkov@9858 | 21 | * questions. |
apetushkov@9858 | 22 | * |
apetushkov@9858 | 23 | */ |
apetushkov@9858 | 24 | |
apetushkov@9858 | 25 | #ifndef SHARE_VM_RUNTIME_OS_PERF_HPP |
apetushkov@9858 | 26 | #define SHARE_VM_RUNTIME_OS_PERF_HPP |
apetushkov@9858 | 27 | |
apetushkov@9858 | 28 | #include "utilities/macros.hpp" |
apetushkov@9858 | 29 | #include "memory/allocation.inline.hpp" |
apetushkov@9858 | 30 | #include "utilities/globalDefinitions.hpp" |
apetushkov@9858 | 31 | |
apetushkov@9858 | 32 | #define FUNCTIONALITY_NOT_IMPLEMENTED -8 |
apetushkov@9858 | 33 | |
apetushkov@9858 | 34 | // XXX |
apetushkov@9858 | 35 | //class EnvironmentVariable : public CHeapObj<mtInternal> { |
apetushkov@9858 | 36 | // public: |
apetushkov@9858 | 37 | // char* _key; |
apetushkov@9858 | 38 | // char* _value; |
apetushkov@9858 | 39 | // |
apetushkov@9858 | 40 | // EnvironmentVariable() { |
apetushkov@9858 | 41 | // _key = NULL; |
apetushkov@9858 | 42 | // _value = NULL; |
apetushkov@9858 | 43 | // } |
apetushkov@9858 | 44 | // |
apetushkov@9858 | 45 | // ~EnvironmentVariable() { |
apetushkov@9858 | 46 | // if (_key != NULL) { |
apetushkov@9858 | 47 | // FREE_C_HEAP_ARRAY(char, _key); |
apetushkov@9858 | 48 | // } |
apetushkov@9858 | 49 | // if (_value != NULL) { |
apetushkov@9858 | 50 | // FREE_C_HEAP_ARRAY(char, _value); |
apetushkov@9858 | 51 | // } |
apetushkov@9858 | 52 | // } |
apetushkov@9858 | 53 | // |
apetushkov@9858 | 54 | // EnvironmentVariable(char* key, char* value) { |
apetushkov@9858 | 55 | // _key = key; |
apetushkov@9858 | 56 | // _value = value; |
apetushkov@9858 | 57 | // } |
apetushkov@9858 | 58 | // |
apetushkov@9858 | 59 | //}; |
apetushkov@9858 | 60 | |
apetushkov@9858 | 61 | |
apetushkov@9858 | 62 | class CPUInformation : public CHeapObj<mtInternal> { |
apetushkov@9858 | 63 | private: |
apetushkov@9858 | 64 | int _no_of_sockets; |
apetushkov@9858 | 65 | int _no_of_cores; |
apetushkov@9858 | 66 | int _no_of_hw_threads; |
apetushkov@9858 | 67 | const char* _description; |
apetushkov@9858 | 68 | const char* _name; |
apetushkov@9858 | 69 | |
apetushkov@9858 | 70 | public: |
apetushkov@9858 | 71 | CPUInformation() { |
apetushkov@9858 | 72 | _no_of_sockets = 0; |
apetushkov@9858 | 73 | _no_of_cores = 0; |
apetushkov@9858 | 74 | _no_of_hw_threads = 0; |
apetushkov@9858 | 75 | _description = NULL; |
apetushkov@9858 | 76 | _name = NULL; |
apetushkov@9858 | 77 | } |
apetushkov@9858 | 78 | |
apetushkov@9858 | 79 | int number_of_sockets(void) const { |
apetushkov@9858 | 80 | return _no_of_sockets; |
apetushkov@9858 | 81 | } |
apetushkov@9858 | 82 | |
apetushkov@9858 | 83 | void set_number_of_sockets(int no_of_sockets) { |
apetushkov@9858 | 84 | _no_of_sockets = no_of_sockets; |
apetushkov@9858 | 85 | } |
apetushkov@9858 | 86 | |
apetushkov@9858 | 87 | int number_of_cores(void) const { |
apetushkov@9858 | 88 | return _no_of_cores; |
apetushkov@9858 | 89 | } |
apetushkov@9858 | 90 | |
apetushkov@9858 | 91 | void set_number_of_cores(int no_of_cores) { |
apetushkov@9858 | 92 | _no_of_cores = no_of_cores; |
apetushkov@9858 | 93 | } |
apetushkov@9858 | 94 | |
apetushkov@9858 | 95 | int number_of_hardware_threads(void) const { |
apetushkov@9858 | 96 | return _no_of_hw_threads; |
apetushkov@9858 | 97 | } |
apetushkov@9858 | 98 | |
apetushkov@9858 | 99 | void set_number_of_hardware_threads(int no_of_hw_threads) { |
apetushkov@9858 | 100 | _no_of_hw_threads = no_of_hw_threads; |
apetushkov@9858 | 101 | } |
apetushkov@9858 | 102 | |
apetushkov@9858 | 103 | const char* cpu_name(void) const { |
apetushkov@9858 | 104 | return _name; |
apetushkov@9858 | 105 | } |
apetushkov@9858 | 106 | |
apetushkov@9858 | 107 | void set_cpu_name(const char* cpu_name) { |
apetushkov@9858 | 108 | _name = cpu_name; |
apetushkov@9858 | 109 | } |
apetushkov@9858 | 110 | |
apetushkov@9858 | 111 | const char* cpu_description(void) const { |
apetushkov@9858 | 112 | return _description; |
apetushkov@9858 | 113 | } |
apetushkov@9858 | 114 | |
apetushkov@9858 | 115 | void set_cpu_description(const char* cpu_description) { |
apetushkov@9858 | 116 | _description = cpu_description; |
apetushkov@9858 | 117 | } |
apetushkov@9858 | 118 | }; |
apetushkov@9858 | 119 | |
apetushkov@9858 | 120 | class SystemProcess : public CHeapObj<mtInternal> { |
apetushkov@9858 | 121 | private: |
apetushkov@9858 | 122 | int _pid; |
apetushkov@9858 | 123 | char* _name; |
apetushkov@9858 | 124 | char* _path; |
apetushkov@9858 | 125 | char* _command_line; |
apetushkov@9858 | 126 | SystemProcess* _next; |
apetushkov@9858 | 127 | |
apetushkov@9858 | 128 | public: |
apetushkov@9858 | 129 | SystemProcess() { |
apetushkov@9858 | 130 | _pid = 0; |
apetushkov@9858 | 131 | _name = NULL; |
apetushkov@9858 | 132 | _path = NULL; |
apetushkov@9858 | 133 | _command_line = NULL; |
apetushkov@9858 | 134 | _next = NULL; |
apetushkov@9858 | 135 | } |
apetushkov@9858 | 136 | |
apetushkov@9858 | 137 | SystemProcess(int pid, char* name, char* path, char* command_line, SystemProcess* next) { |
apetushkov@9858 | 138 | _pid = pid; |
apetushkov@9858 | 139 | _name = name; |
apetushkov@9858 | 140 | _path = path; |
apetushkov@9858 | 141 | _command_line = command_line; |
apetushkov@9858 | 142 | _next = next; |
apetushkov@9858 | 143 | } |
apetushkov@9858 | 144 | |
apetushkov@9858 | 145 | void set_next(SystemProcess* sys_process) { |
apetushkov@9858 | 146 | _next = sys_process; |
apetushkov@9858 | 147 | } |
apetushkov@9858 | 148 | |
apetushkov@9858 | 149 | SystemProcess* next(void) const { |
apetushkov@9858 | 150 | return _next; |
apetushkov@9858 | 151 | } |
apetushkov@9858 | 152 | |
apetushkov@9858 | 153 | int pid(void) const { |
apetushkov@9858 | 154 | return _pid; |
apetushkov@9858 | 155 | } |
apetushkov@9858 | 156 | |
apetushkov@9858 | 157 | void set_pid(int pid) { |
apetushkov@9858 | 158 | _pid = pid; |
apetushkov@9858 | 159 | } |
apetushkov@9858 | 160 | |
apetushkov@9858 | 161 | const char* name(void) const { |
apetushkov@9858 | 162 | return _name; |
apetushkov@9858 | 163 | } |
apetushkov@9858 | 164 | |
apetushkov@9858 | 165 | void set_name(char* name) { |
apetushkov@9858 | 166 | _name = name; |
apetushkov@9858 | 167 | } |
apetushkov@9858 | 168 | |
apetushkov@9858 | 169 | const char* path(void) const { |
apetushkov@9858 | 170 | return _path; |
apetushkov@9858 | 171 | } |
apetushkov@9858 | 172 | |
apetushkov@9858 | 173 | void set_path(char* path) { |
apetushkov@9858 | 174 | _path = path; |
apetushkov@9858 | 175 | } |
apetushkov@9858 | 176 | |
apetushkov@9858 | 177 | const char* command_line(void) const { |
apetushkov@9858 | 178 | return _command_line; |
apetushkov@9858 | 179 | } |
apetushkov@9858 | 180 | |
apetushkov@9858 | 181 | void set_command_line(char* command_line) { |
apetushkov@9858 | 182 | _command_line = command_line; |
apetushkov@9858 | 183 | } |
apetushkov@9858 | 184 | |
apetushkov@9858 | 185 | virtual ~SystemProcess(void) { |
apetushkov@9858 | 186 | if (_name != NULL) { |
apetushkov@9858 | 187 | FREE_C_HEAP_ARRAY(char, _name, mtInternal); |
apetushkov@9858 | 188 | } |
apetushkov@9858 | 189 | if (_path != NULL) { |
apetushkov@9858 | 190 | FREE_C_HEAP_ARRAY(char, _path, mtInternal); |
apetushkov@9858 | 191 | } |
apetushkov@9858 | 192 | if (_command_line != NULL) { |
apetushkov@9858 | 193 | FREE_C_HEAP_ARRAY(char, _command_line, mtInternal); |
apetushkov@9858 | 194 | } |
apetushkov@9858 | 195 | } |
apetushkov@9858 | 196 | }; |
apetushkov@9858 | 197 | |
apetushkov@9858 | 198 | class NetworkInterface : public ResourceObj { |
apetushkov@9858 | 199 | private: |
apetushkov@9858 | 200 | char* _name; |
apetushkov@9858 | 201 | uint64_t _bytes_in; |
apetushkov@9858 | 202 | uint64_t _bytes_out; |
apetushkov@9858 | 203 | NetworkInterface* _next; |
apetushkov@9858 | 204 | |
apetushkov@9858 | 205 | NetworkInterface(); // no impl |
apetushkov@9858 | 206 | NetworkInterface(const NetworkInterface& rhs); // no impl |
apetushkov@9858 | 207 | NetworkInterface& operator=(const NetworkInterface& rhs); // no impl |
apetushkov@9858 | 208 | public: |
apetushkov@9858 | 209 | NetworkInterface(const char* name, uint64_t bytes_in, uint64_t bytes_out, NetworkInterface* next) : |
apetushkov@9858 | 210 | _name(NULL), |
apetushkov@9858 | 211 | _bytes_in(bytes_in), |
apetushkov@9858 | 212 | _bytes_out(bytes_out), |
apetushkov@9858 | 213 | _next(next) { |
apetushkov@9858 | 214 | assert(name != NULL, "invariant"); |
apetushkov@9858 | 215 | const size_t length = strlen(name); |
apetushkov@9858 | 216 | assert(allocated_on_res_area(), "invariant"); |
apetushkov@9858 | 217 | _name = NEW_RESOURCE_ARRAY(char, length + 1); |
apetushkov@9858 | 218 | strncpy(_name, name, length + 1); |
apetushkov@9858 | 219 | assert(strncmp(_name, name, length) == 0, "invariant"); |
apetushkov@9858 | 220 | } |
apetushkov@9858 | 221 | |
apetushkov@9858 | 222 | NetworkInterface* next() const { |
apetushkov@9858 | 223 | return _next; |
apetushkov@9858 | 224 | } |
apetushkov@9858 | 225 | |
apetushkov@9858 | 226 | const char* get_name() const { |
apetushkov@9858 | 227 | return _name; |
apetushkov@9858 | 228 | } |
apetushkov@9858 | 229 | |
apetushkov@9858 | 230 | uint64_t get_bytes_out() const { |
apetushkov@9858 | 231 | return _bytes_out; |
apetushkov@9858 | 232 | } |
apetushkov@9858 | 233 | |
apetushkov@9858 | 234 | uint64_t get_bytes_in() const { |
apetushkov@9858 | 235 | return _bytes_in; |
apetushkov@9858 | 236 | } |
apetushkov@9858 | 237 | }; |
apetushkov@9858 | 238 | |
apetushkov@9858 | 239 | class CPUInformationInterface : public CHeapObj<mtInternal> { |
apetushkov@9858 | 240 | private: |
apetushkov@9858 | 241 | CPUInformation* _cpu_info; |
apetushkov@9858 | 242 | public: |
apetushkov@9858 | 243 | CPUInformationInterface(); |
apetushkov@9858 | 244 | bool initialize(); |
apetushkov@9858 | 245 | ~CPUInformationInterface(); |
apetushkov@9858 | 246 | int cpu_information(CPUInformation& cpu_info); |
apetushkov@9858 | 247 | }; |
apetushkov@9858 | 248 | |
apetushkov@9858 | 249 | class CPUPerformanceInterface : public CHeapObj<mtInternal> { |
apetushkov@9858 | 250 | private: |
apetushkov@9858 | 251 | class CPUPerformance; |
apetushkov@9858 | 252 | CPUPerformance* _impl; |
apetushkov@9858 | 253 | public: |
apetushkov@9858 | 254 | CPUPerformanceInterface(); |
apetushkov@9858 | 255 | ~CPUPerformanceInterface(); |
apetushkov@9858 | 256 | bool initialize(); |
apetushkov@9858 | 257 | |
apetushkov@9858 | 258 | int cpu_load(int which_logical_cpu, double* const cpu_load) const; |
apetushkov@9858 | 259 | int context_switch_rate(double* const rate) const; |
apetushkov@9858 | 260 | int cpu_load_total_process(double* const cpu_load) const; |
apetushkov@9858 | 261 | int cpu_loads_process(double* const pjvmUserLoad, |
apetushkov@9858 | 262 | double* const pjvmKernelLoad, |
apetushkov@9858 | 263 | double* const psystemTotalLoad) const; |
apetushkov@9858 | 264 | }; |
apetushkov@9858 | 265 | |
apetushkov@9858 | 266 | class SystemProcessInterface : public CHeapObj<mtInternal> { |
apetushkov@9858 | 267 | private: |
apetushkov@9858 | 268 | class SystemProcesses; |
apetushkov@9858 | 269 | SystemProcesses* _impl; |
apetushkov@9858 | 270 | public: |
apetushkov@9858 | 271 | SystemProcessInterface(); |
apetushkov@9858 | 272 | ~SystemProcessInterface(); |
apetushkov@9858 | 273 | bool initialize(); |
apetushkov@9858 | 274 | |
apetushkov@9858 | 275 | // information about system processes |
apetushkov@9858 | 276 | int system_processes(SystemProcess** system_procs, int* const no_of_sys_processes) const; |
apetushkov@9858 | 277 | }; |
apetushkov@9858 | 278 | |
apetushkov@9858 | 279 | class NetworkPerformanceInterface : public CHeapObj<mtInternal> { |
apetushkov@9858 | 280 | private: |
apetushkov@9858 | 281 | class NetworkPerformance; |
apetushkov@9858 | 282 | NetworkPerformance* _impl; |
apetushkov@9858 | 283 | NetworkPerformanceInterface(const NetworkPerformanceInterface& rhs); // no impl |
apetushkov@9858 | 284 | NetworkPerformanceInterface& operator=(const NetworkPerformanceInterface& rhs); // no impl |
apetushkov@9858 | 285 | public: |
apetushkov@9858 | 286 | NetworkPerformanceInterface(); |
apetushkov@9858 | 287 | bool initialize(); |
apetushkov@9858 | 288 | ~NetworkPerformanceInterface(); |
apetushkov@9858 | 289 | int network_utilization(NetworkInterface** network_interfaces) const; |
apetushkov@9858 | 290 | }; |
apetushkov@9858 | 291 | |
apetushkov@9858 | 292 | #endif // SHARE_VM_RUNTIME_OS_PERF_HPP |