hotspot/src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp
author trims
Thu, 27 May 2010 19:08:38 -0700
changeset 5547 f4b087cbb361
parent 2255 54abdf3e1055
child 7115 32300e243300
permissions -rw-r--r--
6941466: Oracle rebranding changes for Hotspot repositories Summary: Change all the Sun copyrights to Oracle copyright Reviewed-by: ohair
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2255
diff changeset
     2
 * Copyright (c) 2006, 2009, 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
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
# include "incls/_precompiled.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
# include "incls/_vm_version_solaris_sparc.cpp.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
2253
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    28
# include <sys/auxv.h>
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    29
# include <sys/auxv_SPARC.h>
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
# include <sys/systeminfo.h>
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
2253
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    32
// 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
    33
// versions before 10.
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    34
#ifndef SI_ARCHITECTURE_32
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    35
#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
    36
#endif
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    37
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    38
#ifndef SI_ARCHITECTURE_64
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    39
#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
    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
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
    43
  char   tmp;
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    44
  size_t bufsize = sysinfo(si, &tmp, 1);
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
  // All SI defines used below must be supported.
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    47
  guarantee(bufsize != -1, "must be supported");
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    48
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    49
  char* buf = (char*) malloc(bufsize);
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    50
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    51
  if (buf == NULL)
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    52
    return;
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    53
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    54
  if (sysinfo(si, buf, bufsize) == bufsize) {
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    55
    // Compare the string.
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    56
    if (strcmp(buf, string) == 0) {
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    57
      *features |= mask;
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    58
    }
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    59
  }
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    60
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    61
  free(buf);
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
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
int VM_Version::platform_features(int features) {
2253
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    65
  // 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
    66
  // supported on Solaris 10 and later.
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    67
  if (os::Solaris::supports_getisax()) {
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    68
#ifndef PRODUCT
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    69
    if (PrintMiscellaneous && Verbose)
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    70
      tty->print_cr("getisax(2) supported.");
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    71
#endif
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.
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    80
    uint_t av;
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    81
    uint_t avn = os::Solaris::getisax(&av, 1);
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    82
    assert(avn == 1, "should only return one av");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
2253
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    84
    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
    85
    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
    86
    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
    87
    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
    88
    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
    89
    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
    90
    if (av & AV_SPARC_VIS2)   features |= vis2_instructions_m;
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    91
  } else {
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    92
    // getisax(2) failed, use the old legacy code.
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    93
#ifndef PRODUCT
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    94
    if (PrintMiscellaneous && Verbose)
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    95
      tty->print_cr("getisax(2) not supported.");
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    96
#endif
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    97
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    98
    char   tmp;
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
    99
    size_t bufsize = sysinfo(SI_ISALIST, &tmp, 1);
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   100
    char*  buf     = (char*) malloc(bufsize);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
2253
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   102
    if (buf != NULL) {
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   103
      if (sysinfo(SI_ISALIST, buf, bufsize) == bufsize) {
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   104
        // Figure out what kind of sparc we have
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   105
        char *sparc_string = strstr(buf, "sparc");
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   106
        if (sparc_string != NULL) {              features |= v8_instructions_m;
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   107
          if (sparc_string[5] == 'v') {
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   108
            if (sparc_string[6] == '8') {
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   109
              if (sparc_string[7] == '-') {      features |= hardware_mul32_m;
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   110
                                                 features |= hardware_div32_m;
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   111
              } 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
   112
              else                               features |= generic_v8_m;
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   113
            } 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
   114
          }
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   115
        }
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   116
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   117
        // Check for visualization instructions
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   118
        char *vis = strstr(buf, "vis");
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   119
        if (vis != NULL) {                       features |= vis1_instructions_m;
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   120
          if (vis[3] == '2')                     features |= vis2_instructions_m;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
      }
2253
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   123
      free(buf);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
2253
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   127
  // Determine the machine type.
30268d00878e 6812587: Use auxv to determine SPARC hardware features on Solaris
twisti
parents: 1
diff changeset
   128
  do_sysinfo(SI_MACHINE, "sun4v", &features, sun4v_m);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  return features;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
}