8157141: Fix for JDK-8031290 is unnecessarily fragile

8166454: meminfo(2) has been available since Solaris 9

Reviewed-by: dholmes, kbarrett
This commit is contained in:
Alan Burlison 2016-10-17 19:18:08 -04:00
parent 811ccf69ad
commit 7520497b75
9 changed files with 58 additions and 160 deletions

View File

@ -84,7 +84,6 @@
declare_constant(VM_Version::sun4v_m) \ declare_constant(VM_Version::sun4v_m) \
declare_constant(VM_Version::blk_init_instructions_m) \ declare_constant(VM_Version::blk_init_instructions_m) \
declare_constant(VM_Version::fmaf_instructions_m) \ declare_constant(VM_Version::fmaf_instructions_m) \
declare_constant(VM_Version::fmau_instructions_m) \
declare_constant(VM_Version::sparc64_family_m) \ declare_constant(VM_Version::sparc64_family_m) \
declare_constant(VM_Version::M_family_m) \ declare_constant(VM_Version::M_family_m) \
declare_constant(VM_Version::T_family_m) \ declare_constant(VM_Version::T_family_m) \

View File

@ -34,30 +34,29 @@ class VM_Version: public Abstract_VM_Version {
protected: protected:
enum Feature_Flag { enum Feature_Flag {
v8_instructions = 0, v8_instructions = 0,
hardware_mul32 = 1, hardware_mul32 = 1,
hardware_div32 = 2, hardware_div32 = 2,
hardware_fsmuld = 3, hardware_fsmuld = 3,
hardware_popc = 4, hardware_popc = 4,
v9_instructions = 5, v9_instructions = 5,
vis1_instructions = 6, vis1_instructions = 6,
vis2_instructions = 7, vis2_instructions = 7,
sun4v_instructions = 8, sun4v_instructions = 8,
blk_init_instructions = 9, blk_init_instructions = 9,
fmaf_instructions = 10, fmaf_instructions = 10,
fmau_instructions = 11, vis3_instructions = 11,
vis3_instructions = 12, cbcond_instructions = 12,
cbcond_instructions = 13, sparc64_family = 13,
sparc64_family = 14, M_family = 14,
M_family = 15, T_family = 15,
T_family = 16, T1_model = 16,
T1_model = 17, sparc5_instructions = 17,
sparc5_instructions = 18, aes_instructions = 18,
aes_instructions = 19, sha1_instruction = 19,
sha1_instruction = 20, sha256_instruction = 20,
sha256_instruction = 21, sha512_instruction = 21,
sha512_instruction = 22, crc32c_instruction = 22
crc32c_instruction = 23
}; };
enum Feature_Flag_Set { enum Feature_Flag_Set {
@ -75,7 +74,6 @@ protected:
sun4v_m = 1 << sun4v_instructions, sun4v_m = 1 << sun4v_instructions,
blk_init_instructions_m = 1 << blk_init_instructions, blk_init_instructions_m = 1 << blk_init_instructions,
fmaf_instructions_m = 1 << fmaf_instructions, fmaf_instructions_m = 1 << fmaf_instructions,
fmau_instructions_m = 1 << fmau_instructions,
vis3_instructions_m = 1 << vis3_instructions, vis3_instructions_m = 1 << vis3_instructions,
cbcond_instructions_m = 1 << cbcond_instructions, cbcond_instructions_m = 1 << cbcond_instructions,
sparc64_family_m = 1 << sparc64_family, sparc64_family_m = 1 << sparc64_family,

View File

@ -96,9 +96,6 @@ public class SPARCHotSpotJVMCIBackendFactory implements HotSpotJVMCIBackendFacto
if ((config.vmVersionFeatures & config.sparcFmafInstructions) != 0) { if ((config.vmVersionFeatures & config.sparcFmafInstructions) != 0) {
features.add(CPUFeature.FMAF); features.add(CPUFeature.FMAF);
} }
if ((config.vmVersionFeatures & config.sparcFmauInstructions) != 0) {
features.add(CPUFeature.FMAU);
}
if ((config.vmVersionFeatures & config.sparcSparc64Family) != 0) { if ((config.vmVersionFeatures & config.sparcSparc64Family) != 0) {
features.add(CPUFeature.SPARC64_FAMILY); features.add(CPUFeature.SPARC64_FAMILY);
} }

View File

@ -55,7 +55,6 @@ class SPARCHotSpotVMConfig extends HotSpotVMConfigAccess {
final int sparcSun4v = getConstant("VM_Version::sun4v_m", Integer.class); final int sparcSun4v = getConstant("VM_Version::sun4v_m", Integer.class);
final int sparcBlkInitInstructions = getConstant("VM_Version::blk_init_instructions_m", Integer.class); final int sparcBlkInitInstructions = getConstant("VM_Version::blk_init_instructions_m", Integer.class);
final int sparcFmafInstructions = getConstant("VM_Version::fmaf_instructions_m", Integer.class); final int sparcFmafInstructions = getConstant("VM_Version::fmaf_instructions_m", Integer.class);
final int sparcFmauInstructions = getConstant("VM_Version::fmau_instructions_m", Integer.class);
final int sparcSparc64Family = getConstant("VM_Version::sparc64_family_m", Integer.class); final int sparcSparc64Family = getConstant("VM_Version::sparc64_family_m", Integer.class);
final int sparcMFamily = getConstant("VM_Version::M_family_m", Integer.class); final int sparcMFamily = getConstant("VM_Version::M_family_m", Integer.class);
final int sparcTFamily = getConstant("VM_Version::T_family_m", Integer.class); final int sparcTFamily = getConstant("VM_Version::T_family_m", Integer.class);

View File

@ -349,7 +349,6 @@ public class SPARC extends Architecture {
SUN4V, SUN4V,
BLK_INIT_INSTRUCTIONS, BLK_INIT_INSTRUCTIONS,
FMAF, FMAF,
FMAU,
SPARC64_FAMILY, SPARC64_FAMILY,
M_FAMILY, M_FAMILY,
T_FAMILY, T_FAMILY,

View File

@ -2563,7 +2563,7 @@ bool os::get_page_info(char *start, page_info* info) {
uint64_t outdata[2]; uint64_t outdata[2];
uint_t validity = 0; uint_t validity = 0;
if (os::Solaris::meminfo(&addr, 1, info_types, 2, outdata, &validity) < 0) { if (meminfo(&addr, 1, info_types, 2, outdata, &validity) < 0) {
return false; return false;
} }
@ -2601,7 +2601,7 @@ char *os::scan_pages(char *start, char* end, page_info* page_expected,
addrs_count++; addrs_count++;
} }
if (os::Solaris::meminfo(addrs, addrs_count, info_types, types, outdata, validity) < 0) { if (meminfo(addrs, addrs_count, info_types, types, outdata, validity) < 0) {
return NULL; return NULL;
} }
@ -4160,9 +4160,6 @@ void os::Solaris::install_signal_handlers() {
void report_error(const char* file_name, int line_no, const char* title, void report_error(const char* file_name, int line_no, const char* title,
const char* format, ...); const char* format, ...);
// (Static) wrapper for getisax(2) call.
os::Solaris::getisax_func_t os::Solaris::_getisax = 0;
// (Static) wrappers for the liblgrp API // (Static) wrappers for the liblgrp API
os::Solaris::lgrp_home_func_t os::Solaris::_lgrp_home; os::Solaris::lgrp_home_func_t os::Solaris::_lgrp_home;
os::Solaris::lgrp_init_func_t os::Solaris::_lgrp_init; os::Solaris::lgrp_init_func_t os::Solaris::_lgrp_init;
@ -4174,9 +4171,6 @@ os::Solaris::lgrp_nlgrps_func_t os::Solaris::_lgrp_nlgrps;
os::Solaris::lgrp_cookie_stale_func_t os::Solaris::_lgrp_cookie_stale; os::Solaris::lgrp_cookie_stale_func_t os::Solaris::_lgrp_cookie_stale;
os::Solaris::lgrp_cookie_t os::Solaris::_lgrp_cookie = 0; os::Solaris::lgrp_cookie_t os::Solaris::_lgrp_cookie = 0;
// (Static) wrapper for meminfo() call.
os::Solaris::meminfo_func_t os::Solaris::_meminfo = 0;
static address resolve_symbol_lazy(const char* name) { static address resolve_symbol_lazy(const char* name) {
address addr = (address) dlsym(RTLD_DEFAULT, name); address addr = (address) dlsym(RTLD_DEFAULT, name);
if (addr == NULL) { if (addr == NULL) {
@ -4300,27 +4294,6 @@ bool os::Solaris::liblgrp_init() {
return false; return false;
} }
void os::Solaris::misc_sym_init() {
address func;
// getisax
func = resolve_symbol_lazy("getisax");
if (func != NULL) {
os::Solaris::_getisax = CAST_TO_FN_PTR(getisax_func_t, func);
}
// meminfo
func = resolve_symbol_lazy("meminfo");
if (func != NULL) {
os::Solaris::set_meminfo(CAST_TO_FN_PTR(meminfo_func_t, func));
}
}
uint_t os::Solaris::getisax(uint32_t* array, uint_t n) {
assert(_getisax != NULL, "_getisax not set");
return _getisax(array, n);
}
// int pset_getloadavg(psetid_t pset, double loadavg[], int nelem); // int pset_getloadavg(psetid_t pset, double loadavg[], int nelem);
typedef long (*pset_getloadavg_type)(psetid_t pset, double loadavg[], int nelem); typedef long (*pset_getloadavg_type)(psetid_t pset, double loadavg[], int nelem);
static pset_getloadavg_type pset_getloadavg_ptr = NULL; static pset_getloadavg_type pset_getloadavg_ptr = NULL;
@ -4351,10 +4324,6 @@ void os::init(void) {
Solaris::initialize_system_info(); Solaris::initialize_system_info();
// Initialize misc. symbols as soon as possible, so we can use them
// if we need them.
Solaris::misc_sym_init();
int fd = ::open("/dev/zero", O_RDWR); int fd = ::open("/dev/zero", O_RDWR);
if (fd < 0) { if (fd < 0) {
fatal("os::init: cannot open /dev/zero (%s)", os::strerror(errno)); fatal("os::init: cannot open /dev/zero (%s)", os::strerror(errno));

View File

@ -73,8 +73,6 @@ class Solaris {
LGRP_VIEW_OS // what's available to operating system LGRP_VIEW_OS // what's available to operating system
} lgrp_view_t; } lgrp_view_t;
typedef uint_t (*getisax_func_t)(uint32_t* array, uint_t n);
typedef lgrp_id_t (*lgrp_home_func_t)(idtype_t idtype, id_t id); typedef lgrp_id_t (*lgrp_home_func_t)(idtype_t idtype, id_t id);
typedef lgrp_cookie_t (*lgrp_init_func_t)(lgrp_view_t view); typedef lgrp_cookie_t (*lgrp_init_func_t)(lgrp_view_t view);
typedef int (*lgrp_fini_func_t)(lgrp_cookie_t cookie); typedef int (*lgrp_fini_func_t)(lgrp_cookie_t cookie);
@ -86,11 +84,6 @@ class Solaris {
lgrp_rsrc_t type); lgrp_rsrc_t type);
typedef int (*lgrp_nlgrps_func_t)(lgrp_cookie_t cookie); typedef int (*lgrp_nlgrps_func_t)(lgrp_cookie_t cookie);
typedef int (*lgrp_cookie_stale_func_t)(lgrp_cookie_t cookie); typedef int (*lgrp_cookie_stale_func_t)(lgrp_cookie_t cookie);
typedef int (*meminfo_func_t)(const uint64_t inaddr[], int addr_count,
const uint_t info_req[], int info_count,
uint64_t outdata[], uint_t validity[]);
static getisax_func_t _getisax;
static lgrp_home_func_t _lgrp_home; static lgrp_home_func_t _lgrp_home;
static lgrp_init_func_t _lgrp_init; static lgrp_init_func_t _lgrp_init;
@ -102,8 +95,6 @@ class Solaris {
static lgrp_cookie_stale_func_t _lgrp_cookie_stale; static lgrp_cookie_stale_func_t _lgrp_cookie_stale;
static lgrp_cookie_t _lgrp_cookie; static lgrp_cookie_t _lgrp_cookie;
static meminfo_func_t _meminfo;
// Large Page Support // Large Page Support
static bool is_valid_page_size(size_t bytes); static bool is_valid_page_size(size_t bytes);
static size_t page_size_for_alignment(size_t alignment); static size_t page_size_for_alignment(size_t alignment);
@ -191,8 +182,6 @@ class Solaris {
static void libthread_init(); static void libthread_init();
static void synchronization_init(); static void synchronization_init();
static bool liblgrp_init(); static bool liblgrp_init();
// Load miscellaneous symbols.
static void misc_sym_init();
// This boolean allows users to forward their own non-matching signals // This boolean allows users to forward their own non-matching signals
// to JVM_handle_solaris_signal, harmlessly. // to JVM_handle_solaris_signal, harmlessly.
static bool signal_handlers_are_installed; static bool signal_handlers_are_installed;
@ -272,17 +261,6 @@ class Solaris {
} }
static lgrp_cookie_t lgrp_cookie() { return _lgrp_cookie; } static lgrp_cookie_t lgrp_cookie() { return _lgrp_cookie; }
static bool supports_getisax() { return _getisax != NULL; }
static uint_t getisax(uint32_t* array, uint_t n);
static void set_meminfo(meminfo_func_t func) { _meminfo = func; }
static int meminfo (const uint64_t inaddr[], int addr_count,
const uint_t info_req[], int info_count,
uint64_t outdata[], uint_t validity[]) {
return _meminfo != NULL ? _meminfo(inaddr, addr_count, info_req, info_count,
outdata, validity) : -1;
}
static sigset_t* unblocked_signals(); static sigset_t* unblocked_signals();
static sigset_t* vm_signals(); static sigset_t* vm_signals();
static sigset_t* allowdebug_blocked_signals(); static sigset_t* allowdebug_blocked_signals();

View File

@ -343,8 +343,15 @@ public:
#define _SC_L2CACHE_LINESZ 527 /* Size of L2 cache line */ #define _SC_L2CACHE_LINESZ 527 /* Size of L2 cache line */
#endif #endif
// Hardware capability bits that appeared after Solaris 11.1
#ifndef AV_SPARC_FMAF
#define AV_SPARC_FMAF 0x00000100 /* Fused Multiply-Add */
#endif
#ifndef AV2_SPARC_SPARC5
#define AV2_SPARC_SPARC5 0x00000008 /* The 29 new fp and sub instructions */
#endif
int VM_Version::platform_features(int features) { int VM_Version::platform_features(int features) {
assert(os::Solaris::supports_getisax(), "getisax() must be available");
// Check 32-bit architecture. // Check 32-bit architecture.
if (Sysinfo(SI_ARCHITECTURE_32).match("sparc")) { if (Sysinfo(SI_ARCHITECTURE_32).match("sparc")) {
@ -357,84 +364,37 @@ int VM_Version::platform_features(int features) {
} }
// Extract valid instruction set extensions. // Extract valid instruction set extensions.
uint_t avs[2]; uint_t avs[AV_HW2_IDX + 1];
uint_t avn = os::Solaris::getisax(avs, 2); uint_t avn = getisax(avs, ARRAY_SIZE(avs));
assert(avn <= 2, "should return two or less av's");
uint_t av = avs[0];
log_info(os, cpu)("getisax(2) returned: " PTR32_FORMAT, av); log_info(os, cpu)("getisax(2) returned %d words:", avn);
if (avn > 1) { for (int i = 0; i < avn; i++) {
log_info(os, cpu)(" " PTR32_FORMAT, avs[1]); log_info(os, cpu)(" word %d: " PTR32_FORMAT, i, avs[i]);
} }
if (av & AV_SPARC_MUL32) features |= hardware_mul32_m; uint_t av1 = avs[AV_HW1_IDX];
if (av & AV_SPARC_DIV32) features |= hardware_div32_m; if (av1 & AV_SPARC_MUL32) features |= hardware_mul32_m;
if (av & AV_SPARC_FSMULD) features |= hardware_fsmuld_m; if (av1 & AV_SPARC_DIV32) features |= hardware_div32_m;
if (av & AV_SPARC_V8PLUS) features |= v9_instructions_m; if (av1 & AV_SPARC_FSMULD) features |= hardware_fsmuld_m;
if (av & AV_SPARC_POPC) features |= hardware_popc_m; if (av1 & AV_SPARC_V8PLUS) features |= v9_instructions_m;
if (av & AV_SPARC_VIS) features |= vis1_instructions_m; if (av1 & AV_SPARC_POPC) features |= hardware_popc_m;
if (av & AV_SPARC_VIS2) features |= vis2_instructions_m; if (av1 & AV_SPARC_VIS) features |= vis1_instructions_m;
if (avn > 1) { if (av1 & AV_SPARC_VIS2) features |= vis2_instructions_m;
uint_t av2 = avs[1]; if (av1 & AV_SPARC_ASI_BLK_INIT) features |= blk_init_instructions_m;
#ifndef AV2_SPARC_SPARC5 if (av1 & AV_SPARC_FMAF) features |= fmaf_instructions_m;
#define AV2_SPARC_SPARC5 0x00000008 /* The 29 new fp and sub instructions */ if (av1 & AV_SPARC_VIS3) features |= vis3_instructions_m;
#endif if (av1 & AV_SPARC_CBCOND) features |= cbcond_instructions_m;
if (av2 & AV2_SPARC_SPARC5) features |= sparc5_instructions_m; if (av1 & AV_SPARC_CRC32C) features |= crc32c_instruction_m;
if (av1 & AV_SPARC_AES) features |= aes_instructions_m;
if (av1 & AV_SPARC_SHA1) features |= sha1_instruction_m;
if (av1 & AV_SPARC_SHA256) features |= sha256_instruction_m;
if (av1 & AV_SPARC_SHA512) features |= sha512_instruction_m;
if (avn > AV_HW2_IDX) {
uint_t av2 = avs[AV_HW2_IDX];
if (av2 & AV2_SPARC_SPARC5) features |= sparc5_instructions_m;
} }
// We only build on Solaris 10 and up, but some of the values below
// are not defined on all versions of Solaris 10, so we define them,
// if necessary.
#ifndef AV_SPARC_ASI_BLK_INIT
#define AV_SPARC_ASI_BLK_INIT 0x0080 /* ASI_BLK_INIT_xxx ASI */
#endif
if (av & AV_SPARC_ASI_BLK_INIT) features |= blk_init_instructions_m;
#ifndef AV_SPARC_FMAF
#define AV_SPARC_FMAF 0x0100 /* Fused Multiply-Add */
#endif
if (av & AV_SPARC_FMAF) features |= fmaf_instructions_m;
#ifndef AV_SPARC_FMAU
#define AV_SPARC_FMAU 0x0200 /* Unfused Multiply-Add */
#endif
if (av & AV_SPARC_FMAU) features |= fmau_instructions_m;
#ifndef AV_SPARC_VIS3
#define AV_SPARC_VIS3 0x0400 /* VIS3 instruction set extensions */
#endif
if (av & AV_SPARC_VIS3) features |= vis3_instructions_m;
#ifndef AV_SPARC_CBCOND
#define AV_SPARC_CBCOND 0x10000000 /* compare and branch instrs supported */
#endif
if (av & AV_SPARC_CBCOND) features |= cbcond_instructions_m;
#ifndef AV_SPARC_CRC32C
#define AV_SPARC_CRC32C 0x20000000 /* crc32c instruction supported */
#endif
if (av & AV_SPARC_CRC32C) features |= crc32c_instruction_m;
#ifndef AV_SPARC_AES
#define AV_SPARC_AES 0x00020000 /* aes instrs supported */
#endif
if (av & AV_SPARC_AES) features |= aes_instructions_m;
#ifndef AV_SPARC_SHA1
#define AV_SPARC_SHA1 0x00400000 /* sha1 instruction supported */
#endif
if (av & AV_SPARC_SHA1) features |= sha1_instruction_m;
#ifndef AV_SPARC_SHA256
#define AV_SPARC_SHA256 0x00800000 /* sha256 instruction supported */
#endif
if (av & AV_SPARC_SHA256) features |= sha256_instruction_m;
#ifndef AV_SPARC_SHA512
#define AV_SPARC_SHA512 0x01000000 /* sha512 instruction supported */
#endif
if (av & AV_SPARC_SHA512) features |= sha512_instruction_m;
// Determine the machine type. // Determine the machine type.
if (Sysinfo(SI_MACHINE).match("sun4v")) { if (Sysinfo(SI_MACHINE).match("sun4v")) {
features |= sun4v_m; features |= sun4v_m;

View File

@ -712,7 +712,6 @@
declare_constant(VM_Version::sun4v_m) \ declare_constant(VM_Version::sun4v_m) \
declare_constant(VM_Version::blk_init_instructions_m) \ declare_constant(VM_Version::blk_init_instructions_m) \
declare_constant(VM_Version::fmaf_instructions_m) \ declare_constant(VM_Version::fmaf_instructions_m) \
declare_constant(VM_Version::fmau_instructions_m) \
declare_constant(VM_Version::sparc64_family_m) \ declare_constant(VM_Version::sparc64_family_m) \
declare_constant(VM_Version::M_family_m) \ declare_constant(VM_Version::M_family_m) \
declare_constant(VM_Version::T_family_m) \ declare_constant(VM_Version::T_family_m) \