23 */ |
23 */ |
24 |
24 |
25 # include "incls/_precompiled.incl" |
25 # include "incls/_precompiled.incl" |
26 # include "incls/_vm_version_solaris_sparc.cpp.incl" |
26 # include "incls/_vm_version_solaris_sparc.cpp.incl" |
27 |
27 |
|
28 # include <sys/auxv.h> |
|
29 # include <sys/auxv_SPARC.h> |
28 # include <sys/systeminfo.h> |
30 # include <sys/systeminfo.h> |
29 |
31 |
|
32 // We need to keep these here as long as we have to build on Solaris |
|
33 // versions before 10. |
|
34 #ifndef SI_ARCHITECTURE_32 |
|
35 #define SI_ARCHITECTURE_32 516 /* basic 32-bit SI_ARCHITECTURE */ |
|
36 #endif |
|
37 |
|
38 #ifndef SI_ARCHITECTURE_64 |
|
39 #define SI_ARCHITECTURE_64 517 /* basic 64-bit SI_ARCHITECTURE */ |
|
40 #endif |
|
41 |
|
42 static void do_sysinfo(int si, const char* string, int* features, int mask) { |
|
43 char tmp; |
|
44 size_t bufsize = sysinfo(si, &tmp, 1); |
|
45 |
|
46 // All SI defines used below must be supported. |
|
47 guarantee(bufsize != -1, "must be supported"); |
|
48 |
|
49 char* buf = (char*) malloc(bufsize); |
|
50 |
|
51 if (buf == NULL) |
|
52 return; |
|
53 |
|
54 if (sysinfo(si, buf, bufsize) == bufsize) { |
|
55 // Compare the string. |
|
56 if (strcmp(buf, string) == 0) { |
|
57 *features |= mask; |
|
58 } |
|
59 } |
|
60 |
|
61 free(buf); |
|
62 } |
|
63 |
30 int VM_Version::platform_features(int features) { |
64 int VM_Version::platform_features(int features) { |
31 // We determine what sort of hardware we have via sysinfo(SI_ISALIST, ...). |
65 // getisax(2), SI_ARCHITECTURE_32, and SI_ARCHITECTURE_64 are |
32 // This isn't the best of all possible ways because there's not enough |
66 // supported on Solaris 10 and later. |
33 // detail in the isa list it returns, but it's a bit less arcane than |
67 if (os::Solaris::supports_getisax()) { |
34 // generating assembly code and an illegal instruction handler. We used |
68 #ifndef PRODUCT |
35 // to generate a getpsr trap, but that's even more arcane. |
69 if (PrintMiscellaneous && Verbose) |
36 // |
70 tty->print_cr("getisax(2) supported."); |
37 // Another possibility would be to use sysinfo(SI_PLATFORM, ...), but |
71 #endif |
38 // that would require more knowledge here than is wise. |
|
39 |
72 |
40 // isalist spec via 'man isalist' as of 01-Aug-2001 |
73 // Check 32-bit architecture. |
|
74 do_sysinfo(SI_ARCHITECTURE_32, "sparc", &features, v8_instructions_m); |
41 |
75 |
42 char tmp; |
76 // Check 64-bit architecture. |
43 size_t bufsize = sysinfo(SI_ISALIST, &tmp, 1); |
77 do_sysinfo(SI_ARCHITECTURE_64, "sparcv9", &features, generic_v9_m); |
44 char* buf = (char*)malloc(bufsize); |
|
45 |
78 |
46 if (buf != NULL) { |
79 // Extract valid instruction set extensions. |
47 if (sysinfo(SI_ISALIST, buf, bufsize) == bufsize) { |
80 uint_t av; |
48 // Figure out what kind of sparc we have |
81 uint_t avn = os::Solaris::getisax(&av, 1); |
49 char *sparc_string = strstr(buf, "sparc"); |
82 assert(avn == 1, "should only return one av"); |
50 if (sparc_string != NULL) { features |= v8_instructions_m; |
83 |
51 if (sparc_string[5] == 'v') { |
84 if (av & AV_SPARC_MUL32) features |= hardware_mul32_m; |
52 if (sparc_string[6] == '8') { |
85 if (av & AV_SPARC_DIV32) features |= hardware_div32_m; |
53 if (sparc_string[7] == '-') features |= hardware_int_muldiv_m; |
86 if (av & AV_SPARC_FSMULD) features |= hardware_fsmuld_m; |
54 else if (sparc_string[7] == 'p') features |= generic_v9_m; |
87 if (av & AV_SPARC_V8PLUS) features |= v9_instructions_m; |
55 else features |= generic_v8_m; |
88 if (av & AV_SPARC_VIS) features |= vis1_instructions_m; |
56 } else if (sparc_string[6] == '9') features |= generic_v9_m; |
89 if (av & AV_SPARC_VIS2) features |= vis2_instructions_m; |
|
90 } else { |
|
91 // getisax(2) failed, use the old legacy code. |
|
92 #ifndef PRODUCT |
|
93 if (PrintMiscellaneous && Verbose) |
|
94 tty->print_cr("getisax(2) not supported."); |
|
95 #endif |
|
96 |
|
97 char tmp; |
|
98 size_t bufsize = sysinfo(SI_ISALIST, &tmp, 1); |
|
99 char* buf = (char*) malloc(bufsize); |
|
100 |
|
101 if (buf != NULL) { |
|
102 if (sysinfo(SI_ISALIST, buf, bufsize) == bufsize) { |
|
103 // Figure out what kind of sparc we have |
|
104 char *sparc_string = strstr(buf, "sparc"); |
|
105 if (sparc_string != NULL) { features |= v8_instructions_m; |
|
106 if (sparc_string[5] == 'v') { |
|
107 if (sparc_string[6] == '8') { |
|
108 if (sparc_string[7] == '-') { features |= hardware_mul32_m; |
|
109 features |= hardware_div32_m; |
|
110 } else if (sparc_string[7] == 'p') features |= generic_v9_m; |
|
111 else features |= generic_v8_m; |
|
112 } else if (sparc_string[6] == '9') features |= generic_v9_m; |
|
113 } |
|
114 } |
|
115 |
|
116 // Check for visualization instructions |
|
117 char *vis = strstr(buf, "vis"); |
|
118 if (vis != NULL) { features |= vis1_instructions_m; |
|
119 if (vis[3] == '2') features |= vis2_instructions_m; |
57 } |
120 } |
58 } |
121 } |
59 |
122 free(buf); |
60 // Check for visualization instructions |
|
61 char *vis = strstr(buf, "vis"); |
|
62 if (vis != NULL) { features |= vis1_instructions_m; |
|
63 if (vis[3] == '2') features |= vis2_instructions_m; |
|
64 } |
|
65 } |
123 } |
66 free(buf); |
|
67 } |
124 } |
68 |
125 |
69 bufsize = sysinfo(SI_MACHINE, &tmp, 1); |
126 // Determine the machine type. |
70 buf = (char*)malloc(bufsize); |
127 do_sysinfo(SI_MACHINE, "sun4v", &features, sun4v_m); |
71 |
|
72 if (buf != NULL) { |
|
73 if (sysinfo(SI_MACHINE, buf, bufsize) == bufsize) { |
|
74 if (strstr(buf, "sun4v") != NULL) { |
|
75 features |= sun4v_m; |
|
76 } |
|
77 } |
|
78 free(buf); |
|
79 } |
|
80 |
128 |
81 return features; |
129 return features; |
82 } |
130 } |