Tue, 10 Mar 2009 08:52:16 -0700
Merge
twisti@1020 | 1 | /* |
twisti@1020 | 2 | * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved. |
twisti@1020 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
twisti@1020 | 4 | * |
twisti@1020 | 5 | * This code is free software; you can redistribute it and/or modify it |
twisti@1020 | 6 | * under the terms of the GNU General Public License version 2 only, as |
twisti@1020 | 7 | * published by the Free Software Foundation. |
twisti@1020 | 8 | * |
twisti@1020 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
twisti@1020 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
twisti@1020 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
twisti@1020 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
twisti@1020 | 13 | * accompanied this code). |
twisti@1020 | 14 | * |
twisti@1020 | 15 | * You should have received a copy of the GNU General Public License version |
twisti@1020 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
twisti@1020 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
twisti@1020 | 18 | * |
twisti@1020 | 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
twisti@1020 | 20 | * CA 95054 USA or visit www.sun.com if you need additional information or |
twisti@1020 | 21 | * have any questions. |
twisti@1020 | 22 | * |
twisti@1020 | 23 | */ |
twisti@1020 | 24 | |
twisti@1020 | 25 | # include "incls/_precompiled.incl" |
twisti@1020 | 26 | # include "incls/_vm_version_x86.cpp.incl" |
twisti@1020 | 27 | |
twisti@1020 | 28 | |
twisti@1020 | 29 | int VM_Version::_cpu; |
twisti@1020 | 30 | int VM_Version::_model; |
twisti@1020 | 31 | int VM_Version::_stepping; |
twisti@1020 | 32 | int VM_Version::_cpuFeatures; |
twisti@1020 | 33 | const char* VM_Version::_features_str = ""; |
twisti@1020 | 34 | VM_Version::CpuidInfo VM_Version::_cpuid_info = { 0, }; |
twisti@1020 | 35 | |
twisti@1020 | 36 | static BufferBlob* stub_blob; |
twisti@1020 | 37 | static const int stub_size = 300; |
twisti@1020 | 38 | |
twisti@1020 | 39 | extern "C" { |
twisti@1020 | 40 | typedef void (*getPsrInfo_stub_t)(void*); |
twisti@1020 | 41 | } |
twisti@1020 | 42 | static getPsrInfo_stub_t getPsrInfo_stub = NULL; |
twisti@1020 | 43 | |
twisti@1020 | 44 | |
twisti@1020 | 45 | class VM_Version_StubGenerator: public StubCodeGenerator { |
twisti@1020 | 46 | public: |
twisti@1020 | 47 | |
twisti@1020 | 48 | VM_Version_StubGenerator(CodeBuffer *c) : StubCodeGenerator(c) {} |
twisti@1020 | 49 | |
twisti@1020 | 50 | address generate_getPsrInfo() { |
twisti@1020 | 51 | // Flags to test CPU type. |
twisti@1020 | 52 | const uint32_t EFL_AC = 0x40000; |
twisti@1020 | 53 | const uint32_t EFL_ID = 0x200000; |
twisti@1020 | 54 | // Values for when we don't have a CPUID instruction. |
twisti@1020 | 55 | const int CPU_FAMILY_SHIFT = 8; |
twisti@1020 | 56 | const uint32_t CPU_FAMILY_386 = (3 << CPU_FAMILY_SHIFT); |
twisti@1020 | 57 | const uint32_t CPU_FAMILY_486 = (4 << CPU_FAMILY_SHIFT); |
twisti@1020 | 58 | |
twisti@1020 | 59 | Label detect_486, cpu486, detect_586, std_cpuid1; |
twisti@1020 | 60 | Label ext_cpuid1, ext_cpuid5, done; |
twisti@1020 | 61 | |
twisti@1020 | 62 | StubCodeMark mark(this, "VM_Version", "getPsrInfo_stub"); |
twisti@1020 | 63 | # define __ _masm-> |
twisti@1020 | 64 | |
twisti@1020 | 65 | address start = __ pc(); |
twisti@1020 | 66 | |
twisti@1020 | 67 | // |
twisti@1020 | 68 | // void getPsrInfo(VM_Version::CpuidInfo* cpuid_info); |
twisti@1020 | 69 | // |
twisti@1020 | 70 | // LP64: rcx and rdx are first and second argument registers on windows |
twisti@1020 | 71 | |
twisti@1020 | 72 | __ push(rbp); |
twisti@1020 | 73 | #ifdef _LP64 |
twisti@1020 | 74 | __ mov(rbp, c_rarg0); // cpuid_info address |
twisti@1020 | 75 | #else |
twisti@1020 | 76 | __ movptr(rbp, Address(rsp, 8)); // cpuid_info address |
twisti@1020 | 77 | #endif |
twisti@1020 | 78 | __ push(rbx); |
twisti@1020 | 79 | __ push(rsi); |
twisti@1020 | 80 | __ pushf(); // preserve rbx, and flags |
twisti@1020 | 81 | __ pop(rax); |
twisti@1020 | 82 | __ push(rax); |
twisti@1020 | 83 | __ mov(rcx, rax); |
twisti@1020 | 84 | // |
twisti@1020 | 85 | // if we are unable to change the AC flag, we have a 386 |
twisti@1020 | 86 | // |
twisti@1020 | 87 | __ xorl(rax, EFL_AC); |
twisti@1020 | 88 | __ push(rax); |
twisti@1020 | 89 | __ popf(); |
twisti@1020 | 90 | __ pushf(); |
twisti@1020 | 91 | __ pop(rax); |
twisti@1020 | 92 | __ cmpptr(rax, rcx); |
twisti@1020 | 93 | __ jccb(Assembler::notEqual, detect_486); |
twisti@1020 | 94 | |
twisti@1020 | 95 | __ movl(rax, CPU_FAMILY_386); |
twisti@1020 | 96 | __ movl(Address(rbp, in_bytes(VM_Version::std_cpuid1_offset())), rax); |
twisti@1020 | 97 | __ jmp(done); |
twisti@1020 | 98 | |
twisti@1020 | 99 | // |
twisti@1020 | 100 | // If we are unable to change the ID flag, we have a 486 which does |
twisti@1020 | 101 | // not support the "cpuid" instruction. |
twisti@1020 | 102 | // |
twisti@1020 | 103 | __ bind(detect_486); |
twisti@1020 | 104 | __ mov(rax, rcx); |
twisti@1020 | 105 | __ xorl(rax, EFL_ID); |
twisti@1020 | 106 | __ push(rax); |
twisti@1020 | 107 | __ popf(); |
twisti@1020 | 108 | __ pushf(); |
twisti@1020 | 109 | __ pop(rax); |
twisti@1020 | 110 | __ cmpptr(rcx, rax); |
twisti@1020 | 111 | __ jccb(Assembler::notEqual, detect_586); |
twisti@1020 | 112 | |
twisti@1020 | 113 | __ bind(cpu486); |
twisti@1020 | 114 | __ movl(rax, CPU_FAMILY_486); |
twisti@1020 | 115 | __ movl(Address(rbp, in_bytes(VM_Version::std_cpuid1_offset())), rax); |
twisti@1020 | 116 | __ jmp(done); |
twisti@1020 | 117 | |
twisti@1020 | 118 | // |
twisti@1020 | 119 | // At this point, we have a chip which supports the "cpuid" instruction |
twisti@1020 | 120 | // |
twisti@1020 | 121 | __ bind(detect_586); |
twisti@1020 | 122 | __ xorl(rax, rax); |
twisti@1020 | 123 | __ cpuid(); |
twisti@1020 | 124 | __ orl(rax, rax); |
twisti@1020 | 125 | __ jcc(Assembler::equal, cpu486); // if cpuid doesn't support an input |
twisti@1020 | 126 | // value of at least 1, we give up and |
twisti@1020 | 127 | // assume a 486 |
twisti@1020 | 128 | __ lea(rsi, Address(rbp, in_bytes(VM_Version::std_cpuid0_offset()))); |
twisti@1020 | 129 | __ movl(Address(rsi, 0), rax); |
twisti@1020 | 130 | __ movl(Address(rsi, 4), rbx); |
twisti@1020 | 131 | __ movl(Address(rsi, 8), rcx); |
twisti@1020 | 132 | __ movl(Address(rsi,12), rdx); |
twisti@1020 | 133 | |
twisti@1020 | 134 | __ cmpl(rax, 3); // Is cpuid(0x4) supported? |
twisti@1020 | 135 | __ jccb(Assembler::belowEqual, std_cpuid1); |
twisti@1020 | 136 | |
twisti@1020 | 137 | // |
twisti@1020 | 138 | // cpuid(0x4) Deterministic cache params |
twisti@1020 | 139 | // |
twisti@1020 | 140 | __ movl(rax, 4); |
twisti@1020 | 141 | __ xorl(rcx, rcx); // L1 cache |
twisti@1020 | 142 | __ cpuid(); |
twisti@1020 | 143 | __ push(rax); |
twisti@1020 | 144 | __ andl(rax, 0x1f); // Determine if valid cache parameters used |
twisti@1020 | 145 | __ orl(rax, rax); // eax[4:0] == 0 indicates invalid cache |
twisti@1020 | 146 | __ pop(rax); |
twisti@1020 | 147 | __ jccb(Assembler::equal, std_cpuid1); |
twisti@1020 | 148 | |
twisti@1020 | 149 | __ lea(rsi, Address(rbp, in_bytes(VM_Version::dcp_cpuid4_offset()))); |
twisti@1020 | 150 | __ movl(Address(rsi, 0), rax); |
twisti@1020 | 151 | __ movl(Address(rsi, 4), rbx); |
twisti@1020 | 152 | __ movl(Address(rsi, 8), rcx); |
twisti@1020 | 153 | __ movl(Address(rsi,12), rdx); |
twisti@1020 | 154 | |
twisti@1020 | 155 | // |
twisti@1020 | 156 | // Standard cpuid(0x1) |
twisti@1020 | 157 | // |
twisti@1020 | 158 | __ bind(std_cpuid1); |
twisti@1020 | 159 | __ movl(rax, 1); |
twisti@1020 | 160 | __ cpuid(); |
twisti@1020 | 161 | __ lea(rsi, Address(rbp, in_bytes(VM_Version::std_cpuid1_offset()))); |
twisti@1020 | 162 | __ movl(Address(rsi, 0), rax); |
twisti@1020 | 163 | __ movl(Address(rsi, 4), rbx); |
twisti@1020 | 164 | __ movl(Address(rsi, 8), rcx); |
twisti@1020 | 165 | __ movl(Address(rsi,12), rdx); |
twisti@1020 | 166 | |
twisti@1020 | 167 | __ movl(rax, 0x80000000); |
twisti@1020 | 168 | __ cpuid(); |
twisti@1020 | 169 | __ cmpl(rax, 0x80000000); // Is cpuid(0x80000001) supported? |
twisti@1020 | 170 | __ jcc(Assembler::belowEqual, done); |
twisti@1020 | 171 | __ cmpl(rax, 0x80000004); // Is cpuid(0x80000005) supported? |
twisti@1020 | 172 | __ jccb(Assembler::belowEqual, ext_cpuid1); |
twisti@1020 | 173 | __ cmpl(rax, 0x80000007); // Is cpuid(0x80000008) supported? |
twisti@1020 | 174 | __ jccb(Assembler::belowEqual, ext_cpuid5); |
twisti@1020 | 175 | // |
twisti@1020 | 176 | // Extended cpuid(0x80000008) |
twisti@1020 | 177 | // |
twisti@1020 | 178 | __ movl(rax, 0x80000008); |
twisti@1020 | 179 | __ cpuid(); |
twisti@1020 | 180 | __ lea(rsi, Address(rbp, in_bytes(VM_Version::ext_cpuid8_offset()))); |
twisti@1020 | 181 | __ movl(Address(rsi, 0), rax); |
twisti@1020 | 182 | __ movl(Address(rsi, 4), rbx); |
twisti@1020 | 183 | __ movl(Address(rsi, 8), rcx); |
twisti@1020 | 184 | __ movl(Address(rsi,12), rdx); |
twisti@1020 | 185 | |
twisti@1020 | 186 | // |
twisti@1020 | 187 | // Extended cpuid(0x80000005) |
twisti@1020 | 188 | // |
twisti@1020 | 189 | __ bind(ext_cpuid5); |
twisti@1020 | 190 | __ movl(rax, 0x80000005); |
twisti@1020 | 191 | __ cpuid(); |
twisti@1020 | 192 | __ lea(rsi, Address(rbp, in_bytes(VM_Version::ext_cpuid5_offset()))); |
twisti@1020 | 193 | __ movl(Address(rsi, 0), rax); |
twisti@1020 | 194 | __ movl(Address(rsi, 4), rbx); |
twisti@1020 | 195 | __ movl(Address(rsi, 8), rcx); |
twisti@1020 | 196 | __ movl(Address(rsi,12), rdx); |
twisti@1020 | 197 | |
twisti@1020 | 198 | // |
twisti@1020 | 199 | // Extended cpuid(0x80000001) |
twisti@1020 | 200 | // |
twisti@1020 | 201 | __ bind(ext_cpuid1); |
twisti@1020 | 202 | __ movl(rax, 0x80000001); |
twisti@1020 | 203 | __ cpuid(); |
twisti@1020 | 204 | __ lea(rsi, Address(rbp, in_bytes(VM_Version::ext_cpuid1_offset()))); |
twisti@1020 | 205 | __ movl(Address(rsi, 0), rax); |
twisti@1020 | 206 | __ movl(Address(rsi, 4), rbx); |
twisti@1020 | 207 | __ movl(Address(rsi, 8), rcx); |
twisti@1020 | 208 | __ movl(Address(rsi,12), rdx); |
twisti@1020 | 209 | |
twisti@1020 | 210 | // |
twisti@1020 | 211 | // return |
twisti@1020 | 212 | // |
twisti@1020 | 213 | __ bind(done); |
twisti@1020 | 214 | __ popf(); |
twisti@1020 | 215 | __ pop(rsi); |
twisti@1020 | 216 | __ pop(rbx); |
twisti@1020 | 217 | __ pop(rbp); |
twisti@1020 | 218 | __ ret(0); |
twisti@1020 | 219 | |
twisti@1020 | 220 | # undef __ |
twisti@1020 | 221 | |
twisti@1020 | 222 | return start; |
twisti@1020 | 223 | }; |
twisti@1020 | 224 | }; |
twisti@1020 | 225 | |
twisti@1020 | 226 | |
twisti@1020 | 227 | void VM_Version::get_processor_features() { |
twisti@1020 | 228 | |
twisti@1020 | 229 | _cpu = 4; // 486 by default |
twisti@1020 | 230 | _model = 0; |
twisti@1020 | 231 | _stepping = 0; |
twisti@1020 | 232 | _cpuFeatures = 0; |
twisti@1020 | 233 | _logical_processors_per_package = 1; |
twisti@1020 | 234 | |
twisti@1020 | 235 | if (!Use486InstrsOnly) { |
twisti@1020 | 236 | // Get raw processor info |
twisti@1020 | 237 | getPsrInfo_stub(&_cpuid_info); |
twisti@1020 | 238 | assert_is_initialized(); |
twisti@1020 | 239 | _cpu = extended_cpu_family(); |
twisti@1020 | 240 | _model = extended_cpu_model(); |
twisti@1020 | 241 | _stepping = cpu_stepping(); |
twisti@1020 | 242 | |
twisti@1020 | 243 | if (cpu_family() > 4) { // it supports CPUID |
twisti@1020 | 244 | _cpuFeatures = feature_flags(); |
twisti@1020 | 245 | // Logical processors are only available on P4s and above, |
twisti@1020 | 246 | // and only if hyperthreading is available. |
twisti@1020 | 247 | _logical_processors_per_package = logical_processor_count(); |
twisti@1020 | 248 | } |
twisti@1020 | 249 | } |
twisti@1020 | 250 | |
twisti@1020 | 251 | _supports_cx8 = supports_cmpxchg8(); |
twisti@1020 | 252 | |
twisti@1020 | 253 | #ifdef _LP64 |
twisti@1020 | 254 | // OS should support SSE for x64 and hardware should support at least SSE2. |
twisti@1020 | 255 | if (!VM_Version::supports_sse2()) { |
twisti@1020 | 256 | vm_exit_during_initialization("Unknown x64 processor: SSE2 not supported"); |
twisti@1020 | 257 | } |
twisti@1020 | 258 | #endif |
twisti@1020 | 259 | |
twisti@1020 | 260 | // If the OS doesn't support SSE, we can't use this feature even if the HW does |
twisti@1020 | 261 | if (!os::supports_sse()) |
twisti@1020 | 262 | _cpuFeatures &= ~(CPU_SSE|CPU_SSE2|CPU_SSE3|CPU_SSSE3|CPU_SSE4A|CPU_SSE4_1|CPU_SSE4_2); |
twisti@1020 | 263 | |
twisti@1020 | 264 | if (UseSSE < 4) { |
twisti@1020 | 265 | _cpuFeatures &= ~CPU_SSE4_1; |
twisti@1020 | 266 | _cpuFeatures &= ~CPU_SSE4_2; |
twisti@1020 | 267 | } |
twisti@1020 | 268 | |
twisti@1020 | 269 | if (UseSSE < 3) { |
twisti@1020 | 270 | _cpuFeatures &= ~CPU_SSE3; |
twisti@1020 | 271 | _cpuFeatures &= ~CPU_SSSE3; |
twisti@1020 | 272 | _cpuFeatures &= ~CPU_SSE4A; |
twisti@1020 | 273 | } |
twisti@1020 | 274 | |
twisti@1020 | 275 | if (UseSSE < 2) |
twisti@1020 | 276 | _cpuFeatures &= ~CPU_SSE2; |
twisti@1020 | 277 | |
twisti@1020 | 278 | if (UseSSE < 1) |
twisti@1020 | 279 | _cpuFeatures &= ~CPU_SSE; |
twisti@1020 | 280 | |
twisti@1020 | 281 | if (logical_processors_per_package() == 1) { |
twisti@1020 | 282 | // HT processor could be installed on a system which doesn't support HT. |
twisti@1020 | 283 | _cpuFeatures &= ~CPU_HT; |
twisti@1020 | 284 | } |
twisti@1020 | 285 | |
twisti@1020 | 286 | char buf[256]; |
twisti@1020 | 287 | jio_snprintf(buf, sizeof(buf), "(%u cores per cpu, %u threads per core) family %d model %d stepping %d%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", |
twisti@1020 | 288 | cores_per_cpu(), threads_per_core(), |
twisti@1020 | 289 | cpu_family(), _model, _stepping, |
twisti@1020 | 290 | (supports_cmov() ? ", cmov" : ""), |
twisti@1020 | 291 | (supports_cmpxchg8() ? ", cx8" : ""), |
twisti@1020 | 292 | (supports_fxsr() ? ", fxsr" : ""), |
twisti@1020 | 293 | (supports_mmx() ? ", mmx" : ""), |
twisti@1020 | 294 | (supports_sse() ? ", sse" : ""), |
twisti@1020 | 295 | (supports_sse2() ? ", sse2" : ""), |
twisti@1020 | 296 | (supports_sse3() ? ", sse3" : ""), |
twisti@1020 | 297 | (supports_ssse3()? ", ssse3": ""), |
twisti@1020 | 298 | (supports_sse4_1() ? ", sse4.1" : ""), |
twisti@1020 | 299 | (supports_sse4_2() ? ", sse4.2" : ""), |
twisti@1020 | 300 | (supports_mmx_ext() ? ", mmxext" : ""), |
twisti@1020 | 301 | (supports_3dnow() ? ", 3dnow" : ""), |
twisti@1020 | 302 | (supports_3dnow2() ? ", 3dnowext" : ""), |
twisti@1020 | 303 | (supports_sse4a() ? ", sse4a": ""), |
twisti@1020 | 304 | (supports_ht() ? ", ht": "")); |
twisti@1020 | 305 | _features_str = strdup(buf); |
twisti@1020 | 306 | |
twisti@1020 | 307 | // UseSSE is set to the smaller of what hardware supports and what |
twisti@1020 | 308 | // the command line requires. I.e., you cannot set UseSSE to 2 on |
twisti@1020 | 309 | // older Pentiums which do not support it. |
twisti@1020 | 310 | if( UseSSE > 4 ) UseSSE=4; |
twisti@1020 | 311 | if( UseSSE < 0 ) UseSSE=0; |
twisti@1020 | 312 | if( !supports_sse4_1() ) // Drop to 3 if no SSE4 support |
twisti@1020 | 313 | UseSSE = MIN2((intx)3,UseSSE); |
twisti@1020 | 314 | if( !supports_sse3() ) // Drop to 2 if no SSE3 support |
twisti@1020 | 315 | UseSSE = MIN2((intx)2,UseSSE); |
twisti@1020 | 316 | if( !supports_sse2() ) // Drop to 1 if no SSE2 support |
twisti@1020 | 317 | UseSSE = MIN2((intx)1,UseSSE); |
twisti@1020 | 318 | if( !supports_sse () ) // Drop to 0 if no SSE support |
twisti@1020 | 319 | UseSSE = 0; |
twisti@1020 | 320 | |
twisti@1020 | 321 | // On new cpus instructions which update whole XMM register should be used |
twisti@1020 | 322 | // to prevent partial register stall due to dependencies on high half. |
twisti@1020 | 323 | // |
twisti@1020 | 324 | // UseXmmLoadAndClearUpper == true --> movsd(xmm, mem) |
twisti@1020 | 325 | // UseXmmLoadAndClearUpper == false --> movlpd(xmm, mem) |
twisti@1020 | 326 | // UseXmmRegToRegMoveAll == true --> movaps(xmm, xmm), movapd(xmm, xmm). |
twisti@1020 | 327 | // UseXmmRegToRegMoveAll == false --> movss(xmm, xmm), movsd(xmm, xmm). |
twisti@1020 | 328 | |
twisti@1020 | 329 | if( is_amd() ) { // AMD cpus specific settings |
twisti@1020 | 330 | if( supports_sse2() && FLAG_IS_DEFAULT(UseAddressNop) ) { |
twisti@1020 | 331 | // Use it on new AMD cpus starting from Opteron. |
twisti@1020 | 332 | UseAddressNop = true; |
twisti@1020 | 333 | } |
twisti@1020 | 334 | if( supports_sse2() && FLAG_IS_DEFAULT(UseNewLongLShift) ) { |
twisti@1020 | 335 | // Use it on new AMD cpus starting from Opteron. |
twisti@1020 | 336 | UseNewLongLShift = true; |
twisti@1020 | 337 | } |
twisti@1020 | 338 | if( FLAG_IS_DEFAULT(UseXmmLoadAndClearUpper) ) { |
twisti@1020 | 339 | if( supports_sse4a() ) { |
twisti@1020 | 340 | UseXmmLoadAndClearUpper = true; // use movsd only on '10h' Opteron |
twisti@1020 | 341 | } else { |
twisti@1020 | 342 | UseXmmLoadAndClearUpper = false; |
twisti@1020 | 343 | } |
twisti@1020 | 344 | } |
twisti@1020 | 345 | if( FLAG_IS_DEFAULT(UseXmmRegToRegMoveAll) ) { |
twisti@1020 | 346 | if( supports_sse4a() ) { |
twisti@1020 | 347 | UseXmmRegToRegMoveAll = true; // use movaps, movapd only on '10h' |
twisti@1020 | 348 | } else { |
twisti@1020 | 349 | UseXmmRegToRegMoveAll = false; |
twisti@1020 | 350 | } |
twisti@1020 | 351 | } |
twisti@1020 | 352 | if( FLAG_IS_DEFAULT(UseXmmI2F) ) { |
twisti@1020 | 353 | if( supports_sse4a() ) { |
twisti@1020 | 354 | UseXmmI2F = true; |
twisti@1020 | 355 | } else { |
twisti@1020 | 356 | UseXmmI2F = false; |
twisti@1020 | 357 | } |
twisti@1020 | 358 | } |
twisti@1020 | 359 | if( FLAG_IS_DEFAULT(UseXmmI2D) ) { |
twisti@1020 | 360 | if( supports_sse4a() ) { |
twisti@1020 | 361 | UseXmmI2D = true; |
twisti@1020 | 362 | } else { |
twisti@1020 | 363 | UseXmmI2D = false; |
twisti@1020 | 364 | } |
twisti@1020 | 365 | } |
twisti@1020 | 366 | } |
twisti@1020 | 367 | |
twisti@1020 | 368 | if( is_intel() ) { // Intel cpus specific settings |
twisti@1020 | 369 | if( FLAG_IS_DEFAULT(UseStoreImmI16) ) { |
twisti@1020 | 370 | UseStoreImmI16 = false; // don't use it on Intel cpus |
twisti@1020 | 371 | } |
twisti@1020 | 372 | if( cpu_family() == 6 || cpu_family() == 15 ) { |
twisti@1020 | 373 | if( FLAG_IS_DEFAULT(UseAddressNop) ) { |
twisti@1020 | 374 | // Use it on all Intel cpus starting from PentiumPro |
twisti@1020 | 375 | UseAddressNop = true; |
twisti@1020 | 376 | } |
twisti@1020 | 377 | } |
twisti@1020 | 378 | if( FLAG_IS_DEFAULT(UseXmmLoadAndClearUpper) ) { |
twisti@1020 | 379 | UseXmmLoadAndClearUpper = true; // use movsd on all Intel cpus |
twisti@1020 | 380 | } |
twisti@1020 | 381 | if( FLAG_IS_DEFAULT(UseXmmRegToRegMoveAll) ) { |
twisti@1020 | 382 | if( supports_sse3() ) { |
twisti@1020 | 383 | UseXmmRegToRegMoveAll = true; // use movaps, movapd on new Intel cpus |
twisti@1020 | 384 | } else { |
twisti@1020 | 385 | UseXmmRegToRegMoveAll = false; |
twisti@1020 | 386 | } |
twisti@1020 | 387 | } |
twisti@1020 | 388 | if( cpu_family() == 6 && supports_sse3() ) { // New Intel cpus |
twisti@1020 | 389 | #ifdef COMPILER2 |
twisti@1020 | 390 | if( FLAG_IS_DEFAULT(MaxLoopPad) ) { |
twisti@1020 | 391 | // For new Intel cpus do the next optimization: |
twisti@1020 | 392 | // don't align the beginning of a loop if there are enough instructions |
twisti@1020 | 393 | // left (NumberOfLoopInstrToAlign defined in c2_globals.hpp) |
twisti@1020 | 394 | // in current fetch line (OptoLoopAlignment) or the padding |
twisti@1020 | 395 | // is big (> MaxLoopPad). |
twisti@1020 | 396 | // Set MaxLoopPad to 11 for new Intel cpus to reduce number of |
twisti@1020 | 397 | // generated NOP instructions. 11 is the largest size of one |
twisti@1020 | 398 | // address NOP instruction '0F 1F' (see Assembler::nop(i)). |
twisti@1020 | 399 | MaxLoopPad = 11; |
twisti@1020 | 400 | } |
twisti@1020 | 401 | #endif // COMPILER2 |
twisti@1020 | 402 | if( FLAG_IS_DEFAULT(UseXMMForArrayCopy) ) { |
twisti@1020 | 403 | UseXMMForArrayCopy = true; // use SSE2 movq on new Intel cpus |
twisti@1020 | 404 | } |
twisti@1020 | 405 | if( supports_sse4_2() && supports_ht() ) { // Newest Intel cpus |
twisti@1020 | 406 | if( FLAG_IS_DEFAULT(UseUnalignedLoadStores) && UseXMMForArrayCopy ) { |
twisti@1020 | 407 | UseUnalignedLoadStores = true; // use movdqu on newest Intel cpus |
twisti@1020 | 408 | } |
twisti@1020 | 409 | } |
twisti@1020 | 410 | } |
twisti@1020 | 411 | } |
twisti@1020 | 412 | |
twisti@1020 | 413 | assert(0 <= ReadPrefetchInstr && ReadPrefetchInstr <= 3, "invalid value"); |
twisti@1020 | 414 | assert(0 <= AllocatePrefetchInstr && AllocatePrefetchInstr <= 3, "invalid value"); |
twisti@1020 | 415 | |
twisti@1020 | 416 | // set valid Prefetch instruction |
twisti@1020 | 417 | if( ReadPrefetchInstr < 0 ) ReadPrefetchInstr = 0; |
twisti@1020 | 418 | if( ReadPrefetchInstr > 3 ) ReadPrefetchInstr = 3; |
twisti@1020 | 419 | if( ReadPrefetchInstr == 3 && !supports_3dnow() ) ReadPrefetchInstr = 0; |
twisti@1020 | 420 | if( !supports_sse() && supports_3dnow() ) ReadPrefetchInstr = 3; |
twisti@1020 | 421 | |
twisti@1020 | 422 | if( AllocatePrefetchInstr < 0 ) AllocatePrefetchInstr = 0; |
twisti@1020 | 423 | if( AllocatePrefetchInstr > 3 ) AllocatePrefetchInstr = 3; |
twisti@1020 | 424 | if( AllocatePrefetchInstr == 3 && !supports_3dnow() ) AllocatePrefetchInstr=0; |
twisti@1020 | 425 | if( !supports_sse() && supports_3dnow() ) AllocatePrefetchInstr = 3; |
twisti@1020 | 426 | |
twisti@1020 | 427 | // Allocation prefetch settings |
twisti@1020 | 428 | intx cache_line_size = L1_data_cache_line_size(); |
twisti@1020 | 429 | if( cache_line_size > AllocatePrefetchStepSize ) |
twisti@1020 | 430 | AllocatePrefetchStepSize = cache_line_size; |
twisti@1020 | 431 | if( FLAG_IS_DEFAULT(AllocatePrefetchLines) ) |
twisti@1020 | 432 | AllocatePrefetchLines = 3; // Optimistic value |
twisti@1020 | 433 | assert(AllocatePrefetchLines > 0, "invalid value"); |
twisti@1020 | 434 | if( AllocatePrefetchLines < 1 ) // set valid value in product VM |
twisti@1020 | 435 | AllocatePrefetchLines = 1; // Conservative value |
twisti@1020 | 436 | |
twisti@1020 | 437 | AllocatePrefetchDistance = allocate_prefetch_distance(); |
twisti@1020 | 438 | AllocatePrefetchStyle = allocate_prefetch_style(); |
twisti@1020 | 439 | |
twisti@1020 | 440 | if( AllocatePrefetchStyle == 2 && is_intel() && |
twisti@1020 | 441 | cpu_family() == 6 && supports_sse3() ) { // watermark prefetching on Core |
twisti@1020 | 442 | #ifdef _LP64 |
twisti@1020 | 443 | AllocatePrefetchDistance = 384; |
twisti@1020 | 444 | #else |
twisti@1020 | 445 | AllocatePrefetchDistance = 320; |
twisti@1020 | 446 | #endif |
twisti@1020 | 447 | } |
twisti@1020 | 448 | assert(AllocatePrefetchDistance % AllocatePrefetchStepSize == 0, "invalid value"); |
twisti@1020 | 449 | |
twisti@1020 | 450 | #ifdef _LP64 |
twisti@1020 | 451 | // Prefetch settings |
twisti@1020 | 452 | PrefetchCopyIntervalInBytes = prefetch_copy_interval_in_bytes(); |
twisti@1020 | 453 | PrefetchScanIntervalInBytes = prefetch_scan_interval_in_bytes(); |
twisti@1020 | 454 | PrefetchFieldsAhead = prefetch_fields_ahead(); |
twisti@1020 | 455 | #endif |
twisti@1020 | 456 | |
twisti@1020 | 457 | #ifndef PRODUCT |
twisti@1020 | 458 | if (PrintMiscellaneous && Verbose) { |
twisti@1020 | 459 | tty->print_cr("Logical CPUs per core: %u", |
twisti@1020 | 460 | logical_processors_per_package()); |
twisti@1020 | 461 | tty->print_cr("UseSSE=%d",UseSSE); |
twisti@1020 | 462 | tty->print("Allocation: "); |
twisti@1020 | 463 | if (AllocatePrefetchStyle <= 0 || UseSSE == 0 && !supports_3dnow()) { |
twisti@1020 | 464 | tty->print_cr("no prefetching"); |
twisti@1020 | 465 | } else { |
twisti@1020 | 466 | if (UseSSE == 0 && supports_3dnow()) { |
twisti@1020 | 467 | tty->print("PREFETCHW"); |
twisti@1020 | 468 | } else if (UseSSE >= 1) { |
twisti@1020 | 469 | if (AllocatePrefetchInstr == 0) { |
twisti@1020 | 470 | tty->print("PREFETCHNTA"); |
twisti@1020 | 471 | } else if (AllocatePrefetchInstr == 1) { |
twisti@1020 | 472 | tty->print("PREFETCHT0"); |
twisti@1020 | 473 | } else if (AllocatePrefetchInstr == 2) { |
twisti@1020 | 474 | tty->print("PREFETCHT2"); |
twisti@1020 | 475 | } else if (AllocatePrefetchInstr == 3) { |
twisti@1020 | 476 | tty->print("PREFETCHW"); |
twisti@1020 | 477 | } |
twisti@1020 | 478 | } |
twisti@1020 | 479 | if (AllocatePrefetchLines > 1) { |
twisti@1020 | 480 | tty->print_cr(" %d, %d lines with step %d bytes", AllocatePrefetchDistance, AllocatePrefetchLines, AllocatePrefetchStepSize); |
twisti@1020 | 481 | } else { |
twisti@1020 | 482 | tty->print_cr(" %d, one line", AllocatePrefetchDistance); |
twisti@1020 | 483 | } |
twisti@1020 | 484 | } |
twisti@1020 | 485 | |
twisti@1020 | 486 | if (PrefetchCopyIntervalInBytes > 0) { |
twisti@1020 | 487 | tty->print_cr("PrefetchCopyIntervalInBytes %d", PrefetchCopyIntervalInBytes); |
twisti@1020 | 488 | } |
twisti@1020 | 489 | if (PrefetchScanIntervalInBytes > 0) { |
twisti@1020 | 490 | tty->print_cr("PrefetchScanIntervalInBytes %d", PrefetchScanIntervalInBytes); |
twisti@1020 | 491 | } |
twisti@1020 | 492 | if (PrefetchFieldsAhead > 0) { |
twisti@1020 | 493 | tty->print_cr("PrefetchFieldsAhead %d", PrefetchFieldsAhead); |
twisti@1020 | 494 | } |
twisti@1020 | 495 | } |
twisti@1020 | 496 | #endif // !PRODUCT |
twisti@1020 | 497 | } |
twisti@1020 | 498 | |
twisti@1020 | 499 | void VM_Version::initialize() { |
twisti@1020 | 500 | ResourceMark rm; |
twisti@1020 | 501 | // Making this stub must be FIRST use of assembler |
twisti@1020 | 502 | |
twisti@1020 | 503 | stub_blob = BufferBlob::create("getPsrInfo_stub", stub_size); |
twisti@1020 | 504 | if (stub_blob == NULL) { |
twisti@1020 | 505 | vm_exit_during_initialization("Unable to allocate getPsrInfo_stub"); |
twisti@1020 | 506 | } |
twisti@1020 | 507 | CodeBuffer c(stub_blob->instructions_begin(), |
twisti@1020 | 508 | stub_blob->instructions_size()); |
twisti@1020 | 509 | VM_Version_StubGenerator g(&c); |
twisti@1020 | 510 | getPsrInfo_stub = CAST_TO_FN_PTR(getPsrInfo_stub_t, |
twisti@1020 | 511 | g.generate_getPsrInfo()); |
twisti@1020 | 512 | |
twisti@1020 | 513 | get_processor_features(); |
twisti@1020 | 514 | } |