mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 14:24:46 +02:00
7006505: Use kstat info to identify SPARC processor
Read Solaris kstat data to get more precise CPU information Reviewed-by: iveresov, never, twisti, dholmes
This commit is contained in:
parent
b80ad03e3f
commit
9fd396ce55
8 changed files with 136 additions and 51 deletions
|
@ -61,7 +61,7 @@ include $(GAMMADIR)/make/scm.make
|
|||
QUIETLY$(MAKE_VERBOSE) = @
|
||||
|
||||
# For now, until the compiler is less wobbly:
|
||||
TESTFLAGS = -Xbatch -showversion
|
||||
TESTFLAGS = -Xbatch -Xmx32m -showversion
|
||||
|
||||
### maye ARCH_XXX instead?
|
||||
ifdef USE_GCC
|
||||
|
|
|
@ -119,6 +119,10 @@ else
|
|||
LIBS += -lsocket -lsched -ldl $(LIBM) -lthread -lc
|
||||
endif # sparcWorks
|
||||
|
||||
ifeq ("${Platform_arch}", "sparc")
|
||||
LIBS += -lkstat
|
||||
endif
|
||||
|
||||
# By default, link the *.o into the library, not the executable.
|
||||
LINK_INTO$(LINK_INTO) = LIBJVM
|
||||
|
||||
|
|
|
@ -3556,7 +3556,7 @@ operand immP() %{
|
|||
#ifdef _LP64
|
||||
// Pointer Immediate: 64-bit
|
||||
operand immP_set() %{
|
||||
predicate(!VM_Version::is_niagara1_plus());
|
||||
predicate(!VM_Version::is_niagara_plus());
|
||||
match(ConP);
|
||||
|
||||
op_cost(5);
|
||||
|
@ -3568,7 +3568,7 @@ operand immP_set() %{
|
|||
// Pointer Immediate: 64-bit
|
||||
// From Niagara2 processors on a load should be better than materializing.
|
||||
operand immP_load() %{
|
||||
predicate(VM_Version::is_niagara1_plus() && (n->bottom_type()->isa_oop_ptr() || (MacroAssembler::insts_for_set(n->get_ptr()) > 3)));
|
||||
predicate(VM_Version::is_niagara_plus() && (n->bottom_type()->isa_oop_ptr() || (MacroAssembler::insts_for_set(n->get_ptr()) > 3)));
|
||||
match(ConP);
|
||||
|
||||
op_cost(5);
|
||||
|
@ -3579,7 +3579,7 @@ operand immP_load() %{
|
|||
|
||||
// Pointer Immediate: 64-bit
|
||||
operand immP_no_oop_cheap() %{
|
||||
predicate(VM_Version::is_niagara1_plus() && !n->bottom_type()->isa_oop_ptr() && (MacroAssembler::insts_for_set(n->get_ptr()) <= 3));
|
||||
predicate(VM_Version::is_niagara_plus() && !n->bottom_type()->isa_oop_ptr() && (MacroAssembler::insts_for_set(n->get_ptr()) <= 3));
|
||||
match(ConP);
|
||||
|
||||
op_cost(5);
|
||||
|
@ -3686,7 +3686,7 @@ operand immL_32bits() %{
|
|||
|
||||
// Long Immediate: cheap (materialize in <= 3 instructions)
|
||||
operand immL_cheap() %{
|
||||
predicate(!VM_Version::is_niagara1_plus() || MacroAssembler::insts_for_set64(n->get_long()) <= 3);
|
||||
predicate(!VM_Version::is_niagara_plus() || MacroAssembler::insts_for_set64(n->get_long()) <= 3);
|
||||
match(ConL);
|
||||
op_cost(0);
|
||||
|
||||
|
@ -3696,7 +3696,7 @@ operand immL_cheap() %{
|
|||
|
||||
// Long Immediate: expensive (materialize in > 3 instructions)
|
||||
operand immL_expensive() %{
|
||||
predicate(VM_Version::is_niagara1_plus() && MacroAssembler::insts_for_set64(n->get_long()) > 3);
|
||||
predicate(VM_Version::is_niagara_plus() && MacroAssembler::insts_for_set64(n->get_long()) > 3);
|
||||
match(ConL);
|
||||
op_cost(0);
|
||||
|
||||
|
|
|
@ -38,12 +38,6 @@
|
|||
int VM_Version::_features = VM_Version::unknown_m;
|
||||
const char* VM_Version::_features_str = "";
|
||||
|
||||
bool VM_Version::is_niagara1_plus() {
|
||||
// This is a placeholder until the real test is determined.
|
||||
return is_niagara1() &&
|
||||
(os::processor_count() > maximum_niagara1_processor_count());
|
||||
}
|
||||
|
||||
void VM_Version::initialize() {
|
||||
_features = determine_features();
|
||||
PrefetchCopyIntervalInBytes = prefetch_copy_interval_in_bytes();
|
||||
|
@ -69,11 +63,21 @@ void VM_Version::initialize() {
|
|||
|
||||
_supports_cx8 = has_v9();
|
||||
|
||||
if (is_niagara1()) {
|
||||
if (is_niagara()) {
|
||||
// Indirect branch is the same cost as direct
|
||||
if (FLAG_IS_DEFAULT(UseInlineCaches)) {
|
||||
FLAG_SET_DEFAULT(UseInlineCaches, false);
|
||||
}
|
||||
// Align loops on a single instruction boundary.
|
||||
if (FLAG_IS_DEFAULT(OptoLoopAlignment)) {
|
||||
FLAG_SET_DEFAULT(OptoLoopAlignment, 4);
|
||||
}
|
||||
// When using CMS, we cannot use memset() in BOT updates because
|
||||
// the sun4v/CMT version in libc_psr uses BIS which exposes
|
||||
// "phantom zeros" to concurrent readers. See 6948537.
|
||||
if (FLAG_IS_DEFAULT(UseMemSetInBOT) && UseConcMarkSweepGC) {
|
||||
FLAG_SET_DEFAULT(UseMemSetInBOT, false);
|
||||
}
|
||||
#ifdef _LP64
|
||||
// 32-bit oops don't make sense for the 64-bit VM on sparc
|
||||
// since the 32-bit VM has the same registers and smaller objects.
|
||||
|
@ -89,7 +93,7 @@ void VM_Version::initialize() {
|
|||
if (FLAG_IS_DEFAULT(InteriorEntryAlignment)) {
|
||||
FLAG_SET_DEFAULT(InteriorEntryAlignment, 4);
|
||||
}
|
||||
if (is_niagara1_plus()) {
|
||||
if (is_niagara_plus()) {
|
||||
if (has_blk_init() && AllocatePrefetchStyle > 0 &&
|
||||
FLAG_IS_DEFAULT(AllocatePrefetchStyle)) {
|
||||
// Use BIS instruction for allocation prefetch.
|
||||
|
@ -105,15 +109,6 @@ void VM_Version::initialize() {
|
|||
}
|
||||
}
|
||||
#endif
|
||||
if (FLAG_IS_DEFAULT(OptoLoopAlignment)) {
|
||||
FLAG_SET_DEFAULT(OptoLoopAlignment, 4);
|
||||
}
|
||||
// When using CMS, we cannot use memset() in BOT updates because
|
||||
// the sun4v/CMT version in libc_psr uses BIS which exposes
|
||||
// "phantom zeros" to concurrent readers. See 6948537.
|
||||
if (FLAG_IS_DEFAULT(UseMemSetInBOT) && UseConcMarkSweepGC) {
|
||||
FLAG_SET_DEFAULT(UseMemSetInBOT, false);
|
||||
}
|
||||
}
|
||||
|
||||
// Use hardware population count instruction if available.
|
||||
|
@ -129,17 +124,18 @@ void VM_Version::initialize() {
|
|||
#endif
|
||||
|
||||
char buf[512];
|
||||
jio_snprintf(buf, sizeof(buf), "%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
|
||||
jio_snprintf(buf, sizeof(buf), "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
|
||||
(has_v8() ? ", has_v8" : ""),
|
||||
(has_v9() ? ", has_v9" : ""),
|
||||
(has_hardware_popc() ? ", popc" : ""),
|
||||
(has_vis1() ? ", has_vis1" : ""),
|
||||
(has_vis2() ? ", has_vis2" : ""),
|
||||
(has_vis3() ? ", has_vis3" : ""),
|
||||
(has_blk_init() ? ", has_blk_init" : ""),
|
||||
(is_ultra3() ? ", is_ultra3" : ""),
|
||||
(is_sun4v() ? ", is_sun4v" : ""),
|
||||
(is_niagara1() ? ", is_niagara1" : ""),
|
||||
(is_niagara1_plus() ? ", is_niagara1_plus" : ""),
|
||||
(is_niagara() ? ", is_niagara" : ""),
|
||||
(is_niagara_plus() ? ", is_niagara_plus" : ""),
|
||||
(is_sparc64() ? ", is_sparc64" : ""),
|
||||
(!has_hardware_mul32() ? ", no-mul32" : ""),
|
||||
(!has_hardware_div32() ? ", no-div32" : ""),
|
||||
|
@ -190,17 +186,18 @@ int VM_Version::determine_features() {
|
|||
warning("Cannot recognize SPARC version. Default to V9");
|
||||
}
|
||||
|
||||
if (UseNiagaraInstrs) {
|
||||
if (is_niagara1(features)) {
|
||||
assert(is_T_family(features) == is_niagara(features), "Niagara should be T series");
|
||||
if (UseNiagaraInstrs) { // Force code generation for Niagara
|
||||
if (is_T_family(features)) {
|
||||
// Happy to accomodate...
|
||||
} else {
|
||||
NOT_PRODUCT(if (PrintMiscellaneous && Verbose) tty->print_cr("Version is Forced-Niagara");)
|
||||
features = niagara1_m;
|
||||
features |= T_family_m;
|
||||
}
|
||||
} else {
|
||||
if (is_niagara1(features) && !FLAG_IS_DEFAULT(UseNiagaraInstrs)) {
|
||||
if (is_T_family(features) && !FLAG_IS_DEFAULT(UseNiagaraInstrs)) {
|
||||
NOT_PRODUCT(if (PrintMiscellaneous && Verbose) tty->print_cr("Version is Forced-Not-Niagara");)
|
||||
features &= ~niagara1_unique_m;
|
||||
features &= ~(T_family_m | T1_model_m);
|
||||
} else {
|
||||
// Happy to accomodate...
|
||||
}
|
||||
|
@ -222,7 +219,7 @@ void VM_Version::revert() {
|
|||
|
||||
unsigned int VM_Version::calc_parallel_worker_threads() {
|
||||
unsigned int result;
|
||||
if (is_niagara1_plus()) {
|
||||
if (is_niagara_plus()) {
|
||||
result = nof_parallel_worker_threads(5, 16, 8);
|
||||
} else {
|
||||
result = nof_parallel_worker_threads(5, 8, 8);
|
||||
|
|
|
@ -41,7 +41,12 @@ protected:
|
|||
vis2_instructions = 7,
|
||||
sun4v_instructions = 8,
|
||||
blk_init_instructions = 9,
|
||||
fmaf_instructions = 10
|
||||
fmaf_instructions = 10,
|
||||
fmau_instructions = 11,
|
||||
vis3_instructions = 12,
|
||||
sparc64_family = 13,
|
||||
T_family = 14,
|
||||
T1_model = 15
|
||||
};
|
||||
|
||||
enum Feature_Flag_Set {
|
||||
|
@ -59,6 +64,11 @@ protected:
|
|||
sun4v_m = 1 << sun4v_instructions,
|
||||
blk_init_instructions_m = 1 << blk_init_instructions,
|
||||
fmaf_instructions_m = 1 << fmaf_instructions,
|
||||
fmau_instructions_m = 1 << fmau_instructions,
|
||||
vis3_instructions_m = 1 << vis3_instructions,
|
||||
sparc64_family_m = 1 << sparc64_family,
|
||||
T_family_m = 1 << T_family,
|
||||
T1_model_m = 1 << T1_model,
|
||||
|
||||
generic_v8_m = v8_instructions_m | hardware_mul32_m | hardware_div32_m | hardware_fsmuld_m,
|
||||
generic_v9_m = generic_v8_m | v9_instructions_m,
|
||||
|
@ -76,8 +86,13 @@ protected:
|
|||
static int determine_features();
|
||||
static int platform_features(int features);
|
||||
|
||||
static bool is_niagara1(int features) { return (features & sun4v_m) != 0; }
|
||||
static bool is_sparc64(int features) { return (features & fmaf_instructions_m) != 0; }
|
||||
// Returns true if the platform is in the niagara line (T series)
|
||||
static bool is_T_family(int features) { return (features & T_family_m) != 0; }
|
||||
static bool is_niagara() { return is_T_family(_features); }
|
||||
DEBUG_ONLY( static bool is_niagara(int features) { return (features & sun4v_m) != 0; } )
|
||||
|
||||
// Returns true if it is niagara1 (T1).
|
||||
static bool is_T1_model(int features) { return is_T_family(features) && ((features & T1_model_m) != 0); }
|
||||
|
||||
static int maximum_niagara1_processor_count() { return 32; }
|
||||
|
||||
|
@ -94,6 +109,7 @@ public:
|
|||
static bool has_hardware_popc() { return (_features & hardware_popc_m) != 0; }
|
||||
static bool has_vis1() { return (_features & vis1_instructions_m) != 0; }
|
||||
static bool has_vis2() { return (_features & vis2_instructions_m) != 0; }
|
||||
static bool has_vis3() { return (_features & vis3_instructions_m) != 0; }
|
||||
static bool has_blk_init() { return (_features & blk_init_instructions_m) != 0; }
|
||||
|
||||
static bool supports_compare_and_exchange()
|
||||
|
@ -101,14 +117,14 @@ public:
|
|||
|
||||
static bool is_ultra3() { return (_features & ultra3_m) == ultra3_m; }
|
||||
static bool is_sun4v() { return (_features & sun4v_m) != 0; }
|
||||
static bool is_niagara1() { return is_niagara1(_features); }
|
||||
// Returns true if the platform is in the niagara line and
|
||||
// newer than the niagara1.
|
||||
static bool is_niagara1_plus();
|
||||
static bool is_sparc64() { return is_sparc64(_features); }
|
||||
// Returns true if the platform is in the niagara line (T series)
|
||||
// and newer than the niagara1.
|
||||
static bool is_niagara_plus() { return is_T_family(_features) && !is_T1_model(_features); }
|
||||
// Fujitsu SPARC64
|
||||
static bool is_sparc64() { return (_features & sparc64_family_m) != 0; }
|
||||
|
||||
static bool has_fast_fxtof() { return has_v9() && !is_ultra3(); }
|
||||
static bool has_fast_idiv() { return is_niagara1_plus() || is_sparc64(); }
|
||||
static bool has_fast_fxtof() { return is_niagara() || is_sparc64() || has_v9() && !is_ultra3(); }
|
||||
static bool has_fast_idiv() { return is_niagara_plus() || is_sparc64(); }
|
||||
|
||||
static const char* cpu_features() { return _features_str; }
|
||||
|
||||
|
|
|
@ -3065,7 +3065,7 @@ char* os::attempt_reserve_memory_at(size_t bytes, char* requested_addr) {
|
|||
if (addr == NULL) {
|
||||
jio_snprintf(buf, sizeof(buf), ": %s", strerror(err));
|
||||
}
|
||||
warning("attempt_reserve_memory_at: couldn't reserve %d bytes at "
|
||||
warning("attempt_reserve_memory_at: couldn't reserve " SIZE_FORMAT " bytes at "
|
||||
PTR_FORMAT ": reserve_memory_helper returned " PTR_FORMAT
|
||||
"%s", bytes, requested_addr, addr, buf);
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
# include <sys/auxv.h>
|
||||
# include <sys/auxv_SPARC.h>
|
||||
# include <sys/systeminfo.h>
|
||||
# include <kstat.h>
|
||||
|
||||
// We need to keep these here as long as we have to build on Solaris
|
||||
// versions before 10.
|
||||
|
@ -95,12 +96,24 @@ int VM_Version::platform_features(int features) {
|
|||
// but Solaris 8 is used for jdk6 update builds.
|
||||
#ifndef AV_SPARC_ASI_BLK_INIT
|
||||
#define AV_SPARC_ASI_BLK_INIT 0x0080 /* ASI_BLK_INIT_xxx ASI */
|
||||
#endif
|
||||
#ifndef AV_SPARC_FMAF
|
||||
#define AV_SPARC_FMAF 0x0100 /* Sparc64 Fused Multiply-Add */
|
||||
#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;
|
||||
|
||||
} else {
|
||||
// getisax(2) failed, use the old legacy code.
|
||||
#ifndef PRODUCT
|
||||
|
@ -140,5 +153,59 @@ int VM_Version::platform_features(int features) {
|
|||
// Determine the machine type.
|
||||
do_sysinfo(SI_MACHINE, "sun4v", &features, sun4v_m);
|
||||
|
||||
{
|
||||
// Using kstat to determine the machine type.
|
||||
kstat_ctl_t* kc = kstat_open();
|
||||
kstat_t* ksp = kstat_lookup(kc, (char*)"cpu_info", -1, NULL);
|
||||
const char* implementation = "UNKNOWN";
|
||||
if (ksp != NULL) {
|
||||
if (kstat_read(kc, ksp, NULL) != -1 && ksp->ks_data != NULL) {
|
||||
kstat_named_t* knm = (kstat_named_t *)ksp->ks_data;
|
||||
for (int i = 0; i < ksp->ks_ndata; i++) {
|
||||
if (strcmp((const char*)&(knm[i].name),"implementation") == 0) {
|
||||
#ifndef KSTAT_DATA_STRING
|
||||
#define KSTAT_DATA_STRING 9
|
||||
#endif
|
||||
if (knm[i].data_type == KSTAT_DATA_CHAR) {
|
||||
// VM is running on Solaris 8 which does not have value.str.
|
||||
implementation = &(knm[i].value.c[0]);
|
||||
} else if (knm[i].data_type == KSTAT_DATA_STRING) {
|
||||
// VM is running on Solaris 10.
|
||||
#ifndef KSTAT_NAMED_STR_PTR
|
||||
// Solaris 8 was used to build VM, define the structure it misses.
|
||||
struct str_t {
|
||||
union {
|
||||
char *ptr; /* NULL-term string */
|
||||
char __pad[8]; /* 64-bit padding */
|
||||
} addr;
|
||||
uint32_t len; /* # bytes for strlen + '\0' */
|
||||
};
|
||||
#define KSTAT_NAMED_STR_PTR(knptr) (( (str_t*)&((knptr)->value) )->addr.ptr)
|
||||
#endif
|
||||
implementation = KSTAT_NAMED_STR_PTR(&knm[i]);
|
||||
}
|
||||
#ifndef PRODUCT
|
||||
if (PrintMiscellaneous && Verbose) {
|
||||
tty->print_cr("cpu_info.implementation: %s", implementation);
|
||||
}
|
||||
#endif
|
||||
if (strncmp(implementation, "SPARC64", 7) == 0) {
|
||||
features |= sparc64_family_m;
|
||||
} else if (strncmp(implementation, "UltraSPARC-T", 12) == 0) {
|
||||
features |= T_family_m;
|
||||
if (strncmp(implementation, "UltraSPARC-T1", 13) == 0) {
|
||||
features |= T1_model_m;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
} // for(
|
||||
}
|
||||
}
|
||||
assert(strcmp(implementation, "UNKNOWN") != 0,
|
||||
"unknown cpu info (changed kstat interface?)");
|
||||
kstat_close(kc);
|
||||
}
|
||||
|
||||
return features;
|
||||
}
|
||||
|
|
|
@ -934,7 +934,8 @@ jint Universe::initialize_heap() {
|
|||
// See needs_explicit_null_check.
|
||||
// Only set the heap base for compressed oops because it indicates
|
||||
// compressed oops for pstack code.
|
||||
if (PrintCompressedOopsMode) {
|
||||
bool verbose = PrintCompressedOopsMode || (PrintMiscellaneous && Verbose);
|
||||
if (verbose) {
|
||||
tty->cr();
|
||||
tty->print("heap address: " PTR_FORMAT ", size: " SIZE_FORMAT " MB",
|
||||
Universe::heap()->base(), Universe::heap()->reserved_region().byte_size()/M);
|
||||
|
@ -943,12 +944,12 @@ jint Universe::initialize_heap() {
|
|||
// Can't reserve heap below 32Gb.
|
||||
Universe::set_narrow_oop_base(Universe::heap()->base() - os::vm_page_size());
|
||||
Universe::set_narrow_oop_shift(LogMinObjAlignmentInBytes);
|
||||
if (PrintCompressedOopsMode) {
|
||||
if (verbose) {
|
||||
tty->print(", Compressed Oops with base: "PTR_FORMAT, Universe::narrow_oop_base());
|
||||
}
|
||||
} else {
|
||||
Universe::set_narrow_oop_base(0);
|
||||
if (PrintCompressedOopsMode) {
|
||||
if (verbose) {
|
||||
tty->print(", zero based Compressed Oops");
|
||||
}
|
||||
#ifdef _WIN64
|
||||
|
@ -963,12 +964,12 @@ jint Universe::initialize_heap() {
|
|||
Universe::set_narrow_oop_shift(LogMinObjAlignmentInBytes);
|
||||
} else {
|
||||
Universe::set_narrow_oop_shift(0);
|
||||
if (PrintCompressedOopsMode) {
|
||||
if (verbose) {
|
||||
tty->print(", 32-bits Oops");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (PrintCompressedOopsMode) {
|
||||
if (verbose) {
|
||||
tty->cr();
|
||||
tty->cr();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue