Thu, 24 May 2018 17:06:56 +0800
Merge
aoqi@0 | 1 | /* |
aoqi@0 | 2 | * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. |
aoqi@0 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
aoqi@0 | 4 | * |
aoqi@0 | 5 | * This code is free software; you can redistribute it and/or modify it |
aoqi@0 | 6 | * under the terms of the GNU General Public License version 2 only, as |
aoqi@0 | 7 | * published by the Free Software Foundation. |
aoqi@0 | 8 | * |
aoqi@0 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
aoqi@0 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
aoqi@0 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
aoqi@0 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
aoqi@0 | 13 | * accompanied this code). |
aoqi@0 | 14 | * |
aoqi@0 | 15 | * You should have received a copy of the GNU General Public License version |
aoqi@0 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
aoqi@0 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
aoqi@0 | 18 | * |
aoqi@0 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
aoqi@0 | 20 | * or visit www.oracle.com if you need additional information or have any |
aoqi@0 | 21 | * questions. |
aoqi@0 | 22 | * |
aoqi@0 | 23 | */ |
aoqi@0 | 24 | |
aoqi@0 | 25 | #include "precompiled.hpp" |
aoqi@0 | 26 | #include "asm/macroAssembler.hpp" |
aoqi@0 | 27 | #include "asm/macroAssembler.inline.hpp" |
aoqi@0 | 28 | #include "memory/resourceArea.hpp" |
aoqi@0 | 29 | #include "runtime/java.hpp" |
aoqi@0 | 30 | #include "runtime/stubCodeGenerator.hpp" |
aoqi@0 | 31 | #include "vm_version_x86.hpp" |
aoqi@0 | 32 | #ifdef TARGET_OS_FAMILY_linux |
aoqi@0 | 33 | # include "os_linux.inline.hpp" |
aoqi@0 | 34 | #endif |
aoqi@0 | 35 | #ifdef TARGET_OS_FAMILY_solaris |
aoqi@0 | 36 | # include "os_solaris.inline.hpp" |
aoqi@0 | 37 | #endif |
aoqi@0 | 38 | #ifdef TARGET_OS_FAMILY_windows |
aoqi@0 | 39 | # include "os_windows.inline.hpp" |
aoqi@0 | 40 | #endif |
aoqi@0 | 41 | #ifdef TARGET_OS_FAMILY_bsd |
aoqi@0 | 42 | # include "os_bsd.inline.hpp" |
aoqi@0 | 43 | #endif |
aoqi@0 | 44 | |
aoqi@0 | 45 | |
aoqi@0 | 46 | int VM_Version::_cpu; |
aoqi@0 | 47 | int VM_Version::_model; |
aoqi@0 | 48 | int VM_Version::_stepping; |
aoqi@0 | 49 | int VM_Version::_cpuFeatures; |
aoqi@0 | 50 | const char* VM_Version::_features_str = ""; |
aoqi@0 | 51 | VM_Version::CpuidInfo VM_Version::_cpuid_info = { 0, }; |
aoqi@0 | 52 | |
aoqi@0 | 53 | // Address of instruction which causes SEGV |
aoqi@0 | 54 | address VM_Version::_cpuinfo_segv_addr = 0; |
aoqi@0 | 55 | // Address of instruction after the one which causes SEGV |
aoqi@0 | 56 | address VM_Version::_cpuinfo_cont_addr = 0; |
aoqi@0 | 57 | |
aoqi@0 | 58 | static BufferBlob* stub_blob; |
aoqi@0 | 59 | static const int stub_size = 600; |
aoqi@0 | 60 | |
aoqi@0 | 61 | extern "C" { |
aoqi@0 | 62 | typedef void (*get_cpu_info_stub_t)(void*); |
aoqi@0 | 63 | } |
aoqi@0 | 64 | static get_cpu_info_stub_t get_cpu_info_stub = NULL; |
aoqi@0 | 65 | |
aoqi@0 | 66 | |
aoqi@0 | 67 | class VM_Version_StubGenerator: public StubCodeGenerator { |
aoqi@0 | 68 | public: |
aoqi@0 | 69 | |
aoqi@0 | 70 | VM_Version_StubGenerator(CodeBuffer *c) : StubCodeGenerator(c) {} |
aoqi@0 | 71 | |
aoqi@0 | 72 | address generate_get_cpu_info() { |
aoqi@0 | 73 | // Flags to test CPU type. |
aoqi@0 | 74 | const uint32_t HS_EFL_AC = 0x40000; |
aoqi@0 | 75 | const uint32_t HS_EFL_ID = 0x200000; |
aoqi@0 | 76 | // Values for when we don't have a CPUID instruction. |
aoqi@0 | 77 | const int CPU_FAMILY_SHIFT = 8; |
aoqi@0 | 78 | const uint32_t CPU_FAMILY_386 = (3 << CPU_FAMILY_SHIFT); |
aoqi@0 | 79 | const uint32_t CPU_FAMILY_486 = (4 << CPU_FAMILY_SHIFT); |
aoqi@0 | 80 | |
aoqi@0 | 81 | Label detect_486, cpu486, detect_586, std_cpuid1, std_cpuid4; |
aoqi@0 | 82 | Label sef_cpuid, ext_cpuid, ext_cpuid1, ext_cpuid5, ext_cpuid7, done; |
aoqi@0 | 83 | |
aoqi@0 | 84 | StubCodeMark mark(this, "VM_Version", "get_cpu_info_stub"); |
aoqi@0 | 85 | # define __ _masm-> |
aoqi@0 | 86 | |
aoqi@0 | 87 | address start = __ pc(); |
aoqi@0 | 88 | |
aoqi@0 | 89 | // |
aoqi@0 | 90 | // void get_cpu_info(VM_Version::CpuidInfo* cpuid_info); |
aoqi@0 | 91 | // |
aoqi@0 | 92 | // LP64: rcx and rdx are first and second argument registers on windows |
aoqi@0 | 93 | |
aoqi@0 | 94 | __ push(rbp); |
aoqi@0 | 95 | #ifdef _LP64 |
aoqi@0 | 96 | __ mov(rbp, c_rarg0); // cpuid_info address |
aoqi@0 | 97 | #else |
aoqi@0 | 98 | __ movptr(rbp, Address(rsp, 8)); // cpuid_info address |
aoqi@0 | 99 | #endif |
aoqi@0 | 100 | __ push(rbx); |
aoqi@0 | 101 | __ push(rsi); |
aoqi@0 | 102 | __ pushf(); // preserve rbx, and flags |
aoqi@0 | 103 | __ pop(rax); |
aoqi@0 | 104 | __ push(rax); |
aoqi@0 | 105 | __ mov(rcx, rax); |
aoqi@0 | 106 | // |
aoqi@0 | 107 | // if we are unable to change the AC flag, we have a 386 |
aoqi@0 | 108 | // |
aoqi@0 | 109 | __ xorl(rax, HS_EFL_AC); |
aoqi@0 | 110 | __ push(rax); |
aoqi@0 | 111 | __ popf(); |
aoqi@0 | 112 | __ pushf(); |
aoqi@0 | 113 | __ pop(rax); |
aoqi@0 | 114 | __ cmpptr(rax, rcx); |
aoqi@0 | 115 | __ jccb(Assembler::notEqual, detect_486); |
aoqi@0 | 116 | |
aoqi@0 | 117 | __ movl(rax, CPU_FAMILY_386); |
aoqi@0 | 118 | __ movl(Address(rbp, in_bytes(VM_Version::std_cpuid1_offset())), rax); |
aoqi@0 | 119 | __ jmp(done); |
aoqi@0 | 120 | |
aoqi@0 | 121 | // |
aoqi@0 | 122 | // If we are unable to change the ID flag, we have a 486 which does |
aoqi@0 | 123 | // not support the "cpuid" instruction. |
aoqi@0 | 124 | // |
aoqi@0 | 125 | __ bind(detect_486); |
aoqi@0 | 126 | __ mov(rax, rcx); |
aoqi@0 | 127 | __ xorl(rax, HS_EFL_ID); |
aoqi@0 | 128 | __ push(rax); |
aoqi@0 | 129 | __ popf(); |
aoqi@0 | 130 | __ pushf(); |
aoqi@0 | 131 | __ pop(rax); |
aoqi@0 | 132 | __ cmpptr(rcx, rax); |
aoqi@0 | 133 | __ jccb(Assembler::notEqual, detect_586); |
aoqi@0 | 134 | |
aoqi@0 | 135 | __ bind(cpu486); |
aoqi@0 | 136 | __ movl(rax, CPU_FAMILY_486); |
aoqi@0 | 137 | __ movl(Address(rbp, in_bytes(VM_Version::std_cpuid1_offset())), rax); |
aoqi@0 | 138 | __ jmp(done); |
aoqi@0 | 139 | |
aoqi@0 | 140 | // |
aoqi@0 | 141 | // At this point, we have a chip which supports the "cpuid" instruction |
aoqi@0 | 142 | // |
aoqi@0 | 143 | __ bind(detect_586); |
aoqi@0 | 144 | __ xorl(rax, rax); |
aoqi@0 | 145 | __ cpuid(); |
aoqi@0 | 146 | __ orl(rax, rax); |
aoqi@0 | 147 | __ jcc(Assembler::equal, cpu486); // if cpuid doesn't support an input |
aoqi@0 | 148 | // value of at least 1, we give up and |
aoqi@0 | 149 | // assume a 486 |
aoqi@0 | 150 | __ lea(rsi, Address(rbp, in_bytes(VM_Version::std_cpuid0_offset()))); |
aoqi@0 | 151 | __ movl(Address(rsi, 0), rax); |
aoqi@0 | 152 | __ movl(Address(rsi, 4), rbx); |
aoqi@0 | 153 | __ movl(Address(rsi, 8), rcx); |
aoqi@0 | 154 | __ movl(Address(rsi,12), rdx); |
aoqi@0 | 155 | |
aoqi@0 | 156 | __ cmpl(rax, 0xa); // Is cpuid(0xB) supported? |
aoqi@0 | 157 | __ jccb(Assembler::belowEqual, std_cpuid4); |
aoqi@0 | 158 | |
aoqi@0 | 159 | // |
aoqi@0 | 160 | // cpuid(0xB) Processor Topology |
aoqi@0 | 161 | // |
aoqi@0 | 162 | __ movl(rax, 0xb); |
aoqi@0 | 163 | __ xorl(rcx, rcx); // Threads level |
aoqi@0 | 164 | __ cpuid(); |
aoqi@0 | 165 | |
aoqi@0 | 166 | __ lea(rsi, Address(rbp, in_bytes(VM_Version::tpl_cpuidB0_offset()))); |
aoqi@0 | 167 | __ movl(Address(rsi, 0), rax); |
aoqi@0 | 168 | __ movl(Address(rsi, 4), rbx); |
aoqi@0 | 169 | __ movl(Address(rsi, 8), rcx); |
aoqi@0 | 170 | __ movl(Address(rsi,12), rdx); |
aoqi@0 | 171 | |
aoqi@0 | 172 | __ movl(rax, 0xb); |
aoqi@0 | 173 | __ movl(rcx, 1); // Cores level |
aoqi@0 | 174 | __ cpuid(); |
aoqi@0 | 175 | __ push(rax); |
aoqi@0 | 176 | __ andl(rax, 0x1f); // Determine if valid topology level |
aoqi@0 | 177 | __ orl(rax, rbx); // eax[4:0] | ebx[0:15] == 0 indicates invalid level |
aoqi@0 | 178 | __ andl(rax, 0xffff); |
aoqi@0 | 179 | __ pop(rax); |
aoqi@0 | 180 | __ jccb(Assembler::equal, std_cpuid4); |
aoqi@0 | 181 | |
aoqi@0 | 182 | __ lea(rsi, Address(rbp, in_bytes(VM_Version::tpl_cpuidB1_offset()))); |
aoqi@0 | 183 | __ movl(Address(rsi, 0), rax); |
aoqi@0 | 184 | __ movl(Address(rsi, 4), rbx); |
aoqi@0 | 185 | __ movl(Address(rsi, 8), rcx); |
aoqi@0 | 186 | __ movl(Address(rsi,12), rdx); |
aoqi@0 | 187 | |
aoqi@0 | 188 | __ movl(rax, 0xb); |
aoqi@0 | 189 | __ movl(rcx, 2); // Packages level |
aoqi@0 | 190 | __ cpuid(); |
aoqi@0 | 191 | __ push(rax); |
aoqi@0 | 192 | __ andl(rax, 0x1f); // Determine if valid topology level |
aoqi@0 | 193 | __ orl(rax, rbx); // eax[4:0] | ebx[0:15] == 0 indicates invalid level |
aoqi@0 | 194 | __ andl(rax, 0xffff); |
aoqi@0 | 195 | __ pop(rax); |
aoqi@0 | 196 | __ jccb(Assembler::equal, std_cpuid4); |
aoqi@0 | 197 | |
aoqi@0 | 198 | __ lea(rsi, Address(rbp, in_bytes(VM_Version::tpl_cpuidB2_offset()))); |
aoqi@0 | 199 | __ movl(Address(rsi, 0), rax); |
aoqi@0 | 200 | __ movl(Address(rsi, 4), rbx); |
aoqi@0 | 201 | __ movl(Address(rsi, 8), rcx); |
aoqi@0 | 202 | __ movl(Address(rsi,12), rdx); |
aoqi@0 | 203 | |
aoqi@0 | 204 | // |
aoqi@0 | 205 | // cpuid(0x4) Deterministic cache params |
aoqi@0 | 206 | // |
aoqi@0 | 207 | __ bind(std_cpuid4); |
aoqi@0 | 208 | __ movl(rax, 4); |
aoqi@0 | 209 | __ cmpl(rax, Address(rbp, in_bytes(VM_Version::std_cpuid0_offset()))); // Is cpuid(0x4) supported? |
aoqi@0 | 210 | __ jccb(Assembler::greater, std_cpuid1); |
aoqi@0 | 211 | |
aoqi@0 | 212 | __ xorl(rcx, rcx); // L1 cache |
aoqi@0 | 213 | __ cpuid(); |
aoqi@0 | 214 | __ push(rax); |
aoqi@0 | 215 | __ andl(rax, 0x1f); // Determine if valid cache parameters used |
aoqi@0 | 216 | __ orl(rax, rax); // eax[4:0] == 0 indicates invalid cache |
aoqi@0 | 217 | __ pop(rax); |
aoqi@0 | 218 | __ jccb(Assembler::equal, std_cpuid1); |
aoqi@0 | 219 | |
aoqi@0 | 220 | __ lea(rsi, Address(rbp, in_bytes(VM_Version::dcp_cpuid4_offset()))); |
aoqi@0 | 221 | __ movl(Address(rsi, 0), rax); |
aoqi@0 | 222 | __ movl(Address(rsi, 4), rbx); |
aoqi@0 | 223 | __ movl(Address(rsi, 8), rcx); |
aoqi@0 | 224 | __ movl(Address(rsi,12), rdx); |
aoqi@0 | 225 | |
aoqi@0 | 226 | // |
aoqi@0 | 227 | // Standard cpuid(0x1) |
aoqi@0 | 228 | // |
aoqi@0 | 229 | __ bind(std_cpuid1); |
aoqi@0 | 230 | __ movl(rax, 1); |
aoqi@0 | 231 | __ cpuid(); |
aoqi@0 | 232 | __ lea(rsi, Address(rbp, in_bytes(VM_Version::std_cpuid1_offset()))); |
aoqi@0 | 233 | __ movl(Address(rsi, 0), rax); |
aoqi@0 | 234 | __ movl(Address(rsi, 4), rbx); |
aoqi@0 | 235 | __ movl(Address(rsi, 8), rcx); |
aoqi@0 | 236 | __ movl(Address(rsi,12), rdx); |
aoqi@0 | 237 | |
aoqi@0 | 238 | // |
aoqi@0 | 239 | // Check if OS has enabled XGETBV instruction to access XCR0 |
aoqi@0 | 240 | // (OSXSAVE feature flag) and CPU supports AVX |
aoqi@0 | 241 | // |
aoqi@0 | 242 | __ andl(rcx, 0x18000000); // cpuid1 bits osxsave | avx |
aoqi@0 | 243 | __ cmpl(rcx, 0x18000000); |
aoqi@0 | 244 | __ jccb(Assembler::notEqual, sef_cpuid); // jump if AVX is not supported |
aoqi@0 | 245 | |
aoqi@0 | 246 | // |
aoqi@0 | 247 | // XCR0, XFEATURE_ENABLED_MASK register |
aoqi@0 | 248 | // |
aoqi@0 | 249 | __ xorl(rcx, rcx); // zero for XCR0 register |
aoqi@0 | 250 | __ xgetbv(); |
aoqi@0 | 251 | __ lea(rsi, Address(rbp, in_bytes(VM_Version::xem_xcr0_offset()))); |
aoqi@0 | 252 | __ movl(Address(rsi, 0), rax); |
aoqi@0 | 253 | __ movl(Address(rsi, 4), rdx); |
aoqi@0 | 254 | |
aoqi@0 | 255 | __ andl(rax, 0x6); // xcr0 bits sse | ymm |
aoqi@0 | 256 | __ cmpl(rax, 0x6); |
aoqi@0 | 257 | __ jccb(Assembler::notEqual, sef_cpuid); // jump if AVX is not supported |
aoqi@0 | 258 | |
aoqi@0 | 259 | // |
aoqi@0 | 260 | // Some OSs have a bug when upper 128bits of YMM |
aoqi@0 | 261 | // registers are not restored after a signal processing. |
aoqi@0 | 262 | // Generate SEGV here (reference through NULL) |
aoqi@0 | 263 | // and check upper YMM bits after it. |
aoqi@0 | 264 | // |
aoqi@0 | 265 | VM_Version::set_avx_cpuFeatures(); // Enable temporary to pass asserts |
aoqi@0 | 266 | intx saved_useavx = UseAVX; |
aoqi@0 | 267 | intx saved_usesse = UseSSE; |
aoqi@0 | 268 | UseAVX = 1; |
aoqi@0 | 269 | UseSSE = 2; |
aoqi@0 | 270 | |
aoqi@0 | 271 | // load value into all 32 bytes of ymm7 register |
aoqi@0 | 272 | __ movl(rcx, VM_Version::ymm_test_value()); |
aoqi@0 | 273 | |
aoqi@0 | 274 | __ movdl(xmm0, rcx); |
aoqi@0 | 275 | __ pshufd(xmm0, xmm0, 0x00); |
aoqi@0 | 276 | __ vinsertf128h(xmm0, xmm0, xmm0); |
aoqi@0 | 277 | __ vmovdqu(xmm7, xmm0); |
aoqi@0 | 278 | #ifdef _LP64 |
aoqi@0 | 279 | __ vmovdqu(xmm8, xmm0); |
aoqi@0 | 280 | __ vmovdqu(xmm15, xmm0); |
aoqi@0 | 281 | #endif |
aoqi@0 | 282 | |
aoqi@0 | 283 | __ xorl(rsi, rsi); |
aoqi@0 | 284 | VM_Version::set_cpuinfo_segv_addr( __ pc() ); |
aoqi@0 | 285 | // Generate SEGV |
aoqi@0 | 286 | __ movl(rax, Address(rsi, 0)); |
aoqi@0 | 287 | |
aoqi@0 | 288 | VM_Version::set_cpuinfo_cont_addr( __ pc() ); |
aoqi@0 | 289 | // Returns here after signal. Save xmm0 to check it later. |
aoqi@0 | 290 | __ lea(rsi, Address(rbp, in_bytes(VM_Version::ymm_save_offset()))); |
aoqi@0 | 291 | __ vmovdqu(Address(rsi, 0), xmm0); |
aoqi@0 | 292 | __ vmovdqu(Address(rsi, 32), xmm7); |
aoqi@0 | 293 | #ifdef _LP64 |
aoqi@0 | 294 | __ vmovdqu(Address(rsi, 64), xmm8); |
aoqi@0 | 295 | __ vmovdqu(Address(rsi, 96), xmm15); |
aoqi@0 | 296 | #endif |
aoqi@0 | 297 | |
aoqi@0 | 298 | VM_Version::clean_cpuFeatures(); |
aoqi@0 | 299 | UseAVX = saved_useavx; |
aoqi@0 | 300 | UseSSE = saved_usesse; |
aoqi@0 | 301 | |
aoqi@0 | 302 | // |
aoqi@0 | 303 | // cpuid(0x7) Structured Extended Features |
aoqi@0 | 304 | // |
aoqi@0 | 305 | __ bind(sef_cpuid); |
aoqi@0 | 306 | __ movl(rax, 7); |
aoqi@0 | 307 | __ cmpl(rax, Address(rbp, in_bytes(VM_Version::std_cpuid0_offset()))); // Is cpuid(0x7) supported? |
aoqi@0 | 308 | __ jccb(Assembler::greater, ext_cpuid); |
aoqi@0 | 309 | |
aoqi@0 | 310 | __ xorl(rcx, rcx); |
aoqi@0 | 311 | __ cpuid(); |
aoqi@0 | 312 | __ lea(rsi, Address(rbp, in_bytes(VM_Version::sef_cpuid7_offset()))); |
aoqi@0 | 313 | __ movl(Address(rsi, 0), rax); |
aoqi@0 | 314 | __ movl(Address(rsi, 4), rbx); |
aoqi@0 | 315 | |
aoqi@0 | 316 | // |
aoqi@0 | 317 | // Extended cpuid(0x80000000) |
aoqi@0 | 318 | // |
aoqi@0 | 319 | __ bind(ext_cpuid); |
aoqi@0 | 320 | __ movl(rax, 0x80000000); |
aoqi@0 | 321 | __ cpuid(); |
aoqi@0 | 322 | __ cmpl(rax, 0x80000000); // Is cpuid(0x80000001) supported? |
aoqi@0 | 323 | __ jcc(Assembler::belowEqual, done); |
aoqi@0 | 324 | __ cmpl(rax, 0x80000004); // Is cpuid(0x80000005) supported? |
aoqi@0 | 325 | __ jccb(Assembler::belowEqual, ext_cpuid1); |
aoqi@0 | 326 | __ cmpl(rax, 0x80000006); // Is cpuid(0x80000007) supported? |
aoqi@0 | 327 | __ jccb(Assembler::belowEqual, ext_cpuid5); |
aoqi@0 | 328 | __ cmpl(rax, 0x80000007); // Is cpuid(0x80000008) supported? |
aoqi@0 | 329 | __ jccb(Assembler::belowEqual, ext_cpuid7); |
aoqi@0 | 330 | // |
aoqi@0 | 331 | // Extended cpuid(0x80000008) |
aoqi@0 | 332 | // |
aoqi@0 | 333 | __ movl(rax, 0x80000008); |
aoqi@0 | 334 | __ cpuid(); |
aoqi@0 | 335 | __ lea(rsi, Address(rbp, in_bytes(VM_Version::ext_cpuid8_offset()))); |
aoqi@0 | 336 | __ movl(Address(rsi, 0), rax); |
aoqi@0 | 337 | __ movl(Address(rsi, 4), rbx); |
aoqi@0 | 338 | __ movl(Address(rsi, 8), rcx); |
aoqi@0 | 339 | __ movl(Address(rsi,12), rdx); |
aoqi@0 | 340 | |
aoqi@0 | 341 | // |
aoqi@0 | 342 | // Extended cpuid(0x80000007) |
aoqi@0 | 343 | // |
aoqi@0 | 344 | __ bind(ext_cpuid7); |
aoqi@0 | 345 | __ movl(rax, 0x80000007); |
aoqi@0 | 346 | __ cpuid(); |
aoqi@0 | 347 | __ lea(rsi, Address(rbp, in_bytes(VM_Version::ext_cpuid7_offset()))); |
aoqi@0 | 348 | __ movl(Address(rsi, 0), rax); |
aoqi@0 | 349 | __ movl(Address(rsi, 4), rbx); |
aoqi@0 | 350 | __ movl(Address(rsi, 8), rcx); |
aoqi@0 | 351 | __ movl(Address(rsi,12), rdx); |
aoqi@0 | 352 | |
aoqi@0 | 353 | // |
aoqi@0 | 354 | // Extended cpuid(0x80000005) |
aoqi@0 | 355 | // |
aoqi@0 | 356 | __ bind(ext_cpuid5); |
aoqi@0 | 357 | __ movl(rax, 0x80000005); |
aoqi@0 | 358 | __ cpuid(); |
aoqi@0 | 359 | __ lea(rsi, Address(rbp, in_bytes(VM_Version::ext_cpuid5_offset()))); |
aoqi@0 | 360 | __ movl(Address(rsi, 0), rax); |
aoqi@0 | 361 | __ movl(Address(rsi, 4), rbx); |
aoqi@0 | 362 | __ movl(Address(rsi, 8), rcx); |
aoqi@0 | 363 | __ movl(Address(rsi,12), rdx); |
aoqi@0 | 364 | |
aoqi@0 | 365 | // |
aoqi@0 | 366 | // Extended cpuid(0x80000001) |
aoqi@0 | 367 | // |
aoqi@0 | 368 | __ bind(ext_cpuid1); |
aoqi@0 | 369 | __ movl(rax, 0x80000001); |
aoqi@0 | 370 | __ cpuid(); |
aoqi@0 | 371 | __ lea(rsi, Address(rbp, in_bytes(VM_Version::ext_cpuid1_offset()))); |
aoqi@0 | 372 | __ movl(Address(rsi, 0), rax); |
aoqi@0 | 373 | __ movl(Address(rsi, 4), rbx); |
aoqi@0 | 374 | __ movl(Address(rsi, 8), rcx); |
aoqi@0 | 375 | __ movl(Address(rsi,12), rdx); |
aoqi@0 | 376 | |
aoqi@0 | 377 | // |
aoqi@0 | 378 | // return |
aoqi@0 | 379 | // |
aoqi@0 | 380 | __ bind(done); |
aoqi@0 | 381 | __ popf(); |
aoqi@0 | 382 | __ pop(rsi); |
aoqi@0 | 383 | __ pop(rbx); |
aoqi@0 | 384 | __ pop(rbp); |
aoqi@0 | 385 | __ ret(0); |
aoqi@0 | 386 | |
aoqi@0 | 387 | # undef __ |
aoqi@0 | 388 | |
aoqi@0 | 389 | return start; |
aoqi@0 | 390 | }; |
aoqi@0 | 391 | }; |
aoqi@0 | 392 | |
aoqi@0 | 393 | |
aoqi@0 | 394 | void VM_Version::get_cpu_info_wrapper() { |
aoqi@0 | 395 | get_cpu_info_stub(&_cpuid_info); |
aoqi@0 | 396 | } |
aoqi@0 | 397 | |
aoqi@0 | 398 | #ifndef CALL_TEST_FUNC_WITH_WRAPPER_IF_NEEDED |
aoqi@0 | 399 | #define CALL_TEST_FUNC_WITH_WRAPPER_IF_NEEDED(f) f() |
aoqi@0 | 400 | #endif |
aoqi@0 | 401 | |
aoqi@0 | 402 | void VM_Version::get_processor_features() { |
aoqi@0 | 403 | |
aoqi@0 | 404 | _cpu = 4; // 486 by default |
aoqi@0 | 405 | _model = 0; |
aoqi@0 | 406 | _stepping = 0; |
aoqi@0 | 407 | _cpuFeatures = 0; |
aoqi@0 | 408 | _logical_processors_per_package = 1; |
aoqi@0 | 409 | |
aoqi@0 | 410 | if (!Use486InstrsOnly) { |
aoqi@0 | 411 | // Get raw processor info |
aoqi@0 | 412 | |
aoqi@0 | 413 | // Some platforms (like Win*) need a wrapper around here |
aoqi@0 | 414 | // in order to properly handle SEGV for YMM registers test. |
aoqi@0 | 415 | CALL_TEST_FUNC_WITH_WRAPPER_IF_NEEDED(get_cpu_info_wrapper); |
aoqi@0 | 416 | |
aoqi@0 | 417 | assert_is_initialized(); |
aoqi@0 | 418 | _cpu = extended_cpu_family(); |
aoqi@0 | 419 | _model = extended_cpu_model(); |
aoqi@0 | 420 | _stepping = cpu_stepping(); |
aoqi@0 | 421 | |
aoqi@0 | 422 | if (cpu_family() > 4) { // it supports CPUID |
aoqi@0 | 423 | _cpuFeatures = feature_flags(); |
aoqi@0 | 424 | // Logical processors are only available on P4s and above, |
aoqi@0 | 425 | // and only if hyperthreading is available. |
aoqi@0 | 426 | _logical_processors_per_package = logical_processor_count(); |
aoqi@0 | 427 | } |
aoqi@0 | 428 | } |
aoqi@0 | 429 | |
aoqi@0 | 430 | _supports_cx8 = supports_cmpxchg8(); |
aoqi@0 | 431 | // xchg and xadd instructions |
aoqi@0 | 432 | _supports_atomic_getset4 = true; |
aoqi@0 | 433 | _supports_atomic_getadd4 = true; |
aoqi@0 | 434 | LP64_ONLY(_supports_atomic_getset8 = true); |
aoqi@0 | 435 | LP64_ONLY(_supports_atomic_getadd8 = true); |
aoqi@0 | 436 | |
aoqi@0 | 437 | #ifdef _LP64 |
aoqi@0 | 438 | // OS should support SSE for x64 and hardware should support at least SSE2. |
aoqi@0 | 439 | if (!VM_Version::supports_sse2()) { |
aoqi@0 | 440 | vm_exit_during_initialization("Unknown x64 processor: SSE2 not supported"); |
aoqi@0 | 441 | } |
aoqi@0 | 442 | // in 64 bit the use of SSE2 is the minimum |
aoqi@0 | 443 | if (UseSSE < 2) UseSSE = 2; |
aoqi@0 | 444 | #endif |
aoqi@0 | 445 | |
aoqi@0 | 446 | #ifdef AMD64 |
aoqi@0 | 447 | // flush_icache_stub have to be generated first. |
aoqi@0 | 448 | // That is why Icache line size is hard coded in ICache class, |
aoqi@0 | 449 | // see icache_x86.hpp. It is also the reason why we can't use |
aoqi@0 | 450 | // clflush instruction in 32-bit VM since it could be running |
aoqi@0 | 451 | // on CPU which does not support it. |
aoqi@0 | 452 | // |
aoqi@0 | 453 | // The only thing we can do is to verify that flushed |
aoqi@0 | 454 | // ICache::line_size has correct value. |
aoqi@0 | 455 | guarantee(_cpuid_info.std_cpuid1_edx.bits.clflush != 0, "clflush is not supported"); |
aoqi@0 | 456 | // clflush_size is size in quadwords (8 bytes). |
aoqi@0 | 457 | guarantee(_cpuid_info.std_cpuid1_ebx.bits.clflush_size == 8, "such clflush size is not supported"); |
aoqi@0 | 458 | #endif |
aoqi@0 | 459 | |
aoqi@0 | 460 | // If the OS doesn't support SSE, we can't use this feature even if the HW does |
aoqi@0 | 461 | if (!os::supports_sse()) |
aoqi@0 | 462 | _cpuFeatures &= ~(CPU_SSE|CPU_SSE2|CPU_SSE3|CPU_SSSE3|CPU_SSE4A|CPU_SSE4_1|CPU_SSE4_2); |
aoqi@0 | 463 | |
aoqi@0 | 464 | if (UseSSE < 4) { |
aoqi@0 | 465 | _cpuFeatures &= ~CPU_SSE4_1; |
aoqi@0 | 466 | _cpuFeatures &= ~CPU_SSE4_2; |
aoqi@0 | 467 | } |
aoqi@0 | 468 | |
aoqi@0 | 469 | if (UseSSE < 3) { |
aoqi@0 | 470 | _cpuFeatures &= ~CPU_SSE3; |
aoqi@0 | 471 | _cpuFeatures &= ~CPU_SSSE3; |
aoqi@0 | 472 | _cpuFeatures &= ~CPU_SSE4A; |
aoqi@0 | 473 | } |
aoqi@0 | 474 | |
aoqi@0 | 475 | if (UseSSE < 2) |
aoqi@0 | 476 | _cpuFeatures &= ~CPU_SSE2; |
aoqi@0 | 477 | |
aoqi@0 | 478 | if (UseSSE < 1) |
aoqi@0 | 479 | _cpuFeatures &= ~CPU_SSE; |
aoqi@0 | 480 | |
aoqi@0 | 481 | if (UseAVX < 2) |
aoqi@0 | 482 | _cpuFeatures &= ~CPU_AVX2; |
aoqi@0 | 483 | |
aoqi@0 | 484 | if (UseAVX < 1) |
aoqi@0 | 485 | _cpuFeatures &= ~CPU_AVX; |
aoqi@0 | 486 | |
aoqi@0 | 487 | if (!UseAES && !FLAG_IS_DEFAULT(UseAES)) |
aoqi@0 | 488 | _cpuFeatures &= ~CPU_AES; |
aoqi@0 | 489 | |
aoqi@0 | 490 | if (logical_processors_per_package() == 1) { |
aoqi@0 | 491 | // HT processor could be installed on a system which doesn't support HT. |
aoqi@0 | 492 | _cpuFeatures &= ~CPU_HT; |
aoqi@0 | 493 | } |
aoqi@0 | 494 | |
aoqi@0 | 495 | char buf[256]; |
kvn@7152 | 496 | 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%s%s%s%s%s%s%s%s%s%s%s%s%s", |
aoqi@0 | 497 | cores_per_cpu(), threads_per_core(), |
aoqi@0 | 498 | cpu_family(), _model, _stepping, |
aoqi@0 | 499 | (supports_cmov() ? ", cmov" : ""), |
aoqi@0 | 500 | (supports_cmpxchg8() ? ", cx8" : ""), |
aoqi@0 | 501 | (supports_fxsr() ? ", fxsr" : ""), |
aoqi@0 | 502 | (supports_mmx() ? ", mmx" : ""), |
aoqi@0 | 503 | (supports_sse() ? ", sse" : ""), |
aoqi@0 | 504 | (supports_sse2() ? ", sse2" : ""), |
aoqi@0 | 505 | (supports_sse3() ? ", sse3" : ""), |
aoqi@0 | 506 | (supports_ssse3()? ", ssse3": ""), |
aoqi@0 | 507 | (supports_sse4_1() ? ", sse4.1" : ""), |
aoqi@0 | 508 | (supports_sse4_2() ? ", sse4.2" : ""), |
aoqi@0 | 509 | (supports_popcnt() ? ", popcnt" : ""), |
aoqi@0 | 510 | (supports_avx() ? ", avx" : ""), |
aoqi@0 | 511 | (supports_avx2() ? ", avx2" : ""), |
aoqi@0 | 512 | (supports_aes() ? ", aes" : ""), |
aoqi@0 | 513 | (supports_clmul() ? ", clmul" : ""), |
aoqi@0 | 514 | (supports_erms() ? ", erms" : ""), |
aoqi@0 | 515 | (supports_rtm() ? ", rtm" : ""), |
aoqi@0 | 516 | (supports_mmx_ext() ? ", mmxext" : ""), |
aoqi@0 | 517 | (supports_3dnow_prefetch() ? ", 3dnowpref" : ""), |
aoqi@0 | 518 | (supports_lzcnt() ? ", lzcnt": ""), |
aoqi@0 | 519 | (supports_sse4a() ? ", sse4a": ""), |
aoqi@0 | 520 | (supports_ht() ? ", ht": ""), |
aoqi@0 | 521 | (supports_tsc() ? ", tsc": ""), |
aoqi@0 | 522 | (supports_tscinv_bit() ? ", tscinvbit": ""), |
aoqi@0 | 523 | (supports_tscinv() ? ", tscinv": ""), |
aoqi@0 | 524 | (supports_bmi1() ? ", bmi1" : ""), |
kvn@7152 | 525 | (supports_bmi2() ? ", bmi2" : ""), |
kvn@7152 | 526 | (supports_adx() ? ", adx" : "")); |
aoqi@0 | 527 | _features_str = strdup(buf); |
aoqi@0 | 528 | |
aoqi@0 | 529 | // UseSSE is set to the smaller of what hardware supports and what |
aoqi@0 | 530 | // the command line requires. I.e., you cannot set UseSSE to 2 on |
aoqi@0 | 531 | // older Pentiums which do not support it. |
aoqi@0 | 532 | if (UseSSE > 4) UseSSE=4; |
aoqi@0 | 533 | if (UseSSE < 0) UseSSE=0; |
aoqi@0 | 534 | if (!supports_sse4_1()) // Drop to 3 if no SSE4 support |
aoqi@0 | 535 | UseSSE = MIN2((intx)3,UseSSE); |
aoqi@0 | 536 | if (!supports_sse3()) // Drop to 2 if no SSE3 support |
aoqi@0 | 537 | UseSSE = MIN2((intx)2,UseSSE); |
aoqi@0 | 538 | if (!supports_sse2()) // Drop to 1 if no SSE2 support |
aoqi@0 | 539 | UseSSE = MIN2((intx)1,UseSSE); |
aoqi@0 | 540 | if (!supports_sse ()) // Drop to 0 if no SSE support |
aoqi@0 | 541 | UseSSE = 0; |
aoqi@0 | 542 | |
aoqi@0 | 543 | if (UseAVX > 2) UseAVX=2; |
aoqi@0 | 544 | if (UseAVX < 0) UseAVX=0; |
aoqi@0 | 545 | if (!supports_avx2()) // Drop to 1 if no AVX2 support |
aoqi@0 | 546 | UseAVX = MIN2((intx)1,UseAVX); |
aoqi@0 | 547 | if (!supports_avx ()) // Drop to 0 if no AVX support |
aoqi@0 | 548 | UseAVX = 0; |
aoqi@0 | 549 | |
aoqi@0 | 550 | // Use AES instructions if available. |
aoqi@0 | 551 | if (supports_aes()) { |
aoqi@0 | 552 | if (FLAG_IS_DEFAULT(UseAES)) { |
aoqi@0 | 553 | UseAES = true; |
aoqi@0 | 554 | } |
aoqi@0 | 555 | } else if (UseAES) { |
aoqi@0 | 556 | if (!FLAG_IS_DEFAULT(UseAES)) |
aoqi@0 | 557 | warning("AES instructions are not available on this CPU"); |
aoqi@0 | 558 | FLAG_SET_DEFAULT(UseAES, false); |
aoqi@0 | 559 | } |
aoqi@0 | 560 | |
aoqi@0 | 561 | // Use CLMUL instructions if available. |
aoqi@0 | 562 | if (supports_clmul()) { |
aoqi@0 | 563 | if (FLAG_IS_DEFAULT(UseCLMUL)) { |
aoqi@0 | 564 | UseCLMUL = true; |
aoqi@0 | 565 | } |
aoqi@0 | 566 | } else if (UseCLMUL) { |
aoqi@0 | 567 | if (!FLAG_IS_DEFAULT(UseCLMUL)) |
aoqi@0 | 568 | warning("CLMUL instructions not available on this CPU (AVX may also be required)"); |
aoqi@0 | 569 | FLAG_SET_DEFAULT(UseCLMUL, false); |
aoqi@0 | 570 | } |
aoqi@0 | 571 | |
kvn@7025 | 572 | if (UseCLMUL && (UseSSE > 2)) { |
aoqi@0 | 573 | if (FLAG_IS_DEFAULT(UseCRC32Intrinsics)) { |
aoqi@0 | 574 | UseCRC32Intrinsics = true; |
aoqi@0 | 575 | } |
aoqi@0 | 576 | } else if (UseCRC32Intrinsics) { |
aoqi@0 | 577 | if (!FLAG_IS_DEFAULT(UseCRC32Intrinsics)) |
kvn@7152 | 578 | warning("CRC32 Intrinsics requires CLMUL instructions (not available on this CPU)"); |
aoqi@0 | 579 | FLAG_SET_DEFAULT(UseCRC32Intrinsics, false); |
aoqi@0 | 580 | } |
aoqi@0 | 581 | |
aoqi@0 | 582 | // The AES intrinsic stubs require AES instruction support (of course) |
aoqi@0 | 583 | // but also require sse3 mode for instructions it use. |
aoqi@0 | 584 | if (UseAES && (UseSSE > 2)) { |
aoqi@0 | 585 | if (FLAG_IS_DEFAULT(UseAESIntrinsics)) { |
aoqi@0 | 586 | UseAESIntrinsics = true; |
aoqi@0 | 587 | } |
aoqi@0 | 588 | } else if (UseAESIntrinsics) { |
aoqi@0 | 589 | if (!FLAG_IS_DEFAULT(UseAESIntrinsics)) |
aoqi@0 | 590 | warning("AES intrinsics are not available on this CPU"); |
aoqi@0 | 591 | FLAG_SET_DEFAULT(UseAESIntrinsics, false); |
aoqi@0 | 592 | } |
aoqi@0 | 593 | |
kvn@7027 | 594 | if (UseSHA) { |
kvn@7027 | 595 | warning("SHA instructions are not available on this CPU"); |
kvn@7027 | 596 | FLAG_SET_DEFAULT(UseSHA, false); |
kvn@7027 | 597 | } |
kvn@7027 | 598 | if (UseSHA1Intrinsics || UseSHA256Intrinsics || UseSHA512Intrinsics) { |
kvn@7027 | 599 | warning("SHA intrinsics are not available on this CPU"); |
kvn@7027 | 600 | FLAG_SET_DEFAULT(UseSHA1Intrinsics, false); |
kvn@7027 | 601 | FLAG_SET_DEFAULT(UseSHA256Intrinsics, false); |
kvn@7027 | 602 | FLAG_SET_DEFAULT(UseSHA512Intrinsics, false); |
kvn@7027 | 603 | } |
kvn@7027 | 604 | |
aoqi@0 | 605 | // Adjust RTM (Restricted Transactional Memory) flags |
aoqi@0 | 606 | if (!supports_rtm() && UseRTMLocking) { |
aoqi@0 | 607 | // Can't continue because UseRTMLocking affects UseBiasedLocking flag |
aoqi@0 | 608 | // setting during arguments processing. See use_biased_locking(). |
aoqi@0 | 609 | // VM_Version_init() is executed after UseBiasedLocking is used |
aoqi@0 | 610 | // in Thread::allocate(). |
aoqi@0 | 611 | vm_exit_during_initialization("RTM instructions are not available on this CPU"); |
aoqi@0 | 612 | } |
aoqi@0 | 613 | |
aoqi@0 | 614 | #if INCLUDE_RTM_OPT |
aoqi@0 | 615 | if (UseRTMLocking) { |
kvn@7088 | 616 | if (is_intel_family_core()) { |
kvn@7088 | 617 | if ((_model == CPU_MODEL_HASWELL_E3) || |
kvn@7088 | 618 | (_model == CPU_MODEL_HASWELL_E7 && _stepping < 3) || |
kvn@7088 | 619 | (_model == CPU_MODEL_BROADWELL && _stepping < 4)) { |
kvn@7088 | 620 | if (!UnlockExperimentalVMOptions) { |
kvn@7088 | 621 | vm_exit_during_initialization("UseRTMLocking is only available as experimental option on this platform. It must be enabled via -XX:+UnlockExperimentalVMOptions flag."); |
kvn@7088 | 622 | } else { |
kvn@7088 | 623 | warning("UseRTMLocking is only available as experimental option on this platform."); |
kvn@7088 | 624 | } |
kvn@7088 | 625 | } |
kvn@7088 | 626 | } |
aoqi@0 | 627 | if (!FLAG_IS_CMDLINE(UseRTMLocking)) { |
aoqi@0 | 628 | // RTM locking should be used only for applications with |
aoqi@0 | 629 | // high lock contention. For now we do not use it by default. |
aoqi@0 | 630 | vm_exit_during_initialization("UseRTMLocking flag should be only set on command line"); |
aoqi@0 | 631 | } |
aoqi@0 | 632 | if (!is_power_of_2(RTMTotalCountIncrRate)) { |
aoqi@0 | 633 | warning("RTMTotalCountIncrRate must be a power of 2, resetting it to 64"); |
aoqi@0 | 634 | FLAG_SET_DEFAULT(RTMTotalCountIncrRate, 64); |
aoqi@0 | 635 | } |
aoqi@0 | 636 | if (RTMAbortRatio < 0 || RTMAbortRatio > 100) { |
aoqi@0 | 637 | warning("RTMAbortRatio must be in the range 0 to 100, resetting it to 50"); |
aoqi@0 | 638 | FLAG_SET_DEFAULT(RTMAbortRatio, 50); |
aoqi@0 | 639 | } |
aoqi@0 | 640 | } else { // !UseRTMLocking |
aoqi@0 | 641 | if (UseRTMForStackLocks) { |
aoqi@0 | 642 | if (!FLAG_IS_DEFAULT(UseRTMForStackLocks)) { |
aoqi@0 | 643 | warning("UseRTMForStackLocks flag should be off when UseRTMLocking flag is off"); |
aoqi@0 | 644 | } |
aoqi@0 | 645 | FLAG_SET_DEFAULT(UseRTMForStackLocks, false); |
aoqi@0 | 646 | } |
aoqi@0 | 647 | if (UseRTMDeopt) { |
aoqi@0 | 648 | FLAG_SET_DEFAULT(UseRTMDeopt, false); |
aoqi@0 | 649 | } |
aoqi@0 | 650 | if (PrintPreciseRTMLockingStatistics) { |
aoqi@0 | 651 | FLAG_SET_DEFAULT(PrintPreciseRTMLockingStatistics, false); |
aoqi@0 | 652 | } |
aoqi@0 | 653 | } |
aoqi@0 | 654 | #else |
aoqi@0 | 655 | if (UseRTMLocking) { |
aoqi@0 | 656 | // Only C2 does RTM locking optimization. |
aoqi@0 | 657 | // Can't continue because UseRTMLocking affects UseBiasedLocking flag |
aoqi@0 | 658 | // setting during arguments processing. See use_biased_locking(). |
aoqi@0 | 659 | vm_exit_during_initialization("RTM locking optimization is not supported in this VM"); |
aoqi@0 | 660 | } |
aoqi@0 | 661 | #endif |
aoqi@0 | 662 | |
aoqi@0 | 663 | #ifdef COMPILER2 |
aoqi@0 | 664 | if (UseFPUForSpilling) { |
aoqi@0 | 665 | if (UseSSE < 2) { |
aoqi@0 | 666 | // Only supported with SSE2+ |
aoqi@0 | 667 | FLAG_SET_DEFAULT(UseFPUForSpilling, false); |
aoqi@0 | 668 | } |
aoqi@0 | 669 | } |
aoqi@0 | 670 | if (MaxVectorSize > 0) { |
aoqi@0 | 671 | if (!is_power_of_2(MaxVectorSize)) { |
aoqi@0 | 672 | warning("MaxVectorSize must be a power of 2"); |
aoqi@0 | 673 | FLAG_SET_DEFAULT(MaxVectorSize, 32); |
aoqi@0 | 674 | } |
aoqi@0 | 675 | if (MaxVectorSize > 32) { |
aoqi@0 | 676 | FLAG_SET_DEFAULT(MaxVectorSize, 32); |
aoqi@0 | 677 | } |
aoqi@0 | 678 | if (MaxVectorSize > 16 && (UseAVX == 0 || !os_supports_avx_vectors())) { |
aoqi@0 | 679 | // 32 bytes vectors (in YMM) are only supported with AVX+ |
aoqi@0 | 680 | FLAG_SET_DEFAULT(MaxVectorSize, 16); |
aoqi@0 | 681 | } |
aoqi@0 | 682 | if (UseSSE < 2) { |
aoqi@0 | 683 | // Vectors (in XMM) are only supported with SSE2+ |
aoqi@0 | 684 | FLAG_SET_DEFAULT(MaxVectorSize, 0); |
aoqi@0 | 685 | } |
aoqi@0 | 686 | #ifdef ASSERT |
aoqi@0 | 687 | if (supports_avx() && PrintMiscellaneous && Verbose && TraceNewVectors) { |
aoqi@0 | 688 | tty->print_cr("State of YMM registers after signal handle:"); |
aoqi@0 | 689 | int nreg = 2 LP64_ONLY(+2); |
aoqi@0 | 690 | const char* ymm_name[4] = {"0", "7", "8", "15"}; |
aoqi@0 | 691 | for (int i = 0; i < nreg; i++) { |
aoqi@0 | 692 | tty->print("YMM%s:", ymm_name[i]); |
aoqi@0 | 693 | for (int j = 7; j >=0; j--) { |
aoqi@0 | 694 | tty->print(" %x", _cpuid_info.ymm_save[i*8 + j]); |
aoqi@0 | 695 | } |
aoqi@0 | 696 | tty->cr(); |
aoqi@0 | 697 | } |
aoqi@0 | 698 | } |
aoqi@0 | 699 | #endif |
aoqi@0 | 700 | } |
kvn@7152 | 701 | |
kvn@7152 | 702 | #ifdef _LP64 |
kvn@7152 | 703 | if (FLAG_IS_DEFAULT(UseMultiplyToLenIntrinsic)) { |
kvn@7152 | 704 | UseMultiplyToLenIntrinsic = true; |
kvn@7152 | 705 | } |
igerasim@8307 | 706 | if (FLAG_IS_DEFAULT(UseSquareToLenIntrinsic)) { |
vkempik@8319 | 707 | UseSquareToLenIntrinsic = false; |
igerasim@8307 | 708 | } |
igerasim@8307 | 709 | if (FLAG_IS_DEFAULT(UseMulAddIntrinsic)) { |
vkempik@8319 | 710 | UseMulAddIntrinsic = false; |
igerasim@8307 | 711 | } |
vkempik@8318 | 712 | if (FLAG_IS_DEFAULT(UseMontgomeryMultiplyIntrinsic)) { |
vkempik@8319 | 713 | UseMontgomeryMultiplyIntrinsic = false; |
vkempik@8318 | 714 | } |
vkempik@8318 | 715 | if (FLAG_IS_DEFAULT(UseMontgomerySquareIntrinsic)) { |
vkempik@8319 | 716 | UseMontgomerySquareIntrinsic = false; |
vkempik@8318 | 717 | } |
kvn@7152 | 718 | #else |
kvn@7152 | 719 | if (UseMultiplyToLenIntrinsic) { |
kvn@7152 | 720 | if (!FLAG_IS_DEFAULT(UseMultiplyToLenIntrinsic)) { |
kvn@7152 | 721 | warning("multiplyToLen intrinsic is not available in 32-bit VM"); |
kvn@7152 | 722 | } |
kvn@7152 | 723 | FLAG_SET_DEFAULT(UseMultiplyToLenIntrinsic, false); |
kvn@7152 | 724 | } |
igerasim@8307 | 725 | if (UseSquareToLenIntrinsic) { |
igerasim@8307 | 726 | if (!FLAG_IS_DEFAULT(UseSquareToLenIntrinsic)) { |
igerasim@8307 | 727 | warning("squareToLen intrinsic is not available in 32-bit VM"); |
igerasim@8307 | 728 | } |
igerasim@8307 | 729 | FLAG_SET_DEFAULT(UseSquareToLenIntrinsic, false); |
igerasim@8307 | 730 | } |
igerasim@8307 | 731 | if (UseMulAddIntrinsic) { |
igerasim@8307 | 732 | if (!FLAG_IS_DEFAULT(UseMulAddIntrinsic)) { |
igerasim@8307 | 733 | warning("mulAdd intrinsic is not available in 32-bit VM"); |
igerasim@8307 | 734 | } |
igerasim@8307 | 735 | FLAG_SET_DEFAULT(UseMulAddIntrinsic, false); |
igerasim@8307 | 736 | } |
vkempik@8318 | 737 | if (UseMontgomeryMultiplyIntrinsic) { |
vkempik@8318 | 738 | if (!FLAG_IS_DEFAULT(UseMontgomeryMultiplyIntrinsic)) { |
vkempik@8318 | 739 | warning("montgomeryMultiply intrinsic is not available in 32-bit VM"); |
vkempik@8318 | 740 | } |
vkempik@8318 | 741 | FLAG_SET_DEFAULT(UseMontgomeryMultiplyIntrinsic, false); |
vkempik@8318 | 742 | } |
vkempik@8318 | 743 | if (UseMontgomerySquareIntrinsic) { |
vkempik@8318 | 744 | if (!FLAG_IS_DEFAULT(UseMontgomerySquareIntrinsic)) { |
vkempik@8318 | 745 | warning("montgomerySquare intrinsic is not available in 32-bit VM"); |
vkempik@8318 | 746 | } |
vkempik@8318 | 747 | FLAG_SET_DEFAULT(UseMontgomerySquareIntrinsic, false); |
vkempik@8318 | 748 | } |
aoqi@0 | 749 | #endif |
kvn@7152 | 750 | #endif // COMPILER2 |
aoqi@0 | 751 | |
aoqi@0 | 752 | // On new cpus instructions which update whole XMM register should be used |
aoqi@0 | 753 | // to prevent partial register stall due to dependencies on high half. |
aoqi@0 | 754 | // |
aoqi@0 | 755 | // UseXmmLoadAndClearUpper == true --> movsd(xmm, mem) |
aoqi@0 | 756 | // UseXmmLoadAndClearUpper == false --> movlpd(xmm, mem) |
aoqi@0 | 757 | // UseXmmRegToRegMoveAll == true --> movaps(xmm, xmm), movapd(xmm, xmm). |
aoqi@0 | 758 | // UseXmmRegToRegMoveAll == false --> movss(xmm, xmm), movsd(xmm, xmm). |
aoqi@0 | 759 | |
aoqi@0 | 760 | if( is_amd() ) { // AMD cpus specific settings |
aoqi@0 | 761 | if( supports_sse2() && FLAG_IS_DEFAULT(UseAddressNop) ) { |
aoqi@0 | 762 | // Use it on new AMD cpus starting from Opteron. |
aoqi@0 | 763 | UseAddressNop = true; |
aoqi@0 | 764 | } |
aoqi@0 | 765 | if( supports_sse2() && FLAG_IS_DEFAULT(UseNewLongLShift) ) { |
aoqi@0 | 766 | // Use it on new AMD cpus starting from Opteron. |
aoqi@0 | 767 | UseNewLongLShift = true; |
aoqi@0 | 768 | } |
aoqi@0 | 769 | if( FLAG_IS_DEFAULT(UseXmmLoadAndClearUpper) ) { |
aoqi@0 | 770 | if( supports_sse4a() ) { |
aoqi@0 | 771 | UseXmmLoadAndClearUpper = true; // use movsd only on '10h' Opteron |
aoqi@0 | 772 | } else { |
aoqi@0 | 773 | UseXmmLoadAndClearUpper = false; |
aoqi@0 | 774 | } |
aoqi@0 | 775 | } |
aoqi@0 | 776 | if( FLAG_IS_DEFAULT(UseXmmRegToRegMoveAll) ) { |
aoqi@0 | 777 | if( supports_sse4a() ) { |
aoqi@0 | 778 | UseXmmRegToRegMoveAll = true; // use movaps, movapd only on '10h' |
aoqi@0 | 779 | } else { |
aoqi@0 | 780 | UseXmmRegToRegMoveAll = false; |
aoqi@0 | 781 | } |
aoqi@0 | 782 | } |
aoqi@0 | 783 | if( FLAG_IS_DEFAULT(UseXmmI2F) ) { |
aoqi@0 | 784 | if( supports_sse4a() ) { |
aoqi@0 | 785 | UseXmmI2F = true; |
aoqi@0 | 786 | } else { |
aoqi@0 | 787 | UseXmmI2F = false; |
aoqi@0 | 788 | } |
aoqi@0 | 789 | } |
aoqi@0 | 790 | if( FLAG_IS_DEFAULT(UseXmmI2D) ) { |
aoqi@0 | 791 | if( supports_sse4a() ) { |
aoqi@0 | 792 | UseXmmI2D = true; |
aoqi@0 | 793 | } else { |
aoqi@0 | 794 | UseXmmI2D = false; |
aoqi@0 | 795 | } |
aoqi@0 | 796 | } |
aoqi@0 | 797 | if( FLAG_IS_DEFAULT(UseSSE42Intrinsics) ) { |
aoqi@0 | 798 | if( supports_sse4_2() && UseSSE >= 4 ) { |
aoqi@0 | 799 | UseSSE42Intrinsics = true; |
aoqi@0 | 800 | } |
aoqi@0 | 801 | } |
aoqi@0 | 802 | |
aoqi@0 | 803 | // some defaults for AMD family 15h |
aoqi@0 | 804 | if ( cpu_family() == 0x15 ) { |
aoqi@0 | 805 | // On family 15h processors default is no sw prefetch |
aoqi@0 | 806 | if (FLAG_IS_DEFAULT(AllocatePrefetchStyle)) { |
aoqi@0 | 807 | AllocatePrefetchStyle = 0; |
aoqi@0 | 808 | } |
aoqi@0 | 809 | // Also, if some other prefetch style is specified, default instruction type is PREFETCHW |
aoqi@0 | 810 | if (FLAG_IS_DEFAULT(AllocatePrefetchInstr)) { |
aoqi@0 | 811 | AllocatePrefetchInstr = 3; |
aoqi@0 | 812 | } |
aoqi@0 | 813 | // On family 15h processors use XMM and UnalignedLoadStores for Array Copy |
aoqi@0 | 814 | if (supports_sse2() && FLAG_IS_DEFAULT(UseXMMForArrayCopy)) { |
aoqi@0 | 815 | UseXMMForArrayCopy = true; |
aoqi@0 | 816 | } |
aoqi@0 | 817 | if (supports_sse2() && FLAG_IS_DEFAULT(UseUnalignedLoadStores)) { |
aoqi@0 | 818 | UseUnalignedLoadStores = true; |
aoqi@0 | 819 | } |
aoqi@0 | 820 | } |
aoqi@0 | 821 | |
aoqi@0 | 822 | #ifdef COMPILER2 |
aoqi@0 | 823 | if (MaxVectorSize > 16) { |
aoqi@0 | 824 | // Limit vectors size to 16 bytes on current AMD cpus. |
aoqi@0 | 825 | FLAG_SET_DEFAULT(MaxVectorSize, 16); |
aoqi@0 | 826 | } |
aoqi@0 | 827 | #endif // COMPILER2 |
aoqi@0 | 828 | } |
aoqi@0 | 829 | |
aoqi@0 | 830 | if( is_intel() ) { // Intel cpus specific settings |
aoqi@0 | 831 | if( FLAG_IS_DEFAULT(UseStoreImmI16) ) { |
aoqi@0 | 832 | UseStoreImmI16 = false; // don't use it on Intel cpus |
aoqi@0 | 833 | } |
aoqi@0 | 834 | if( cpu_family() == 6 || cpu_family() == 15 ) { |
aoqi@0 | 835 | if( FLAG_IS_DEFAULT(UseAddressNop) ) { |
aoqi@0 | 836 | // Use it on all Intel cpus starting from PentiumPro |
aoqi@0 | 837 | UseAddressNop = true; |
aoqi@0 | 838 | } |
aoqi@0 | 839 | } |
aoqi@0 | 840 | if( FLAG_IS_DEFAULT(UseXmmLoadAndClearUpper) ) { |
aoqi@0 | 841 | UseXmmLoadAndClearUpper = true; // use movsd on all Intel cpus |
aoqi@0 | 842 | } |
aoqi@0 | 843 | if( FLAG_IS_DEFAULT(UseXmmRegToRegMoveAll) ) { |
aoqi@0 | 844 | if( supports_sse3() ) { |
aoqi@0 | 845 | UseXmmRegToRegMoveAll = true; // use movaps, movapd on new Intel cpus |
aoqi@0 | 846 | } else { |
aoqi@0 | 847 | UseXmmRegToRegMoveAll = false; |
aoqi@0 | 848 | } |
aoqi@0 | 849 | } |
aoqi@0 | 850 | if( cpu_family() == 6 && supports_sse3() ) { // New Intel cpus |
aoqi@0 | 851 | #ifdef COMPILER2 |
aoqi@0 | 852 | if( FLAG_IS_DEFAULT(MaxLoopPad) ) { |
aoqi@0 | 853 | // For new Intel cpus do the next optimization: |
aoqi@0 | 854 | // don't align the beginning of a loop if there are enough instructions |
aoqi@0 | 855 | // left (NumberOfLoopInstrToAlign defined in c2_globals.hpp) |
aoqi@0 | 856 | // in current fetch line (OptoLoopAlignment) or the padding |
aoqi@0 | 857 | // is big (> MaxLoopPad). |
aoqi@0 | 858 | // Set MaxLoopPad to 11 for new Intel cpus to reduce number of |
aoqi@0 | 859 | // generated NOP instructions. 11 is the largest size of one |
aoqi@0 | 860 | // address NOP instruction '0F 1F' (see Assembler::nop(i)). |
aoqi@0 | 861 | MaxLoopPad = 11; |
aoqi@0 | 862 | } |
aoqi@0 | 863 | #endif // COMPILER2 |
aoqi@0 | 864 | if (FLAG_IS_DEFAULT(UseXMMForArrayCopy)) { |
aoqi@0 | 865 | UseXMMForArrayCopy = true; // use SSE2 movq on new Intel cpus |
aoqi@0 | 866 | } |
aoqi@0 | 867 | if (supports_sse4_2() && supports_ht()) { // Newest Intel cpus |
aoqi@0 | 868 | if (FLAG_IS_DEFAULT(UseUnalignedLoadStores)) { |
aoqi@0 | 869 | UseUnalignedLoadStores = true; // use movdqu on newest Intel cpus |
aoqi@0 | 870 | } |
aoqi@0 | 871 | } |
aoqi@0 | 872 | if (supports_sse4_2() && UseSSE >= 4) { |
aoqi@0 | 873 | if (FLAG_IS_DEFAULT(UseSSE42Intrinsics)) { |
aoqi@0 | 874 | UseSSE42Intrinsics = true; |
aoqi@0 | 875 | } |
aoqi@0 | 876 | } |
aoqi@0 | 877 | } |
kvn@7025 | 878 | if ((cpu_family() == 0x06) && |
kvn@7025 | 879 | ((extended_cpu_model() == 0x36) || // Centerton |
kvn@7025 | 880 | (extended_cpu_model() == 0x37) || // Silvermont |
kvn@7025 | 881 | (extended_cpu_model() == 0x4D))) { |
kvn@7025 | 882 | #ifdef COMPILER2 |
kvn@7025 | 883 | if (FLAG_IS_DEFAULT(OptoScheduling)) { |
kvn@7025 | 884 | OptoScheduling = true; |
kvn@7025 | 885 | } |
kvn@7025 | 886 | #endif |
kvn@7025 | 887 | if (supports_sse4_2()) { // Silvermont |
kvn@7025 | 888 | if (FLAG_IS_DEFAULT(UseUnalignedLoadStores)) { |
kvn@7025 | 889 | UseUnalignedLoadStores = true; // use movdqu on newest Intel cpus |
kvn@7025 | 890 | } |
kvn@7025 | 891 | } |
kvn@7025 | 892 | } |
kvn@7152 | 893 | if(FLAG_IS_DEFAULT(AllocatePrefetchInstr) && supports_3dnow_prefetch()) { |
kvn@7152 | 894 | AllocatePrefetchInstr = 3; |
kvn@7152 | 895 | } |
aoqi@0 | 896 | } |
aoqi@0 | 897 | |
aoqi@0 | 898 | // Use count leading zeros count instruction if available. |
aoqi@0 | 899 | if (supports_lzcnt()) { |
aoqi@0 | 900 | if (FLAG_IS_DEFAULT(UseCountLeadingZerosInstruction)) { |
aoqi@0 | 901 | UseCountLeadingZerosInstruction = true; |
aoqi@0 | 902 | } |
aoqi@0 | 903 | } else if (UseCountLeadingZerosInstruction) { |
aoqi@0 | 904 | warning("lzcnt instruction is not available on this CPU"); |
aoqi@0 | 905 | FLAG_SET_DEFAULT(UseCountLeadingZerosInstruction, false); |
aoqi@0 | 906 | } |
aoqi@0 | 907 | |
kvn@7152 | 908 | // Use count trailing zeros instruction if available |
aoqi@0 | 909 | if (supports_bmi1()) { |
kvn@7152 | 910 | // tzcnt does not require VEX prefix |
kvn@7152 | 911 | if (FLAG_IS_DEFAULT(UseCountTrailingZerosInstruction)) { |
kvn@7269 | 912 | if (!UseBMI1Instructions && !FLAG_IS_DEFAULT(UseBMI1Instructions)) { |
kvn@7269 | 913 | // Don't use tzcnt if BMI1 is switched off on command line. |
kvn@7269 | 914 | UseCountTrailingZerosInstruction = false; |
kvn@7269 | 915 | } else { |
kvn@7269 | 916 | UseCountTrailingZerosInstruction = true; |
kvn@7269 | 917 | } |
kvn@7152 | 918 | } |
kvn@7152 | 919 | } else if (UseCountTrailingZerosInstruction) { |
kvn@7152 | 920 | warning("tzcnt instruction is not available on this CPU"); |
kvn@7152 | 921 | FLAG_SET_DEFAULT(UseCountTrailingZerosInstruction, false); |
kvn@7152 | 922 | } |
kvn@7152 | 923 | |
kvn@7269 | 924 | // BMI instructions (except tzcnt) use an encoding with VEX prefix. |
kvn@7152 | 925 | // VEX prefix is generated only when AVX > 0. |
kvn@7152 | 926 | if (supports_bmi1() && supports_avx()) { |
aoqi@0 | 927 | if (FLAG_IS_DEFAULT(UseBMI1Instructions)) { |
aoqi@0 | 928 | UseBMI1Instructions = true; |
aoqi@0 | 929 | } |
aoqi@0 | 930 | } else if (UseBMI1Instructions) { |
kvn@7152 | 931 | warning("BMI1 instructions are not available on this CPU (AVX is also required)"); |
aoqi@0 | 932 | FLAG_SET_DEFAULT(UseBMI1Instructions, false); |
aoqi@0 | 933 | } |
aoqi@0 | 934 | |
kvn@7152 | 935 | if (supports_bmi2() && supports_avx()) { |
kvn@7152 | 936 | if (FLAG_IS_DEFAULT(UseBMI2Instructions)) { |
kvn@7152 | 937 | UseBMI2Instructions = true; |
aoqi@0 | 938 | } |
kvn@7152 | 939 | } else if (UseBMI2Instructions) { |
kvn@7152 | 940 | warning("BMI2 instructions are not available on this CPU (AVX is also required)"); |
kvn@7152 | 941 | FLAG_SET_DEFAULT(UseBMI2Instructions, false); |
aoqi@0 | 942 | } |
aoqi@0 | 943 | |
aoqi@0 | 944 | // Use population count instruction if available. |
aoqi@0 | 945 | if (supports_popcnt()) { |
aoqi@0 | 946 | if (FLAG_IS_DEFAULT(UsePopCountInstruction)) { |
aoqi@0 | 947 | UsePopCountInstruction = true; |
aoqi@0 | 948 | } |
aoqi@0 | 949 | } else if (UsePopCountInstruction) { |
aoqi@0 | 950 | warning("POPCNT instruction is not available on this CPU"); |
aoqi@0 | 951 | FLAG_SET_DEFAULT(UsePopCountInstruction, false); |
aoqi@0 | 952 | } |
aoqi@0 | 953 | |
aoqi@0 | 954 | // Use fast-string operations if available. |
aoqi@0 | 955 | if (supports_erms()) { |
aoqi@0 | 956 | if (FLAG_IS_DEFAULT(UseFastStosb)) { |
aoqi@0 | 957 | UseFastStosb = true; |
aoqi@0 | 958 | } |
aoqi@0 | 959 | } else if (UseFastStosb) { |
aoqi@0 | 960 | warning("fast-string operations are not available on this CPU"); |
aoqi@0 | 961 | FLAG_SET_DEFAULT(UseFastStosb, false); |
aoqi@0 | 962 | } |
aoqi@0 | 963 | |
aoqi@0 | 964 | #ifdef COMPILER2 |
aoqi@0 | 965 | if (FLAG_IS_DEFAULT(AlignVector)) { |
aoqi@0 | 966 | // Modern processors allow misaligned memory operations for vectors. |
aoqi@0 | 967 | AlignVector = !UseUnalignedLoadStores; |
aoqi@0 | 968 | } |
aoqi@0 | 969 | #endif // COMPILER2 |
aoqi@0 | 970 | |
aoqi@0 | 971 | assert(0 <= ReadPrefetchInstr && ReadPrefetchInstr <= 3, "invalid value"); |
aoqi@0 | 972 | assert(0 <= AllocatePrefetchInstr && AllocatePrefetchInstr <= 3, "invalid value"); |
aoqi@0 | 973 | |
aoqi@0 | 974 | // set valid Prefetch instruction |
aoqi@0 | 975 | if( ReadPrefetchInstr < 0 ) ReadPrefetchInstr = 0; |
aoqi@0 | 976 | if( ReadPrefetchInstr > 3 ) ReadPrefetchInstr = 3; |
aoqi@0 | 977 | if( ReadPrefetchInstr == 3 && !supports_3dnow_prefetch() ) ReadPrefetchInstr = 0; |
aoqi@0 | 978 | if( !supports_sse() && supports_3dnow_prefetch() ) ReadPrefetchInstr = 3; |
aoqi@0 | 979 | |
aoqi@0 | 980 | if( AllocatePrefetchInstr < 0 ) AllocatePrefetchInstr = 0; |
aoqi@0 | 981 | if( AllocatePrefetchInstr > 3 ) AllocatePrefetchInstr = 3; |
aoqi@0 | 982 | if( AllocatePrefetchInstr == 3 && !supports_3dnow_prefetch() ) AllocatePrefetchInstr=0; |
aoqi@0 | 983 | if( !supports_sse() && supports_3dnow_prefetch() ) AllocatePrefetchInstr = 3; |
aoqi@0 | 984 | |
aoqi@0 | 985 | // Allocation prefetch settings |
aoqi@0 | 986 | intx cache_line_size = prefetch_data_size(); |
aoqi@0 | 987 | if( cache_line_size > AllocatePrefetchStepSize ) |
aoqi@0 | 988 | AllocatePrefetchStepSize = cache_line_size; |
aoqi@0 | 989 | |
aoqi@0 | 990 | assert(AllocatePrefetchLines > 0, "invalid value"); |
aoqi@0 | 991 | if( AllocatePrefetchLines < 1 ) // set valid value in product VM |
aoqi@0 | 992 | AllocatePrefetchLines = 3; |
aoqi@0 | 993 | assert(AllocateInstancePrefetchLines > 0, "invalid value"); |
aoqi@0 | 994 | if( AllocateInstancePrefetchLines < 1 ) // set valid value in product VM |
aoqi@0 | 995 | AllocateInstancePrefetchLines = 1; |
aoqi@0 | 996 | |
aoqi@0 | 997 | AllocatePrefetchDistance = allocate_prefetch_distance(); |
aoqi@0 | 998 | AllocatePrefetchStyle = allocate_prefetch_style(); |
aoqi@0 | 999 | |
kvn@7025 | 1000 | if (is_intel() && cpu_family() == 6 && supports_sse3()) { |
kvn@7025 | 1001 | if (AllocatePrefetchStyle == 2) { // watermark prefetching on Core |
aoqi@0 | 1002 | #ifdef _LP64 |
aoqi@0 | 1003 | AllocatePrefetchDistance = 384; |
aoqi@0 | 1004 | #else |
aoqi@0 | 1005 | AllocatePrefetchDistance = 320; |
aoqi@0 | 1006 | #endif |
aoqi@0 | 1007 | } |
kvn@7025 | 1008 | if (supports_sse4_2() && supports_ht()) { // Nehalem based cpus |
aoqi@0 | 1009 | AllocatePrefetchDistance = 192; |
aoqi@0 | 1010 | AllocatePrefetchLines = 4; |
kvn@7025 | 1011 | } |
aoqi@0 | 1012 | #ifdef COMPILER2 |
kvn@7025 | 1013 | if (supports_sse4_2()) { |
kvn@7025 | 1014 | if (FLAG_IS_DEFAULT(UseFPUForSpilling)) { |
aoqi@0 | 1015 | FLAG_SET_DEFAULT(UseFPUForSpilling, true); |
aoqi@0 | 1016 | } |
kvn@7025 | 1017 | } |
aoqi@0 | 1018 | #endif |
aoqi@0 | 1019 | } |
aoqi@0 | 1020 | assert(AllocatePrefetchDistance % AllocatePrefetchStepSize == 0, "invalid value"); |
aoqi@0 | 1021 | |
aoqi@0 | 1022 | #ifdef _LP64 |
aoqi@0 | 1023 | // Prefetch settings |
aoqi@0 | 1024 | PrefetchCopyIntervalInBytes = prefetch_copy_interval_in_bytes(); |
aoqi@0 | 1025 | PrefetchScanIntervalInBytes = prefetch_scan_interval_in_bytes(); |
aoqi@0 | 1026 | PrefetchFieldsAhead = prefetch_fields_ahead(); |
aoqi@0 | 1027 | #endif |
aoqi@0 | 1028 | |
aoqi@0 | 1029 | if (FLAG_IS_DEFAULT(ContendedPaddingWidth) && |
aoqi@0 | 1030 | (cache_line_size > ContendedPaddingWidth)) |
aoqi@0 | 1031 | ContendedPaddingWidth = cache_line_size; |
aoqi@0 | 1032 | |
aoqi@0 | 1033 | #ifndef PRODUCT |
aoqi@0 | 1034 | if (PrintMiscellaneous && Verbose) { |
aoqi@0 | 1035 | tty->print_cr("Logical CPUs per core: %u", |
aoqi@0 | 1036 | logical_processors_per_package()); |
aoqi@0 | 1037 | tty->print("UseSSE=%d", (int) UseSSE); |
aoqi@0 | 1038 | if (UseAVX > 0) { |
aoqi@0 | 1039 | tty->print(" UseAVX=%d", (int) UseAVX); |
aoqi@0 | 1040 | } |
aoqi@0 | 1041 | if (UseAES) { |
aoqi@0 | 1042 | tty->print(" UseAES=1"); |
aoqi@0 | 1043 | } |
aoqi@0 | 1044 | #ifdef COMPILER2 |
aoqi@0 | 1045 | if (MaxVectorSize > 0) { |
aoqi@0 | 1046 | tty->print(" MaxVectorSize=%d", (int) MaxVectorSize); |
aoqi@0 | 1047 | } |
aoqi@0 | 1048 | #endif |
aoqi@0 | 1049 | tty->cr(); |
aoqi@0 | 1050 | tty->print("Allocation"); |
aoqi@0 | 1051 | if (AllocatePrefetchStyle <= 0 || UseSSE == 0 && !supports_3dnow_prefetch()) { |
aoqi@0 | 1052 | tty->print_cr(": no prefetching"); |
aoqi@0 | 1053 | } else { |
aoqi@0 | 1054 | tty->print(" prefetching: "); |
aoqi@0 | 1055 | if (UseSSE == 0 && supports_3dnow_prefetch()) { |
aoqi@0 | 1056 | tty->print("PREFETCHW"); |
aoqi@0 | 1057 | } else if (UseSSE >= 1) { |
aoqi@0 | 1058 | if (AllocatePrefetchInstr == 0) { |
aoqi@0 | 1059 | tty->print("PREFETCHNTA"); |
aoqi@0 | 1060 | } else if (AllocatePrefetchInstr == 1) { |
aoqi@0 | 1061 | tty->print("PREFETCHT0"); |
aoqi@0 | 1062 | } else if (AllocatePrefetchInstr == 2) { |
aoqi@0 | 1063 | tty->print("PREFETCHT2"); |
aoqi@0 | 1064 | } else if (AllocatePrefetchInstr == 3) { |
aoqi@0 | 1065 | tty->print("PREFETCHW"); |
aoqi@0 | 1066 | } |
aoqi@0 | 1067 | } |
aoqi@0 | 1068 | if (AllocatePrefetchLines > 1) { |
aoqi@0 | 1069 | tty->print_cr(" at distance %d, %d lines of %d bytes", (int) AllocatePrefetchDistance, (int) AllocatePrefetchLines, (int) AllocatePrefetchStepSize); |
aoqi@0 | 1070 | } else { |
aoqi@0 | 1071 | tty->print_cr(" at distance %d, one line of %d bytes", (int) AllocatePrefetchDistance, (int) AllocatePrefetchStepSize); |
aoqi@0 | 1072 | } |
aoqi@0 | 1073 | } |
aoqi@0 | 1074 | |
aoqi@0 | 1075 | if (PrefetchCopyIntervalInBytes > 0) { |
aoqi@0 | 1076 | tty->print_cr("PrefetchCopyIntervalInBytes %d", (int) PrefetchCopyIntervalInBytes); |
aoqi@0 | 1077 | } |
aoqi@0 | 1078 | if (PrefetchScanIntervalInBytes > 0) { |
aoqi@0 | 1079 | tty->print_cr("PrefetchScanIntervalInBytes %d", (int) PrefetchScanIntervalInBytes); |
aoqi@0 | 1080 | } |
aoqi@0 | 1081 | if (PrefetchFieldsAhead > 0) { |
aoqi@0 | 1082 | tty->print_cr("PrefetchFieldsAhead %d", (int) PrefetchFieldsAhead); |
aoqi@0 | 1083 | } |
aoqi@0 | 1084 | if (ContendedPaddingWidth > 0) { |
aoqi@0 | 1085 | tty->print_cr("ContendedPaddingWidth %d", (int) ContendedPaddingWidth); |
aoqi@0 | 1086 | } |
aoqi@0 | 1087 | } |
aoqi@0 | 1088 | #endif // !PRODUCT |
aoqi@0 | 1089 | } |
aoqi@0 | 1090 | |
aoqi@0 | 1091 | bool VM_Version::use_biased_locking() { |
aoqi@0 | 1092 | #if INCLUDE_RTM_OPT |
aoqi@0 | 1093 | // RTM locking is most useful when there is high lock contention and |
aoqi@0 | 1094 | // low data contention. With high lock contention the lock is usually |
aoqi@0 | 1095 | // inflated and biased locking is not suitable for that case. |
aoqi@0 | 1096 | // RTM locking code requires that biased locking is off. |
aoqi@0 | 1097 | // Note: we can't switch off UseBiasedLocking in get_processor_features() |
aoqi@0 | 1098 | // because it is used by Thread::allocate() which is called before |
aoqi@0 | 1099 | // VM_Version::initialize(). |
aoqi@0 | 1100 | if (UseRTMLocking && UseBiasedLocking) { |
aoqi@0 | 1101 | if (FLAG_IS_DEFAULT(UseBiasedLocking)) { |
aoqi@0 | 1102 | FLAG_SET_DEFAULT(UseBiasedLocking, false); |
aoqi@0 | 1103 | } else { |
aoqi@0 | 1104 | warning("Biased locking is not supported with RTM locking; ignoring UseBiasedLocking flag." ); |
aoqi@0 | 1105 | UseBiasedLocking = false; |
aoqi@0 | 1106 | } |
aoqi@0 | 1107 | } |
aoqi@0 | 1108 | #endif |
aoqi@0 | 1109 | return UseBiasedLocking; |
aoqi@0 | 1110 | } |
aoqi@0 | 1111 | |
aoqi@0 | 1112 | void VM_Version::initialize() { |
aoqi@0 | 1113 | ResourceMark rm; |
aoqi@0 | 1114 | // Making this stub must be FIRST use of assembler |
aoqi@0 | 1115 | |
aoqi@0 | 1116 | stub_blob = BufferBlob::create("get_cpu_info_stub", stub_size); |
aoqi@0 | 1117 | if (stub_blob == NULL) { |
aoqi@0 | 1118 | vm_exit_during_initialization("Unable to allocate get_cpu_info_stub"); |
aoqi@0 | 1119 | } |
aoqi@0 | 1120 | CodeBuffer c(stub_blob); |
aoqi@0 | 1121 | VM_Version_StubGenerator g(&c); |
aoqi@0 | 1122 | get_cpu_info_stub = CAST_TO_FN_PTR(get_cpu_info_stub_t, |
aoqi@0 | 1123 | g.generate_get_cpu_info()); |
aoqi@0 | 1124 | |
aoqi@0 | 1125 | get_processor_features(); |
aoqi@0 | 1126 | } |