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