src/hotspot/os_cpu/solaris_sparc/vm_version_solaris_sparc.cpp
author darcy
Tue, 12 Nov 2019 10:45:23 -0800
changeset 59037 3d2575331a41
parent 51815 d23d7389142f
child 59122 5d73255c2d52
permissions -rw-r--r--
8233940: Preview API tests for String methods should use ${jdk.version} as -source arg Reviewed-by: jlaskey, jlahoda
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
37430
fd743dadef12 8151939: VM_Version_init() print buffer is too small
coleenp
parents: 36346
diff changeset
     2
 * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2255
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2255
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2255
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7115
diff changeset
    25
#include "precompiled.hpp"
37430
fd743dadef12 8151939: VM_Version_init() print buffer is too small
coleenp
parents: 36346
diff changeset
    26
#include "logging/log.hpp"
25949
34557722059b 6424123: JVM crashes on failed 'strdup' call
zgu
parents: 24953
diff changeset
    27
#include "memory/allocation.hpp"
34557722059b 6424123: JVM crashes on failed 'strdup' call
zgu
parents: 24953
diff changeset
    28
#include "memory/allocation.inline.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7115
diff changeset
    29
#include "runtime/os.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7115
diff changeset
    30
#include "vm_version_sparc.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
26579
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
    32
#include <sys/auxv.h>
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
    33
#include <sys/systeminfo.h>
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
    34
#include <picl.h>
27426
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
    35
#include <dlfcn.h>
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
    36
#include <link.h>
26579
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
    37
27456
854b988388f3 8062591: SPARC PICL causes significantly longer startup times
iveresov
parents: 27426
diff changeset
    38
extern "C" static int PICL_visit_cpu_helper(picl_nodehdl_t nodeh, void *result);
26579
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
    39
27426
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
    40
// Functions from the library we need (signatures should match those in picl.h)
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
    41
extern "C" {
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
    42
  typedef int (*picl_initialize_func_t)(void);
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
    43
  typedef int (*picl_shutdown_func_t)(void);
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
    44
  typedef int (*picl_get_root_func_t)(picl_nodehdl_t *nodehandle);
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
    45
  typedef int (*picl_walk_tree_by_class_func_t)(picl_nodehdl_t rooth,
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
    46
      const char *classname, void *c_args,
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
    47
      int (*callback_fn)(picl_nodehdl_t hdl, void *args));
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
    48
  typedef int (*picl_get_prop_by_name_func_t)(picl_nodehdl_t nodeh, const char *nm,
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
    49
      picl_prophdl_t *ph);
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
    50
  typedef int (*picl_get_propval_func_t)(picl_prophdl_t proph, void *valbuf, size_t sz);
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
    51
  typedef int (*picl_get_propinfo_func_t)(picl_prophdl_t proph, picl_propinfo_t *pi);
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
    52
}
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
    53
26579
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
    54
