src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp

Thu, 21 Oct 2010 11:55:10 -0700

author
never
date
Thu, 21 Oct 2010 11:55:10 -0700
changeset 2262
1e9a9d2e6509
parent 1907
c18cbe5936b8
child 2269
ae065c367d93
permissions
-rw-r--r--

6970683: improvements to hs_err output
Reviewed-by: kvn, jrose, dholmes, coleenp

duke@435 1 /*
trims@1907 2 * Copyright (c) 2006, 2009, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
duke@435 25 # include "incls/_precompiled.incl"
duke@435 26 # include "incls/_vm_version_solaris_sparc.cpp.incl"
duke@435 27
twisti@1076 28 # include <sys/auxv.h>
twisti@1076 29 # include <sys/auxv_SPARC.h>
duke@435 30 # include <sys/systeminfo.h>
duke@435 31
twisti@1076 32 // We need to keep these here as long as we have to build on Solaris
twisti@1076 33 // versions before 10.
twisti@1076 34 #ifndef SI_ARCHITECTURE_32
twisti@1076 35 #define SI_ARCHITECTURE_32 516 /* basic 32-bit SI_ARCHITECTURE */
twisti@1076 36 #endif
twisti@1076 37
twisti@1076 38 #ifndef SI_ARCHITECTURE_64
twisti@1076 39 #define SI_ARCHITECTURE_64 517 /* basic 64-bit SI_ARCHITECTURE */
twisti@1076 40 #endif
twisti@1076 41
twisti@1076 42 static void do_sysinfo(int si, const char* string, int* features, int mask) {
twisti@1076 43 char tmp;
twisti@1076 44 size_t bufsize = sysinfo(si, &tmp, 1);
twisti@1076 45
twisti@1076 46 // All SI defines used below must be supported.
twisti@1076 47 guarantee(bufsize != -1, "must be supported");
twisti@1076 48
twisti@1076 49 char* buf = (char*) malloc(bufsize);
twisti@1076 50
twisti@1076 51 if (buf == NULL)
twisti@1076 52 return;
twisti@1076 53
twisti@1076 54 if (sysinfo(si, buf, bufsize) == bufsize) {
twisti@1076 55 // Compare the string.
twisti@1076 56 if (strcmp(buf, string) == 0) {
twisti@1076 57 *features |= mask;
twisti@1076 58 }
twisti@1076 59 }
twisti@1076 60
twisti@1076 61 free(buf);
twisti@1076 62 }
twisti@1076 63
duke@435 64 int VM_Version::platform_features(int features) {
twisti@1076 65 // getisax(2), SI_ARCHITECTURE_32, and SI_ARCHITECTURE_64 are
twisti@1076 66 // supported on Solaris 10 and later.
twisti@1076 67 if (os::Solaris::supports_getisax()) {
twisti@1076 68 #ifndef PRODUCT
twisti@1076 69 if (PrintMiscellaneous && Verbose)
twisti@1076 70 tty->print_cr("getisax(2) supported.");
twisti@1076 71 #endif
duke@435 72
twisti@1076 73 // Check 32-bit architecture.
twisti@1076 74 do_sysinfo(SI_ARCHITECTURE_32, "sparc", &features, v8_instructions_m);
duke@435 75
twisti@1076 76 // Check 64-bit architecture.
twisti@1076 77 do_sysinfo(SI_ARCHITECTURE_64, "sparcv9", &features, generic_v9_m);
duke@435 78
twisti@1076 79 // Extract valid instruction set extensions.
twisti@1076 80 uint_t av;
twisti@1076 81 uint_t avn = os::Solaris::getisax(&av, 1);
twisti@1076 82 assert(avn == 1, "should only return one av");
twisti@1076 83
twisti@1076 84 if (av & AV_SPARC_MUL32) features |= hardware_mul32_m;
twisti@1076 85 if (av & AV_SPARC_DIV32) features |= hardware_div32_m;
twisti@1076 86 if (av & AV_SPARC_FSMULD) features |= hardware_fsmuld_m;
twisti@1076 87 if (av & AV_SPARC_V8PLUS) features |= v9_instructions_m;
twisti@1078 88 if (av & AV_SPARC_POPC) features |= hardware_popc_m;
twisti@1076 89 if (av & AV_SPARC_VIS) features |= vis1_instructions_m;
twisti@1076 90 if (av & AV_SPARC_VIS2) features |= vis2_instructions_m;
twisti@1076 91 } else {
twisti@1076 92 // getisax(2) failed, use the old legacy code.
twisti@1076 93 #ifndef PRODUCT
twisti@1076 94 if (PrintMiscellaneous && Verbose)
twisti@1076 95 tty->print_cr("getisax(2) not supported.");
twisti@1076 96 #endif
twisti@1076 97
twisti@1076 98 char tmp;
twisti@1076 99 size_t bufsize = sysinfo(SI_ISALIST, &tmp, 1);
twisti@1076 100 char* buf = (char*) malloc(bufsize);
twisti@1076 101
twisti@1076 102 if (buf != NULL) {
twisti@1076 103 if (sysinfo(SI_ISALIST, buf, bufsize) == bufsize) {
twisti@1076 104 // Figure out what kind of sparc we have
twisti@1076 105 char *sparc_string = strstr(buf, "sparc");
twisti@1076 106 if (sparc_string != NULL) { features |= v8_instructions_m;
twisti@1076 107 if (sparc_string[5] == 'v') {
twisti@1076 108 if (sparc_string[6] == '8') {
twisti@1076 109 if (sparc_string[7] == '-') { features |= hardware_mul32_m;
twisti@1076 110 features |= hardware_div32_m;
twisti@1076 111 } else if (sparc_string[7] == 'p') features |= generic_v9_m;
twisti@1076 112 else features |= generic_v8_m;
twisti@1076 113 } else if (sparc_string[6] == '9') features |= generic_v9_m;
twisti@1076 114 }
twisti@1076 115 }
twisti@1076 116
twisti@1076 117 // Check for visualization instructions
twisti@1076 118 char *vis = strstr(buf, "vis");
twisti@1076 119 if (vis != NULL) { features |= vis1_instructions_m;
twisti@1076 120 if (vis[3] == '2') features |= vis2_instructions_m;
duke@435 121 }
duke@435 122 }
twisti@1076 123 free(buf);
duke@435 124 }
duke@435 125 }
duke@435 126
twisti@1076 127 // Determine the machine type.
twisti@1076 128 do_sysinfo(SI_MACHINE, "sun4v", &features, sun4v_m);
duke@435 129
duke@435 130 return features;
duke@435 131 }

mercurial