src/hotspot/cpu/zero/vm_version_ext_zero.cpp
author stefank
Thu, 09 May 2019 14:28:30 +0200
changeset 54786 ebf733a324d4
parent 50174 78d9ffb8146f
permissions -rw-r--r--
8223624: Cleanup includes of universe.hpp Reviewed-by: coleenp, lkorinth
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
50174
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
     1
/*
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
     2
 * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
     4
 *
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
     7
 * published by the Free Software Foundation.
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
     8
 *
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    13
 * accompanied this code).
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    14
 *
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    18
 *
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    21
 * questions.
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    22
 *
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    23
 */
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    24
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    25
#include "memory/allocation.hpp"
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    26
#include "memory/allocation.inline.hpp"
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    27
#include "runtime/os.inline.hpp"
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    28
#include "vm_version_ext_zero.hpp"
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    29
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    30
// VM_Version_Ext statics
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    31
int VM_Version_Ext::_no_of_threads = 0;
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    32
int VM_Version_Ext::_no_of_cores = 0;
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    33
int VM_Version_Ext::_no_of_sockets = 0;
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    34
bool VM_Version_Ext::_initialized = false;
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    35
char VM_Version_Ext::_cpu_name[CPU_TYPE_DESC_BUF_SIZE] = {0};
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    36
char VM_Version_Ext::_cpu_desc[CPU_DETAILED_DESC_BUF_SIZE] = {0};
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    37
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    38
void VM_Version_Ext::initialize_cpu_information(void) {
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    39
  // do nothing if cpu info has been initialized
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    40
  if (_initialized) {
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    41
    return;
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    42
  }
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    43
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    44
  int core_id = -1;
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    45
  int chip_id = -1;
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    46
  int len = 0;
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    47
  char* src_string = NULL;
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    48
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    49
  _no_of_cores  = os::processor_count();
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    50
  _no_of_threads = _no_of_cores;
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    51
  _no_of_sockets = _no_of_cores;
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    52
  snprintf(_cpu_name, CPU_TYPE_DESC_BUF_SIZE - 1, "Zero VM");
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    53
  snprintf(_cpu_desc, CPU_DETAILED_DESC_BUF_SIZE, "%s", _features_string);
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    54
  _initialized = true;
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    55
}
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    56
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    57
int VM_Version_Ext::number_of_threads(void) {
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    58
  initialize_cpu_information();
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    59
  return _no_of_threads;
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    60
}
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    61
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    62
int VM_Version_Ext::number_of_cores(void) {
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    63
  initialize_cpu_information();
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    64
  return _no_of_cores;
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    65
}
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    66
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    67
int VM_Version_Ext::number_of_sockets(void) {
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    68
  initialize_cpu_information();
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    69
  return _no_of_sockets;
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    70
}
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    71
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    72
const char* VM_Version_Ext::cpu_name(void) {
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    73
  initialize_cpu_information();
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    74
  char* tmp = NEW_C_HEAP_ARRAY_RETURN_NULL(char, CPU_TYPE_DESC_BUF_SIZE, mtTracing);
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    75
  if (NULL == tmp) {
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    76
    return NULL;
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    77
  }
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    78
  strncpy(tmp, _cpu_name, CPU_TYPE_DESC_BUF_SIZE);
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    79
  return tmp;
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    80
}
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    81
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    82
const char* VM_Version_Ext::cpu_description(void) {
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    83
  initialize_cpu_information();
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    84
  char* tmp = NEW_C_HEAP_ARRAY_RETURN_NULL(char, CPU_DETAILED_DESC_BUF_SIZE, mtTracing);
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    85
  if (NULL == tmp) {
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    86
    return NULL;
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    87
  }
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    88
  strncpy(tmp, _cpu_desc, CPU_DETAILED_DESC_BUF_SIZE);
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    89
  return tmp;
78d9ffb8146f 8203287: Zero fails to build after JDK-8199712 (Flight Recorder)
sgehwolf
parents:
diff changeset
    90
}