class PICL {
27426
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
    55
  // Pointers to functions in the library
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
    56
  picl_initialize_func_t _picl_initialize;
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
    57
  picl_shutdown_func_t _picl_shutdown;
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
    58
  picl_get_root_func_t _picl_get_root;
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
    59
  picl_walk_tree_by_class_func_t _picl_walk_tree_by_class;
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
    60
  picl_get_prop_by_name_func_t _picl_get_prop_by_name;
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
    61
  picl_get_propval_func_t _picl_get_propval;
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
    62
  picl_get_propinfo_func_t _picl_get_propinfo;
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
    63
  // Handle to the library that is returned by dlopen
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
    64
  void *_dl_handle;
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
    65
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
    66
  bool open_library();
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
    67
  void close_library();
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
    68
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
    69
  template<typename FuncType> bool bind(FuncType& func, const char* name);
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
    70
  bool bind_library_functions();
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
    71
26579
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
    72
  // Get a value of the integer property. The value in the tree can be either 32 or 64 bit
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
    73
  // depending on the platform. The result is converted to int.
27426
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
    74
  int get_int_property(picl_nodehdl_t nodeh, const char* name, int* result) {
26579
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
    75
    picl_propinfo_t pinfo;
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
    76
    picl_prophdl_t proph;
27426
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
    77
    if (_picl_get_prop_by_name(nodeh, name, &proph) != PICL_SUCCESS ||
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
    78
        _picl_get_propinfo(proph, &pinfo) != PICL_SUCCESS) {
26579
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
    79
      return PICL_FAILURE;
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
    80
    }
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
    81
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
    82
    if (pinfo.type != PICL_PTYPE_INT && pinfo.type != PICL_PTYPE_UNSIGNED_INT) {
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
    83
      assert(false, "Invalid property type");
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
    84
      return PICL_FAILURE;
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
    85
    }
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
    86
    if (pinfo.size == sizeof(int64_t)) {
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
    87
      int64_t val;
27426
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
    88
      if (_picl_get_propval(proph, &val, sizeof(int64_t)) != PICL_SUCCESS) {
26579
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
    89
        return PICL_FAILURE;
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
    90
      }
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
    91
      *result = static_cast<int>(val);
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
    92
    } else if (pinfo.size == sizeof(int32_t)) {
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
    93
      int32_t val;
27426
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
    94
      if (_picl_get_propval(proph, &val, sizeof(int32_t)) != PICL_SUCCESS) {
26579
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
    95
        return PICL_FAILURE;
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
    96
      }
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
    97
      *result = static_cast<int>(val);
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
    98
    } else {
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
    99
      assert(false, "Unexpected integer property size");
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
   100
      return PICL_FAILURE;
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
   101
    }
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
   102
    return PICL_SUCCESS;
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
   103
  }
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
   104
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
   105
  // Visitor and a state machine that visits integer properties and verifies that the
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
   106
  // values are the same. Stores the unique value observed.
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
   107
  class UniqueValueVisitor {
27426
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
   108
    PICL *_picl;
26579
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
   109
    enum {
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
   110
      INITIAL,        // Start state, no assignments happened
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
   111
      ASSIGNED,       // Assigned a value
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
   112
      INCONSISTENT    // Inconsistent value seen
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
   113
    } _state;
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
   114
    int _value;
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
   115
  public:
27426
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
   116
    UniqueValueVisitor(PICL* picl) : _picl(picl), _state(INITIAL) { }
26579
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
   117
    int value() {
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
   118
      assert(_state == ASSIGNED, "Precondition");
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
   119
      return _value;
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
   120
    }
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
   121
    void set_value(int value) {
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
   122
      assert(_state == INITIAL, "Precondition");
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
   123
      _value = value;
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
   124
      _state = ASSIGNED;
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
   125
    }
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
   126
    bool is_initial()       { return _state == INITIAL;      }
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
   127
    bool is_assigned()      { return _state == ASSIGNED;     }
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
   128
    bool is_inconsistent()  { return _state == INCONSISTENT; }
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
   129
    void set_inconsistent() { _state = INCONSISTENT;         }
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
   130
30217
5eb8768d86c4 8076968: PICL based initialization of L2 cache line size on some SPARC systems is incorrect
iveresov
parents: 27456
diff changeset
   131
    bool visit(picl_nodehdl_t nodeh, const char* name) {
27456
854b988388f3 8062591: SPARC PICL causes significantly longer startup times
iveresov
parents: 27426
diff changeset
   132
      assert(!is_inconsistent(), "Precondition");
26579
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
   133
      int curr;
27456
854b988388f3 8062591: SPARC PICL causes significantly longer startup times
iveresov
parents: 27426
diff changeset
   134
      if (_picl->get_int_property(nodeh, name, &curr) == PICL_SUCCESS) {
854b988388f3 8062591: SPARC PICL causes significantly longer startup times
iveresov
parents: 27426
diff changeset
   135
        if (!is_assigned()) { // first iteration
854b988388f3 8062591: SPARC PICL causes significantly longer startup times
iveresov
parents: 27426
diff changeset
   136
          set_value(curr);
854b988388f3 8062591: SPARC PICL causes significantly longer startup times
iveresov
parents: 27426
diff changeset
   137
        } else if (curr != value()) { // following iterations
854b988388f3 8062591: SPARC PICL causes significantly longer startup times
iveresov
parents: 27426
diff changeset
   138
          set_inconsistent();
26579
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
   139
        }
30217
5eb8768d86c4 8076968: PICL based initialization of L2 cache line size on some SPARC systems is incorrect
iveresov
parents: 27456
diff changeset
   140
        return true;
26579
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
   141
      }
30217
5eb8768d86c4 8076968: PICL based initialization of L2 cache line size on some SPARC systems is incorrect
iveresov
parents: 27456
diff changeset
   142
      return false;
27456
854b988388f3 8062591: SPARC PICL causes significantly longer startup times
iveresov
parents: 27426
diff changeset
   143
    }
854b988388f3 8062591: SPARC PICL causes significantly longer startup times
iveresov
parents: 27426
diff changeset
   144
  };
854b988388f3 8062591: SPARC PICL causes significantly longer startup times
iveresov
parents: 27426
diff changeset
   145
854b988388f3 8062591: SPARC PICL causes significantly longer startup times
iveresov
parents: 27426
diff changeset
   146
  class CPUVisitor {
854b988388f3 8062591: SPARC PICL causes significantly longer startup times
iveresov
parents: 27426
diff changeset
   147
    UniqueValueVisitor _l1_visitor;
854b988388f3 8062591: SPARC PICL causes significantly longer startup times
iveresov
parents: 27426
diff changeset
   148
    UniqueValueVisitor _l2_visitor;
854b988388f3 8062591: SPARC PICL causes significantly longer startup times
iveresov
parents: 27426
diff changeset
   149
    int _limit; // number of times visit() can be run
854b988388f3 8062591: SPARC PICL causes significantly longer startup times
iveresov
parents: 27426
diff changeset
   150
  public:
854b988388f3 8062591: SPARC PICL causes significantly longer startup times
iveresov
parents: 27426
diff changeset
   151
    CPUVisitor(PICL *picl, int limit) : _l1_visitor(picl), _l2_visitor(picl), _limit(limit) {}
854b988388f3 8062591: SPARC PICL causes significantly longer startup times
iveresov
parents: 27426
diff changeset
   152
    static int visit(picl_nodehdl_t nodeh, void *arg) {
854b988388f3 8062591: SPARC PICL causes significantly longer startup times
iveresov
parents: 27426
diff changeset
   153
      CPUVisitor *cpu_visitor = static_cast<CPUVisitor*>(arg);
854b988388f3 8062591: SPARC PICL causes significantly longer startup times
iveresov
parents: 27426
diff changeset
   154
      UniqueValueVisitor* l1_visitor = cpu_visitor->l1_visitor();
854b988388f3 8062591: SPARC PICL causes significantly longer startup times
iveresov
parents: 27426
diff changeset
   155
      UniqueValueVisitor* l2_visitor = cpu_visitor->l2_visitor();
854b988388f3 8062591: SPARC PICL causes significantly longer startup times
iveresov
parents: 27426
diff changeset
   156
      if (!l1_visitor->is_inconsistent()) {
854b988388f3 8062591: SPARC PICL causes significantly longer startup times
iveresov
parents: 27426
diff changeset
   157
        l1_visitor->visit(nodeh, "l1-dcache-line-size");
854b988388f3 8062591: SPARC PICL causes significantly longer startup times
iveresov
parents: 27426
diff changeset
   158
      }
30217
5eb8768d86c4 8076968: PICL based initialization of L2 cache line size on some SPARC systems is incorrect
iveresov
parents: 27456
diff changeset
   159
      static const char* l2_data_cache_line_property_name = NULL;
5eb8768d86c4 8076968: PICL based initialization of L2 cache line size on some SPARC systems is incorrect
iveresov
parents: 27456
diff changeset
   160
      // On the first visit determine the name of the l2 cache line size property and memoize it.
5eb8768d86c4 8076968: PICL based initialization of L2 cache line size on some SPARC systems is incorrect
iveresov
parents: 27456
diff changeset
   161
      if (l2_data_cache_line_property_name == NULL) {
5eb8768d86c4 8076968: PICL based initialization of L2 cache line size on some SPARC systems is incorrect
iveresov
parents: 27456
diff changeset
   162
        assert(!l2_visitor->is_inconsistent(), "First iteration cannot be inconsistent");
5eb8768d86c4 8076968: PICL based initialization of L2 cache line size on some SPARC systems is incorrect
iveresov
parents: 27456
diff changeset
   163
        l2_data_cache_line_property_name = "l2-cache-line-size";
5eb8768d86c4 8076968: PICL based initialization of L2 cache line size on some SPARC systems is incorrect
iveresov
parents: 27456
diff changeset
   164
        if (!l2_visitor->visit(nodeh, l2_data_cache_line_property_name)) {
5eb8768d86c4 8076968: PICL based initialization of L2 cache line size on some SPARC systems is incorrect
iveresov
parents: 27456
diff changeset
   165
          l2_data_cache_line_property_name = "l2-dcache-line-size";
5eb8768d86c4 8076968: PICL based initialization of L2 cache line size on some SPARC systems is incorrect
iveresov
parents: 27456
diff changeset
   166
          l2_visitor->visit(nodeh, l2_data_cache_line_property_name);
5eb8768d86c4 8076968: PICL based initialization of L2 cache line size on some SPARC systems is incorrect
iveresov
parents: 27456
diff changeset
   167
        }
5eb8768d86c4 8076968: PICL based initialization of L2 cache line size on some SPARC systems is incorrect
iveresov
parents: 27456
diff changeset
   168
      } else {
5eb8768d86c4 8076968: PICL based initialization of L2 cache line size on some SPARC systems is incorrect
iveresov
parents: 27456
diff changeset
   169
        if (!l2_visitor->is_inconsistent()) {
5eb8768d86c4 8076968: PICL based initialization of L2 cache line size on some SPARC systems is incorrect
iveresov
parents: 27456
diff changeset
   170
          l2_visitor->visit(nodeh, l2_data_cache_line_property_name);
5eb8768d86c4 8076968: PICL based initialization of L2 cache line size on some SPARC systems is incorrect
iveresov
parents: 27456
diff changeset
   171
        }
27456
854b988388f3 8062591: SPARC PICL causes significantly longer startup times
iveresov
parents: 27426
diff changeset
   172
      }
854b988388f3 8062591: SPARC PICL causes significantly longer startup times
iveresov
parents: 27426
diff changeset
   173
854b988388f3 8062591: SPARC PICL causes significantly longer startup times
iveresov
parents: 27426
diff changeset
   174
      if (l1_visitor->is_inconsistent() && l2_visitor->is_inconsistent()) {
854b988388f3 8062591: SPARC PICL causes significantly longer startup times
iveresov
parents: 27426
diff changeset
   175
        return PICL_WALK_TERMINATE;
854b988388f3 8062591: SPARC PICL causes significantly longer startup times
iveresov
parents: 27426
diff changeset
   176
      }
854b988388f3 8062591: SPARC PICL causes significantly longer startup times
iveresov
parents: 27426
diff changeset
   177
      cpu_visitor->_limit--;
854b988388f3 8062591: SPARC PICL causes significantly longer startup times
iveresov
parents: 27426
diff changeset
   178
      if (cpu_visitor->_limit <= 0) {
26579
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
   179
        return PICL_WALK_TERMINATE;
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
   180
      }
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
   181
      return PICL_WALK_CONTINUE;
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
   182
    }
27456
854b988388f3 8062591: SPARC PICL causes significantly longer startup times
iveresov
parents: 27426
diff changeset
   183
    UniqueValueVisitor* l1_visitor() { return &_l1_visitor; }
854b988388f3 8062591: SPARC PICL causes significantly longer startup times
iveresov
parents: 27426
diff changeset
   184
    UniqueValueVisitor* l2_visitor() { return &_l2_visitor; }
26579
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
   185
  };
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
   186
  int _L1_data_cache_line_size;
30217
5eb8768d86c4 8076968: PICL based initialization of L2 cache line size on some SPARC systems is incorrect
iveresov
parents: 27456
diff changeset
   187
  int _L2_data_cache_line_size;
26579
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
   188
public:
27456
854b988388f3 8062591: SPARC PICL causes significantly longer startup times
iveresov
parents: 27426
diff changeset
   189
  static int visit_cpu(picl_nodehdl_t nodeh, void *state) {
854b988388f3 8062591: SPARC PICL causes significantly longer startup times
iveresov
parents: 27426
diff changeset
   190
    return CPUVisitor::visit(nodeh, state);
26579
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
   191
  }
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
   192
31585
de50b10196d7 8080012: JVM times out with vdbench on SPARC M7-16
iveresov
parents: 31515
diff changeset
   193
  PICL(bool is_fujitsu, bool is_sun4v) : _L1_data_cache_line_size(0), _L2_data_cache_line_size(0), _dl_handle(NULL) {
27426
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
   194
    if (!open_library()) {
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
   195
      return;
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
   196
    }
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
   197
    if (_picl_initialize() == PICL_SUCCESS) {
26579
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
   198
      picl_nodehdl_t rooth;
27426
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
   199
      if (_picl_get_root(&rooth) == PICL_SUCCESS) {
27456
854b988388f3 8062591: SPARC PICL causes significantly longer startup times
iveresov
parents: 27426
diff changeset
   200
        const char* cpu_class = "cpu";
854b988388f3 8062591: SPARC PICL causes significantly longer startup times
iveresov
parents: 27426
diff changeset
   201
        // If it's a Fujitsu machine, it's a "core"
854b988388f3 8062591: SPARC PICL causes significantly longer startup times
iveresov
parents: 27426
diff changeset
   202
        if (is_fujitsu) {
854b988388f3 8062591: SPARC PICL causes significantly longer startup times
iveresov
parents: 27426
diff changeset
   203
          cpu_class = "core";
26579
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
   204
        }
31585
de50b10196d7 8080012: JVM times out with vdbench on SPARC M7-16
iveresov
parents: 31515
diff changeset
   205
        CPUVisitor cpu_visitor(this, (is_sun4v && !is_fujitsu) ? 1 : os::processor_count());
27456
854b988388f3 8062591: SPARC PICL causes significantly longer startup times
iveresov
parents: 27426
diff changeset
   206
        _picl_walk_tree_by_class(rooth, cpu_class, &cpu_visitor, PICL_visit_cpu_helper);
854b988388f3 8062591: SPARC PICL causes significantly longer startup times
iveresov
parents: 27426
diff changeset
   207
        if (cpu_visitor.l1_visitor()->is_assigned()) { // Is there a value?
854b988388f3 8062591: SPARC PICL causes significantly longer startup times
iveresov
parents: 27426
diff changeset
   208
          _L1_data_cache_line_size = cpu_visitor.l1_visitor()->value();
26579
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
   209
        }
27456
854b988388f3 8062591: SPARC PICL causes significantly longer startup times
iveresov
parents: 27426
diff changeset
   210
        if (cpu_visitor.l2_visitor()->is_assigned()) {
30217
5eb8768d86c4 8076968: PICL based initialization of L2 cache line size on some SPARC systems is incorrect
iveresov
parents: 27456
diff changeset
   211
          _L2_data_cache_line_size = cpu_visitor.l2_visitor()->value();
26579
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
   212
        }
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
   213
      }
27426
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
   214
      _picl_shutdown();
26579
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
   215
    }
27426
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
   216
    close_library();
26579
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
   217
  }
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
   218
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
   219
  unsigned int L1_data_cache_line_size() const { return _L1_data_cache_line_size; }
30217
5eb8768d86c4 8076968: PICL based initialization of L2 cache line size on some SPARC systems is incorrect
iveresov
parents: 27456
diff changeset
   220
  unsigned int L2_data_cache_line_size() const { return _L2_data_cache_line_size; }
26579
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
   221
};
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
   222
