2007-12-01 00:00:00 +00:00
|
|
|
/*
|
2010-11-02 09:00:37 -07:00
|
|
|
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
|
2007-12-01 00:00:00 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
*
|
|
|
|
* This code is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License version 2 only, as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* version 2 for more details (a copy is included in the LICENSE file that
|
|
|
|
* accompanied this code).
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License version
|
|
|
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
2010-05-27 19:08:38 -07:00
|
|
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
|
|
* or visit www.oracle.com if you need additional information or have any
|
|
|
|
* questions.
|
2007-12-01 00:00:00 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "precompiled.hpp"
|
|
|
|
#include "assembler_sparc.inline.hpp"
|
|
|
|
#include "memory/resourceArea.hpp"
|
|
|
|
#include "runtime/java.hpp"
|
|
|
|
#include "runtime/stubCodeGenerator.hpp"
|
|
|
|
#include "vm_version_sparc.hpp"
|
|
|
|
#ifdef TARGET_OS_FAMILY_linux
|
|
|
|
# include "os_linux.inline.hpp"
|
|
|
|
#endif
|
|
|
|
#ifdef TARGET_OS_FAMILY_solaris
|
|
|
|
# include "os_solaris.inline.hpp"
|
|
|
|
#endif
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
int VM_Version::_features = VM_Version::unknown_m;
|
|
|
|
const char* VM_Version::_features_str = "";
|
|
|
|
|
|
|
|
void VM_Version::initialize() {
|
|
|
|
_features = determine_features();
|
|
|
|
PrefetchCopyIntervalInBytes = prefetch_copy_interval_in_bytes();
|
|
|
|
PrefetchScanIntervalInBytes = prefetch_scan_interval_in_bytes();
|
|
|
|
PrefetchFieldsAhead = prefetch_fields_ahead();
|
|
|
|
|
2011-08-16 16:59:46 -07:00
|
|
|
assert(0 <= AllocatePrefetchInstr && AllocatePrefetchInstr <= 1, "invalid value");
|
|
|
|
if( AllocatePrefetchInstr < 0 ) AllocatePrefetchInstr = 0;
|
|
|
|
if( AllocatePrefetchInstr > 1 ) AllocatePrefetchInstr = 0;
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// Allocation prefetch settings
|
2011-08-16 16:59:46 -07:00
|
|
|
intx cache_line_size = prefetch_data_size();
|
2007-12-01 00:00:00 +00:00
|
|
|
if( cache_line_size > AllocatePrefetchStepSize )
|
|
|
|
AllocatePrefetchStepSize = cache_line_size;
|
2011-08-16 16:59:46 -07:00
|
|
|
|
|
|
|
assert(AllocatePrefetchLines > 0, "invalid value");
|
|
|
|
if( AllocatePrefetchLines < 1 ) // set valid value in product VM
|
|
|
|
AllocatePrefetchLines = 3;
|
|
|
|
assert(AllocateInstancePrefetchLines > 0, "invalid value");
|
|
|
|
if( AllocateInstancePrefetchLines < 1 ) // set valid value in product VM
|
|
|
|
AllocateInstancePrefetchLines = 1;
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
AllocatePrefetchDistance = allocate_prefetch_distance();
|
|
|
|
AllocatePrefetchStyle = allocate_prefetch_style();
|
|
|
|
|
2011-08-16 16:59:46 -07:00
|
|
|
assert((AllocatePrefetchDistance % AllocatePrefetchStepSize) == 0 &&
|
|
|
|
(AllocatePrefetchDistance > 0), "invalid value");
|
|
|
|
if ((AllocatePrefetchDistance % AllocatePrefetchStepSize) != 0 ||
|
|
|
|
(AllocatePrefetchDistance <= 0)) {
|
|
|
|
AllocatePrefetchDistance = AllocatePrefetchStepSize;
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2011-07-21 11:25:07 -07:00
|
|
|
if (AllocatePrefetchStyle == 3 && !has_blk_init()) {
|
|
|
|
warning("BIS instructions are not available on this CPU");
|
|
|
|
FLAG_SET_DEFAULT(AllocatePrefetchStyle, 1);
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
UseSSE = 0; // Only on x86 and x64
|
|
|
|
|
2011-08-16 16:59:46 -07:00
|
|
|
_supports_cx8 = has_v9();
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2010-12-16 14:15:12 -08:00
|
|
|
if (is_niagara()) {
|
2007-12-01 00:00:00 +00:00
|
|
|
// Indirect branch is the same cost as direct
|
|
|
|
if (FLAG_IS_DEFAULT(UseInlineCaches)) {
|
2009-03-30 18:19:31 -07:00
|
|
|
FLAG_SET_DEFAULT(UseInlineCaches, false);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2010-12-16 14:15:12 -08:00
|
|
|
// 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);
|
|
|
|
}
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
#ifdef _LP64
|
2009-03-12 10:37:46 -07:00
|
|
|
// 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.
|
|
|
|
Universe::set_narrow_oop_shift(LogMinObjAlignmentInBytes);
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
#endif // _LP64
|
2007-12-01 00:00:00 +00:00
|
|
|
#ifdef COMPILER2
|
|
|
|
// Indirect branch is the same cost as direct
|
|
|
|
if (FLAG_IS_DEFAULT(UseJumpTables)) {
|
2009-03-30 18:19:31 -07:00
|
|
|
FLAG_SET_DEFAULT(UseJumpTables, true);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
// Single-issue, so entry and loop tops are
|
|
|
|
// aligned on a single instruction boundary
|
|
|
|
if (FLAG_IS_DEFAULT(InteriorEntryAlignment)) {
|
2009-03-30 18:19:31 -07:00
|
|
|
FLAG_SET_DEFAULT(InteriorEntryAlignment, 4);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2010-12-16 14:15:12 -08:00
|
|
|
if (is_niagara_plus()) {
|
2011-08-16 16:59:46 -07:00
|
|
|
if (has_blk_init() && UseTLAB &&
|
|
|
|
FLAG_IS_DEFAULT(AllocatePrefetchInstr)) {
|
|
|
|
// Use BIS instruction for TLAB allocation prefetch.
|
|
|
|
FLAG_SET_ERGO(intx, AllocatePrefetchInstr, 1);
|
|
|
|
if (FLAG_IS_DEFAULT(AllocatePrefetchStyle)) {
|
|
|
|
FLAG_SET_ERGO(intx, AllocatePrefetchStyle, 3);
|
|
|
|
}
|
2010-04-07 12:39:27 -07:00
|
|
|
if (FLAG_IS_DEFAULT(AllocatePrefetchDistance)) {
|
2011-08-16 16:59:46 -07:00
|
|
|
// Use smaller prefetch distance with BIS
|
2010-04-07 12:39:27 -07:00
|
|
|
FLAG_SET_DEFAULT(AllocatePrefetchDistance, 64);
|
|
|
|
}
|
|
|
|
}
|
2011-08-16 16:59:46 -07:00
|
|
|
if (is_T4()) {
|
|
|
|
// Double number of prefetched cache lines on T4
|
|
|
|
// since L2 cache line size is smaller (32 bytes).
|
|
|
|
if (FLAG_IS_DEFAULT(AllocatePrefetchLines)) {
|
|
|
|
FLAG_SET_ERGO(intx, AllocatePrefetchLines, AllocatePrefetchLines*2);
|
|
|
|
}
|
|
|
|
if (FLAG_IS_DEFAULT(AllocateInstancePrefetchLines)) {
|
|
|
|
FLAG_SET_ERGO(intx, AllocateInstancePrefetchLines, AllocateInstancePrefetchLines*2);
|
|
|
|
}
|
|
|
|
}
|
2010-04-07 12:39:27 -07:00
|
|
|
if (AllocatePrefetchStyle != 3 && FLAG_IS_DEFAULT(AllocatePrefetchDistance)) {
|
|
|
|
// Use different prefetch distance without BIS
|
|
|
|
FLAG_SET_DEFAULT(AllocatePrefetchDistance, 256);
|
|
|
|
}
|
2011-08-16 16:59:46 -07:00
|
|
|
if (AllocatePrefetchInstr == 1) {
|
|
|
|
// Need a space at the end of TLAB for BIS since it
|
|
|
|
// will fault when accessing memory outside of heap.
|
|
|
|
|
|
|
|
// +1 for rounding up to next cache line, +1 to be safe
|
|
|
|
int lines = AllocatePrefetchLines + 2;
|
|
|
|
int step_size = AllocatePrefetchStepSize;
|
|
|
|
int distance = AllocatePrefetchDistance;
|
|
|
|
_reserve_for_allocation_prefetch = (distance + step_size*lines)/(int)HeapWordSize;
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2009-03-13 11:35:17 -07:00
|
|
|
// Use hardware population count instruction if available.
|
|
|
|
if (has_hardware_popc()) {
|
|
|
|
if (FLAG_IS_DEFAULT(UsePopCountInstruction)) {
|
2009-03-30 18:19:31 -07:00
|
|
|
FLAG_SET_DEFAULT(UsePopCountInstruction, true);
|
2009-03-13 11:35:17 -07:00
|
|
|
}
|
2011-07-21 11:25:07 -07:00
|
|
|
} else if (UsePopCountInstruction) {
|
|
|
|
warning("POPC instruction is not available on this CPU");
|
|
|
|
FLAG_SET_DEFAULT(UsePopCountInstruction, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
// T4 and newer Sparc cpus have new compare and branch instruction.
|
|
|
|
if (has_cbcond()) {
|
|
|
|
if (FLAG_IS_DEFAULT(UseCBCond)) {
|
|
|
|
FLAG_SET_DEFAULT(UseCBCond, true);
|
|
|
|
}
|
|
|
|
} else if (UseCBCond) {
|
|
|
|
warning("CBCOND instruction is not available on this CPU");
|
|
|
|
FLAG_SET_DEFAULT(UseCBCond, false);
|
2009-03-13 11:35:17 -07:00
|
|
|
}
|
|
|
|
|
2010-08-19 14:51:47 -07:00
|
|
|
#ifdef COMPILER2
|
2011-07-21 11:25:07 -07:00
|
|
|
// T4 and newer Sparc cpus have fast RDPC.
|
|
|
|
if (has_fast_rdpc() && FLAG_IS_DEFAULT(UseRDPCForConstantTableBase)) {
|
|
|
|
// FLAG_SET_DEFAULT(UseRDPCForConstantTableBase, true);
|
|
|
|
}
|
|
|
|
|
2010-08-19 14:51:47 -07:00
|
|
|
// Currently not supported anywhere.
|
|
|
|
FLAG_SET_DEFAULT(UseFPUForSpilling, false);
|
2011-08-11 12:08:11 -07:00
|
|
|
|
|
|
|
assert((InteriorEntryAlignment % relocInfo::addr_unit()) == 0, "alignment is not a multiple of NOP size");
|
2010-08-19 14:51:47 -07:00
|
|
|
#endif
|
|
|
|
|
2011-08-11 12:08:11 -07:00
|
|
|
assert((CodeEntryAlignment % relocInfo::addr_unit()) == 0, "alignment is not a multiple of NOP size");
|
|
|
|
assert((OptoLoopAlignment % relocInfo::addr_unit()) == 0, "alignment is not a multiple of NOP size");
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
char buf[512];
|
2011-07-21 11:25:07 -07:00
|
|
|
jio_snprintf(buf, sizeof(buf), "%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
|
|
|
|
(has_v9() ? ", v9" : (has_v8() ? ", v8" : "")),
|
2009-03-13 11:35:17 -07:00
|
|
|
(has_hardware_popc() ? ", popc" : ""),
|
2011-07-21 11:25:07 -07:00
|
|
|
(has_vis1() ? ", vis1" : ""),
|
|
|
|
(has_vis2() ? ", vis2" : ""),
|
|
|
|
(has_vis3() ? ", vis3" : ""),
|
|
|
|
(has_blk_init() ? ", blk_init" : ""),
|
|
|
|
(has_cbcond() ? ", cbcond" : ""),
|
|
|
|
(is_ultra3() ? ", ultra3" : ""),
|
|
|
|
(is_sun4v() ? ", sun4v" : ""),
|
|
|
|
(is_niagara_plus() ? ", niagara_plus" : (is_niagara() ? ", niagara" : "")),
|
|
|
|
(is_sparc64() ? ", sparc64" : ""),
|
2009-03-11 14:16:13 -07:00
|
|
|
(!has_hardware_mul32() ? ", no-mul32" : ""),
|
|
|
|
(!has_hardware_div32() ? ", no-div32" : ""),
|
2007-12-01 00:00:00 +00:00
|
|
|
(!has_hardware_fsmuld() ? ", no-fsmuld" : ""));
|
|
|
|
|
|
|
|
// buf is started with ", " or is empty
|
|
|
|
_features_str = strdup(strlen(buf) > 2 ? buf + 2 : buf);
|
|
|
|
|
2011-07-08 09:38:48 -07:00
|
|
|
// UseVIS is set to the smallest of what hardware supports and what
|
|
|
|
// the command line requires. I.e., you cannot set UseVIS to 3 on
|
|
|
|
// older UltraSparc which do not support it.
|
|
|
|
if (UseVIS > 3) UseVIS=3;
|
|
|
|
if (UseVIS < 0) UseVIS=0;
|
|
|
|
if (!has_vis3()) // Drop to 2 if no VIS3 support
|
|
|
|
UseVIS = MIN2((intx)2,UseVIS);
|
|
|
|
if (!has_vis2()) // Drop to 1 if no VIS2 support
|
|
|
|
UseVIS = MIN2((intx)1,UseVIS);
|
|
|
|
if (!has_vis1()) // Drop to 0 if no VIS1 support
|
|
|
|
UseVIS = 0;
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
#ifndef PRODUCT
|
|
|
|
if (PrintMiscellaneous && Verbose) {
|
2011-08-16 16:59:46 -07:00
|
|
|
tty->print("Allocation");
|
2007-12-01 00:00:00 +00:00
|
|
|
if (AllocatePrefetchStyle <= 0) {
|
2011-08-16 16:59:46 -07:00
|
|
|
tty->print_cr(": no prefetching");
|
2007-12-01 00:00:00 +00:00
|
|
|
} else {
|
2011-08-16 16:59:46 -07:00
|
|
|
tty->print(" prefetching: ");
|
|
|
|
if (AllocatePrefetchInstr == 0) {
|
|
|
|
tty->print("PREFETCH");
|
|
|
|
} else if (AllocatePrefetchInstr == 1) {
|
|
|
|
tty->print("BIS");
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
if (AllocatePrefetchLines > 1) {
|
2011-08-16 16:59:46 -07:00
|
|
|
tty->print_cr(" at distance %d, %d lines of %d bytes", AllocatePrefetchDistance, AllocatePrefetchLines, AllocatePrefetchStepSize);
|
2007-12-01 00:00:00 +00:00
|
|
|
} else {
|
2011-08-16 16:59:46 -07:00
|
|
|
tty->print_cr(" at distance %d, one line of %d bytes", AllocatePrefetchDistance, AllocatePrefetchStepSize);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (PrefetchCopyIntervalInBytes > 0) {
|
|
|
|
tty->print_cr("PrefetchCopyIntervalInBytes %d", PrefetchCopyIntervalInBytes);
|
|
|
|
}
|
|
|
|
if (PrefetchScanIntervalInBytes > 0) {
|
|
|
|
tty->print_cr("PrefetchScanIntervalInBytes %d", PrefetchScanIntervalInBytes);
|
|
|
|
}
|
|
|
|
if (PrefetchFieldsAhead > 0) {
|
|
|
|
tty->print_cr("PrefetchFieldsAhead %d", PrefetchFieldsAhead);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // PRODUCT
|
|
|
|
}
|
|
|
|
|
|
|
|
void VM_Version::print_features() {
|
|
|
|
tty->print_cr("Version:%s", cpu_features());
|
|
|
|
}
|
|
|
|
|
|
|
|
int VM_Version::determine_features() {
|
|
|
|
if (UseV8InstrsOnly) {
|
|
|
|
NOT_PRODUCT(if (PrintMiscellaneous && Verbose) tty->print_cr("Version is Forced-V8");)
|
|
|
|
return generic_v8_m;
|
|
|
|
}
|
|
|
|
|
|
|
|
int features = platform_features(unknown_m); // platform_features() is os_arch specific
|
|
|
|
|
|
|
|
if (features == unknown_m) {
|
|
|
|
features = generic_v9_m;
|
|
|
|
warning("Cannot recognize SPARC version. Default to V9");
|
|
|
|
}
|
|
|
|
|
2010-12-16 14:15:12 -08:00
|
|
|
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)) {
|
2007-12-01 00:00:00 +00:00
|
|
|
// Happy to accomodate...
|
|
|
|
} else {
|
|
|
|
NOT_PRODUCT(if (PrintMiscellaneous && Verbose) tty->print_cr("Version is Forced-Niagara");)
|
2010-12-16 14:15:12 -08:00
|
|
|
features |= T_family_m;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
} else {
|
2010-12-16 14:15:12 -08:00
|
|
|
if (is_T_family(features) && !FLAG_IS_DEFAULT(UseNiagaraInstrs)) {
|
2007-12-01 00:00:00 +00:00
|
|
|
NOT_PRODUCT(if (PrintMiscellaneous && Verbose) tty->print_cr("Version is Forced-Not-Niagara");)
|
2010-12-16 14:15:12 -08:00
|
|
|
features &= ~(T_family_m | T1_model_m);
|
2007-12-01 00:00:00 +00:00
|
|
|
} else {
|
|
|
|
// Happy to accomodate...
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return features;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int saved_features = 0;
|
|
|
|
|
|
|
|
void VM_Version::allow_all() {
|
|
|
|
saved_features = _features;
|
|
|
|
_features = all_features_m;
|
|
|
|
}
|
|
|
|
|
|
|
|
void VM_Version::revert() {
|
|
|
|
_features = saved_features;
|
|
|
|
}
|
2008-02-22 17:17:14 -08:00
|
|
|
|
|
|
|
unsigned int VM_Version::calc_parallel_worker_threads() {
|
|
|
|
unsigned int result;
|
2010-12-16 14:15:12 -08:00
|
|
|
if (is_niagara_plus()) {
|
2008-02-22 17:17:14 -08:00
|
|
|
result = nof_parallel_worker_threads(5, 16, 8);
|
|
|
|
} else {
|
|
|
|
result = nof_parallel_worker_threads(5, 8, 8);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|