hotspot/src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp
author zgu
Mon, 11 Aug 2014 10:18:09 -0700
changeset 25949 34557722059b
parent 24953 9680119572be
child 26175 d8a4e0741439
permissions -rw-r--r--
6424123: JVM crashes on failed 'strdup' call Summary: Calling os::malloc()/os::strdup() and new os::strdup_check_oom() instead of ::malloc()/::strdup() for native memory tracking purpose Reviewed-by: coleenp, ctornqvi, kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
24953
9680119572be 8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents: 22554
diff changeset
     2
 * Copyright (c) 2006, 2014, 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"
25949
34557722059b 6424123: JVM crashes on failed 'strdup' call
zgu
parents: 24953
diff changeset
    26
#include "memory/allocation.hpp"
34557722059b 6424123: JVM crashes on failed 'strdup' call
zgu
parents: 24953
diff changeset
    27
#include "memory/allocation.inline.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7115
diff changeset
    28
#include "runtime/os.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7115
diff changeset
    29
#include "vm_version_sparc.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
2253
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    31
# include <sys/auxv.h>
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    32
# include <sys/auxv_SPARC.h>
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
# include <sys/systeminfo.h>
7704
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
    34
# include <kstat.h>
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
2253
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    36
// We need to keep these here as long as we have to build on Solaris
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    37
// versions before 10.
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    38
#ifndef SI_ARCHITECTURE_32
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    39
#define SI_ARCHITECTURE_32      516     /* basic 32-bit SI_ARCHITECTURE */
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    40
#endif
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    41
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    42
#ifndef SI_ARCHITECTURE_64
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    43
#define SI_ARCHITECTURE_64      517     /* basic 64-bit SI_ARCHITECTURE */
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    44
#endif
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    45
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    46
static void do_sysinfo(int si, const char* string, int* features, int mask) {
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    47
  char   tmp;
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    48
  size_t bufsize = sysinfo(si, &tmp, 1);
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    49
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    50
  // All SI defines used below must be supported.
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    51
  guarantee(bufsize != -1, "must be supported");
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    52
25949
34557722059b 6424123: JVM crashes on failed 'strdup' call
zgu
parents: 24953
diff changeset
    53
  char* buf = (char*) os::malloc(bufsize, mtInternal);
2253
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    54
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    55
  if (buf == NULL)
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    56
    return;
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    57
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    58
  if (sysinfo(si, buf, bufsize) == bufsize) {
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    59
    // Compare the string.
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    60
    if (strcmp(buf, string) == 0) {
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    61
      *features |= mask;
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    62
    }
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    63
  }
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    64
25949
34557722059b 6424123: JVM crashes on failed 'strdup' call
zgu
parents: 24953
diff changeset
    65
  os::free(buf);
2253
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    66
}
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    67
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
int VM_Version::platform_features(int features) {
2253
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    69
  // getisax(2), SI_ARCHITECTURE_32, and SI_ARCHITECTURE_64 are
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    70
  // supported on Solaris 10 and later.
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    71
  if (os::Solaris::supports_getisax()) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
2253
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    73
    // Check 32-bit architecture.
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    74
    do_sysinfo(SI_ARCHITECTURE_32, "sparc", &features, v8_instructions_m);
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    75
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    76
    // Check 64-bit architecture.
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    77
    do_sysinfo(SI_ARCHITECTURE_64, "sparcv9", &features, generic_v9_m);
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    78
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    79
    // Extract valid instruction set extensions.
22554
a19b9cf9ffa8 8031290: Adjust call to getisax() for additional words returned
jmasa
parents: 22505
diff changeset
    80
    uint_t avs[2];
a19b9cf9ffa8 8031290: Adjust call to getisax() for additional words returned
jmasa
parents: 22505
diff changeset
    81
    uint_t avn = os::Solaris::getisax(avs, 2);
a19b9cf9ffa8 8031290: Adjust call to getisax() for additional words returned
jmasa
parents: 22505
diff changeset
    82
    assert(avn <= 2, "should return two or less av's");
a19b9cf9ffa8 8031290: Adjust call to getisax() for additional words returned
jmasa
parents: 22505
diff changeset
    83
    uint_t av = avs[0];
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
7115
32300e243300 6987135: Performance regression on Intel platform with 32-bits edition between 6u13 and 6u14.
kvn
parents: 5547
diff changeset
    85
#ifndef PRODUCT
22554
a19b9cf9ffa8 8031290: Adjust call to getisax() for additional words returned
jmasa
parents: 22505
diff changeset
    86
    if (PrintMiscellaneous && Verbose) {
a19b9cf9ffa8 8031290: Adjust call to getisax() for additional words returned
jmasa
parents: 22505
diff changeset
    87
      tty->print("getisax(2) returned: " PTR32_FORMAT, av);
a19b9cf9ffa8 8031290: Adjust call to getisax() for additional words returned
jmasa
parents: 22505
diff changeset
    88
      if (avn > 1) {
a19b9cf9ffa8 8031290: Adjust call to getisax() for additional words returned
jmasa
parents: 22505
diff changeset
    89
        tty->print(", " PTR32_FORMAT, avs[1]);
a19b9cf9ffa8 8031290: Adjust call to getisax() for additional words returned
jmasa
parents: 22505
diff changeset
    90
      }
a19b9cf9ffa8 8031290: Adjust call to getisax() for additional words returned
jmasa
parents: 22505
diff changeset
    91
      tty->cr();
a19b9cf9ffa8 8031290: Adjust call to getisax() for additional words returned
jmasa
parents: 22505
diff changeset
    92
    }
7115
32300e243300 6987135: Performance regression on Intel platform with 32-bits edition between 6u13 and 6u14.
kvn
parents: 5547
diff changeset
    93
#endif
32300e243300 6987135: Performance regression on Intel platform with 32-bits edition between 6u13 and 6u14.
kvn
parents: 5547
diff changeset
    94
2253
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    95
    if (av & AV_SPARC_MUL32)  features |= hardware_mul32_m;
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    96
    if (av & AV_SPARC_DIV32)  features |= hardware_div32_m;
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    97
    if (av & AV_SPARC_FSMULD) features |= hardware_fsmuld_m;
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    98
    if (av & AV_SPARC_V8PLUS) features |= v9_instructions_m;
2255
54abdf3e1055 6378821: bitCount() should use POPC on SPARC processors and AMD+10h
twisti
parents: 2253
diff changeset
    99
    if (av & AV_SPARC_POPC)   features |= hardware_popc_m;
2253
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   100
    if (av & AV_SPARC_VIS)    features |= vis1_instructions_m;
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   101
    if (av & AV_SPARC_VIS2)   features |= vis2_instructions_m;
22554
a19b9cf9ffa8 8031290: Adjust call to getisax() for additional words returned
jmasa
parents: 22505
diff changeset
   102
    if (avn > 1) {
a19b9cf9ffa8 8031290: Adjust call to getisax() for additional words returned
jmasa
parents: 22505
diff changeset
   103
      uint_t av2 = avs[1];
a19b9cf9ffa8 8031290: Adjust call to getisax() for additional words returned
jmasa
parents: 22505
diff changeset
   104
#ifndef AV2_SPARC_SPARC5
a19b9cf9ffa8 8031290: Adjust call to getisax() for additional words returned
jmasa
parents: 22505
diff changeset
   105
#define AV2_SPARC_SPARC5 0x00000008 /* The 29 new fp and sub instructions */
a19b9cf9ffa8 8031290: Adjust call to getisax() for additional words returned
jmasa
parents: 22505
diff changeset
   106
#endif
a19b9cf9ffa8 8031290: Adjust call to getisax() for additional words returned
jmasa
parents: 22505
diff changeset
   107
      if (av2 & AV2_SPARC_SPARC5)       features |= sparc5_instructions_m;
a19b9cf9ffa8 8031290: Adjust call to getisax() for additional words returned
jmasa
parents: 22505
diff changeset
   108
    }
7115
32300e243300 6987135: Performance regression on Intel platform with 32-bits edition between 6u13 and 6u14.
kvn
parents: 5547
diff changeset
   109
32300e243300 6987135: Performance regression on Intel platform with 32-bits edition between 6u13 and 6u14.
kvn
parents: 5547
diff changeset
   110
    // Next values are not defined before Solaris 10
32300e243300 6987135: Performance regression on Intel platform with 32-bits edition between 6u13 and 6u14.
kvn
parents: 5547
diff changeset
   111
    // but Solaris 8 is used for jdk6 update builds.
32300e243300 6987135: Performance regression on Intel platform with 32-bits edition between 6u13 and 6u14.
kvn
parents: 5547
diff changeset
   112
#ifndef AV_SPARC_ASI_BLK_INIT
32300e243300 6987135: Performance regression on Intel platform with 32-bits edition between 6u13 and 6u14.
kvn
parents: 5547
diff changeset
   113
#define AV_SPARC_ASI_BLK_INIT 0x0080  /* ASI_BLK_INIT_xxx ASI */
32300e243300 6987135: Performance regression on Intel platform with 32-bits edition between 6u13 and 6u14.
kvn
parents: 5547
diff changeset
   114
#endif
7704
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   115
    if (av & AV_SPARC_ASI_BLK_INIT) features |= blk_init_instructions_m;
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   116
7115
32300e243300 6987135: Performance regression on Intel platform with 32-bits edition between 6u13 and 6u14.
kvn
parents: 5547
diff changeset
   117
#ifndef AV_SPARC_FMAF
7704
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   118
#define AV_SPARC_FMAF 0x0100        /* Fused Multiply-Add */
7115
32300e243300 6987135: Performance regression on Intel platform with 32-bits edition between 6u13 and 6u14.
kvn
parents: 5547
diff changeset
   119
#endif
32300e243300 6987135: Performance regression on Intel platform with 32-bits edition between 6u13 and 6u14.
kvn
parents: 5547
diff changeset
   120
    if (av & AV_SPARC_FMAF)         features |= fmaf_instructions_m;
7704
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   121
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   122
#ifndef AV_SPARC_FMAU
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   123
#define    AV_SPARC_FMAU    0x0200  /* Unfused Multiply-Add */
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   124
#endif
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   125
    if (av & AV_SPARC_FMAU)         features |= fmau_instructions_m;
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   126
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   127
#ifndef AV_SPARC_VIS3
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   128
#define    AV_SPARC_VIS3    0x0400  /* VIS3 instruction set extensions */
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   129
#endif
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   130
    if (av & AV_SPARC_VIS3)         features |= vis3_instructions_m;
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   131
10252
0981ce1c3eef 7063628: Use cbcond on T4
kvn
parents: 8317
diff changeset
   132
#ifndef AV_SPARC_CBCOND
0981ce1c3eef 7063628: Use cbcond on T4
kvn
parents: 8317
diff changeset
   133
#define AV_SPARC_CBCOND 0x10000000  /* compare and branch instrs supported */
0981ce1c3eef 7063628: Use cbcond on T4
kvn
parents: 8317
diff changeset
   134
#endif
0981ce1c3eef 7063628: Use cbcond on T4
kvn
parents: 8317
diff changeset
   135
    if (av & AV_SPARC_CBCOND)       features |= cbcond_instructions_m;
0981ce1c3eef 7063628: Use cbcond on T4
kvn
parents: 8317
diff changeset
   136
22505
4523090c9674 8002074: Support for AES on SPARC
kvn
parents: 13963
diff changeset
   137
#ifndef AV_SPARC_AES
4523090c9674 8002074: Support for AES on SPARC
kvn
parents: 13963
diff changeset
   138
#define AV_SPARC_AES 0x00020000  /* aes instrs supported */
4523090c9674 8002074: Support for AES on SPARC
kvn
parents: 13963
diff changeset
   139
#endif
4523090c9674 8002074: Support for AES on SPARC
kvn
parents: 13963
diff changeset
   140
    if (av & AV_SPARC_AES)       features |= aes_instructions_m;
4523090c9674 8002074: Support for AES on SPARC
kvn
parents: 13963
diff changeset
   141
24953
9680119572be 8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents: 22554
diff changeset
   142
#ifndef AV_SPARC_SHA1
9680119572be 8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents: 22554
diff changeset
   143
#define AV_SPARC_SHA1   0x00400000  /* sha1 instruction supported */
9680119572be 8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents: 22554
diff changeset
   144
#endif
9680119572be 8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents: 22554
diff changeset
   145
    if (av & AV_SPARC_SHA1)         features |= sha1_instruction_m;
9680119572be 8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents: 22554
diff changeset
   146
9680119572be 8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents: 22554
diff changeset
   147
#ifndef AV_SPARC_SHA256
9680119572be 8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents: 22554
diff changeset
   148
#define AV_SPARC_SHA256 0x00800000  /* sha256 instruction supported */
9680119572be 8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents: 22554
diff changeset
   149
#endif
9680119572be 8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents: 22554
diff changeset
   150
    if (av & AV_SPARC_SHA256)       features |= sha256_instruction_m;
9680119572be 8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents: 22554
diff changeset
   151
9680119572be 8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents: 22554
diff changeset
   152
#ifndef AV_SPARC_SHA512
9680119572be 8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents: 22554
diff changeset
   153
#define AV_SPARC_SHA512 0x01000000  /* sha512 instruction supported */
9680119572be 8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents: 22554
diff changeset
   154
#endif
9680119572be 8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents: 22554
diff changeset
   155
    if (av & AV_SPARC_SHA512)       features |= sha512_instruction_m;
9680119572be 8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents: 22554
diff changeset
   156
2253
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   157
  } else {
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   158
    // getisax(2) failed, use the old legacy code.
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   159
#ifndef PRODUCT
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   160
    if (PrintMiscellaneous && Verbose)
7115
32300e243300 6987135: Performance regression on Intel platform with 32-bits edition between 6u13 and 6u14.
kvn
parents: 5547
diff changeset
   161
      tty->print_cr("getisax(2) is not supported.");
2253
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   162
#endif
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   163
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   164
    char   tmp;
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   165
    size_t bufsize = sysinfo(SI_ISALIST, &tmp, 1);
25949
34557722059b 6424123: JVM crashes on failed 'strdup' call
zgu
parents: 24953
diff changeset
   166
    char*  buf     = (char*) os::malloc(bufsize, mtInternal);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
2253
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   168
    if (buf != NULL) {
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   169
      if (sysinfo(SI_ISALIST, buf, bufsize) == bufsize) {
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   170
        // Figure out what kind of sparc we have
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   171
        char *sparc_string = strstr(buf, "sparc");
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   172
        if (sparc_string != NULL) {              features |= v8_instructions_m;
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   173
          if (sparc_string[5] == 'v') {
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   174
            if (sparc_string[6] == '8') {
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   175
              if (sparc_string[7] == '-') {      features |= hardware_mul32_m;
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   176
                                                 features |= hardware_div32_m;
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   177
              } else if (sparc_string[7] == 'p') features |= generic_v9_m;
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   178
              else                               features |= generic_v8_m;
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   179
            } else if (sparc_string[6] == '9')   features |= generic_v9_m;
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   180
          }
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   181
        }
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   182
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   183
        // Check for visualization instructions
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   184
        char *vis = strstr(buf, "vis");
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   185
        if (vis != NULL) {                       features |= vis1_instructions_m;
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   186
          if (vis[3] == '2')                     features |= vis2_instructions_m;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
      }
25949
34557722059b 6424123: JVM crashes on failed 'strdup' call
zgu
parents: 24953
diff changeset
   189
      os::free(buf);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
2253
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   193
  // Determine the machine type.
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   194
  do_sysinfo(SI_MACHINE, "sun4v", &features, sun4v_m);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
7704
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   196
  {
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   197
    // Using kstat to determine the machine type.
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   198
    kstat_ctl_t* kc = kstat_open();
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   199
    kstat_t* ksp = kstat_lookup(kc, (char*)"cpu_info", -1, NULL);
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   200
    const char* implementation = "UNKNOWN";
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   201
    if (ksp != NULL) {
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   202
      if (kstat_read(kc, ksp, NULL) != -1 && ksp->ks_data != NULL) {
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   203
        kstat_named_t* knm = (kstat_named_t *)ksp->ks_data;
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   204
        for (int i = 0; i < ksp->ks_ndata; i++) {
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   205
          if (strcmp((const char*)&(knm[i].name),"implementation") == 0) {
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   206
#ifndef KSTAT_DATA_STRING
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   207
#define KSTAT_DATA_STRING   9
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   208
#endif
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   209
            if (knm[i].data_type == KSTAT_DATA_CHAR) {
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   210
              // VM is running on Solaris 8 which does not have value.str.
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   211
              implementation = &(knm[i].value.c[0]);
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   212
            } else if (knm[i].data_type == KSTAT_DATA_STRING) {
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   213
              // VM is running on Solaris 10.
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   214
#ifndef KSTAT_NAMED_STR_PTR
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   215
              // Solaris 8 was used to build VM, define the structure it misses.
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   216
              struct str_t {
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   217
                union {
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   218
                  char *ptr;     /* NULL-term string */
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   219
                  char __pad[8]; /* 64-bit padding */
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   220
                } addr;
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   221
                uint32_t len;    /* # bytes for strlen + '\0' */
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   222
              };
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   223
#define KSTAT_NAMED_STR_PTR(knptr) (( (str_t*)&((knptr)->value) )->addr.ptr)
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   224
#endif
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   225
              implementation = KSTAT_NAMED_STR_PTR(&knm[i]);
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   226
            }
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   227
#ifndef PRODUCT
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   228
            if (PrintMiscellaneous && Verbose) {
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   229
              tty->print_cr("cpu_info.implementation: %s", implementation);
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   230
            }
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   231
#endif
8317
34de38f6de90 7014998: assert(is_T_family(features) == is_niagara(features)) failed: Niagara should be T series
kvn
parents: 7704
diff changeset
   232
            // Convert to UPPER case before compare.
25949
34557722059b 6424123: JVM crashes on failed 'strdup' call
zgu
parents: 24953
diff changeset
   233
            char* impl = os::strdup_check_oom(implementation);
8317
34de38f6de90 7014998: assert(is_T_family(features) == is_niagara(features)) failed: Niagara should be T series
kvn
parents: 7704
diff changeset
   234
34de38f6de90 7014998: assert(is_T_family(features) == is_niagara(features)) failed: Niagara should be T series
kvn
parents: 7704
diff changeset
   235
            for (int i = 0; impl[i] != 0; i++)
34de38f6de90 7014998: assert(is_T_family(features) == is_niagara(features)) failed: Niagara should be T series
kvn
parents: 7704
diff changeset
   236
              impl[i] = (char)toupper((uint)impl[i]);
34de38f6de90 7014998: assert(is_T_family(features) == is_niagara(features)) failed: Niagara should be T series
kvn
parents: 7704
diff changeset
   237
            if (strstr(impl, "SPARC64") != NULL) {
7704
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   238
              features |= sparc64_family_m;
13394
930691003b55 7188227: VM should recognize M-series SPARC
kvn
parents: 10252
diff changeset
   239
            } else if (strstr(impl, "SPARC-M") != NULL) {
930691003b55 7188227: VM should recognize M-series SPARC
kvn
parents: 10252
diff changeset
   240
              // M-series SPARC is based on T-series.
930691003b55 7188227: VM should recognize M-series SPARC
kvn
parents: 10252
diff changeset
   241
              features |= (M_family_m | T_family_m);
8317
34de38f6de90 7014998: assert(is_T_family(features) == is_niagara(features)) failed: Niagara should be T series
kvn
parents: 7704
diff changeset
   242
            } else if (strstr(impl, "SPARC-T") != NULL) {
7704
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   243
              features |= T_family_m;
8317
34de38f6de90 7014998: assert(is_T_family(features) == is_niagara(features)) failed: Niagara should be T series
kvn
parents: 7704
diff changeset
   244
              if (strstr(impl, "SPARC-T1") != NULL) {
7704
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   245
                features |= T1_model_m;
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   246
              }
8317
34de38f6de90 7014998: assert(is_T_family(features) == is_niagara(features)) failed: Niagara should be T series
kvn
parents: 7704
diff changeset
   247
            } else {
13394
930691003b55 7188227: VM should recognize M-series SPARC
kvn
parents: 10252
diff changeset
   248
              if (strstr(impl, "SPARC") == NULL) {
930691003b55 7188227: VM should recognize M-series SPARC
kvn
parents: 10252
diff changeset
   249
#ifndef PRODUCT
930691003b55 7188227: VM should recognize M-series SPARC
kvn
parents: 10252
diff changeset
   250
                // kstat on Solaris 8 virtual machines (branded zones)
930691003b55 7188227: VM should recognize M-series SPARC
kvn
parents: 10252
diff changeset
   251
                // returns "(unsupported)" implementation.
930691003b55 7188227: VM should recognize M-series SPARC
kvn
parents: 10252
diff changeset
   252
                warning("kstat cpu_info implementation = '%s', should contain SPARC", impl);
930691003b55 7188227: VM should recognize M-series SPARC
kvn
parents: 10252
diff changeset
   253
#endif
930691003b55 7188227: VM should recognize M-series SPARC
kvn
parents: 10252
diff changeset
   254
                implementation = "SPARC";
930691003b55 7188227: VM should recognize M-series SPARC
kvn
parents: 10252
diff changeset
   255
              }
7704
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   256
            }
25949
34557722059b 6424123: JVM crashes on failed 'strdup' call
zgu
parents: 24953
diff changeset
   257
            os::free((void*)impl);
7704
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   258
            break;
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   259
          }
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   260
        } // for(
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   261
      }
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   262
    }
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   263
    assert(strcmp(implementation, "UNKNOWN") != 0,
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   264
           "unknown cpu info (changed kstat interface?)");
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   265
    kstat_close(kc);
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   266
  }
cc9d3ed42704 7006505: Use kstat info to identify SPARC processor
kvn
parents: 7397
diff changeset
   267
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
  return features;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
}