Thu, 15 Aug 2013 20:04:10 -0400
8003424: Enable Class Data Sharing for CompressedOops
8016729: ObjectAlignmentInBytes=16 now forces the use of heap based compressed oops
8005933: The -Xshare:auto option is ignored for -server
Summary: Move klass metaspace above the heap and support CDS with compressed klass ptrs.
Reviewed-by: coleenp, kvn, mgerdin, tschatzl, stefank
twisti@1020 | 1 | /* |
drchase@5353 | 2 | * Copyright (c) 1997, 2013, Oracle and/or its affiliates. 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 | * |
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. |
twisti@1020 | 22 | * |
twisti@1020 | 23 | */ |
twisti@1020 | 24 | |
stefank@2314 | 25 | #include "precompiled.hpp" |
twisti@4318 | 26 | #include "asm/macroAssembler.hpp" |
twisti@4318 | 27 | #include "asm/macroAssembler.inline.hpp" |
stefank@2314 | 28 | #include "memory/resourceArea.hpp" |
stefank@2314 | 29 | #include "runtime/java.hpp" |
stefank@2314 | 30 | #include "runtime/stubCodeGenerator.hpp" |
stefank@2314 | 31 | #include "vm_version_x86.hpp" |
stefank@2314 | 32 | #ifdef TARGET_OS_FAMILY_linux |
stefank@2314 | 33 | # include "os_linux.inline.hpp" |
stefank@2314 | 34 | #endif |
stefank@2314 | 35 | #ifdef TARGET_OS_FAMILY_solaris |
stefank@2314 | 36 | # include "os_solaris.inline.hpp" |
stefank@2314 | 37 | #endif |
stefank@2314 | 38 | #ifdef TARGET_OS_FAMILY_windows |
stefank@2314 | 39 | # include "os_windows.inline.hpp" |
stefank@2314 | 40 | #endif |
never@3156 | 41 | #ifdef TARGET_OS_FAMILY_bsd |
never@3156 | 42 | # include "os_bsd.inline.hpp" |
never@3156 | 43 | #endif |
twisti@1020 | 44 | |
twisti@1020 | 45 | |
twisti@1020 | 46 | int VM_Version::_cpu; |
twisti@1020 | 47 | int VM_Version::_model; |
twisti@1020 | 48 | int VM_Version::_stepping; |
twisti@1020 | 49 | int VM_Version::_cpuFeatures; |
twisti@1020 | 50 | const char* VM_Version::_features_str = ""; |
twisti@1020 | 51 | VM_Version::CpuidInfo VM_Version::_cpuid_info = { 0, }; |
twisti@1020 | 52 | |
twisti@1020 | 53 | static BufferBlob* stub_blob; |
kvn@3400 | 54 | static const int stub_size = 550; |
twisti@1020 | 55 | |
twisti@1020 | 56 | extern "C" { |
twisti@1020 | 57 | typedef void (*getPsrInfo_stub_t)(void*); |
twisti@1020 | 58 | } |
twisti@1020 | 59 | static getPsrInfo_stub_t getPsrInfo_stub = NULL; |
twisti@1020 | 60 | |
twisti@1020 | 61 | |
twisti@1020 | 62 | class VM_Version_StubGenerator: public StubCodeGenerator { |
twisti@1020 | 63 | public: |
twisti@1020 | 64 | |
twisti@1020 | 65 | VM_Version_StubGenerator(CodeBuffer *c) : StubCodeGenerator(c) {} |
twisti@1020 | 66 | |
twisti@1020 | 67 | address generate_getPsrInfo() { |
twisti@1020 | 68 | // Flags to test CPU type. |
sla@3587 | 69 | const uint32_t HS_EFL_AC = 0x40000; |
sla@3587 | 70 | const uint32_t HS_EFL_ID = 0x200000; |
twisti@1020 | 71 | // Values for when we don't have a CPUID instruction. |
twisti@1020 | 72 | const int CPU_FAMILY_SHIFT = 8; |
twisti@1020 | 73 | const uint32_t CPU_FAMILY_386 = (3 << CPU_FAMILY_SHIFT); |
twisti@1020 | 74 | const uint32_t CPU_FAMILY_486 = (4 << CPU_FAMILY_SHIFT); |
twisti@1020 | 75 | |
kvn@1977 | 76 | Label detect_486, cpu486, detect_586, std_cpuid1, std_cpuid4; |
kvn@3400 | 77 | Label sef_cpuid, ext_cpuid, ext_cpuid1, ext_cpuid5, ext_cpuid7, done; |
twisti@1020 | 78 | |
twisti@1020 | 79 | StubCodeMark mark(this, "VM_Version", "getPsrInfo_stub"); |
twisti@1020 | 80 | # define __ _masm-> |
twisti@1020 | 81 | |
twisti@1020 | 82 | address start = __ pc(); |
twisti@1020 | 83 | |
twisti@1020 | 84 | // |
twisti@1020 | 85 | // void getPsrInfo(VM_Version::CpuidInfo* cpuid_info); |
twisti@1020 | 86 | // |
twisti@1020 | 87 | // LP64: rcx and rdx are first and second argument registers on windows |
twisti@1020 | 88 | |
twisti@1020 | 89 | __ push(rbp); |
twisti@1020 | 90 | #ifdef _LP64 |
twisti@1020 | 91 | __ mov(rbp, c_rarg0); // cpuid_info address |
twisti@1020 | 92 | #else |
twisti@1020 | 93 | __ movptr(rbp, Address(rsp, 8)); // cpuid_info address |
twisti@1020 | 94 | #endif |
twisti@1020 | 95 | __ push(rbx); |
twisti@1020 | 96 | __ push(rsi); |
twisti@1020 | 97 | __ pushf(); // preserve rbx, and flags |
twisti@1020 | 98 | __ pop(rax); |
twisti@1020 | 99 | __ push(rax); |
twisti@1020 | 100 | __ mov(rcx, rax); |
twisti@1020 | 101 | // |
twisti@1020 | 102 | // if we are unable to change the AC flag, we have a 386 |
twisti@1020 | 103 | // |
sla@3587 | 104 | __ xorl(rax, HS_EFL_AC); |
twisti@1020 | 105 | __ push(rax); |
twisti@1020 | 106 | __ popf(); |
twisti@1020 | 107 | __ pushf(); |
twisti@1020 | 108 | __ pop(rax); |
twisti@1020 | 109 | __ cmpptr(rax, rcx); |
twisti@1020 | 110 | __ jccb(Assembler::notEqual, detect_486); |
twisti@1020 | 111 | |
twisti@1020 | 112 | __ movl(rax, CPU_FAMILY_386); |
twisti@1020 | 113 | __ movl(Address(rbp, in_bytes(VM_Version::std_cpuid1_offset())), rax); |
twisti@1020 | 114 | __ jmp(done); |
twisti@1020 | 115 | |
twisti@1020 | 116 | // |
twisti@1020 | 117 | // If we are unable to change the ID flag, we have a 486 which does |
twisti@1020 | 118 | // not support the "cpuid" instruction. |
twisti@1020 | 119 | // |
twisti@1020 | 120 | __ bind(detect_486); |
twisti@1020 | 121 | __ mov(rax, rcx); |
sla@3587 | 122 | __ xorl(rax, HS_EFL_ID); |
twisti@1020 | 123 | __ push(rax); |
twisti@1020 | 124 | __ popf(); |
twisti@1020 | 125 | __ pushf(); |
twisti@1020 | 126 | __ pop(rax); |
twisti@1020 | 127 | __ cmpptr(rcx, rax); |
twisti@1020 | 128 | __ jccb(Assembler::notEqual, detect_586); |
twisti@1020 | 129 | |
twisti@1020 | 130 | __ bind(cpu486); |
twisti@1020 | 131 | __ movl(rax, CPU_FAMILY_486); |
twisti@1020 | 132 | __ movl(Address(rbp, in_bytes(VM_Version::std_cpuid1_offset())), rax); |
twisti@1020 | 133 | __ jmp(done); |
twisti@1020 | 134 | |
twisti@1020 | 135 | // |
twisti@1020 | 136 | // At this point, we have a chip which supports the "cpuid" instruction |
twisti@1020 | 137 | // |
twisti@1020 | 138 | __ bind(detect_586); |
twisti@1020 | 139 | __ xorl(rax, rax); |
twisti@1020 | 140 | __ cpuid(); |
twisti@1020 | 141 | __ orl(rax, rax); |
twisti@1020 | 142 | __ jcc(Assembler::equal, cpu486); // if cpuid doesn't support an input |
twisti@1020 | 143 | // value of at least 1, we give up and |
twisti@1020 | 144 | // assume a 486 |
twisti@1020 | 145 | __ lea(rsi, Address(rbp, in_bytes(VM_Version::std_cpuid0_offset()))); |
twisti@1020 | 146 | __ movl(Address(rsi, 0), rax); |
twisti@1020 | 147 | __ movl(Address(rsi, 4), rbx); |
twisti@1020 | 148 | __ movl(Address(rsi, 8), rcx); |
twisti@1020 | 149 | __ movl(Address(rsi,12), rdx); |
twisti@1020 | 150 | |
kvn@1977 | 151 | __ cmpl(rax, 0xa); // Is cpuid(0xB) supported? |
kvn@1977 | 152 | __ jccb(Assembler::belowEqual, std_cpuid4); |
kvn@1977 | 153 | |
kvn@1977 | 154 | // |
kvn@1977 | 155 | // cpuid(0xB) Processor Topology |
kvn@1977 | 156 | // |
kvn@1977 | 157 | __ movl(rax, 0xb); |
kvn@1977 | 158 | __ xorl(rcx, rcx); // Threads level |
kvn@1977 | 159 | __ cpuid(); |
kvn@1977 | 160 | |
kvn@1977 | 161 | __ lea(rsi, Address(rbp, in_bytes(VM_Version::tpl_cpuidB0_offset()))); |
kvn@1977 | 162 | __ movl(Address(rsi, 0), rax); |
kvn@1977 | 163 | __ movl(Address(rsi, 4), rbx); |
kvn@1977 | 164 | __ movl(Address(rsi, 8), rcx); |
kvn@1977 | 165 | __ movl(Address(rsi,12), rdx); |
kvn@1977 | 166 | |
kvn@1977 | 167 | __ movl(rax, 0xb); |
kvn@1977 | 168 | __ movl(rcx, 1); // Cores level |
kvn@1977 | 169 | __ cpuid(); |
kvn@1977 | 170 | __ push(rax); |
kvn@1977 | 171 | __ andl(rax, 0x1f); // Determine if valid topology level |
kvn@1977 | 172 | __ orl(rax, rbx); // eax[4:0] | ebx[0:15] == 0 indicates invalid level |
kvn@1977 | 173 | __ andl(rax, 0xffff); |
kvn@1977 | 174 | __ pop(rax); |
kvn@1977 | 175 | __ jccb(Assembler::equal, std_cpuid4); |
kvn@1977 | 176 | |
kvn@1977 | 177 | __ lea(rsi, Address(rbp, in_bytes(VM_Version::tpl_cpuidB1_offset()))); |
kvn@1977 | 178 | __ movl(Address(rsi, 0), rax); |
kvn@1977 | 179 | __ movl(Address(rsi, 4), rbx); |
kvn@1977 | 180 | __ movl(Address(rsi, 8), rcx); |
kvn@1977 | 181 | __ movl(Address(rsi,12), rdx); |
kvn@1977 | 182 | |
kvn@1977 | 183 | __ movl(rax, 0xb); |
kvn@1977 | 184 | __ movl(rcx, 2); // Packages level |
kvn@1977 | 185 | __ cpuid(); |
kvn@1977 | 186 | __ push(rax); |
kvn@1977 | 187 | __ andl(rax, 0x1f); // Determine if valid topology level |
kvn@1977 | 188 | __ orl(rax, rbx); // eax[4:0] | ebx[0:15] == 0 indicates invalid level |
kvn@1977 | 189 | __ andl(rax, 0xffff); |
kvn@1977 | 190 | __ pop(rax); |
kvn@1977 | 191 | __ jccb(Assembler::equal, std_cpuid4); |
kvn@1977 | 192 | |
kvn@1977 | 193 | __ lea(rsi, Address(rbp, in_bytes(VM_Version::tpl_cpuidB2_offset()))); |
kvn@1977 | 194 | __ movl(Address(rsi, 0), rax); |
kvn@1977 | 195 | __ movl(Address(rsi, 4), rbx); |
kvn@1977 | 196 | __ movl(Address(rsi, 8), rcx); |
kvn@1977 | 197 | __ movl(Address(rsi,12), rdx); |
twisti@1020 | 198 | |
twisti@1020 | 199 | // |
twisti@1020 | 200 | // cpuid(0x4) Deterministic cache params |
twisti@1020 | 201 | // |
kvn@1977 | 202 | __ bind(std_cpuid4); |
twisti@1020 | 203 | __ movl(rax, 4); |
kvn@1977 | 204 | __ cmpl(rax, Address(rbp, in_bytes(VM_Version::std_cpuid0_offset()))); // Is cpuid(0x4) supported? |
kvn@1977 | 205 | __ jccb(Assembler::greater, std_cpuid1); |
kvn@1977 | 206 | |
twisti@1020 | 207 | __ xorl(rcx, rcx); // L1 cache |
twisti@1020 | 208 | __ cpuid(); |
twisti@1020 | 209 | __ push(rax); |
twisti@1020 | 210 | __ andl(rax, 0x1f); // Determine if valid cache parameters used |
twisti@1020 | 211 | __ orl(rax, rax); // eax[4:0] == 0 indicates invalid cache |
twisti@1020 | 212 | __ pop(rax); |
twisti@1020 | 213 | __ jccb(Assembler::equal, std_cpuid1); |
twisti@1020 | 214 | |
twisti@1020 | 215 | __ lea(rsi, Address(rbp, in_bytes(VM_Version::dcp_cpuid4_offset()))); |
twisti@1020 | 216 | __ movl(Address(rsi, 0), rax); |
twisti@1020 | 217 | __ movl(Address(rsi, 4), rbx); |
twisti@1020 | 218 | __ movl(Address(rsi, 8), rcx); |
twisti@1020 | 219 | __ movl(Address(rsi,12), rdx); |
twisti@1020 | 220 | |
twisti@1020 | 221 | // |
twisti@1020 | 222 | // Standard cpuid(0x1) |
twisti@1020 | 223 | // |
twisti@1020 | 224 | __ bind(std_cpuid1); |
twisti@1020 | 225 | __ movl(rax, 1); |
twisti@1020 | 226 | __ cpuid(); |
twisti@1020 | 227 | __ lea(rsi, Address(rbp, in_bytes(VM_Version::std_cpuid1_offset()))); |
twisti@1020 | 228 | __ movl(Address(rsi, 0), rax); |
twisti@1020 | 229 | __ movl(Address(rsi, 4), rbx); |
twisti@1020 | 230 | __ movl(Address(rsi, 8), rcx); |
twisti@1020 | 231 | __ movl(Address(rsi,12), rdx); |
twisti@1020 | 232 | |
kvn@3388 | 233 | // |
kvn@3388 | 234 | // Check if OS has enabled XGETBV instruction to access XCR0 |
kvn@3388 | 235 | // (OSXSAVE feature flag) and CPU supports AVX |
kvn@3388 | 236 | // |
kvn@3388 | 237 | __ andl(rcx, 0x18000000); |
kvn@3388 | 238 | __ cmpl(rcx, 0x18000000); |
kvn@3388 | 239 | __ jccb(Assembler::notEqual, sef_cpuid); |
kvn@3388 | 240 | |
kvn@3388 | 241 | // |
kvn@3388 | 242 | // XCR0, XFEATURE_ENABLED_MASK register |
kvn@3388 | 243 | // |
kvn@3388 | 244 | __ xorl(rcx, rcx); // zero for XCR0 register |
kvn@3388 | 245 | __ xgetbv(); |
kvn@3388 | 246 | __ lea(rsi, Address(rbp, in_bytes(VM_Version::xem_xcr0_offset()))); |
kvn@3388 | 247 | __ movl(Address(rsi, 0), rax); |
kvn@3388 | 248 | __ movl(Address(rsi, 4), rdx); |
kvn@3388 | 249 | |
kvn@3388 | 250 | // |
kvn@3388 | 251 | // cpuid(0x7) Structured Extended Features |
kvn@3388 | 252 | // |
kvn@3388 | 253 | __ bind(sef_cpuid); |
kvn@3388 | 254 | __ movl(rax, 7); |
kvn@3388 | 255 | __ cmpl(rax, Address(rbp, in_bytes(VM_Version::std_cpuid0_offset()))); // Is cpuid(0x7) supported? |
kvn@3388 | 256 | __ jccb(Assembler::greater, ext_cpuid); |
kvn@3388 | 257 | |
kvn@3388 | 258 | __ xorl(rcx, rcx); |
kvn@3388 | 259 | __ cpuid(); |
kvn@3388 | 260 | __ lea(rsi, Address(rbp, in_bytes(VM_Version::sef_cpuid7_offset()))); |
kvn@3388 | 261 | __ movl(Address(rsi, 0), rax); |
kvn@3388 | 262 | __ movl(Address(rsi, 4), rbx); |
kvn@3388 | 263 | |
kvn@3388 | 264 | // |
kvn@3388 | 265 | // Extended cpuid(0x80000000) |
kvn@3388 | 266 | // |
kvn@3388 | 267 | __ bind(ext_cpuid); |
twisti@1020 | 268 | __ movl(rax, 0x80000000); |
twisti@1020 | 269 | __ cpuid(); |
twisti@1020 | 270 | __ cmpl(rax, 0x80000000); // Is cpuid(0x80000001) supported? |
twisti@1020 | 271 | __ jcc(Assembler::belowEqual, done); |
twisti@1020 | 272 | __ cmpl(rax, 0x80000004); // Is cpuid(0x80000005) supported? |
twisti@1020 | 273 | __ jccb(Assembler::belowEqual, ext_cpuid1); |
phh@3378 | 274 | __ cmpl(rax, 0x80000006); // Is cpuid(0x80000007) supported? |
phh@3378 | 275 | __ jccb(Assembler::belowEqual, ext_cpuid5); |
twisti@1020 | 276 | __ cmpl(rax, 0x80000007); // Is cpuid(0x80000008) supported? |
phh@3378 | 277 | __ jccb(Assembler::belowEqual, ext_cpuid7); |
twisti@1020 | 278 | // |
twisti@1020 | 279 | // Extended cpuid(0x80000008) |
twisti@1020 | 280 | // |
twisti@1020 | 281 | __ movl(rax, 0x80000008); |
twisti@1020 | 282 | __ cpuid(); |
twisti@1020 | 283 | __ lea(rsi, Address(rbp, in_bytes(VM_Version::ext_cpuid8_offset()))); |
twisti@1020 | 284 | __ movl(Address(rsi, 0), rax); |
twisti@1020 | 285 | __ movl(Address(rsi, 4), rbx); |
twisti@1020 | 286 | __ movl(Address(rsi, 8), rcx); |
twisti@1020 | 287 | __ movl(Address(rsi,12), rdx); |
twisti@1020 | 288 | |
twisti@1020 | 289 | // |
phh@3378 | 290 | // Extended cpuid(0x80000007) |
phh@3378 | 291 | // |
phh@3378 | 292 | __ bind(ext_cpuid7); |
phh@3378 | 293 | __ movl(rax, 0x80000007); |
phh@3378 | 294 | __ cpuid(); |
phh@3378 | 295 | __ lea(rsi, Address(rbp, in_bytes(VM_Version::ext_cpuid7_offset()))); |
phh@3378 | 296 | __ movl(Address(rsi, 0), rax); |
phh@3378 | 297 | __ movl(Address(rsi, 4), rbx); |
phh@3378 | 298 | __ movl(Address(rsi, 8), rcx); |
phh@3378 | 299 | __ movl(Address(rsi,12), rdx); |
phh@3378 | 300 | |
phh@3378 | 301 | // |
twisti@1020 | 302 | // Extended cpuid(0x80000005) |
twisti@1020 | 303 | // |
twisti@1020 | 304 | __ bind(ext_cpuid5); |
twisti@1020 | 305 | __ movl(rax, 0x80000005); |
twisti@1020 | 306 | __ cpuid(); |
twisti@1020 | 307 | __ lea(rsi, Address(rbp, in_bytes(VM_Version::ext_cpuid5_offset()))); |
twisti@1020 | 308 | __ movl(Address(rsi, 0), rax); |
twisti@1020 | 309 | __ movl(Address(rsi, 4), rbx); |
twisti@1020 | 310 | __ movl(Address(rsi, 8), rcx); |
twisti@1020 | 311 | __ movl(Address(rsi,12), rdx); |
twisti@1020 | 312 | |
twisti@1020 | 313 | // |
twisti@1020 | 314 | // Extended cpuid(0x80000001) |
twisti@1020 | 315 | // |
twisti@1020 | 316 | __ bind(ext_cpuid1); |
twisti@1020 | 317 | __ movl(rax, 0x80000001); |
twisti@1020 | 318 | __ cpuid(); |
twisti@1020 | 319 | __ lea(rsi, Address(rbp, in_bytes(VM_Version::ext_cpuid1_offset()))); |
twisti@1020 | 320 | __ movl(Address(rsi, 0), rax); |
twisti@1020 | 321 | __ movl(Address(rsi, 4), rbx); |
twisti@1020 | 322 | __ movl(Address(rsi, 8), rcx); |
twisti@1020 | 323 | __ movl(Address(rsi,12), rdx); |
twisti@1020 | 324 | |
twisti@1020 | 325 | // |
twisti@1020 | 326 | // return |
twisti@1020 | 327 | // |
twisti@1020 | 328 | __ bind(done); |
twisti@1020 | 329 | __ popf(); |
twisti@1020 | 330 | __ pop(rsi); |
twisti@1020 | 331 | __ pop(rbx); |
twisti@1020 | 332 | __ pop(rbp); |
twisti@1020 | 333 | __ ret(0); |
twisti@1020 | 334 | |
twisti@1020 | 335 | # undef __ |
twisti@1020 | 336 | |
twisti@1020 | 337 | return start; |
twisti@1020 | 338 | }; |
twisti@1020 | 339 | }; |
twisti@1020 | 340 | |
twisti@1020 | 341 | |
twisti@1020 | 342 | void VM_Version::get_processor_features() { |
twisti@1020 | 343 | |
twisti@1020 | 344 | _cpu = 4; // 486 by default |
twisti@1020 | 345 | _model = 0; |
twisti@1020 | 346 | _stepping = 0; |
twisti@1020 | 347 | _cpuFeatures = 0; |
twisti@1020 | 348 | _logical_processors_per_package = 1; |
twisti@1020 | 349 | |
twisti@1020 | 350 | if (!Use486InstrsOnly) { |
twisti@1020 | 351 | // Get raw processor info |
twisti@1020 | 352 | getPsrInfo_stub(&_cpuid_info); |
twisti@1020 | 353 | assert_is_initialized(); |
twisti@1020 | 354 | _cpu = extended_cpu_family(); |
twisti@1020 | 355 | _model = extended_cpu_model(); |
twisti@1020 | 356 | _stepping = cpu_stepping(); |
twisti@1020 | 357 | |
twisti@1020 | 358 | if (cpu_family() > 4) { // it supports CPUID |
twisti@1020 | 359 | _cpuFeatures = feature_flags(); |
twisti@1020 | 360 | // Logical processors are only available on P4s and above, |
twisti@1020 | 361 | // and only if hyperthreading is available. |
twisti@1020 | 362 | _logical_processors_per_package = logical_processor_count(); |
twisti@1020 | 363 | } |
twisti@1020 | 364 | } |
twisti@1020 | 365 | |
twisti@1020 | 366 | _supports_cx8 = supports_cmpxchg8(); |
roland@4106 | 367 | // xchg and xadd instructions |
roland@4106 | 368 | _supports_atomic_getset4 = true; |
roland@4106 | 369 | _supports_atomic_getadd4 = true; |
roland@4106 | 370 | LP64_ONLY(_supports_atomic_getset8 = true); |
roland@4106 | 371 | LP64_ONLY(_supports_atomic_getadd8 = true); |
twisti@1020 | 372 | |
twisti@1020 | 373 | #ifdef _LP64 |
twisti@1020 | 374 | // OS should support SSE for x64 and hardware should support at least SSE2. |
twisti@1020 | 375 | if (!VM_Version::supports_sse2()) { |
twisti@1020 | 376 | vm_exit_during_initialization("Unknown x64 processor: SSE2 not supported"); |
twisti@1020 | 377 | } |
roland@1495 | 378 | // in 64 bit the use of SSE2 is the minimum |
roland@1495 | 379 | if (UseSSE < 2) UseSSE = 2; |
twisti@1020 | 380 | #endif |
twisti@1020 | 381 | |
kvn@2984 | 382 | #ifdef AMD64 |
kvn@2984 | 383 | // flush_icache_stub have to be generated first. |
kvn@2984 | 384 | // That is why Icache line size is hard coded in ICache class, |
kvn@2984 | 385 | // see icache_x86.hpp. It is also the reason why we can't use |
kvn@2984 | 386 | // clflush instruction in 32-bit VM since it could be running |
kvn@2984 | 387 | // on CPU which does not support it. |
kvn@2984 | 388 | // |
kvn@2984 | 389 | // The only thing we can do is to verify that flushed |
kvn@2984 | 390 | // ICache::line_size has correct value. |
kvn@2984 | 391 | guarantee(_cpuid_info.std_cpuid1_edx.bits.clflush != 0, "clflush is not supported"); |
kvn@2984 | 392 | // clflush_size is size in quadwords (8 bytes). |
kvn@2984 | 393 | guarantee(_cpuid_info.std_cpuid1_ebx.bits.clflush_size == 8, "such clflush size is not supported"); |
kvn@2984 | 394 | #endif |
kvn@2984 | 395 | |
twisti@1020 | 396 | // If the OS doesn't support SSE, we can't use this feature even if the HW does |
twisti@1020 | 397 | if (!os::supports_sse()) |
twisti@1020 | 398 | _cpuFeatures &= ~(CPU_SSE|CPU_SSE2|CPU_SSE3|CPU_SSSE3|CPU_SSE4A|CPU_SSE4_1|CPU_SSE4_2); |
twisti@1020 | 399 | |
twisti@1020 | 400 | if (UseSSE < 4) { |
twisti@1020 | 401 | _cpuFeatures &= ~CPU_SSE4_1; |
twisti@1020 | 402 | _cpuFeatures &= ~CPU_SSE4_2; |
twisti@1020 | 403 | } |
twisti@1020 | 404 | |
twisti@1020 | 405 | if (UseSSE < 3) { |
twisti@1020 | 406 | _cpuFeatures &= ~CPU_SSE3; |
twisti@1020 | 407 | _cpuFeatures &= ~CPU_SSSE3; |
twisti@1020 | 408 | _cpuFeatures &= ~CPU_SSE4A; |
twisti@1020 | 409 | } |
twisti@1020 | 410 | |
twisti@1020 | 411 | if (UseSSE < 2) |
twisti@1020 | 412 | _cpuFeatures &= ~CPU_SSE2; |
twisti@1020 | 413 | |
twisti@1020 | 414 | if (UseSSE < 1) |
twisti@1020 | 415 | _cpuFeatures &= ~CPU_SSE; |
twisti@1020 | 416 | |
kvn@3388 | 417 | if (UseAVX < 2) |
kvn@3388 | 418 | _cpuFeatures &= ~CPU_AVX2; |
kvn@3388 | 419 | |
kvn@3388 | 420 | if (UseAVX < 1) |
kvn@3388 | 421 | _cpuFeatures &= ~CPU_AVX; |
kvn@3388 | 422 | |
kvn@4205 | 423 | if (!UseAES && !FLAG_IS_DEFAULT(UseAES)) |
kvn@4205 | 424 | _cpuFeatures &= ~CPU_AES; |
kvn@4205 | 425 | |
twisti@1020 | 426 | if (logical_processors_per_package() == 1) { |
twisti@1020 | 427 | // HT processor could be installed on a system which doesn't support HT. |
twisti@1020 | 428 | _cpuFeatures &= ~CPU_HT; |
twisti@1020 | 429 | } |
twisti@1020 | 430 | |
twisti@1020 | 431 | char buf[256]; |
kvn@4410 | 432 | 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", |
twisti@1020 | 433 | cores_per_cpu(), threads_per_core(), |
twisti@1020 | 434 | cpu_family(), _model, _stepping, |
twisti@1020 | 435 | (supports_cmov() ? ", cmov" : ""), |
twisti@1020 | 436 | (supports_cmpxchg8() ? ", cx8" : ""), |
twisti@1020 | 437 | (supports_fxsr() ? ", fxsr" : ""), |
twisti@1020 | 438 | (supports_mmx() ? ", mmx" : ""), |
twisti@1020 | 439 | (supports_sse() ? ", sse" : ""), |
twisti@1020 | 440 | (supports_sse2() ? ", sse2" : ""), |
twisti@1020 | 441 | (supports_sse3() ? ", sse3" : ""), |
twisti@1020 | 442 | (supports_ssse3()? ", ssse3": ""), |
twisti@1020 | 443 | (supports_sse4_1() ? ", sse4.1" : ""), |
twisti@1020 | 444 | (supports_sse4_2() ? ", sse4.2" : ""), |
twisti@1078 | 445 | (supports_popcnt() ? ", popcnt" : ""), |
kvn@3388 | 446 | (supports_avx() ? ", avx" : ""), |
kvn@3388 | 447 | (supports_avx2() ? ", avx2" : ""), |
kvn@4205 | 448 | (supports_aes() ? ", aes" : ""), |
drchase@5353 | 449 | (supports_clmul() ? ", clmul" : ""), |
kvn@4410 | 450 | (supports_erms() ? ", erms" : ""), |
twisti@1020 | 451 | (supports_mmx_ext() ? ", mmxext" : ""), |
kvn@2761 | 452 | (supports_3dnow_prefetch() ? ", 3dnowpref" : ""), |
twisti@1210 | 453 | (supports_lzcnt() ? ", lzcnt": ""), |
twisti@1020 | 454 | (supports_sse4a() ? ", sse4a": ""), |
phh@3378 | 455 | (supports_ht() ? ", ht": ""), |
phh@3378 | 456 | (supports_tsc() ? ", tsc": ""), |
phh@3378 | 457 | (supports_tscinv_bit() ? ", tscinvbit": ""), |
phh@3378 | 458 | (supports_tscinv() ? ", tscinv": "")); |
twisti@1020 | 459 | _features_str = strdup(buf); |
twisti@1020 | 460 | |
twisti@1020 | 461 | // UseSSE is set to the smaller of what hardware supports and what |
twisti@1020 | 462 | // the command line requires. I.e., you cannot set UseSSE to 2 on |
twisti@1020 | 463 | // older Pentiums which do not support it. |
kvn@3388 | 464 | if (UseSSE > 4) UseSSE=4; |
kvn@3388 | 465 | if (UseSSE < 0) UseSSE=0; |
kvn@3388 | 466 | if (!supports_sse4_1()) // Drop to 3 if no SSE4 support |
twisti@1020 | 467 | UseSSE = MIN2((intx)3,UseSSE); |
kvn@3388 | 468 | if (!supports_sse3()) // Drop to 2 if no SSE3 support |
twisti@1020 | 469 | UseSSE = MIN2((intx)2,UseSSE); |
kvn@3388 | 470 | if (!supports_sse2()) // Drop to 1 if no SSE2 support |
twisti@1020 | 471 | UseSSE = MIN2((intx)1,UseSSE); |
kvn@3388 | 472 | if (!supports_sse ()) // Drop to 0 if no SSE support |
twisti@1020 | 473 | UseSSE = 0; |
twisti@1020 | 474 | |
kvn@3388 | 475 | if (UseAVX > 2) UseAVX=2; |
kvn@3388 | 476 | if (UseAVX < 0) UseAVX=0; |
kvn@3388 | 477 | if (!supports_avx2()) // Drop to 1 if no AVX2 support |
kvn@3388 | 478 | UseAVX = MIN2((intx)1,UseAVX); |
kvn@3388 | 479 | if (!supports_avx ()) // Drop to 0 if no AVX support |
kvn@3388 | 480 | UseAVX = 0; |
kvn@3388 | 481 | |
kvn@4205 | 482 | // Use AES instructions if available. |
kvn@4205 | 483 | if (supports_aes()) { |
kvn@4205 | 484 | if (FLAG_IS_DEFAULT(UseAES)) { |
kvn@4205 | 485 | UseAES = true; |
kvn@4205 | 486 | } |
kvn@4205 | 487 | } else if (UseAES) { |
kvn@4205 | 488 | if (!FLAG_IS_DEFAULT(UseAES)) |
kvn@4205 | 489 | warning("AES instructions not available on this CPU"); |
kvn@4205 | 490 | FLAG_SET_DEFAULT(UseAES, false); |
kvn@4205 | 491 | } |
kvn@4205 | 492 | |
drchase@5353 | 493 | // Use CLMUL instructions if available. |
drchase@5353 | 494 | if (supports_clmul()) { |
drchase@5353 | 495 | if (FLAG_IS_DEFAULT(UseCLMUL)) { |
drchase@5353 | 496 | UseCLMUL = true; |
drchase@5353 | 497 | } |
drchase@5353 | 498 | } else if (UseCLMUL) { |
drchase@5353 | 499 | if (!FLAG_IS_DEFAULT(UseCLMUL)) |
drchase@5353 | 500 | warning("CLMUL instructions not available on this CPU (AVX may also be required)"); |
drchase@5353 | 501 | FLAG_SET_DEFAULT(UseCLMUL, false); |
drchase@5353 | 502 | } |
drchase@5353 | 503 | |
drchase@5353 | 504 | if (UseCLMUL && (UseAVX > 0) && (UseSSE > 2)) { |
drchase@5353 | 505 | if (FLAG_IS_DEFAULT(UseCRC32Intrinsics)) { |
drchase@5353 | 506 | UseCRC32Intrinsics = true; |
drchase@5353 | 507 | } |
drchase@5353 | 508 | } else if (UseCRC32Intrinsics) { |
drchase@5353 | 509 | if (!FLAG_IS_DEFAULT(UseCRC32Intrinsics)) |
drchase@5353 | 510 | warning("CRC32 Intrinsics requires AVX and CLMUL instructions (not available on this CPU)"); |
drchase@5353 | 511 | FLAG_SET_DEFAULT(UseCRC32Intrinsics, false); |
drchase@5353 | 512 | } |
drchase@5353 | 513 | |
kvn@4205 | 514 | // The AES intrinsic stubs require AES instruction support (of course) |
kvn@4363 | 515 | // but also require sse3 mode for instructions it use. |
kvn@4363 | 516 | if (UseAES && (UseSSE > 2)) { |
kvn@4205 | 517 | if (FLAG_IS_DEFAULT(UseAESIntrinsics)) { |
kvn@4205 | 518 | UseAESIntrinsics = true; |
kvn@4205 | 519 | } |
kvn@4205 | 520 | } else if (UseAESIntrinsics) { |
kvn@4205 | 521 | if (!FLAG_IS_DEFAULT(UseAESIntrinsics)) |
kvn@4205 | 522 | warning("AES intrinsics not available on this CPU"); |
kvn@4205 | 523 | FLAG_SET_DEFAULT(UseAESIntrinsics, false); |
kvn@4205 | 524 | } |
kvn@4205 | 525 | |
kvn@3882 | 526 | #ifdef COMPILER2 |
kvn@3882 | 527 | if (UseFPUForSpilling) { |
kvn@3882 | 528 | if (UseSSE < 2) { |
kvn@3882 | 529 | // Only supported with SSE2+ |
kvn@3882 | 530 | FLAG_SET_DEFAULT(UseFPUForSpilling, false); |
kvn@3882 | 531 | } |
kvn@3882 | 532 | } |
kvn@3882 | 533 | if (MaxVectorSize > 0) { |
kvn@3882 | 534 | if (!is_power_of_2(MaxVectorSize)) { |
kvn@3882 | 535 | warning("MaxVectorSize must be a power of 2"); |
kvn@3882 | 536 | FLAG_SET_DEFAULT(MaxVectorSize, 32); |
kvn@3882 | 537 | } |
kvn@3882 | 538 | if (MaxVectorSize > 32) { |
kvn@3882 | 539 | FLAG_SET_DEFAULT(MaxVectorSize, 32); |
kvn@3882 | 540 | } |
kvn@3882 | 541 | if (MaxVectorSize > 16 && UseAVX == 0) { |
kvn@3882 | 542 | // Only supported with AVX+ |
kvn@3882 | 543 | FLAG_SET_DEFAULT(MaxVectorSize, 16); |
kvn@3882 | 544 | } |
kvn@3882 | 545 | if (UseSSE < 2) { |
kvn@3882 | 546 | // Only supported with SSE2+ |
kvn@3882 | 547 | FLAG_SET_DEFAULT(MaxVectorSize, 0); |
kvn@3882 | 548 | } |
kvn@3882 | 549 | } |
kvn@3882 | 550 | #endif |
kvn@3882 | 551 | |
twisti@1020 | 552 | // On new cpus instructions which update whole XMM register should be used |
twisti@1020 | 553 | // to prevent partial register stall due to dependencies on high half. |
twisti@1020 | 554 | // |
twisti@1020 | 555 | // UseXmmLoadAndClearUpper == true --> movsd(xmm, mem) |
twisti@1020 | 556 | // UseXmmLoadAndClearUpper == false --> movlpd(xmm, mem) |
twisti@1020 | 557 | // UseXmmRegToRegMoveAll == true --> movaps(xmm, xmm), movapd(xmm, xmm). |
twisti@1020 | 558 | // UseXmmRegToRegMoveAll == false --> movss(xmm, xmm), movsd(xmm, xmm). |
twisti@1020 | 559 | |
twisti@1020 | 560 | if( is_amd() ) { // AMD cpus specific settings |
twisti@1020 | 561 | if( supports_sse2() && FLAG_IS_DEFAULT(UseAddressNop) ) { |
twisti@1020 | 562 | // Use it on new AMD cpus starting from Opteron. |
twisti@1020 | 563 | UseAddressNop = true; |
twisti@1020 | 564 | } |
twisti@1020 | 565 | if( supports_sse2() && FLAG_IS_DEFAULT(UseNewLongLShift) ) { |
twisti@1020 | 566 | // Use it on new AMD cpus starting from Opteron. |
twisti@1020 | 567 | UseNewLongLShift = true; |
twisti@1020 | 568 | } |
twisti@1020 | 569 | if( FLAG_IS_DEFAULT(UseXmmLoadAndClearUpper) ) { |
twisti@1020 | 570 | if( supports_sse4a() ) { |
twisti@1020 | 571 | UseXmmLoadAndClearUpper = true; // use movsd only on '10h' Opteron |
twisti@1020 | 572 | } else { |
twisti@1020 | 573 | UseXmmLoadAndClearUpper = false; |
twisti@1020 | 574 | } |
twisti@1020 | 575 | } |
twisti@1020 | 576 | if( FLAG_IS_DEFAULT(UseXmmRegToRegMoveAll) ) { |
twisti@1020 | 577 | if( supports_sse4a() ) { |
twisti@1020 | 578 | UseXmmRegToRegMoveAll = true; // use movaps, movapd only on '10h' |
twisti@1020 | 579 | } else { |
twisti@1020 | 580 | UseXmmRegToRegMoveAll = false; |
twisti@1020 | 581 | } |
twisti@1020 | 582 | } |
twisti@1020 | 583 | if( FLAG_IS_DEFAULT(UseXmmI2F) ) { |
twisti@1020 | 584 | if( supports_sse4a() ) { |
twisti@1020 | 585 | UseXmmI2F = true; |
twisti@1020 | 586 | } else { |
twisti@1020 | 587 | UseXmmI2F = false; |
twisti@1020 | 588 | } |
twisti@1020 | 589 | } |
twisti@1020 | 590 | if( FLAG_IS_DEFAULT(UseXmmI2D) ) { |
twisti@1020 | 591 | if( supports_sse4a() ) { |
twisti@1020 | 592 | UseXmmI2D = true; |
twisti@1020 | 593 | } else { |
twisti@1020 | 594 | UseXmmI2D = false; |
twisti@1020 | 595 | } |
twisti@1020 | 596 | } |
kvn@2688 | 597 | if( FLAG_IS_DEFAULT(UseSSE42Intrinsics) ) { |
kvn@2688 | 598 | if( supports_sse4_2() && UseSSE >= 4 ) { |
kvn@2688 | 599 | UseSSE42Intrinsics = true; |
kvn@2688 | 600 | } |
kvn@2688 | 601 | } |
twisti@1210 | 602 | |
twisti@1210 | 603 | // Use count leading zeros count instruction if available. |
twisti@1210 | 604 | if (supports_lzcnt()) { |
twisti@1210 | 605 | if (FLAG_IS_DEFAULT(UseCountLeadingZerosInstruction)) { |
twisti@1210 | 606 | UseCountLeadingZerosInstruction = true; |
twisti@1210 | 607 | } |
twisti@1210 | 608 | } |
kvn@2640 | 609 | |
kvn@2808 | 610 | // some defaults for AMD family 15h |
kvn@2808 | 611 | if ( cpu_family() == 0x15 ) { |
kvn@2808 | 612 | // On family 15h processors default is no sw prefetch |
kvn@2640 | 613 | if (FLAG_IS_DEFAULT(AllocatePrefetchStyle)) { |
kvn@2640 | 614 | AllocatePrefetchStyle = 0; |
kvn@2640 | 615 | } |
kvn@2808 | 616 | // Also, if some other prefetch style is specified, default instruction type is PREFETCHW |
kvn@2808 | 617 | if (FLAG_IS_DEFAULT(AllocatePrefetchInstr)) { |
kvn@2808 | 618 | AllocatePrefetchInstr = 3; |
kvn@2808 | 619 | } |
kvn@2808 | 620 | // On family 15h processors use XMM and UnalignedLoadStores for Array Copy |
kvn@4105 | 621 | if (supports_sse2() && FLAG_IS_DEFAULT(UseXMMForArrayCopy)) { |
kvn@2808 | 622 | UseXMMForArrayCopy = true; |
kvn@2808 | 623 | } |
kvn@4105 | 624 | if (supports_sse2() && FLAG_IS_DEFAULT(UseUnalignedLoadStores)) { |
kvn@2808 | 625 | UseUnalignedLoadStores = true; |
kvn@2808 | 626 | } |
kvn@2640 | 627 | } |
kvn@2808 | 628 | |
kvn@3882 | 629 | #ifdef COMPILER2 |
kvn@3882 | 630 | if (MaxVectorSize > 16) { |
kvn@3882 | 631 | // Limit vectors size to 16 bytes on current AMD cpus. |
kvn@3882 | 632 | FLAG_SET_DEFAULT(MaxVectorSize, 16); |
kvn@3882 | 633 | } |
kvn@3882 | 634 | #endif // COMPILER2 |
twisti@1020 | 635 | } |
twisti@1020 | 636 | |
twisti@1020 | 637 | if( is_intel() ) { // Intel cpus specific settings |
twisti@1020 | 638 | if( FLAG_IS_DEFAULT(UseStoreImmI16) ) { |
twisti@1020 | 639 | UseStoreImmI16 = false; // don't use it on Intel cpus |
twisti@1020 | 640 | } |
twisti@1020 | 641 | if( cpu_family() == 6 || cpu_family() == 15 ) { |
twisti@1020 | 642 | if( FLAG_IS_DEFAULT(UseAddressNop) ) { |
twisti@1020 | 643 | // Use it on all Intel cpus starting from PentiumPro |
twisti@1020 | 644 | UseAddressNop = true; |
twisti@1020 | 645 | } |
twisti@1020 | 646 | } |
twisti@1020 | 647 | if( FLAG_IS_DEFAULT(UseXmmLoadAndClearUpper) ) { |
twisti@1020 | 648 | UseXmmLoadAndClearUpper = true; // use movsd on all Intel cpus |
twisti@1020 | 649 | } |
twisti@1020 | 650 | if( FLAG_IS_DEFAULT(UseXmmRegToRegMoveAll) ) { |
twisti@1020 | 651 | if( supports_sse3() ) { |
twisti@1020 | 652 | UseXmmRegToRegMoveAll = true; // use movaps, movapd on new Intel cpus |
twisti@1020 | 653 | } else { |
twisti@1020 | 654 | UseXmmRegToRegMoveAll = false; |
twisti@1020 | 655 | } |
twisti@1020 | 656 | } |
twisti@1020 | 657 | if( cpu_family() == 6 && supports_sse3() ) { // New Intel cpus |
twisti@1020 | 658 | #ifdef COMPILER2 |
twisti@1020 | 659 | if( FLAG_IS_DEFAULT(MaxLoopPad) ) { |
twisti@1020 | 660 | // For new Intel cpus do the next optimization: |
twisti@1020 | 661 | // don't align the beginning of a loop if there are enough instructions |
twisti@1020 | 662 | // left (NumberOfLoopInstrToAlign defined in c2_globals.hpp) |
twisti@1020 | 663 | // in current fetch line (OptoLoopAlignment) or the padding |
twisti@1020 | 664 | // is big (> MaxLoopPad). |
twisti@1020 | 665 | // Set MaxLoopPad to 11 for new Intel cpus to reduce number of |
twisti@1020 | 666 | // generated NOP instructions. 11 is the largest size of one |
twisti@1020 | 667 | // address NOP instruction '0F 1F' (see Assembler::nop(i)). |
twisti@1020 | 668 | MaxLoopPad = 11; |
twisti@1020 | 669 | } |
twisti@1020 | 670 | #endif // COMPILER2 |
kvn@4105 | 671 | if (FLAG_IS_DEFAULT(UseXMMForArrayCopy)) { |
twisti@1020 | 672 | UseXMMForArrayCopy = true; // use SSE2 movq on new Intel cpus |
twisti@1020 | 673 | } |
kvn@4105 | 674 | if (supports_sse4_2() && supports_ht()) { // Newest Intel cpus |
kvn@4105 | 675 | if (FLAG_IS_DEFAULT(UseUnalignedLoadStores)) { |
twisti@1020 | 676 | UseUnalignedLoadStores = true; // use movdqu on newest Intel cpus |
twisti@1020 | 677 | } |
twisti@1020 | 678 | } |
kvn@4105 | 679 | if (supports_sse4_2() && UseSSE >= 4) { |
kvn@4105 | 680 | if (FLAG_IS_DEFAULT(UseSSE42Intrinsics)) { |
cfang@1116 | 681 | UseSSE42Intrinsics = true; |
cfang@1116 | 682 | } |
cfang@1116 | 683 | } |
twisti@1020 | 684 | } |
twisti@1020 | 685 | } |
kvn@4480 | 686 | #if defined(COMPILER2) && defined(_ALLBSD_SOURCE) |
kvn@4480 | 687 | if (MaxVectorSize > 16) { |
kvn@4480 | 688 | // Limit vectors size to 16 bytes on BSD until it fixes |
kvn@4480 | 689 | // restoring upper 128bit of YMM registers on return |
kvn@4480 | 690 | // from signal handler. |
kvn@4480 | 691 | FLAG_SET_DEFAULT(MaxVectorSize, 16); |
kvn@4480 | 692 | } |
kvn@4480 | 693 | #endif // COMPILER2 |
twisti@1020 | 694 | |
twisti@1078 | 695 | // Use population count instruction if available. |
twisti@1078 | 696 | if (supports_popcnt()) { |
twisti@1078 | 697 | if (FLAG_IS_DEFAULT(UsePopCountInstruction)) { |
twisti@1078 | 698 | UsePopCountInstruction = true; |
twisti@1078 | 699 | } |
kvn@3388 | 700 | } else if (UsePopCountInstruction) { |
kvn@3388 | 701 | warning("POPCNT instruction is not available on this CPU"); |
kvn@3388 | 702 | FLAG_SET_DEFAULT(UsePopCountInstruction, false); |
twisti@1078 | 703 | } |
twisti@1078 | 704 | |
kvn@4410 | 705 | // Use fast-string operations if available. |
kvn@4410 | 706 | if (supports_erms()) { |
kvn@4410 | 707 | if (FLAG_IS_DEFAULT(UseFastStosb)) { |
kvn@4410 | 708 | UseFastStosb = true; |
kvn@4410 | 709 | } |
kvn@4410 | 710 | } else if (UseFastStosb) { |
kvn@4410 | 711 | warning("fast-string operations are not available on this CPU"); |
kvn@4410 | 712 | FLAG_SET_DEFAULT(UseFastStosb, false); |
kvn@4410 | 713 | } |
kvn@4410 | 714 | |
kvn@4105 | 715 | #ifdef COMPILER2 |
kvn@4105 | 716 | if (FLAG_IS_DEFAULT(AlignVector)) { |
kvn@4105 | 717 | // Modern processors allow misaligned memory operations for vectors. |
kvn@4105 | 718 | AlignVector = !UseUnalignedLoadStores; |
kvn@4105 | 719 | } |
kvn@4105 | 720 | #endif // COMPILER2 |
kvn@4105 | 721 | |
twisti@1020 | 722 | assert(0 <= ReadPrefetchInstr && ReadPrefetchInstr <= 3, "invalid value"); |
twisti@1020 | 723 | assert(0 <= AllocatePrefetchInstr && AllocatePrefetchInstr <= 3, "invalid value"); |
twisti@1020 | 724 | |
twisti@1020 | 725 | // set valid Prefetch instruction |
twisti@1020 | 726 | if( ReadPrefetchInstr < 0 ) ReadPrefetchInstr = 0; |
twisti@1020 | 727 | if( ReadPrefetchInstr > 3 ) ReadPrefetchInstr = 3; |
kvn@2761 | 728 | if( ReadPrefetchInstr == 3 && !supports_3dnow_prefetch() ) ReadPrefetchInstr = 0; |
kvn@2761 | 729 | if( !supports_sse() && supports_3dnow_prefetch() ) ReadPrefetchInstr = 3; |
twisti@1020 | 730 | |
twisti@1020 | 731 | if( AllocatePrefetchInstr < 0 ) AllocatePrefetchInstr = 0; |
twisti@1020 | 732 | if( AllocatePrefetchInstr > 3 ) AllocatePrefetchInstr = 3; |
kvn@2761 | 733 | if( AllocatePrefetchInstr == 3 && !supports_3dnow_prefetch() ) AllocatePrefetchInstr=0; |
kvn@2761 | 734 | if( !supports_sse() && supports_3dnow_prefetch() ) AllocatePrefetchInstr = 3; |
twisti@1020 | 735 | |
twisti@1020 | 736 | // Allocation prefetch settings |
kvn@3052 | 737 | intx cache_line_size = prefetch_data_size(); |
twisti@1020 | 738 | if( cache_line_size > AllocatePrefetchStepSize ) |
twisti@1020 | 739 | AllocatePrefetchStepSize = cache_line_size; |
kvn@3052 | 740 | |
twisti@1020 | 741 | assert(AllocatePrefetchLines > 0, "invalid value"); |
kvn@3052 | 742 | if( AllocatePrefetchLines < 1 ) // set valid value in product VM |
kvn@3052 | 743 | AllocatePrefetchLines = 3; |
kvn@3052 | 744 | assert(AllocateInstancePrefetchLines > 0, "invalid value"); |
kvn@3052 | 745 | if( AllocateInstancePrefetchLines < 1 ) // set valid value in product VM |
kvn@3052 | 746 | AllocateInstancePrefetchLines = 1; |
twisti@1020 | 747 | |
twisti@1020 | 748 | AllocatePrefetchDistance = allocate_prefetch_distance(); |
twisti@1020 | 749 | AllocatePrefetchStyle = allocate_prefetch_style(); |
twisti@1020 | 750 | |
kvn@1977 | 751 | if( is_intel() && cpu_family() == 6 && supports_sse3() ) { |
kvn@1977 | 752 | if( AllocatePrefetchStyle == 2 ) { // watermark prefetching on Core |
twisti@1020 | 753 | #ifdef _LP64 |
kvn@1977 | 754 | AllocatePrefetchDistance = 384; |
twisti@1020 | 755 | #else |
kvn@1977 | 756 | AllocatePrefetchDistance = 320; |
twisti@1020 | 757 | #endif |
kvn@1977 | 758 | } |
kvn@1977 | 759 | if( supports_sse4_2() && supports_ht() ) { // Nehalem based cpus |
kvn@1977 | 760 | AllocatePrefetchDistance = 192; |
kvn@1977 | 761 | AllocatePrefetchLines = 4; |
never@2085 | 762 | #ifdef COMPILER2 |
never@2085 | 763 | if (AggressiveOpts && FLAG_IS_DEFAULT(UseFPUForSpilling)) { |
never@2085 | 764 | FLAG_SET_DEFAULT(UseFPUForSpilling, true); |
never@2085 | 765 | } |
never@2085 | 766 | #endif |
kvn@1977 | 767 | } |
twisti@1020 | 768 | } |
twisti@1020 | 769 | assert(AllocatePrefetchDistance % AllocatePrefetchStepSize == 0, "invalid value"); |
twisti@1020 | 770 | |
twisti@1020 | 771 | #ifdef _LP64 |
twisti@1020 | 772 | // Prefetch settings |
twisti@1020 | 773 | PrefetchCopyIntervalInBytes = prefetch_copy_interval_in_bytes(); |
twisti@1020 | 774 | PrefetchScanIntervalInBytes = prefetch_scan_interval_in_bytes(); |
twisti@1020 | 775 | PrefetchFieldsAhead = prefetch_fields_ahead(); |
twisti@1020 | 776 | #endif |
twisti@1020 | 777 | |
jwilhelm@4430 | 778 | if (FLAG_IS_DEFAULT(ContendedPaddingWidth) && |
jwilhelm@4430 | 779 | (cache_line_size > ContendedPaddingWidth)) |
jwilhelm@4430 | 780 | ContendedPaddingWidth = cache_line_size; |
jwilhelm@4430 | 781 | |
twisti@1020 | 782 | #ifndef PRODUCT |
twisti@1020 | 783 | if (PrintMiscellaneous && Verbose) { |
twisti@1020 | 784 | tty->print_cr("Logical CPUs per core: %u", |
twisti@1020 | 785 | logical_processors_per_package()); |
kvn@3388 | 786 | tty->print("UseSSE=%d",UseSSE); |
kvn@3388 | 787 | if (UseAVX > 0) { |
kvn@3388 | 788 | tty->print(" UseAVX=%d",UseAVX); |
kvn@3388 | 789 | } |
kvn@4205 | 790 | if (UseAES) { |
kvn@4205 | 791 | tty->print(" UseAES=1"); |
kvn@4205 | 792 | } |
kvn@3388 | 793 | tty->cr(); |
kvn@3052 | 794 | tty->print("Allocation"); |
kvn@2761 | 795 | if (AllocatePrefetchStyle <= 0 || UseSSE == 0 && !supports_3dnow_prefetch()) { |
kvn@3052 | 796 | tty->print_cr(": no prefetching"); |
twisti@1020 | 797 | } else { |
kvn@3052 | 798 | tty->print(" prefetching: "); |
kvn@2761 | 799 | if (UseSSE == 0 && supports_3dnow_prefetch()) { |
twisti@1020 | 800 | tty->print("PREFETCHW"); |
twisti@1020 | 801 | } else if (UseSSE >= 1) { |
twisti@1020 | 802 | if (AllocatePrefetchInstr == 0) { |
twisti@1020 | 803 | tty->print("PREFETCHNTA"); |
twisti@1020 | 804 | } else if (AllocatePrefetchInstr == 1) { |
twisti@1020 | 805 | tty->print("PREFETCHT0"); |
twisti@1020 | 806 | } else if (AllocatePrefetchInstr == 2) { |
twisti@1020 | 807 | tty->print("PREFETCHT2"); |
twisti@1020 | 808 | } else if (AllocatePrefetchInstr == 3) { |
twisti@1020 | 809 | tty->print("PREFETCHW"); |
twisti@1020 | 810 | } |
twisti@1020 | 811 | } |
twisti@1020 | 812 | if (AllocatePrefetchLines > 1) { |
kvn@3052 | 813 | tty->print_cr(" at distance %d, %d lines of %d bytes", AllocatePrefetchDistance, AllocatePrefetchLines, AllocatePrefetchStepSize); |
twisti@1020 | 814 | } else { |
kvn@3052 | 815 | tty->print_cr(" at distance %d, one line of %d bytes", AllocatePrefetchDistance, AllocatePrefetchStepSize); |
twisti@1020 | 816 | } |
twisti@1020 | 817 | } |
twisti@1020 | 818 | |
twisti@1020 | 819 | if (PrefetchCopyIntervalInBytes > 0) { |
twisti@1020 | 820 | tty->print_cr("PrefetchCopyIntervalInBytes %d", PrefetchCopyIntervalInBytes); |
twisti@1020 | 821 | } |
twisti@1020 | 822 | if (PrefetchScanIntervalInBytes > 0) { |
twisti@1020 | 823 | tty->print_cr("PrefetchScanIntervalInBytes %d", PrefetchScanIntervalInBytes); |
twisti@1020 | 824 | } |
twisti@1020 | 825 | if (PrefetchFieldsAhead > 0) { |
twisti@1020 | 826 | tty->print_cr("PrefetchFieldsAhead %d", PrefetchFieldsAhead); |
twisti@1020 | 827 | } |
jwilhelm@4430 | 828 | if (ContendedPaddingWidth > 0) { |
jwilhelm@4430 | 829 | tty->print_cr("ContendedPaddingWidth %d", ContendedPaddingWidth); |
jwilhelm@4430 | 830 | } |
twisti@1020 | 831 | } |
twisti@1020 | 832 | #endif // !PRODUCT |
twisti@1020 | 833 | } |
twisti@1020 | 834 | |
twisti@1020 | 835 | void VM_Version::initialize() { |
twisti@1020 | 836 | ResourceMark rm; |
twisti@1020 | 837 | // Making this stub must be FIRST use of assembler |
twisti@1020 | 838 | |
twisti@1020 | 839 | stub_blob = BufferBlob::create("getPsrInfo_stub", stub_size); |
twisti@1020 | 840 | if (stub_blob == NULL) { |
twisti@1020 | 841 | vm_exit_during_initialization("Unable to allocate getPsrInfo_stub"); |
twisti@1020 | 842 | } |
twisti@2103 | 843 | CodeBuffer c(stub_blob); |
twisti@1020 | 844 | VM_Version_StubGenerator g(&c); |
twisti@1020 | 845 | getPsrInfo_stub = CAST_TO_FN_PTR(getPsrInfo_stub_t, |
twisti@1020 | 846 | g.generate_getPsrInfo()); |
twisti@1020 | 847 | |
twisti@1020 | 848 | get_processor_features(); |
twisti@1020 | 849 | } |