src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp

Tue, 01 Feb 2011 11:23:19 -0500

author
coleenp
date
Tue, 01 Feb 2011 11:23:19 -0500
changeset 2507
d70fe6ab4436
parent 2403
c04052fd6ae1
child 2554
c52cba2a3359
permissions
-rw-r--r--

6588413: Use -fvisibility=hidden for gcc compiles
Summary: Add option for gcc 4 and above, define JNIEXPORT and JNIIMPORT to visibility=default, add for jio_snprintf and others since -fvisibility=hidden overrides --version-script definitions.
Reviewed-by: kamg, never

duke@435 1 /*
kvn@2269 2 * Copyright (c) 2006, 2010, 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
stefank@2314 25 #include "precompiled.hpp"
stefank@2314 26 #include "runtime/os.hpp"
stefank@2314 27 #include "vm_version_sparc.hpp"
duke@435 28
twisti@1076 29 # include <sys/auxv.h>
twisti@1076 30 # include <sys/auxv_SPARC.h>
duke@435 31 # include <sys/systeminfo.h>
kvn@2403 32 # include <kstat.h>
duke@435 33
twisti@1076 34 // We need to keep these here as long as we have to build on Solaris
twisti@1076 35 // versions before 10.
twisti@1076 36 #ifndef SI_ARCHITECTURE_32
twisti@1076 37 #define SI_ARCHITECTURE_32 516 /* basic 32-bit SI_ARCHITECTURE */
twisti@1076 38 #endif
twisti@1076 39
twisti@1076 40 #ifndef SI_ARCHITECTURE_64
twisti@1076 41 #define SI_ARCHITECTURE_64 517 /* basic 64-bit SI_ARCHITECTURE */
twisti@1076 42 #endif
twisti@1076 43
twisti@1076 44 static void do_sysinfo(int si, const char* string, int* features, int mask) {
twisti@1076 45 char tmp;
twisti@1076 46 size_t bufsize = sysinfo(si, &tmp, 1);
twisti@1076 47
twisti@1076 48 // All SI defines used below must be supported.
twisti@1076 49 guarantee(bufsize != -1, "must be supported");
twisti@1076 50
twisti@1076 51 char* buf = (char*) malloc(bufsize);
twisti@1076 52
twisti@1076 53 if (buf == NULL)
twisti@1076 54 return;
twisti@1076 55
twisti@1076 56 if (sysinfo(si, buf, bufsize) == bufsize) {
twisti@1076 57 // Compare the string.
twisti@1076 58 if (strcmp(buf, string) == 0) {
twisti@1076 59 *features |= mask;
twisti@1076 60 }
twisti@1076 61 }
twisti@1076 62
twisti@1076 63 free(buf);
twisti@1076 64 }
twisti@1076 65
duke@435 66 int VM_Version::platform_features(int features) {
twisti@1076 67 // getisax(2), SI_ARCHITECTURE_32, and SI_ARCHITECTURE_64 are
twisti@1076 68 // supported on Solaris 10 and later.
twisti@1076 69 if (os::Solaris::supports_getisax()) {
duke@435 70
twisti@1076 71 // Check 32-bit architecture.
twisti@1076 72 do_sysinfo(SI_ARCHITECTURE_32, "sparc", &features, v8_instructions_m);
duke@435 73
twisti@1076 74 // Check 64-bit architecture.
twisti@1076 75 do_sysinfo(SI_ARCHITECTURE_64, "sparcv9", &features, generic_v9_m);
duke@435 76
twisti@1076 77 // Extract valid instruction set extensions.
twisti@1076 78 uint_t av;
twisti@1076 79 uint_t avn = os::Solaris::getisax(&av, 1);
twisti@1076 80 assert(avn == 1, "should only return one av");
twisti@1076 81
kvn@2269 82 #ifndef PRODUCT
kvn@2269 83 if (PrintMiscellaneous && Verbose)
kvn@2269 84 tty->print_cr("getisax(2) returned: " PTR32_FORMAT, av);
kvn@2269 85 #endif
kvn@2269 86
twisti@1076 87 if (av & AV_SPARC_MUL32) features |= hardware_mul32_m;
twisti@1076 88 if (av & AV_SPARC_DIV32) features |= hardware_div32_m;
twisti@1076 89 if (av & AV_SPARC_FSMULD) features |= hardware_fsmuld_m;
twisti@1076 90 if (av & AV_SPARC_V8PLUS) features |= v9_instructions_m;
twisti@1078 91 if (av & AV_SPARC_POPC) features |= hardware_popc_m;
twisti@1076 92 if (av & AV_SPARC_VIS) features |= vis1_instructions_m;
twisti@1076 93 if (av & AV_SPARC_VIS2) features |= vis2_instructions_m;
kvn@2269 94
kvn@2269 95 // Next values are not defined before Solaris 10
kvn@2269 96 // but Solaris 8 is used for jdk6 update builds.
kvn@2269 97 #ifndef AV_SPARC_ASI_BLK_INIT
kvn@2269 98 #define AV_SPARC_ASI_BLK_INIT 0x0080 /* ASI_BLK_INIT_xxx ASI */
kvn@2269 99 #endif
kvn@2403 100 if (av & AV_SPARC_ASI_BLK_INIT) features |= blk_init_instructions_m;
kvn@2403 101
kvn@2269 102 #ifndef AV_SPARC_FMAF
kvn@2403 103 #define AV_SPARC_FMAF 0x0100 /* Fused Multiply-Add */
kvn@2269 104 #endif
kvn@2269 105 if (av & AV_SPARC_FMAF) features |= fmaf_instructions_m;
kvn@2403 106
kvn@2403 107 #ifndef AV_SPARC_FMAU
kvn@2403 108 #define AV_SPARC_FMAU 0x0200 /* Unfused Multiply-Add */
kvn@2403 109 #endif
kvn@2403 110 if (av & AV_SPARC_FMAU) features |= fmau_instructions_m;
kvn@2403 111
kvn@2403 112 #ifndef AV_SPARC_VIS3
kvn@2403 113 #define AV_SPARC_VIS3 0x0400 /* VIS3 instruction set extensions */
kvn@2403 114 #endif
kvn@2403 115 if (av & AV_SPARC_VIS3) features |= vis3_instructions_m;
kvn@2403 116
twisti@1076 117 } else {
twisti@1076 118 // getisax(2) failed, use the old legacy code.
twisti@1076 119 #ifndef PRODUCT
twisti@1076 120 if (PrintMiscellaneous && Verbose)
kvn@2269 121 tty->print_cr("getisax(2) is not supported.");
twisti@1076 122 #endif
twisti@1076 123
twisti@1076 124 char tmp;
twisti@1076 125 size_t bufsize = sysinfo(SI_ISALIST, &tmp, 1);
twisti@1076 126 char* buf = (char*) malloc(bufsize);
twisti@1076 127
twisti@1076 128 if (buf != NULL) {
twisti@1076 129 if (sysinfo(SI_ISALIST, buf, bufsize) == bufsize) {
twisti@1076 130 // Figure out what kind of sparc we have
twisti@1076 131 char *sparc_string = strstr(buf, "sparc");
twisti@1076 132 if (sparc_string != NULL) { features |= v8_instructions_m;
twisti@1076 133 if (sparc_string[5] == 'v') {
twisti@1076 134 if (sparc_string[6] == '8') {
twisti@1076 135 if (sparc_string[7] == '-') { features |= hardware_mul32_m;
twisti@1076 136 features |= hardware_div32_m;
twisti@1076 137 } else if (sparc_string[7] == 'p') features |= generic_v9_m;
twisti@1076 138 else features |= generic_v8_m;
twisti@1076 139 } else if (sparc_string[6] == '9') features |= generic_v9_m;
twisti@1076 140 }
twisti@1076 141 }
twisti@1076 142
twisti@1076 143 // Check for visualization instructions
twisti@1076 144 char *vis = strstr(buf, "vis");
twisti@1076 145 if (vis != NULL) { features |= vis1_instructions_m;
twisti@1076 146 if (vis[3] == '2') features |= vis2_instructions_m;
duke@435 147 }
duke@435 148 }
twisti@1076 149 free(buf);
duke@435 150 }
duke@435 151 }
duke@435 152
twisti@1076 153 // Determine the machine type.
twisti@1076 154 do_sysinfo(SI_MACHINE, "sun4v", &features, sun4v_m);
duke@435 155
kvn@2403 156 {
kvn@2403 157 // Using kstat to determine the machine type.
kvn@2403 158 kstat_ctl_t* kc = kstat_open();
kvn@2403 159 kstat_t* ksp = kstat_lookup(kc, (char*)"cpu_info", -1, NULL);
kvn@2403 160 const char* implementation = "UNKNOWN";
kvn@2403 161 if (ksp != NULL) {
kvn@2403 162 if (kstat_read(kc, ksp, NULL) != -1 && ksp->ks_data != NULL) {
kvn@2403 163 kstat_named_t* knm = (kstat_named_t *)ksp->ks_data;
kvn@2403 164 for (int i = 0; i < ksp->ks_ndata; i++) {
kvn@2403 165 if (strcmp((const char*)&(knm[i].name),"implementation") == 0) {
kvn@2403 166 #ifndef KSTAT_DATA_STRING
kvn@2403 167 #define KSTAT_DATA_STRING 9
kvn@2403 168 #endif
kvn@2403 169 if (knm[i].data_type == KSTAT_DATA_CHAR) {
kvn@2403 170 // VM is running on Solaris 8 which does not have value.str.
kvn@2403 171 implementation = &(knm[i].value.c[0]);
kvn@2403 172 } else if (knm[i].data_type == KSTAT_DATA_STRING) {
kvn@2403 173 // VM is running on Solaris 10.
kvn@2403 174 #ifndef KSTAT_NAMED_STR_PTR
kvn@2403 175 // Solaris 8 was used to build VM, define the structure it misses.
kvn@2403 176 struct str_t {
kvn@2403 177 union {
kvn@2403 178 char *ptr; /* NULL-term string */
kvn@2403 179 char __pad[8]; /* 64-bit padding */
kvn@2403 180 } addr;
kvn@2403 181 uint32_t len; /* # bytes for strlen + '\0' */
kvn@2403 182 };
kvn@2403 183 #define KSTAT_NAMED_STR_PTR(knptr) (( (str_t*)&((knptr)->value) )->addr.ptr)
kvn@2403 184 #endif
kvn@2403 185 implementation = KSTAT_NAMED_STR_PTR(&knm[i]);
kvn@2403 186 }
kvn@2403 187 #ifndef PRODUCT
kvn@2403 188 if (PrintMiscellaneous && Verbose) {
kvn@2403 189 tty->print_cr("cpu_info.implementation: %s", implementation);
kvn@2403 190 }
kvn@2403 191 #endif
kvn@2403 192 if (strncmp(implementation, "SPARC64", 7) == 0) {
kvn@2403 193 features |= sparc64_family_m;
kvn@2403 194 } else if (strncmp(implementation, "UltraSPARC-T", 12) == 0) {
kvn@2403 195 features |= T_family_m;
kvn@2403 196 if (strncmp(implementation, "UltraSPARC-T1", 13) == 0) {
kvn@2403 197 features |= T1_model_m;
kvn@2403 198 }
kvn@2403 199 }
kvn@2403 200 break;
kvn@2403 201 }
kvn@2403 202 } // for(
kvn@2403 203 }
kvn@2403 204 }
kvn@2403 205 assert(strcmp(implementation, "UNKNOWN") != 0,
kvn@2403 206 "unknown cpu info (changed kstat interface?)");
kvn@2403 207 kstat_close(kc);
kvn@2403 208 }
kvn@2403 209
duke@435 210 return features;
duke@435 211 }

mercurial