Mercurial > hg > truffle
comparison src/cpu/x86/vm/vm_version_x86.cpp @ 4749:7ab5f6318694
7125934: Add a fast unordered timestamp capability to Hotspot on x86/x64
Summary: Add rdtsc detection and inline generation.
Reviewed-by: kamg, dholmes
Contributed-by: karen.kinnear@oracle.com
author | phh |
---|---|
date | Sun, 01 Jan 2012 11:17:59 -0500 |
parents | f08d439fab8c |
children | 22cee0ee8927 |
comparison
equal
deleted
inserted
replaced
4732:4ec93d767458 | 4749:7ab5f6318694 |
---|---|
48 int VM_Version::_cpuFeatures; | 48 int VM_Version::_cpuFeatures; |
49 const char* VM_Version::_features_str = ""; | 49 const char* VM_Version::_features_str = ""; |
50 VM_Version::CpuidInfo VM_Version::_cpuid_info = { 0, }; | 50 VM_Version::CpuidInfo VM_Version::_cpuid_info = { 0, }; |
51 | 51 |
52 static BufferBlob* stub_blob; | 52 static BufferBlob* stub_blob; |
53 static const int stub_size = 400; | 53 static const int stub_size = 500; |
54 | 54 |
55 extern "C" { | 55 extern "C" { |
56 typedef void (*getPsrInfo_stub_t)(void*); | 56 typedef void (*getPsrInfo_stub_t)(void*); |
57 } | 57 } |
58 static getPsrInfo_stub_t getPsrInfo_stub = NULL; | 58 static getPsrInfo_stub_t getPsrInfo_stub = NULL; |
71 const int CPU_FAMILY_SHIFT = 8; | 71 const int CPU_FAMILY_SHIFT = 8; |
72 const uint32_t CPU_FAMILY_386 = (3 << CPU_FAMILY_SHIFT); | 72 const uint32_t CPU_FAMILY_386 = (3 << CPU_FAMILY_SHIFT); |
73 const uint32_t CPU_FAMILY_486 = (4 << CPU_FAMILY_SHIFT); | 73 const uint32_t CPU_FAMILY_486 = (4 << CPU_FAMILY_SHIFT); |
74 | 74 |
75 Label detect_486, cpu486, detect_586, std_cpuid1, std_cpuid4; | 75 Label detect_486, cpu486, detect_586, std_cpuid1, std_cpuid4; |
76 Label ext_cpuid1, ext_cpuid5, done; | 76 Label ext_cpuid1, ext_cpuid5, ext_cpuid7, done; |
77 | 77 |
78 StubCodeMark mark(this, "VM_Version", "getPsrInfo_stub"); | 78 StubCodeMark mark(this, "VM_Version", "getPsrInfo_stub"); |
79 # define __ _masm-> | 79 # define __ _masm-> |
80 | 80 |
81 address start = __ pc(); | 81 address start = __ pc(); |
233 __ cpuid(); | 233 __ cpuid(); |
234 __ cmpl(rax, 0x80000000); // Is cpuid(0x80000001) supported? | 234 __ cmpl(rax, 0x80000000); // Is cpuid(0x80000001) supported? |
235 __ jcc(Assembler::belowEqual, done); | 235 __ jcc(Assembler::belowEqual, done); |
236 __ cmpl(rax, 0x80000004); // Is cpuid(0x80000005) supported? | 236 __ cmpl(rax, 0x80000004); // Is cpuid(0x80000005) supported? |
237 __ jccb(Assembler::belowEqual, ext_cpuid1); | 237 __ jccb(Assembler::belowEqual, ext_cpuid1); |
238 __ cmpl(rax, 0x80000006); // Is cpuid(0x80000007) supported? | |
239 __ jccb(Assembler::belowEqual, ext_cpuid5); | |
238 __ cmpl(rax, 0x80000007); // Is cpuid(0x80000008) supported? | 240 __ cmpl(rax, 0x80000007); // Is cpuid(0x80000008) supported? |
239 __ jccb(Assembler::belowEqual, ext_cpuid5); | 241 __ jccb(Assembler::belowEqual, ext_cpuid7); |
240 // | 242 // |
241 // Extended cpuid(0x80000008) | 243 // Extended cpuid(0x80000008) |
242 // | 244 // |
243 __ movl(rax, 0x80000008); | 245 __ movl(rax, 0x80000008); |
244 __ cpuid(); | 246 __ cpuid(); |
245 __ lea(rsi, Address(rbp, in_bytes(VM_Version::ext_cpuid8_offset()))); | 247 __ lea(rsi, Address(rbp, in_bytes(VM_Version::ext_cpuid8_offset()))); |
248 __ movl(Address(rsi, 0), rax); | |
249 __ movl(Address(rsi, 4), rbx); | |
250 __ movl(Address(rsi, 8), rcx); | |
251 __ movl(Address(rsi,12), rdx); | |
252 | |
253 // | |
254 // Extended cpuid(0x80000007) | |
255 // | |
256 __ bind(ext_cpuid7); | |
257 __ movl(rax, 0x80000007); | |
258 __ cpuid(); | |
259 __ lea(rsi, Address(rbp, in_bytes(VM_Version::ext_cpuid7_offset()))); | |
246 __ movl(Address(rsi, 0), rax); | 260 __ movl(Address(rsi, 0), rax); |
247 __ movl(Address(rsi, 4), rbx); | 261 __ movl(Address(rsi, 4), rbx); |
248 __ movl(Address(rsi, 8), rcx); | 262 __ movl(Address(rsi, 8), rcx); |
249 __ movl(Address(rsi,12), rdx); | 263 __ movl(Address(rsi,12), rdx); |
250 | 264 |
363 // HT processor could be installed on a system which doesn't support HT. | 377 // HT processor could be installed on a system which doesn't support HT. |
364 _cpuFeatures &= ~CPU_HT; | 378 _cpuFeatures &= ~CPU_HT; |
365 } | 379 } |
366 | 380 |
367 char buf[256]; | 381 char buf[256]; |
368 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", | 382 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", |
369 cores_per_cpu(), threads_per_core(), | 383 cores_per_cpu(), threads_per_core(), |
370 cpu_family(), _model, _stepping, | 384 cpu_family(), _model, _stepping, |
371 (supports_cmov() ? ", cmov" : ""), | 385 (supports_cmov() ? ", cmov" : ""), |
372 (supports_cmpxchg8() ? ", cx8" : ""), | 386 (supports_cmpxchg8() ? ", cx8" : ""), |
373 (supports_fxsr() ? ", fxsr" : ""), | 387 (supports_fxsr() ? ", fxsr" : ""), |
381 (supports_popcnt() ? ", popcnt" : ""), | 395 (supports_popcnt() ? ", popcnt" : ""), |
382 (supports_mmx_ext() ? ", mmxext" : ""), | 396 (supports_mmx_ext() ? ", mmxext" : ""), |
383 (supports_3dnow_prefetch() ? ", 3dnowpref" : ""), | 397 (supports_3dnow_prefetch() ? ", 3dnowpref" : ""), |
384 (supports_lzcnt() ? ", lzcnt": ""), | 398 (supports_lzcnt() ? ", lzcnt": ""), |
385 (supports_sse4a() ? ", sse4a": ""), | 399 (supports_sse4a() ? ", sse4a": ""), |
386 (supports_ht() ? ", ht": "")); | 400 (supports_ht() ? ", ht": ""), |
401 (supports_tsc() ? ", tsc": ""), | |
402 (supports_tscinv_bit() ? ", tscinvbit": ""), | |
403 (supports_tscinv() ? ", tscinv": "")); | |
387 _features_str = strdup(buf); | 404 _features_str = strdup(buf); |
388 | 405 |
389 // UseSSE is set to the smaller of what hardware supports and what | 406 // UseSSE is set to the smaller of what hardware supports and what |
390 // the command line requires. I.e., you cannot set UseSSE to 2 on | 407 // the command line requires. I.e., you cannot set UseSSE to 2 on |
391 // older Pentiums which do not support it. | 408 // older Pentiums which do not support it. |