27456
854b988388f3 8062591: SPARC PICL causes significantly longer startup times
iveresov
parents: 27426
diff changeset
   223
854b988388f3 8062591: SPARC PICL causes significantly longer startup times
iveresov
parents: 27426
diff changeset
   224
extern "C" static int PICL_visit_cpu_helper(picl_nodehdl_t nodeh, void *result) {
854b988388f3 8062591: SPARC PICL causes significantly longer startup times
iveresov
parents: 27426
diff changeset
   225
  return PICL::visit_cpu(nodeh, result);
26579
522d6486f410 8056124: Hotspot should use PICL interface to get cacheline size on SPARC
iveresov
parents: 26175
diff changeset
   226
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
27426
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
   228
template<typename FuncType>
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
   229
bool PICL::bind(FuncType& func, const char* name) {
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
   230
  func = reinterpret_cast<FuncType>(dlsym(_dl_handle, name));
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
   231
  return func != NULL;
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
   232
}
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
   233
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
   234
bool PICL::bind_library_functions() {
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
   235
  assert(_dl_handle != NULL, "library should be open");
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
   236
  return bind(_picl_initialize,         "picl_initialize"        ) &&
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
   237
         bind(_picl_shutdown,           "picl_shutdown"          ) &&
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
   238
         bind(_picl_get_root,           "picl_get_root"          ) &&
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
   239
         bind(_picl_walk_tree_by_class, "picl_walk_tree_by_class") &&
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
   240
         bind(_picl_get_prop_by_name,   "picl_get_prop_by_name"  ) &&
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
   241
         bind(_picl_get_propval,        "picl_get_propval"       ) &&
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
   242
         bind(_picl_get_propinfo,       "picl_get_propinfo"      );
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
   243
}
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
   244
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
   245
bool PICL::open_library() {
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
   246
  _dl_handle = dlopen("libpicl.so.1", RTLD_LAZY);
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
   247
  if (_dl_handle == NULL) {
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
   248
    return false;
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
   249
  }
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
   250
  if (!bind_library_functions()) {
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
   251
    assert(false, "unexpected PICL API change");
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
   252
    close_library();
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
   253
    return false;
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
   254
  }
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
   255
  return true;
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
   256
}
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
   257
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
   258
void PICL::close_library() {
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
   259
  assert(_dl_handle != NULL, "library should be open");
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
   260
  dlclose(_dl_handle);
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
   261
  _dl_handle = NULL;
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
   262
}
66fc2ab37003 8059200: Promoted JDK9 b31 for Solaris-amd64 fails (Error: dl failure on line 744, no picl library) on Solaris 11.1
iveresov
parents: 26579
diff changeset
   263
36346
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   264
class Sysinfo {
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   265
  char* _string;
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   266
public:
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   267
  Sysinfo(int si) : _string(NULL) {
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   268
    char   tmp;
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   269
    size_t bufsize = sysinfo(si, &tmp, 1);
2253
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   270
36346
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   271
    if (bufsize != -1) {
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   272
      char* buf = (char*) os::malloc(bufsize, mtInternal);
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   273
      if (buf != NULL) {
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   274
        if (sysinfo(si, buf, bufsize) == bufsize) {
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   275
          _string = buf;
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   276
        } else {
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   277
          os::free(buf);
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   278
        }
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   279
      }
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   280
    }
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   281
  }
2253
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   282
36346
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   283
  ~Sysinfo() {
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   284
    if (_string != NULL) {
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   285
      os::free(_string);
2253
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   286
    }
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   287
  }
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   288
36346
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   289
  const char* value() const {
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   290
    return _string;
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   291
  }
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   292
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   293
  bool valid() const {
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   294
    return _string != NULL;
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   295
  }
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   296
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   297
  bool match(const char* s) const {
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   298
    return valid() ? strcmp(_string, s) == 0 : false;
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   299
  }
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   300
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   301
  bool match_substring(const char* s) const {
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   302
    return valid() ? strstr(_string, s) != NULL : false;
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   303
  }
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   304
};
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   305
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   306
class Sysconf {
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   307
  int _value;
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   308
public:
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   309
  Sysconf(int sc) : _value(-1) {
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   310
    _value = sysconf(sc);
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   311
  }
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   312
  bool valid() const {
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   313
    return _value != -1;
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   314
  }
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   315
  int value() const {
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   316
    return _value;
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   317
  }
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   318
};
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   319
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   320
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   321
#ifndef _SC_DCACHE_LINESZ
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   322
#define _SC_DCACHE_LINESZ       508     /* Data cache line size */
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   323
#endif
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   324
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   325
#ifndef _SC_L2CACHE_LINESZ
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   326
#define _SC_L2CACHE_LINESZ      527     /* Size of L2 cache line */
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   327
#endif
2253
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   328
46592
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   329
void VM_Version::platform_features() {
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   330
  uint64_t features = ISA_v9_msk;   // Basic SPARC-V9 required (V8 not supported).
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
46592
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   332
  assert(Sysinfo(SI_ARCHITECTURE_64).match("sparcv9"), "must be");
2253
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   333
26168
0011f98755e3 8043913: remove legacy code in SPARC's VM_Version::platform_features
anoll
parents: 24953
diff changeset
   334
  // Extract valid instruction set extensions.
46592
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   335
  uint32_t avs[AV_HW2_IDX + 1];
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   336
  uint_t avn = getisax(avs, AV_HW2_IDX + 1);
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   337
  assert(avn <= 2, "should return two or less av's");
7115
32300e243300 6987135: Performance regression on Intel platform with 32-bits edition between 6u13 and 6u14.
kvn
parents: 5547
diff changeset
   338
41707
7a8490836761 8157141: Fix for JDK-8031290 is unnecessarily fragile
alanbur
parents: 41706
diff changeset
   339
  log_info(os, cpu)("getisax(2) returned %d words:", avn);
7a8490836761 8157141: Fix for JDK-8031290 is unnecessarily fragile
alanbur
parents: 41706
diff changeset
   340
  for (int i = 0; i < avn; i++) {
7a8490836761 8157141: Fix for JDK-8031290 is unnecessarily fragile
alanbur
parents: 41706
diff changeset
   341
    log_info(os, cpu)("    word %d: " PTR32_FORMAT, i, avs[i]);
26168
0011f98755e3 8043913: remove legacy code in SPARC's VM_Version::platform_features
anoll
parents: 24953
diff changeset
   342
  }
7115
32300e243300 6987135: Performance regression on Intel platform with 32-bits edition between 6u13 and 6u14.
kvn
parents: 5547
diff changeset
   343
46592
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   344
  uint32_t av = avs[AV_HW1_IDX];
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   345
51815
d23d7389142f 8210284: "assert((av & 0x00000001) == 0) failed: unsupported V8" on Solaris 11.4
phedlin
parents: 47562
diff changeset
   346
  // Obsolete and 32b legacy mode capabilites NOT probed here, despite being
d23d7389142f 8210284: "assert((av & 0x00000001) == 0) failed: unsupported V8" on Solaris 11.4
phedlin
parents: 47562
diff changeset
   347
  // set by Solaris 11.4 (onward) also on V9; AV_SPARC_MUL32, AV_SPARC_DIV32
d23d7389142f 8210284: "assert((av & 0x00000001) == 0) failed: unsupported V8" on Solaris 11.4
phedlin
parents: 47562
diff changeset
   348
  // and AV_SPARC_FSMULD (and AV_SPARC_V8PLUS).
46592
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   349
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   350
  if (av & AV_SPARC_POPC) features |= ISA_popc_msk;
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   351
  if (av & AV_SPARC_VIS)  features |= ISA_vis1_msk;
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   352
  if (av & AV_SPARC_VIS2) features |= ISA_vis2_msk;
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   353
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   354
  // Hardware capability defines introduced after Solaris 11.1:
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   355
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   356
#ifndef AV_SPARC_FMAF
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   357
#define AV_SPARC_FMAF         0x00000100 // Fused Multiply-Add
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   358
#endif
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   359
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   360
  if (av & AV_SPARC_ASI_BLK_INIT) features |= ISA_blk_init_msk;
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   361
  if (av & AV_SPARC_FMAF)         features |= ISA_fmaf_msk;
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   362
  if (av & AV_SPARC_VIS3)         features |= ISA_vis3_msk;
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   363
  if (av & AV_SPARC_HPC)          features |= ISA_hpc_msk;
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   364
  if (av & AV_SPARC_IMA)          features |= ISA_ima_msk;
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   365
  if (av & AV_SPARC_AES)          features |= ISA_aes_msk;
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   366
  if (av & AV_SPARC_DES)          features |= ISA_des_msk;
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   367
  if (av & AV_SPARC_KASUMI)       features |= ISA_kasumi_msk;
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   368
  if (av & AV_SPARC_CAMELLIA)     features |= ISA_camellia_msk;
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   369
  if (av & AV_SPARC_MD5)          features |= ISA_md5_msk;
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   370
  if (av & AV_SPARC_SHA1)         features |= ISA_sha1_msk;
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   371
  if (av & AV_SPARC_SHA256)       features |= ISA_sha256_msk;
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   372
  if (av & AV_SPARC_SHA512)       features |= ISA_sha512_msk;
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   373
  if (av & AV_SPARC_MPMUL)        features |= ISA_mpmul_msk;
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   374
  if (av & AV_SPARC_MONT)         features |= ISA_mont_msk;
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   375
  if (av & AV_SPARC_PAUSE)        features |= ISA_pause_msk;
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   376
  if (av & AV_SPARC_CBCOND)       features |= ISA_cbcond_msk;
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   377
  if (av & AV_SPARC_CRC32C)       features |= ISA_crc32c_msk;
7704
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   378
46592
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   379
#ifndef AV2_SPARC_FJATHPLUS
47562
f789ccebcfe4 8182279: Updating SPARC feature/capability detection to support Core C5.
neliasso
parents: 47216
diff changeset
   380
#define AV2_SPARC_FJATHPLUS  0x00000001 // Fujitsu Athena+ insns
46592
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   381
#endif
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   382
#ifndef AV2_SPARC_VIS3B
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   383
#define AV2_SPARC_VIS3B      0x00000002 // VIS3 present on multiple chips
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   384
#endif
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   385
#ifndef AV2_SPARC_ADI
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   386
#define AV2_SPARC_ADI        0x00000004 // Application Data Integrity
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   387
#endif
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   388
#ifndef AV2_SPARC_SPARC5
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   389
#define AV2_SPARC_SPARC5     0x00000008 // The 29 new fp and sub instructions
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   390
#endif
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   391
#ifndef AV2_SPARC_MWAIT
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   392
#define AV2_SPARC_MWAIT      0x00000010 // mwait instruction and load/monitor ASIs
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   393
#endif
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   394
#ifndef AV2_SPARC_XMPMUL
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   395
#define AV2_SPARC_XMPMUL     0x00000020 // XOR multiple precision multiply
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   396
#endif
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   397
#ifndef AV2_SPARC_XMONT
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   398
#define AV2_SPARC_XMONT      0x00000040 // XOR Montgomery mult/sqr instructions
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   399
#endif
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   400
#ifndef AV2_SPARC_PAUSE_NSEC
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   401
#define AV2_SPARC_PAUSE_NSEC 0x00000080 // pause instruction with support for nsec timings
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   402
#endif
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   403
#ifndef AV2_SPARC_VAMASK
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   404
#define AV2_SPARC_VAMASK     0x00000100 // Virtual Address masking
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   405
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
47562
f789ccebcfe4 8182279: Updating SPARC feature/capability detection to support Core C5.
neliasso
parents: 47216
diff changeset
   407
#ifndef AV2_SPARC_SPARC6
f789ccebcfe4 8182279: Updating SPARC feature/capability detection to support Core C5.
neliasso
parents: 47216
diff changeset
   408
#define AV2_SPARC_SPARC6     0x00000200 // REVB*, FPSLL*, RDENTROPY, LDM* and STM*
f789ccebcfe4 8182279: Updating SPARC feature/capability detection to support Core C5.
neliasso
parents: 47216
diff changeset
   409
#endif
f789ccebcfe4 8182279: Updating SPARC feature/capability detection to support Core C5.
neliasso
parents: 47216
diff changeset
   410
#ifndef AV2_SPARC_DICTUNP
f789ccebcfe4 8182279: Updating SPARC feature/capability detection to support Core C5.
neliasso
parents: 47216
diff changeset
   411
#define AV2_SPARC_DICTUNP    0x00002000 // Dictionary unpack instruction
f789ccebcfe4 8182279: Updating SPARC feature/capability detection to support Core C5.
neliasso
parents: 47216
diff changeset
   412
#endif
f789ccebcfe4 8182279: Updating SPARC feature/capability detection to support Core C5.
neliasso
parents: 47216
diff changeset
   413
#ifndef AV2_SPARC_FPCMPSHL
f789ccebcfe4 8182279: Updating SPARC feature/capability detection to support Core C5.
neliasso
parents: 47216
diff changeset
   414
#define AV2_SPARC_FPCMPSHL   0x00004000 // Partition compare with shifted result
f789ccebcfe4 8182279: Updating SPARC feature/capability detection to support Core C5.
neliasso
parents: 47216
diff changeset
   415
#endif
f789ccebcfe4 8182279: Updating SPARC feature/capability detection to support Core C5.
neliasso
parents: 47216
diff changeset
   416
#ifndef AV2_SPARC_RLE
f789ccebcfe4 8182279: Updating SPARC feature/capability detection to support Core C5.
neliasso
parents: 47216
diff changeset
   417
#define AV2_SPARC_RLE        0x00008000 // Run-length encoded burst and length
f789ccebcfe4 8182279: Updating SPARC feature/capability detection to support Core C5.
neliasso
parents: 47216
diff changeset
   418
#endif
f789ccebcfe4 8182279: Updating SPARC feature/capability detection to support Core C5.
neliasso
parents: 47216
diff changeset
   419
#ifndef AV2_SPARC_SHA3
f789ccebcfe4 8182279: Updating SPARC feature/capability detection to support Core C5.
neliasso
parents: 47216
diff changeset
   420
#define AV2_SPARC_SHA3       0x00010000 // SHA3 instructions
f789ccebcfe4 8182279: Updating SPARC feature/capability detection to support Core C5.
neliasso
parents: 47216
diff changeset
   421
#endif
f789ccebcfe4 8182279: Updating SPARC feature/capability detection to support Core C5.
neliasso
parents: 47216
diff changeset
   422
#ifndef AV2_SPARC_FJATHPLUS2
f789ccebcfe4 8182279: Updating SPARC feature/capability detection to support Core C5.
neliasso
parents: 47216
diff changeset
   423
#define AV2_SPARC_FJATHPLUS2 0x00020000 // Fujitsu Athena++ insns
f789ccebcfe4 8182279: Updating SPARC feature/capability detection to support Core C5.
neliasso
parents: 47216
diff changeset
   424
#endif
f789ccebcfe4 8182279: Updating SPARC feature/capability detection to support Core C5.
neliasso
parents: 47216
diff changeset
   425
#ifndef AV2_SPARC_VIS3C
f789ccebcfe4 8182279: Updating SPARC feature/capability detection to support Core C5.
neliasso
parents: 47216
diff changeset
   426
#define AV2_SPARC_VIS3C      0x00040000 // Subset of VIS3 insns provided by Athena++
f789ccebcfe4 8182279: Updating SPARC feature/capability detection to support Core C5.
neliasso
parents: 47216
diff changeset
   427
#endif
f789ccebcfe4 8182279: Updating SPARC feature/capability detection to support Core C5.
neliasso
parents: 47216
diff changeset
   428
#ifndef AV2_SPARC_SPARC5B
f789ccebcfe4 8182279: Updating SPARC feature/capability detection to support Core C5.
neliasso
parents: 47216
diff changeset
   429
#define AV2_SPARC_SPARC5B    0x00080000 // subset of SPARC5 insns (fpadd8, fpsub8)
f789ccebcfe4 8182279: Updating SPARC feature/capability detection to support Core C5.
neliasso
parents: 47216
diff changeset
   430
#endif
f789ccebcfe4 8182279: Updating SPARC feature/capability detection to support Core C5.
neliasso
parents: 47216
diff changeset
   431
#ifndef AV2_SPARC_MME
f789ccebcfe4 8182279: Updating SPARC feature/capability detection to support Core C5.
neliasso
parents: 47216
diff changeset
   432
#define AV2_SPARC_MME        0x00100000 // Misaligned Mitigation Enable
f789ccebcfe4 8182279: Updating SPARC feature/capability detection to support Core C5.
neliasso
parents: 47216
diff changeset
   433
#endif
f789ccebcfe4 8182279: Updating SPARC feature/capability detection to support Core C5.
neliasso
parents: 47216
diff changeset
   434
46592
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   435
  if (avn > 1) {
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   436
    uint32_t av2 = avs[AV_HW2_IDX];
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   437
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   438
    if (av2 & AV2_SPARC_FJATHPLUS)  features |= ISA_fjathplus_msk;
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   439
    if (av2 & AV2_SPARC_VIS3B)      features |= ISA_vis3b_msk;
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   440
    if (av2 & AV2_SPARC_ADI)        features |= ISA_adi_msk;
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   441
    if (av2 & AV2_SPARC_SPARC5)     features |= ISA_sparc5_msk;
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   442
    if (av2 & AV2_SPARC_MWAIT)      features |= ISA_mwait_msk;
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   443
    if (av2 & AV2_SPARC_XMPMUL)     features |= ISA_xmpmul_msk;
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   444
    if (av2 & AV2_SPARC_XMONT)      features |= ISA_xmont_msk;
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   445
    if (av2 & AV2_SPARC_PAUSE_NSEC) features |= ISA_pause_nsec_msk;
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   446
    if (av2 & AV2_SPARC_VAMASK)     features |= ISA_vamask_msk;
47562
f789ccebcfe4 8182279: Updating SPARC feature/capability detection to support Core C5.
neliasso
parents: 47216
diff changeset
   447
f789ccebcfe4 8182279: Updating SPARC feature/capability detection to support Core C5.
neliasso
parents: 47216
diff changeset
   448
    if (av2 & AV2_SPARC_SPARC6)     features |= ISA_sparc6_msk;
f789ccebcfe4 8182279: Updating SPARC feature/capability detection to support Core C5.
neliasso
parents: 47216
diff changeset
   449
    if (av2 & AV2_SPARC_DICTUNP)    features |= ISA_dictunp_msk;
f789ccebcfe4 8182279: Updating SPARC feature/capability detection to support Core C5.
neliasso
parents: 47216
diff changeset
   450
    if (av2 & AV2_SPARC_FPCMPSHL)   features |= ISA_fpcmpshl_msk;
f789ccebcfe4 8182279: Updating SPARC feature/capability detection to support Core C5.
neliasso
parents: 47216
diff changeset
   451
    if (av2 & AV2_SPARC_RLE)        features |= ISA_rle_msk;
f789ccebcfe4 8182279: Updating SPARC feature/capability detection to support Core C5.
neliasso
parents: 47216
diff changeset
   452
    if (av2 & AV2_SPARC_SHA3)       features |= ISA_sha3_msk;
f789ccebcfe4 8182279: Updating SPARC feature/capability detection to support Core C5.
neliasso
parents: 47216
diff changeset
   453
    if (av2 & AV2_SPARC_FJATHPLUS2) features |= ISA_fjathplus2_msk;
f789ccebcfe4 8182279: Updating SPARC feature/capability detection to support Core C5.
neliasso
parents: 47216
diff changeset
   454
    if (av2 & AV2_SPARC_VIS3C)      features |= ISA_vis3c_msk;
f789ccebcfe4 8182279: Updating SPARC feature/capability detection to support Core C5.
neliasso
parents: 47216
diff changeset
   455
    if (av2 & AV2_SPARC_SPARC5B)    features |= ISA_sparc5b_msk;
f789ccebcfe4 8182279: Updating SPARC feature/capability detection to support Core C5.
neliasso
parents: 47216
diff changeset
   456
    if (av2 & AV2_SPARC_MME)        features |= ISA_mme_msk;
36346
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   457
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
46592
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   459
  _features = features;     // ISA feature set completed, update state.
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   460
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   461
  Sysinfo machine(SI_MACHINE);
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   462
47562
f789ccebcfe4 8182279: Updating SPARC feature/capability detection to support Core C5.
neliasso
parents: 47216
diff changeset
   463
  bool is_sun4v = machine.match("sun4v");   // All Oracle SPARC + Fujitsu Athena+/++
46592
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   464
  bool is_sun4u = machine.match("sun4u");   // All other Fujitsu
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   465
47562
f789ccebcfe4 8182279: Updating SPARC feature/capability detection to support Core C5.
neliasso
parents: 47216
diff changeset
   466
  // Handle Athena+/++ conservatively (simply because we are lacking info.).
46592
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   467
47562
f789ccebcfe4 8182279: Updating SPARC feature/capability detection to support Core C5.
neliasso
parents: 47216
diff changeset
   468
  bool an_athena = has_athena_plus() || has_athena_plus2();
f789ccebcfe4 8182279: Updating SPARC feature/capability detection to support Core C5.
neliasso
parents: 47216
diff changeset
   469
  bool do_sun4v  = is_sun4v && !an_athena;
f789ccebcfe4 8182279: Updating SPARC feature/capability detection to support Core C5.
neliasso
parents: 47216
diff changeset
   470
  bool do_sun4u  = is_sun4u ||  an_athena;
46592
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   471
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   472
  uint64_t synthetic = 0;
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   473
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   474
  if (do_sun4v) {
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   475
    // Indirect and direct branches are equally fast.
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   476
    synthetic = CPU_fast_ind_br_msk;
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   477
    // Fast IDIV, BIS and LD available on Niagara Plus.
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   478
    if (has_vis2()) {
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   479
      synthetic |= (CPU_fast_idiv_msk | CPU_fast_ld_msk);
47562
f789ccebcfe4 8182279: Updating SPARC feature/capability detection to support Core C5.
neliasso
parents: 47216
diff changeset
   480
      // ...on Core C4 however, we prefer not to use BIS.
46592
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   481
      if (!has_sparc5()) {
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   482
        synthetic |= CPU_fast_bis_msk;
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   483
      }
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   484
    }
47562
f789ccebcfe4 8182279: Updating SPARC feature/capability detection to support Core C5.
neliasso
parents: 47216
diff changeset
   485
    // SPARC Core C3 supports fast RDPC and block zeroing.
46592
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   486
    if (has_ima()) {
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   487
      synthetic |= (CPU_fast_rdpc_msk | CPU_blk_zeroing_msk);
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   488
    }
47562
f789ccebcfe4 8182279: Updating SPARC feature/capability detection to support Core C5.
neliasso
parents: 47216
diff changeset
   489
    // SPARC Core C3 and C4 have slow CMOVE.
46592
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   490
    if (!has_ima()) {
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   491
      synthetic |= CPU_fast_cmove_msk;
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   492
    }
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   493
  } else if (do_sun4u) {
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   494
    // SPARC64 only have fast IDIV and RDPC.
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   495
    synthetic |= (CPU_fast_idiv_msk | CPU_fast_rdpc_msk);
36346
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   496
  } else {
46592
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   497
    log_info(os, cpu)("Unable to derive CPU features: %s", machine.value());
7704
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   498
  }
46592
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   499
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   500
  _features += synthetic;   // Including CPU derived/synthetic features.
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   501
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   502
  Sysconf l1_dcache_line_size(_SC_DCACHE_LINESZ);
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   503
  Sysconf l2_dcache_line_size(_SC_L2CACHE_LINESZ);
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   504
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   505
  // Require both Sysconf requests to be valid or use fall-back.
7704
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   506
46592
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   507
  if (l1_dcache_line_size.valid() &&
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   508
      l2_dcache_line_size.valid()) {
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   509
    _L1_data_cache_line_size = l1_dcache_line_size.value();
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   510
    _L2_data_cache_line_size = l2_dcache_line_size.value();
36346
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   511
  } else {
46592
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   512
    // Otherwise figure out the cache line sizes using PICL.
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46418
diff changeset
   513
    PICL picl(is_sun4u, is_sun4v);
36346
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   514
    _L1_data_cache_line_size = picl.L1_data_cache_line_size();
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   515
    _L2_data_cache_line_size = picl.L2_data_cache_line_size();
0a02e923ec29 8134119: Use new API to get cache line sizes
iveresov
parents: 36093
diff changeset
   516
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
}