duke@435: /* twisti@1076: * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved. duke@435: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: * duke@435: * This code is free software; you can redistribute it and/or modify it duke@435: * under the terms of the GNU General Public License version 2 only, as duke@435: * published by the Free Software Foundation. duke@435: * duke@435: * This code is distributed in the hope that it will be useful, but WITHOUT duke@435: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: * version 2 for more details (a copy is included in the LICENSE file that duke@435: * accompanied this code). duke@435: * duke@435: * You should have received a copy of the GNU General Public License version duke@435: * 2 along with this work; if not, write to the Free Software Foundation, duke@435: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: * duke@435: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, duke@435: * CA 95054 USA or visit www.sun.com if you need additional information or duke@435: * have any questions. duke@435: * duke@435: */ duke@435: duke@435: # include "incls/_precompiled.incl" duke@435: # include "incls/_vm_version_sparc.cpp.incl" duke@435: duke@435: int VM_Version::_features = VM_Version::unknown_m; duke@435: const char* VM_Version::_features_str = ""; duke@435: jmasa@445: bool VM_Version::is_niagara1_plus() { jmasa@445: // This is a placeholder until the real test is determined. jmasa@445: return is_niagara1() && jmasa@445: (os::processor_count() > maximum_niagara1_processor_count()); jmasa@445: } jmasa@445: duke@435: void VM_Version::initialize() { duke@435: _features = determine_features(); duke@435: PrefetchCopyIntervalInBytes = prefetch_copy_interval_in_bytes(); duke@435: PrefetchScanIntervalInBytes = prefetch_scan_interval_in_bytes(); duke@435: PrefetchFieldsAhead = prefetch_fields_ahead(); duke@435: duke@435: // Allocation prefetch settings duke@435: intx cache_line_size = L1_data_cache_line_size(); duke@435: if( cache_line_size > AllocatePrefetchStepSize ) duke@435: AllocatePrefetchStepSize = cache_line_size; duke@435: if( FLAG_IS_DEFAULT(AllocatePrefetchLines) ) duke@435: AllocatePrefetchLines = 3; // Optimistic value duke@435: assert( AllocatePrefetchLines > 0, "invalid value"); duke@435: if( AllocatePrefetchLines < 1 ) // set valid value in product VM duke@435: AllocatePrefetchLines = 1; // Conservative value duke@435: duke@435: AllocatePrefetchDistance = allocate_prefetch_distance(); duke@435: AllocatePrefetchStyle = allocate_prefetch_style(); duke@435: duke@435: assert(AllocatePrefetchDistance % AllocatePrefetchStepSize == 0, "invalid value"); duke@435: duke@435: UseSSE = 0; // Only on x86 and x64 duke@435: duke@435: _supports_cx8 = has_v9(); duke@435: duke@435: if (is_niagara1()) { duke@435: // Indirect branch is the same cost as direct duke@435: if (FLAG_IS_DEFAULT(UseInlineCaches)) { duke@435: UseInlineCaches = false; duke@435: } coleenp@548: #ifdef _LP64 coleenp@548: // Single issue niagara1 is slower for CompressedOops coleenp@548: // but niagaras after that it's fine. coleenp@548: if (!is_niagara1_plus()) { coleenp@548: if (FLAG_IS_DEFAULT(UseCompressedOops)) { coleenp@548: FLAG_SET_ERGO(bool, UseCompressedOops, false); coleenp@548: } coleenp@548: } kvn@1077: // 32-bit oops don't make sense for the 64-bit VM on sparc kvn@1077: // since the 32-bit VM has the same registers and smaller objects. kvn@1077: Universe::set_narrow_oop_shift(LogMinObjAlignmentInBytes); coleenp@548: #endif // _LP64 duke@435: #ifdef COMPILER2 duke@435: // Indirect branch is the same cost as direct duke@435: if (FLAG_IS_DEFAULT(UseJumpTables)) { duke@435: UseJumpTables = true; duke@435: } duke@435: // Single-issue, so entry and loop tops are duke@435: // aligned on a single instruction boundary duke@435: if (FLAG_IS_DEFAULT(InteriorEntryAlignment)) { duke@435: InteriorEntryAlignment = 4; duke@435: } duke@435: if (FLAG_IS_DEFAULT(OptoLoopAlignment)) { duke@435: OptoLoopAlignment = 4; duke@435: } duke@435: #endif duke@435: } duke@435: twisti@1078: // Use hardware population count instruction if available. twisti@1078: if (has_hardware_popc()) { twisti@1078: if (FLAG_IS_DEFAULT(UsePopCountInstruction)) { twisti@1078: UsePopCountInstruction = true; twisti@1078: } twisti@1078: } twisti@1078: duke@435: char buf[512]; twisti@1078: jio_snprintf(buf, sizeof(buf), "%s%s%s%s%s%s%s%s%s%s%s%s", duke@435: (has_v8() ? ", has_v8" : ""), duke@435: (has_v9() ? ", has_v9" : ""), twisti@1078: (has_hardware_popc() ? ", popc" : ""), duke@435: (has_vis1() ? ", has_vis1" : ""), duke@435: (has_vis2() ? ", has_vis2" : ""), duke@435: (is_ultra3() ? ", is_ultra3" : ""), duke@435: (is_sun4v() ? ", is_sun4v" : ""), duke@435: (is_niagara1() ? ", is_niagara1" : ""), twisti@1076: (is_niagara1_plus() ? ", is_niagara1_plus" : ""), twisti@1076: (!has_hardware_mul32() ? ", no-mul32" : ""), twisti@1076: (!has_hardware_div32() ? ", no-div32" : ""), duke@435: (!has_hardware_fsmuld() ? ", no-fsmuld" : "")); duke@435: duke@435: // buf is started with ", " or is empty duke@435: _features_str = strdup(strlen(buf) > 2 ? buf + 2 : buf); duke@435: duke@435: #ifndef PRODUCT duke@435: if (PrintMiscellaneous && Verbose) { duke@435: tty->print("Allocation: "); duke@435: if (AllocatePrefetchStyle <= 0) { duke@435: tty->print_cr("no prefetching"); duke@435: } else { duke@435: if (AllocatePrefetchLines > 1) { duke@435: tty->print_cr("PREFETCH %d, %d lines of size %d bytes", AllocatePrefetchDistance, AllocatePrefetchLines, AllocatePrefetchStepSize); duke@435: } else { duke@435: tty->print_cr("PREFETCH %d, one line", AllocatePrefetchDistance); duke@435: } duke@435: } duke@435: if (PrefetchCopyIntervalInBytes > 0) { duke@435: tty->print_cr("PrefetchCopyIntervalInBytes %d", PrefetchCopyIntervalInBytes); duke@435: } duke@435: if (PrefetchScanIntervalInBytes > 0) { duke@435: tty->print_cr("PrefetchScanIntervalInBytes %d", PrefetchScanIntervalInBytes); duke@435: } duke@435: if (PrefetchFieldsAhead > 0) { duke@435: tty->print_cr("PrefetchFieldsAhead %d", PrefetchFieldsAhead); duke@435: } duke@435: } duke@435: #endif // PRODUCT duke@435: } duke@435: duke@435: void VM_Version::print_features() { duke@435: tty->print_cr("Version:%s", cpu_features()); duke@435: } duke@435: duke@435: int VM_Version::determine_features() { duke@435: if (UseV8InstrsOnly) { duke@435: NOT_PRODUCT(if (PrintMiscellaneous && Verbose) tty->print_cr("Version is Forced-V8");) duke@435: return generic_v8_m; duke@435: } duke@435: duke@435: int features = platform_features(unknown_m); // platform_features() is os_arch specific duke@435: duke@435: if (features == unknown_m) { duke@435: features = generic_v9_m; duke@435: warning("Cannot recognize SPARC version. Default to V9"); duke@435: } duke@435: duke@435: if (UseNiagaraInstrs) { duke@435: if (is_niagara1(features)) { duke@435: // Happy to accomodate... duke@435: } else { duke@435: NOT_PRODUCT(if (PrintMiscellaneous && Verbose) tty->print_cr("Version is Forced-Niagara");) duke@435: features = niagara1_m; duke@435: } duke@435: } else { duke@435: if (is_niagara1(features) && !FLAG_IS_DEFAULT(UseNiagaraInstrs)) { duke@435: NOT_PRODUCT(if (PrintMiscellaneous && Verbose) tty->print_cr("Version is Forced-Not-Niagara");) duke@435: features &= ~niagara1_unique_m; duke@435: } else { duke@435: // Happy to accomodate... duke@435: } duke@435: } duke@435: duke@435: return features; duke@435: } duke@435: duke@435: static int saved_features = 0; duke@435: duke@435: void VM_Version::allow_all() { duke@435: saved_features = _features; duke@435: _features = all_features_m; duke@435: } duke@435: duke@435: void VM_Version::revert() { duke@435: _features = saved_features; duke@435: } jmasa@445: jmasa@445: unsigned int VM_Version::calc_parallel_worker_threads() { jmasa@445: unsigned int result; jmasa@445: if (is_niagara1_plus()) { jmasa@445: result = nof_parallel_worker_threads(5, 16, 8); jmasa@445: } else { jmasa@445: result = nof_parallel_worker_threads(5, 8, 8); jmasa@445: } jmasa@445: return result; jmasa@445: }