#15190 MIPS port of 8243823: JFR Backport - vm_version_ext_mips.(h|c)pp support mips-jdk8u262-b10

Sat, 24 Oct 2020 14:55:37 +0800

author
aoqi
date
Sat, 24 Oct 2020 14:55:37 +0800
changeset 9933
0672fc1cf811
parent 9932
86ea9a02a717
child 9934
2251ba078bec

#15190 MIPS port of 8243823: JFR Backport - vm_version_ext_mips.(h|c)pp support

src/cpu/mips/vm/vm_version_ext_mips.cpp file | annotate | diff | comparison | revisions
src/cpu/mips/vm/vm_version_ext_mips.hpp file | annotate | diff | comparison | revisions
src/os/linux/vm/os_perf_linux.cpp file | annotate | diff | comparison | revisions
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/cpu/mips/vm/vm_version_ext_mips.cpp	Sat Oct 24 14:55:37 2020 +0800
     1.3 @@ -0,0 +1,92 @@
     1.4 +/*
     1.5 + * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 2018, 2020, Loongson Technology. All rights reserved.
     1.7 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8 + *
     1.9 + * This code is free software; you can redistribute it and/or modify it
    1.10 + * under the terms of the GNU General Public License version 2 only, as
    1.11 + * published by the Free Software Foundation.
    1.12 + *
    1.13 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.14 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.15 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.16 + * version 2 for more details (a copy is included in the LICENSE file that
    1.17 + * accompanied this code).
    1.18 + *
    1.19 + * You should have received a copy of the GNU General Public License version
    1.20 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.21 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.22 + *
    1.23 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.24 + * or visit www.oracle.com if you need additional information or have any
    1.25 + * questions.
    1.26 + *
    1.27 + */
    1.28 +
    1.29 +#include "memory/allocation.inline.hpp"
    1.30 +#include "vm_version_ext_mips.hpp"
    1.31 +
    1.32 +// VM_Version_Ext statics
    1.33 +int VM_Version_Ext::_no_of_threads = 0;
    1.34 +int VM_Version_Ext::_no_of_cores = 0;
    1.35 +int VM_Version_Ext::_no_of_sockets = 0;
    1.36 +bool VM_Version_Ext::_initialized = false;
    1.37 +char VM_Version_Ext::_cpu_name[CPU_TYPE_DESC_BUF_SIZE] = {0};
    1.38 +char VM_Version_Ext::_cpu_desc[CPU_DETAILED_DESC_BUF_SIZE] = {0};
    1.39 +
    1.40 +void VM_Version_Ext::initialize_cpu_information(void) {
    1.41 +  // do nothing if cpu info has been initialized
    1.42 +  if (_initialized) {
    1.43 +    return;
    1.44 +  }
    1.45 +
    1.46 +  int core_id = -1;
    1.47 +  int chip_id = -1;
    1.48 +  int len = 0;
    1.49 +  char* src_string = NULL;
    1.50 +
    1.51 +  _no_of_cores  = os::processor_count();
    1.52 +  _no_of_threads = _no_of_cores;
    1.53 +  _no_of_sockets = _no_of_cores;
    1.54 +  if (is_loongson())
    1.55 +    snprintf(_cpu_name, CPU_TYPE_DESC_BUF_SIZE - 1, "Loongson");
    1.56 +  else
    1.57 +    snprintf(_cpu_name, CPU_TYPE_DESC_BUF_SIZE - 1, "MIPS");
    1.58 +  snprintf(_cpu_desc, CPU_DETAILED_DESC_BUF_SIZE, "%s", cpu_features());
    1.59 +  _initialized = true;
    1.60 +}
    1.61 +
    1.62 +int VM_Version_Ext::number_of_threads(void) {
    1.63 +  initialize_cpu_information();
    1.64 +  return _no_of_threads;
    1.65 +}
    1.66 +
    1.67 +int VM_Version_Ext::number_of_cores(void) {
    1.68 +  initialize_cpu_information();
    1.69 +  return _no_of_cores;
    1.70 +}
    1.71 +
    1.72 +int VM_Version_Ext::number_of_sockets(void) {
    1.73 +  initialize_cpu_information();
    1.74 +  return _no_of_sockets;
    1.75 +}
    1.76 +
    1.77 +const char* VM_Version_Ext::cpu_name(void) {
    1.78 +  initialize_cpu_information();
    1.79 +  char* tmp = NEW_C_HEAP_ARRAY_RETURN_NULL(char, CPU_TYPE_DESC_BUF_SIZE, mtTracing);
    1.80 +  if (NULL == tmp) {
    1.81 +    return NULL;
    1.82 +  }
    1.83 +  strncpy(tmp, _cpu_name, CPU_TYPE_DESC_BUF_SIZE);
    1.84 +  return tmp;
    1.85 +}
    1.86 +
    1.87 +const char* VM_Version_Ext::cpu_description(void) {
    1.88 +  initialize_cpu_information();
    1.89 +  char* tmp = NEW_C_HEAP_ARRAY_RETURN_NULL(char, CPU_DETAILED_DESC_BUF_SIZE, mtTracing);
    1.90 +  if (NULL == tmp) {
    1.91 +    return NULL;
    1.92 +  }
    1.93 +  strncpy(tmp, _cpu_desc, CPU_DETAILED_DESC_BUF_SIZE);
    1.94 +  return tmp;
    1.95 +}
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/src/cpu/mips/vm/vm_version_ext_mips.hpp	Sat Oct 24 14:55:37 2020 +0800
     2.3 @@ -0,0 +1,54 @@
     2.4 +/*
     2.5 + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
     2.6 + * Copyright (c) 2018, 2020, Loongson Technology. All rights reserved.
     2.7 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2.8 + *
     2.9 + * This code is free software; you can redistribute it and/or modify it
    2.10 + * under the terms of the GNU General Public License version 2 only, as
    2.11 + * published by the Free Software Foundation.
    2.12 + *
    2.13 + * This code is distributed in the hope that it will be useful, but WITHOUT
    2.14 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    2.15 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    2.16 + * version 2 for more details (a copy is included in the LICENSE file that
    2.17 + * accompanied this code).
    2.18 + *
    2.19 + * You should have received a copy of the GNU General Public License version
    2.20 + * 2 along with this work; if not, write to the Free Software Foundation,
    2.21 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    2.22 + *
    2.23 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    2.24 + * or visit www.oracle.com if you need additional information or have any
    2.25 + * questions.
    2.26 + *
    2.27 + */
    2.28 +
    2.29 +#ifndef CPU_MIPS_VM_VM_VERSION_EXT_MIPS_HPP
    2.30 +#define CPU_MIPS_VM_VM_VERSION_EXT_MIPS_HPP
    2.31 +
    2.32 +#include "runtime/vm_version.hpp"
    2.33 +#include "utilities/macros.hpp"
    2.34 +
    2.35 +class VM_Version_Ext : public VM_Version {
    2.36 + private:
    2.37 +  static const size_t      CPU_TYPE_DESC_BUF_SIZE = 256;
    2.38 +  static const size_t      CPU_DETAILED_DESC_BUF_SIZE = 4096;
    2.39 +
    2.40 +  static int               _no_of_threads;
    2.41 +  static int               _no_of_cores;
    2.42 +  static int               _no_of_sockets;
    2.43 +  static bool              _initialized;
    2.44 +  static char              _cpu_name[CPU_TYPE_DESC_BUF_SIZE];
    2.45 +  static char              _cpu_desc[CPU_DETAILED_DESC_BUF_SIZE];
    2.46 +
    2.47 + public:
    2.48 +  static int number_of_threads(void);
    2.49 +  static int number_of_cores(void);
    2.50 +  static int number_of_sockets(void);
    2.51 +
    2.52 +  static const char* cpu_name(void);
    2.53 +  static const char* cpu_description(void);
    2.54 +  static void initialize_cpu_information(void);
    2.55 +};
    2.56 +
    2.57 +#endif // CPU_MIPS_VM_VM_VERSION_EXT_MIPS_HPP
     3.1 --- a/src/os/linux/vm/os_perf_linux.cpp	Fri Oct 23 18:04:23 2020 +0800
     3.2 +++ b/src/os/linux/vm/os_perf_linux.cpp	Sat Oct 24 14:55:37 2020 +0800
     3.3 @@ -47,6 +47,9 @@
     3.4  #ifdef TARGET_ARCH_ppc
     3.5  # include "vm_version_ext_ppc.hpp"
     3.6  #endif
     3.7 +#ifdef TARGET_ARCH_mips
     3.8 +# include "vm_version_ext_mips.hpp"
     3.9 +#endif
    3.10  
    3.11  #include <stdio.h>
    3.12  #include <stdarg.h>

mercurial