Thu, 21 Jul 2011 11:25:07 -0700
7063628: Use cbcond on T4
Summary: Add new short branch instruction to Hotspot sparc assembler.
Reviewed-by: never, twisti, jrose
duke@435 | 1 | /* |
kvn@2269 | 2 | * Copyright (c) 1997, 2010, 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 | |
stefank@2314 | 25 | #include "precompiled.hpp" |
stefank@2314 | 26 | #include "assembler_sparc.inline.hpp" |
stefank@2314 | 27 | #include "memory/resourceArea.hpp" |
stefank@2314 | 28 | #include "runtime/java.hpp" |
stefank@2314 | 29 | #include "runtime/stubCodeGenerator.hpp" |
stefank@2314 | 30 | #include "vm_version_sparc.hpp" |
stefank@2314 | 31 | #ifdef TARGET_OS_FAMILY_linux |
stefank@2314 | 32 | # include "os_linux.inline.hpp" |
stefank@2314 | 33 | #endif |
stefank@2314 | 34 | #ifdef TARGET_OS_FAMILY_solaris |
stefank@2314 | 35 | # include "os_solaris.inline.hpp" |
stefank@2314 | 36 | #endif |
duke@435 | 37 | |
duke@435 | 38 | int VM_Version::_features = VM_Version::unknown_m; |
duke@435 | 39 | const char* VM_Version::_features_str = ""; |
duke@435 | 40 | |
duke@435 | 41 | void VM_Version::initialize() { |
duke@435 | 42 | _features = determine_features(); |
duke@435 | 43 | PrefetchCopyIntervalInBytes = prefetch_copy_interval_in_bytes(); |
duke@435 | 44 | PrefetchScanIntervalInBytes = prefetch_scan_interval_in_bytes(); |
duke@435 | 45 | PrefetchFieldsAhead = prefetch_fields_ahead(); |
duke@435 | 46 | |
duke@435 | 47 | // Allocation prefetch settings |
duke@435 | 48 | intx cache_line_size = L1_data_cache_line_size(); |
duke@435 | 49 | if( cache_line_size > AllocatePrefetchStepSize ) |
duke@435 | 50 | AllocatePrefetchStepSize = cache_line_size; |
duke@435 | 51 | if( FLAG_IS_DEFAULT(AllocatePrefetchLines) ) |
duke@435 | 52 | AllocatePrefetchLines = 3; // Optimistic value |
duke@435 | 53 | assert( AllocatePrefetchLines > 0, "invalid value"); |
duke@435 | 54 | if( AllocatePrefetchLines < 1 ) // set valid value in product VM |
duke@435 | 55 | AllocatePrefetchLines = 1; // Conservative value |
duke@435 | 56 | |
duke@435 | 57 | AllocatePrefetchDistance = allocate_prefetch_distance(); |
duke@435 | 58 | AllocatePrefetchStyle = allocate_prefetch_style(); |
duke@435 | 59 | |
duke@435 | 60 | assert(AllocatePrefetchDistance % AllocatePrefetchStepSize == 0, "invalid value"); |
duke@435 | 61 | |
kvn@3037 | 62 | if (AllocatePrefetchStyle == 3 && !has_blk_init()) { |
kvn@3037 | 63 | warning("BIS instructions are not available on this CPU"); |
kvn@3037 | 64 | FLAG_SET_DEFAULT(AllocatePrefetchStyle, 1); |
kvn@3037 | 65 | } |
kvn@3037 | 66 | |
duke@435 | 67 | UseSSE = 0; // Only on x86 and x64 |
duke@435 | 68 | |
duke@435 | 69 | _supports_cx8 = has_v9(); |
duke@435 | 70 | |
kvn@2403 | 71 | if (is_niagara()) { |
duke@435 | 72 | // Indirect branch is the same cost as direct |
duke@435 | 73 | if (FLAG_IS_DEFAULT(UseInlineCaches)) { |
kvn@1110 | 74 | FLAG_SET_DEFAULT(UseInlineCaches, false); |
duke@435 | 75 | } |
kvn@2403 | 76 | // Align loops on a single instruction boundary. |
kvn@2403 | 77 | if (FLAG_IS_DEFAULT(OptoLoopAlignment)) { |
kvn@2403 | 78 | FLAG_SET_DEFAULT(OptoLoopAlignment, 4); |
kvn@2403 | 79 | } |
kvn@2403 | 80 | // When using CMS, we cannot use memset() in BOT updates because |
kvn@2403 | 81 | // the sun4v/CMT version in libc_psr uses BIS which exposes |
kvn@2403 | 82 | // "phantom zeros" to concurrent readers. See 6948537. |
kvn@2403 | 83 | if (FLAG_IS_DEFAULT(UseMemSetInBOT) && UseConcMarkSweepGC) { |
kvn@2403 | 84 | FLAG_SET_DEFAULT(UseMemSetInBOT, false); |
kvn@2403 | 85 | } |
coleenp@548 | 86 | #ifdef _LP64 |
kvn@1077 | 87 | // 32-bit oops don't make sense for the 64-bit VM on sparc |
kvn@1077 | 88 | // since the 32-bit VM has the same registers and smaller objects. |
kvn@1077 | 89 | Universe::set_narrow_oop_shift(LogMinObjAlignmentInBytes); |
coleenp@548 | 90 | #endif // _LP64 |
duke@435 | 91 | #ifdef COMPILER2 |
duke@435 | 92 | // Indirect branch is the same cost as direct |
duke@435 | 93 | if (FLAG_IS_DEFAULT(UseJumpTables)) { |
kvn@1110 | 94 | FLAG_SET_DEFAULT(UseJumpTables, true); |
duke@435 | 95 | } |
duke@435 | 96 | // Single-issue, so entry and loop tops are |
duke@435 | 97 | // aligned on a single instruction boundary |
duke@435 | 98 | if (FLAG_IS_DEFAULT(InteriorEntryAlignment)) { |
kvn@1110 | 99 | FLAG_SET_DEFAULT(InteriorEntryAlignment, 4); |
duke@435 | 100 | } |
kvn@2403 | 101 | if (is_niagara_plus()) { |
kvn@2269 | 102 | if (has_blk_init() && AllocatePrefetchStyle > 0 && |
kvn@2269 | 103 | FLAG_IS_DEFAULT(AllocatePrefetchStyle)) { |
kvn@1802 | 104 | // Use BIS instruction for allocation prefetch. |
kvn@1802 | 105 | FLAG_SET_DEFAULT(AllocatePrefetchStyle, 3); |
kvn@1802 | 106 | if (FLAG_IS_DEFAULT(AllocatePrefetchDistance)) { |
kvn@1802 | 107 | // Use smaller prefetch distance on N2 with BIS |
kvn@1802 | 108 | FLAG_SET_DEFAULT(AllocatePrefetchDistance, 64); |
kvn@1802 | 109 | } |
kvn@1802 | 110 | } |
kvn@1802 | 111 | if (AllocatePrefetchStyle != 3 && FLAG_IS_DEFAULT(AllocatePrefetchDistance)) { |
kvn@1802 | 112 | // Use different prefetch distance without BIS |
kvn@1802 | 113 | FLAG_SET_DEFAULT(AllocatePrefetchDistance, 256); |
kvn@1802 | 114 | } |
duke@435 | 115 | } |
duke@435 | 116 | #endif |
duke@435 | 117 | } |
duke@435 | 118 | |
twisti@1078 | 119 | // Use hardware population count instruction if available. |
twisti@1078 | 120 | if (has_hardware_popc()) { |
twisti@1078 | 121 | if (FLAG_IS_DEFAULT(UsePopCountInstruction)) { |
kvn@1110 | 122 | FLAG_SET_DEFAULT(UsePopCountInstruction, true); |
twisti@1078 | 123 | } |
kvn@3037 | 124 | } else if (UsePopCountInstruction) { |
kvn@3037 | 125 | warning("POPC instruction is not available on this CPU"); |
kvn@3037 | 126 | FLAG_SET_DEFAULT(UsePopCountInstruction, false); |
kvn@3037 | 127 | } |
kvn@3037 | 128 | |
kvn@3037 | 129 | // T4 and newer Sparc cpus have new compare and branch instruction. |
kvn@3037 | 130 | if (has_cbcond()) { |
kvn@3037 | 131 | if (FLAG_IS_DEFAULT(UseCBCond)) { |
kvn@3037 | 132 | FLAG_SET_DEFAULT(UseCBCond, true); |
kvn@3037 | 133 | } |
kvn@3037 | 134 | } else if (UseCBCond) { |
kvn@3037 | 135 | warning("CBCOND instruction is not available on this CPU"); |
kvn@3037 | 136 | FLAG_SET_DEFAULT(UseCBCond, false); |
twisti@1078 | 137 | } |
twisti@1078 | 138 | |
never@2085 | 139 | #ifdef COMPILER2 |
kvn@3037 | 140 | // T4 and newer Sparc cpus have fast RDPC. |
kvn@3037 | 141 | if (has_fast_rdpc() && FLAG_IS_DEFAULT(UseRDPCForConstantTableBase)) { |
kvn@3037 | 142 | // FLAG_SET_DEFAULT(UseRDPCForConstantTableBase, true); |
kvn@3037 | 143 | } |
kvn@3037 | 144 | |
never@2085 | 145 | // Currently not supported anywhere. |
never@2085 | 146 | FLAG_SET_DEFAULT(UseFPUForSpilling, false); |
never@2085 | 147 | #endif |
never@2085 | 148 | |
duke@435 | 149 | char buf[512]; |
kvn@3037 | 150 | jio_snprintf(buf, sizeof(buf), "%s%s%s%s%s%s%s%s%s%s%s%s%s%s", |
kvn@3037 | 151 | (has_v9() ? ", v9" : (has_v8() ? ", v8" : "")), |
twisti@1078 | 152 | (has_hardware_popc() ? ", popc" : ""), |
kvn@3037 | 153 | (has_vis1() ? ", vis1" : ""), |
kvn@3037 | 154 | (has_vis2() ? ", vis2" : ""), |
kvn@3037 | 155 | (has_vis3() ? ", vis3" : ""), |
kvn@3037 | 156 | (has_blk_init() ? ", blk_init" : ""), |
kvn@3037 | 157 | (has_cbcond() ? ", cbcond" : ""), |
kvn@3037 | 158 | (is_ultra3() ? ", ultra3" : ""), |
kvn@3037 | 159 | (is_sun4v() ? ", sun4v" : ""), |
kvn@3037 | 160 | (is_niagara_plus() ? ", niagara_plus" : (is_niagara() ? ", niagara" : "")), |
kvn@3037 | 161 | (is_sparc64() ? ", sparc64" : ""), |
twisti@1076 | 162 | (!has_hardware_mul32() ? ", no-mul32" : ""), |
twisti@1076 | 163 | (!has_hardware_div32() ? ", no-div32" : ""), |
duke@435 | 164 | (!has_hardware_fsmuld() ? ", no-fsmuld" : "")); |
duke@435 | 165 | |
duke@435 | 166 | // buf is started with ", " or is empty |
duke@435 | 167 | _features_str = strdup(strlen(buf) > 2 ? buf + 2 : buf); |
duke@435 | 168 | |
kvn@3001 | 169 | // UseVIS is set to the smallest of what hardware supports and what |
kvn@3001 | 170 | // the command line requires. I.e., you cannot set UseVIS to 3 on |
kvn@3001 | 171 | // older UltraSparc which do not support it. |
kvn@3001 | 172 | if (UseVIS > 3) UseVIS=3; |
kvn@3001 | 173 | if (UseVIS < 0) UseVIS=0; |
kvn@3001 | 174 | if (!has_vis3()) // Drop to 2 if no VIS3 support |
kvn@3001 | 175 | UseVIS = MIN2((intx)2,UseVIS); |
kvn@3001 | 176 | if (!has_vis2()) // Drop to 1 if no VIS2 support |
kvn@3001 | 177 | UseVIS = MIN2((intx)1,UseVIS); |
kvn@3001 | 178 | if (!has_vis1()) // Drop to 0 if no VIS1 support |
kvn@3001 | 179 | UseVIS = 0; |
kvn@3001 | 180 | |
duke@435 | 181 | #ifndef PRODUCT |
duke@435 | 182 | if (PrintMiscellaneous && Verbose) { |
duke@435 | 183 | tty->print("Allocation: "); |
duke@435 | 184 | if (AllocatePrefetchStyle <= 0) { |
duke@435 | 185 | tty->print_cr("no prefetching"); |
duke@435 | 186 | } else { |
duke@435 | 187 | if (AllocatePrefetchLines > 1) { |
duke@435 | 188 | tty->print_cr("PREFETCH %d, %d lines of size %d bytes", AllocatePrefetchDistance, AllocatePrefetchLines, AllocatePrefetchStepSize); |
duke@435 | 189 | } else { |
duke@435 | 190 | tty->print_cr("PREFETCH %d, one line", AllocatePrefetchDistance); |
duke@435 | 191 | } |
duke@435 | 192 | } |
duke@435 | 193 | if (PrefetchCopyIntervalInBytes > 0) { |
duke@435 | 194 | tty->print_cr("PrefetchCopyIntervalInBytes %d", PrefetchCopyIntervalInBytes); |
duke@435 | 195 | } |
duke@435 | 196 | if (PrefetchScanIntervalInBytes > 0) { |
duke@435 | 197 | tty->print_cr("PrefetchScanIntervalInBytes %d", PrefetchScanIntervalInBytes); |
duke@435 | 198 | } |
duke@435 | 199 | if (PrefetchFieldsAhead > 0) { |
duke@435 | 200 | tty->print_cr("PrefetchFieldsAhead %d", PrefetchFieldsAhead); |
duke@435 | 201 | } |
duke@435 | 202 | } |
duke@435 | 203 | #endif // PRODUCT |
duke@435 | 204 | } |
duke@435 | 205 | |
duke@435 | 206 | void VM_Version::print_features() { |
duke@435 | 207 | tty->print_cr("Version:%s", cpu_features()); |
duke@435 | 208 | } |
duke@435 | 209 | |
duke@435 | 210 | int VM_Version::determine_features() { |
duke@435 | 211 | if (UseV8InstrsOnly) { |
duke@435 | 212 | NOT_PRODUCT(if (PrintMiscellaneous && Verbose) tty->print_cr("Version is Forced-V8");) |
duke@435 | 213 | return generic_v8_m; |
duke@435 | 214 | } |
duke@435 | 215 | |
duke@435 | 216 | int features = platform_features(unknown_m); // platform_features() is os_arch specific |
duke@435 | 217 | |
duke@435 | 218 | if (features == unknown_m) { |
duke@435 | 219 | features = generic_v9_m; |
duke@435 | 220 | warning("Cannot recognize SPARC version. Default to V9"); |
duke@435 | 221 | } |
duke@435 | 222 | |
kvn@2403 | 223 | assert(is_T_family(features) == is_niagara(features), "Niagara should be T series"); |
kvn@2403 | 224 | if (UseNiagaraInstrs) { // Force code generation for Niagara |
kvn@2403 | 225 | if (is_T_family(features)) { |
duke@435 | 226 | // Happy to accomodate... |
duke@435 | 227 | } else { |
duke@435 | 228 | NOT_PRODUCT(if (PrintMiscellaneous && Verbose) tty->print_cr("Version is Forced-Niagara");) |
kvn@2403 | 229 | features |= T_family_m; |
duke@435 | 230 | } |
duke@435 | 231 | } else { |
kvn@2403 | 232 | if (is_T_family(features) && !FLAG_IS_DEFAULT(UseNiagaraInstrs)) { |
duke@435 | 233 | NOT_PRODUCT(if (PrintMiscellaneous && Verbose) tty->print_cr("Version is Forced-Not-Niagara");) |
kvn@2403 | 234 | features &= ~(T_family_m | T1_model_m); |
duke@435 | 235 | } else { |
duke@435 | 236 | // Happy to accomodate... |
duke@435 | 237 | } |
duke@435 | 238 | } |
duke@435 | 239 | |
duke@435 | 240 | return features; |
duke@435 | 241 | } |
duke@435 | 242 | |
duke@435 | 243 | static int saved_features = 0; |
duke@435 | 244 | |
duke@435 | 245 | void VM_Version::allow_all() { |
duke@435 | 246 | saved_features = _features; |
duke@435 | 247 | _features = all_features_m; |
duke@435 | 248 | } |
duke@435 | 249 | |
duke@435 | 250 | void VM_Version::revert() { |
duke@435 | 251 | _features = saved_features; |
duke@435 | 252 | } |
jmasa@445 | 253 | |
jmasa@445 | 254 | unsigned int VM_Version::calc_parallel_worker_threads() { |
jmasa@445 | 255 | unsigned int result; |
kvn@2403 | 256 | if (is_niagara_plus()) { |
jmasa@445 | 257 | result = nof_parallel_worker_threads(5, 16, 8); |
jmasa@445 | 258 | } else { |
jmasa@445 | 259 | result = nof_parallel_worker_threads(5, 8, 8); |
jmasa@445 | 260 | } |
jmasa@445 | 261 | return result; |
jmasa@445 | 262 | } |