src/cpu/sparc/vm/vm_version_sparc.cpp

Tue, 03 Aug 2010 08:13:38 -0400

author
bobv
date
Tue, 03 Aug 2010 08:13:38 -0400
changeset 2036
126ea7725993
parent 1934
e9ff18c4ace7
child 2085
f55c4f82ab9d
permissions
-rw-r--r--

6953477: Increase portability and flexibility of building Hotspot
Summary: A collection of portability improvements including shared code support for PPC, ARM platforms, software floating point, cross compilation support and improvements in error crash detail.
Reviewed-by: phh, never, coleenp, dholmes

duke@435 1 /*
trims@1907 2 * Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
duke@435 25 # include "incls/_precompiled.incl"
duke@435 26 # include "incls/_vm_version_sparc.cpp.incl"
duke@435 27
duke@435 28 int VM_Version::_features = VM_Version::unknown_m;
duke@435 29 const char* VM_Version::_features_str = "";
duke@435 30
jmasa@445 31 bool VM_Version::is_niagara1_plus() {
jmasa@445 32 // This is a placeholder until the real test is determined.
jmasa@445 33 return is_niagara1() &&
jmasa@445 34 (os::processor_count() > maximum_niagara1_processor_count());
jmasa@445 35 }
jmasa@445 36
duke@435 37 void VM_Version::initialize() {
duke@435 38 _features = determine_features();
duke@435 39 PrefetchCopyIntervalInBytes = prefetch_copy_interval_in_bytes();
duke@435 40 PrefetchScanIntervalInBytes = prefetch_scan_interval_in_bytes();
duke@435 41 PrefetchFieldsAhead = prefetch_fields_ahead();
duke@435 42
duke@435 43 // Allocation prefetch settings
duke@435 44 intx cache_line_size = L1_data_cache_line_size();
duke@435 45 if( cache_line_size > AllocatePrefetchStepSize )
duke@435 46 AllocatePrefetchStepSize = cache_line_size;
duke@435 47 if( FLAG_IS_DEFAULT(AllocatePrefetchLines) )
duke@435 48 AllocatePrefetchLines = 3; // Optimistic value
duke@435 49 assert( AllocatePrefetchLines > 0, "invalid value");
duke@435 50 if( AllocatePrefetchLines < 1 ) // set valid value in product VM
duke@435 51 AllocatePrefetchLines = 1; // Conservative value
duke@435 52
duke@435 53 AllocatePrefetchDistance = allocate_prefetch_distance();
duke@435 54 AllocatePrefetchStyle = allocate_prefetch_style();
duke@435 55
duke@435 56 assert(AllocatePrefetchDistance % AllocatePrefetchStepSize == 0, "invalid value");
duke@435 57
duke@435 58 UseSSE = 0; // Only on x86 and x64
duke@435 59
duke@435 60 _supports_cx8 = has_v9();
duke@435 61
duke@435 62 if (is_niagara1()) {
duke@435 63 // Indirect branch is the same cost as direct
duke@435 64 if (FLAG_IS_DEFAULT(UseInlineCaches)) {
kvn@1110 65 FLAG_SET_DEFAULT(UseInlineCaches, false);
duke@435 66 }
coleenp@548 67 #ifdef _LP64
kvn@1077 68 // 32-bit oops don't make sense for the 64-bit VM on sparc
kvn@1077 69 // since the 32-bit VM has the same registers and smaller objects.
kvn@1077 70 Universe::set_narrow_oop_shift(LogMinObjAlignmentInBytes);
coleenp@548 71 #endif // _LP64
duke@435 72 #ifdef COMPILER2
duke@435 73 // Indirect branch is the same cost as direct
duke@435 74 if (FLAG_IS_DEFAULT(UseJumpTables)) {
kvn@1110 75 FLAG_SET_DEFAULT(UseJumpTables, true);
duke@435 76 }
duke@435 77 // Single-issue, so entry and loop tops are
duke@435 78 // aligned on a single instruction boundary
duke@435 79 if (FLAG_IS_DEFAULT(InteriorEntryAlignment)) {
kvn@1110 80 FLAG_SET_DEFAULT(InteriorEntryAlignment, 4);
duke@435 81 }
kvn@1802 82 if (is_niagara1_plus()) {
kvn@1802 83 if (AllocatePrefetchStyle > 0 && FLAG_IS_DEFAULT(AllocatePrefetchStyle)) {
kvn@1802 84 // Use BIS instruction for allocation prefetch.
kvn@1802 85 FLAG_SET_DEFAULT(AllocatePrefetchStyle, 3);
kvn@1802 86 if (FLAG_IS_DEFAULT(AllocatePrefetchDistance)) {
kvn@1802 87 // Use smaller prefetch distance on N2 with BIS
kvn@1802 88 FLAG_SET_DEFAULT(AllocatePrefetchDistance, 64);
kvn@1802 89 }
kvn@1802 90 }
kvn@1802 91 if (AllocatePrefetchStyle != 3 && FLAG_IS_DEFAULT(AllocatePrefetchDistance)) {
kvn@1802 92 // Use different prefetch distance without BIS
kvn@1802 93 FLAG_SET_DEFAULT(AllocatePrefetchDistance, 256);
kvn@1802 94 }
duke@435 95 }
duke@435 96 #endif
kvn@1800 97 if (FLAG_IS_DEFAULT(OptoLoopAlignment)) {
kvn@1800 98 FLAG_SET_DEFAULT(OptoLoopAlignment, 4);
kvn@1800 99 }
ysr@1873 100 // When using CMS, we cannot use memset() in BOT updates because
ysr@1873 101 // the sun4v/CMT version in libc_psr uses BIS which exposes
ysr@1873 102 // "phantom zeros" to concurrent readers. See 6948537.
ysr@1873 103 if (FLAG_IS_DEFAULT(UseMemSetInBOT) && UseConcMarkSweepGC) {
ysr@1873 104 FLAG_SET_DEFAULT(UseMemSetInBOT, false);
ysr@1873 105 }
duke@435 106 }
duke@435 107
twisti@1078 108 // Use hardware population count instruction if available.
twisti@1078 109 if (has_hardware_popc()) {
twisti@1078 110 if (FLAG_IS_DEFAULT(UsePopCountInstruction)) {
kvn@1110 111 FLAG_SET_DEFAULT(UsePopCountInstruction, true);
twisti@1078 112 }
twisti@1078 113 }
twisti@1078 114
duke@435 115 char buf[512];
twisti@1078 116 jio_snprintf(buf, sizeof(buf), "%s%s%s%s%s%s%s%s%s%s%s%s",
duke@435 117 (has_v8() ? ", has_v8" : ""),
duke@435 118 (has_v9() ? ", has_v9" : ""),
twisti@1078 119 (has_hardware_popc() ? ", popc" : ""),
duke@435 120 (has_vis1() ? ", has_vis1" : ""),
duke@435 121 (has_vis2() ? ", has_vis2" : ""),
duke@435 122 (is_ultra3() ? ", is_ultra3" : ""),
duke@435 123 (is_sun4v() ? ", is_sun4v" : ""),
duke@435 124 (is_niagara1() ? ", is_niagara1" : ""),
twisti@1076 125 (is_niagara1_plus() ? ", is_niagara1_plus" : ""),
twisti@1076 126 (!has_hardware_mul32() ? ", no-mul32" : ""),
twisti@1076 127 (!has_hardware_div32() ? ", no-div32" : ""),
duke@435 128 (!has_hardware_fsmuld() ? ", no-fsmuld" : ""));
duke@435 129
duke@435 130 // buf is started with ", " or is empty
duke@435 131 _features_str = strdup(strlen(buf) > 2 ? buf + 2 : buf);
duke@435 132
duke@435 133 #ifndef PRODUCT
duke@435 134 if (PrintMiscellaneous && Verbose) {
duke@435 135 tty->print("Allocation: ");
duke@435 136 if (AllocatePrefetchStyle <= 0) {
duke@435 137 tty->print_cr("no prefetching");
duke@435 138 } else {
duke@435 139 if (AllocatePrefetchLines > 1) {
duke@435 140 tty->print_cr("PREFETCH %d, %d lines of size %d bytes", AllocatePrefetchDistance, AllocatePrefetchLines, AllocatePrefetchStepSize);
duke@435 141 } else {
duke@435 142 tty->print_cr("PREFETCH %d, one line", AllocatePrefetchDistance);
duke@435 143 }
duke@435 144 }
duke@435 145 if (PrefetchCopyIntervalInBytes > 0) {
duke@435 146 tty->print_cr("PrefetchCopyIntervalInBytes %d", PrefetchCopyIntervalInBytes);
duke@435 147 }
duke@435 148 if (PrefetchScanIntervalInBytes > 0) {
duke@435 149 tty->print_cr("PrefetchScanIntervalInBytes %d", PrefetchScanIntervalInBytes);
duke@435 150 }
duke@435 151 if (PrefetchFieldsAhead > 0) {
duke@435 152 tty->print_cr("PrefetchFieldsAhead %d", PrefetchFieldsAhead);
duke@435 153 }
duke@435 154 }
duke@435 155 #endif // PRODUCT
duke@435 156 }
duke@435 157
duke@435 158 void VM_Version::print_features() {
duke@435 159 tty->print_cr("Version:%s", cpu_features());
duke@435 160 }
duke@435 161
duke@435 162 int VM_Version::determine_features() {
duke@435 163 if (UseV8InstrsOnly) {
duke@435 164 NOT_PRODUCT(if (PrintMiscellaneous && Verbose) tty->print_cr("Version is Forced-V8");)
duke@435 165 return generic_v8_m;
duke@435 166 }
duke@435 167
duke@435 168 int features = platform_features(unknown_m); // platform_features() is os_arch specific
duke@435 169
duke@435 170 if (features == unknown_m) {
duke@435 171 features = generic_v9_m;
duke@435 172 warning("Cannot recognize SPARC version. Default to V9");
duke@435 173 }
duke@435 174
duke@435 175 if (UseNiagaraInstrs) {
duke@435 176 if (is_niagara1(features)) {
duke@435 177 // Happy to accomodate...
duke@435 178 } else {
duke@435 179 NOT_PRODUCT(if (PrintMiscellaneous && Verbose) tty->print_cr("Version is Forced-Niagara");)
duke@435 180 features = niagara1_m;
duke@435 181 }
duke@435 182 } else {
duke@435 183 if (is_niagara1(features) && !FLAG_IS_DEFAULT(UseNiagaraInstrs)) {
duke@435 184 NOT_PRODUCT(if (PrintMiscellaneous && Verbose) tty->print_cr("Version is Forced-Not-Niagara");)
duke@435 185 features &= ~niagara1_unique_m;
duke@435 186 } else {
duke@435 187 // Happy to accomodate...
duke@435 188 }
duke@435 189 }
duke@435 190
duke@435 191 return features;
duke@435 192 }
duke@435 193
duke@435 194 static int saved_features = 0;
duke@435 195
duke@435 196 void VM_Version::allow_all() {
duke@435 197 saved_features = _features;
duke@435 198 _features = all_features_m;
duke@435 199 }
duke@435 200
duke@435 201 void VM_Version::revert() {
duke@435 202 _features = saved_features;
duke@435 203 }
jmasa@445 204
jmasa@445 205 unsigned int VM_Version::calc_parallel_worker_threads() {
jmasa@445 206 unsigned int result;
jmasa@445 207 if (is_niagara1_plus()) {
jmasa@445 208 result = nof_parallel_worker_threads(5, 16, 8);
jmasa@445 209 } else {
jmasa@445 210 result = nof_parallel_worker_threads(5, 8, 8);
jmasa@445 211 }
jmasa@445 212 return result;
jmasa@445 213 }

mercurial