src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp

Tue, 23 Nov 2010 13:22:55 -0800

author
stefank
date
Tue, 23 Nov 2010 13:22:55 -0800
changeset 2314
f95d63e2154a
parent 2269
ae065c367d93
child 2403
c04052fd6ae1
permissions
-rw-r--r--

6989984: Use standard include model for Hospot
Summary: Replaced MakeDeps and the includeDB files with more standardized solutions.
Reviewed-by: coleenp, kvn, kamg

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>
duke@435 32
twisti@1076 33 // We need to keep these here as long as we have to build on Solaris
twisti@1076 34 // versions before 10.
twisti@1076 35 #ifndef SI_ARCHITECTURE_32
twisti@1076 36 #define SI_ARCHITECTURE_32 516 /* basic 32-bit SI_ARCHITECTURE */
twisti@1076 37 #endif
twisti@1076 38
twisti@1076 39 #ifndef SI_ARCHITECTURE_64
twisti@1076 40 #define SI_ARCHITECTURE_64 517 /* basic 64-bit SI_ARCHITECTURE */
twisti@1076 41 #endif
twisti@1076 42
twisti@1076 43 static void do_sysinfo(int si, const char* string, int* features, int mask) {
twisti@1076 44 char tmp;
twisti@1076 45 size_t bufsize = sysinfo(si, &tmp, 1);
twisti@1076 46
twisti@1076 47 // All SI defines used below must be supported.
twisti@1076 48 guarantee(bufsize != -1, "must be supported");
twisti@1076 49
twisti@1076 50 char* buf = (char*) malloc(bufsize);
twisti@1076 51
twisti@1076 52 if (buf == NULL)
twisti@1076 53 return;
twisti@1076 54
twisti@1076 55 if (sysinfo(si, buf, bufsize) == bufsize) {
twisti@1076 56 // Compare the string.
twisti@1076 57 if (strcmp(buf, string) == 0) {
twisti@1076 58 *features |= mask;
twisti@1076 59 }
twisti@1076 60 }
twisti@1076 61
twisti@1076 62 free(buf);
twisti@1076 63 }
twisti@1076 64
duke@435 65 int VM_Version::platform_features(int features) {
twisti@1076 66 // getisax(2), SI_ARCHITECTURE_32, and SI_ARCHITECTURE_64 are
twisti@1076 67 // supported on Solaris 10 and later.
twisti@1076 68 if (os::Solaris::supports_getisax()) {
duke@435 69
twisti@1076 70 // Check 32-bit architecture.
twisti@1076 71 do_sysinfo(SI_ARCHITECTURE_32, "sparc", &features, v8_instructions_m);
duke@435 72
twisti@1076 73 // Check 64-bit architecture.
twisti@1076 74 do_sysinfo(SI_ARCHITECTURE_64, "sparcv9", &features, generic_v9_m);
duke@435 75
twisti@1076 76 // Extract valid instruction set extensions.
twisti@1076 77 uint_t av;
twisti@1076 78 uint_t avn = os::Solaris::getisax(&av, 1);
twisti@1076 79 assert(avn == 1, "should only return one av");
twisti@1076 80
kvn@2269 81 #ifndef PRODUCT
kvn@2269 82 if (PrintMiscellaneous && Verbose)
kvn@2269 83 tty->print_cr("getisax(2) returned: " PTR32_FORMAT, av);
kvn@2269 84 #endif
kvn@2269 85
twisti@1076 86 if (av & AV_SPARC_MUL32) features |= hardware_mul32_m;
twisti@1076 87 if (av & AV_SPARC_DIV32) features |= hardware_div32_m;
twisti@1076 88 if (av & AV_SPARC_FSMULD) features |= hardware_fsmuld_m;
twisti@1076 89 if (av & AV_SPARC_V8PLUS) features |= v9_instructions_m;
twisti@1078 90 if (av & AV_SPARC_POPC) features |= hardware_popc_m;
twisti@1076 91 if (av & AV_SPARC_VIS) features |= vis1_instructions_m;
twisti@1076 92 if (av & AV_SPARC_VIS2) features |= vis2_instructions_m;
kvn@2269 93
kvn@2269 94 // Next values are not defined before Solaris 10
kvn@2269 95 // but Solaris 8 is used for jdk6 update builds.
kvn@2269 96 #ifndef AV_SPARC_ASI_BLK_INIT
kvn@2269 97 #define AV_SPARC_ASI_BLK_INIT 0x0080 /* ASI_BLK_INIT_xxx ASI */
kvn@2269 98 #endif
kvn@2269 99 #ifndef AV_SPARC_FMAF
kvn@2269 100 #define AV_SPARC_FMAF 0x0100 /* Sparc64 Fused Multiply-Add */
kvn@2269 101 #endif
kvn@2269 102 if (av & AV_SPARC_ASI_BLK_INIT) features |= blk_init_instructions_m;
kvn@2269 103 if (av & AV_SPARC_FMAF) features |= fmaf_instructions_m;
twisti@1076 104 } else {
twisti@1076 105 // getisax(2) failed, use the old legacy code.
twisti@1076 106 #ifndef PRODUCT
twisti@1076 107 if (PrintMiscellaneous && Verbose)
kvn@2269 108 tty->print_cr("getisax(2) is not supported.");
twisti@1076 109 #endif
twisti@1076 110
twisti@1076 111 char tmp;
twisti@1076 112 size_t bufsize = sysinfo(SI_ISALIST, &tmp, 1);
twisti@1076 113 char* buf = (char*) malloc(bufsize);
twisti@1076 114
twisti@1076 115 if (buf != NULL) {
twisti@1076 116 if (sysinfo(SI_ISALIST, buf, bufsize) == bufsize) {
twisti@1076 117 // Figure out what kind of sparc we have
twisti@1076 118 char *sparc_string = strstr(buf, "sparc");
twisti@1076 119 if (sparc_string != NULL) { features |= v8_instructions_m;
twisti@1076 120 if (sparc_string[5] == 'v') {
twisti@1076 121 if (sparc_string[6] == '8') {
twisti@1076 122 if (sparc_string[7] == '-') { features |= hardware_mul32_m;
twisti@1076 123 features |= hardware_div32_m;
twisti@1076 124 } else if (sparc_string[7] == 'p') features |= generic_v9_m;
twisti@1076 125 else features |= generic_v8_m;
twisti@1076 126 } else if (sparc_string[6] == '9') features |= generic_v9_m;
twisti@1076 127 }
twisti@1076 128 }
twisti@1076 129
twisti@1076 130 // Check for visualization instructions
twisti@1076 131 char *vis = strstr(buf, "vis");
twisti@1076 132 if (vis != NULL) { features |= vis1_instructions_m;
twisti@1076 133 if (vis[3] == '2') features |= vis2_instructions_m;
duke@435 134 }
duke@435 135 }
twisti@1076 136 free(buf);
duke@435 137 }
duke@435 138 }
duke@435 139
twisti@1076 140 // Determine the machine type.
twisti@1076 141 do_sysinfo(SI_MACHINE, "sun4v", &features, sun4v_m);
duke@435 142
duke@435 143 return features;
duke@435 144 }

mercurial