comparison src/cpu/x86/vm/vm_version_x86.cpp @ 1930:2d26b0046e0d

Merge.
author Thomas Wuerthinger <wuerthinger@ssw.jku.at>
date Tue, 30 Nov 2010 14:53:30 +0100
parents 3e8fbc61cee8
children f95d63e2154a
comparison
equal deleted inserted replaced
1484:6b7001391c97 1930:2d26b0046e0d
1 /* 1 /*
2 * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved. 2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
14 * 14 *
15 * You should have received a copy of the GNU General Public License version 15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation, 16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 * 18 *
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * CA 95054 USA or visit www.sun.com if you need additional information or 20 * or visit www.oracle.com if you need additional information or have any
21 * have any questions. 21 * questions.
22 * 22 *
23 */ 23 */
24 24
25 # include "incls/_precompiled.incl" 25 # include "incls/_precompiled.incl"
26 # include "incls/_vm_version_x86.cpp.incl" 26 # include "incls/_vm_version_x86.cpp.incl"
32 int VM_Version::_cpuFeatures; 32 int VM_Version::_cpuFeatures;
33 const char* VM_Version::_features_str = ""; 33 const char* VM_Version::_features_str = "";
34 VM_Version::CpuidInfo VM_Version::_cpuid_info = { 0, }; 34 VM_Version::CpuidInfo VM_Version::_cpuid_info = { 0, };
35 35
36 static BufferBlob* stub_blob; 36 static BufferBlob* stub_blob;
37 static const int stub_size = 300; 37 static const int stub_size = 400;
38 38
39 extern "C" { 39 extern "C" {
40 typedef void (*getPsrInfo_stub_t)(void*); 40 typedef void (*getPsrInfo_stub_t)(void*);
41 } 41 }
42 static getPsrInfo_stub_t getPsrInfo_stub = NULL; 42 static getPsrInfo_stub_t getPsrInfo_stub = NULL;
54 // Values for when we don't have a CPUID instruction. 54 // Values for when we don't have a CPUID instruction.
55 const int CPU_FAMILY_SHIFT = 8; 55 const int CPU_FAMILY_SHIFT = 8;
56 const uint32_t CPU_FAMILY_386 = (3 << CPU_FAMILY_SHIFT); 56 const uint32_t CPU_FAMILY_386 = (3 << CPU_FAMILY_SHIFT);
57 const uint32_t CPU_FAMILY_486 = (4 << CPU_FAMILY_SHIFT); 57 const uint32_t CPU_FAMILY_486 = (4 << CPU_FAMILY_SHIFT);
58 58
59 Label detect_486, cpu486, detect_586, std_cpuid1; 59 Label detect_486, cpu486, detect_586, std_cpuid1, std_cpuid4;
60 Label ext_cpuid1, ext_cpuid5, done; 60 Label ext_cpuid1, ext_cpuid5, done;
61 61
62 StubCodeMark mark(this, "VM_Version", "getPsrInfo_stub"); 62 StubCodeMark mark(this, "VM_Version", "getPsrInfo_stub");
63 # define __ _masm-> 63 # define __ _masm->
64 64
129 __ movl(Address(rsi, 0), rax); 129 __ movl(Address(rsi, 0), rax);
130 __ movl(Address(rsi, 4), rbx); 130 __ movl(Address(rsi, 4), rbx);
131 __ movl(Address(rsi, 8), rcx); 131 __ movl(Address(rsi, 8), rcx);
132 __ movl(Address(rsi,12), rdx); 132 __ movl(Address(rsi,12), rdx);
133 133
134 __ cmpl(rax, 3); // Is cpuid(0x4) supported? 134 __ cmpl(rax, 0xa); // Is cpuid(0xB) supported?
135 __ jccb(Assembler::belowEqual, std_cpuid1); 135 __ jccb(Assembler::belowEqual, std_cpuid4);
136
137 //
138 // cpuid(0xB) Processor Topology
139 //
140 __ movl(rax, 0xb);
141 __ xorl(rcx, rcx); // Threads level
142 __ cpuid();
143
144 __ lea(rsi, Address(rbp, in_bytes(VM_Version::tpl_cpuidB0_offset())));
145 __ movl(Address(rsi, 0), rax);
146 __ movl(Address(rsi, 4), rbx);
147 __ movl(Address(rsi, 8), rcx);
148 __ movl(Address(rsi,12), rdx);
149
150 __ movl(rax, 0xb);
151 __ movl(rcx, 1); // Cores level
152 __ cpuid();
153 __ push(rax);
154 __ andl(rax, 0x1f); // Determine if valid topology level
155 __ orl(rax, rbx); // eax[4:0] | ebx[0:15] == 0 indicates invalid level
156 __ andl(rax, 0xffff);
157 __ pop(rax);
158 __ jccb(Assembler::equal, std_cpuid4);
159
160 __ lea(rsi, Address(rbp, in_bytes(VM_Version::tpl_cpuidB1_offset())));
161 __ movl(Address(rsi, 0), rax);
162 __ movl(Address(rsi, 4), rbx);
163 __ movl(Address(rsi, 8), rcx);
164 __ movl(Address(rsi,12), rdx);
165
166 __ movl(rax, 0xb);
167 __ movl(rcx, 2); // Packages level
168 __ cpuid();
169 __ push(rax);
170 __ andl(rax, 0x1f); // Determine if valid topology level
171 __ orl(rax, rbx); // eax[4:0] | ebx[0:15] == 0 indicates invalid level
172 __ andl(rax, 0xffff);
173 __ pop(rax);
174 __ jccb(Assembler::equal, std_cpuid4);
175
176 __ lea(rsi, Address(rbp, in_bytes(VM_Version::tpl_cpuidB2_offset())));
177 __ movl(Address(rsi, 0), rax);
178 __ movl(Address(rsi, 4), rbx);
179 __ movl(Address(rsi, 8), rcx);
180 __ movl(Address(rsi,12), rdx);
136 181
137 // 182 //
138 // cpuid(0x4) Deterministic cache params 183 // cpuid(0x4) Deterministic cache params
139 // 184 //
185 __ bind(std_cpuid4);
140 __ movl(rax, 4); 186 __ movl(rax, 4);
187 __ cmpl(rax, Address(rbp, in_bytes(VM_Version::std_cpuid0_offset()))); // Is cpuid(0x4) supported?
188 __ jccb(Assembler::greater, std_cpuid1);
189
141 __ xorl(rcx, rcx); // L1 cache 190 __ xorl(rcx, rcx); // L1 cache
142 __ cpuid(); 191 __ cpuid();
143 __ push(rax); 192 __ push(rax);
144 __ andl(rax, 0x1f); // Determine if valid cache parameters used 193 __ andl(rax, 0x1f); // Determine if valid cache parameters used
145 __ orl(rax, rax); // eax[4:0] == 0 indicates invalid cache 194 __ orl(rax, rax); // eax[4:0] == 0 indicates invalid cache
431 if (FLAG_IS_DEFAULT(UsePopCountInstruction)) { 480 if (FLAG_IS_DEFAULT(UsePopCountInstruction)) {
432 UsePopCountInstruction = true; 481 UsePopCountInstruction = true;
433 } 482 }
434 } 483 }
435 484
485 #ifdef COMPILER2
486 if (UseFPUForSpilling) {
487 if (UseSSE < 2) {
488 // Only supported with SSE2+
489 FLAG_SET_DEFAULT(UseFPUForSpilling, false);
490 }
491 }
492 #endif
493
436 assert(0 <= ReadPrefetchInstr && ReadPrefetchInstr <= 3, "invalid value"); 494 assert(0 <= ReadPrefetchInstr && ReadPrefetchInstr <= 3, "invalid value");
437 assert(0 <= AllocatePrefetchInstr && AllocatePrefetchInstr <= 3, "invalid value"); 495 assert(0 <= AllocatePrefetchInstr && AllocatePrefetchInstr <= 3, "invalid value");
438 496
439 // set valid Prefetch instruction 497 // set valid Prefetch instruction
440 if( ReadPrefetchInstr < 0 ) ReadPrefetchInstr = 0; 498 if( ReadPrefetchInstr < 0 ) ReadPrefetchInstr = 0;
458 AllocatePrefetchLines = 1; // Conservative value 516 AllocatePrefetchLines = 1; // Conservative value
459 517
460 AllocatePrefetchDistance = allocate_prefetch_distance(); 518 AllocatePrefetchDistance = allocate_prefetch_distance();
461 AllocatePrefetchStyle = allocate_prefetch_style(); 519 AllocatePrefetchStyle = allocate_prefetch_style();
462 520
463 if( AllocatePrefetchStyle == 2 && is_intel() && 521 if( is_intel() && cpu_family() == 6 && supports_sse3() ) {
464 cpu_family() == 6 && supports_sse3() ) { // watermark prefetching on Core 522 if( AllocatePrefetchStyle == 2 ) { // watermark prefetching on Core
465 #ifdef _LP64 523 #ifdef _LP64
466 AllocatePrefetchDistance = 384; 524 AllocatePrefetchDistance = 384;
467 #else 525 #else
468 AllocatePrefetchDistance = 320; 526 AllocatePrefetchDistance = 320;
469 #endif 527 #endif
528 }
529 if( supports_sse4_2() && supports_ht() ) { // Nehalem based cpus
530 AllocatePrefetchDistance = 192;
531 AllocatePrefetchLines = 4;
532 #ifdef COMPILER2
533 if (AggressiveOpts && FLAG_IS_DEFAULT(UseFPUForSpilling)) {
534 FLAG_SET_DEFAULT(UseFPUForSpilling, true);
535 }
536 #endif
537 }
470 } 538 }
471 assert(AllocatePrefetchDistance % AllocatePrefetchStepSize == 0, "invalid value"); 539 assert(AllocatePrefetchDistance % AllocatePrefetchStepSize == 0, "invalid value");
472 540
473 #ifdef _LP64 541 #ifdef _LP64
474 // Prefetch settings 542 // Prefetch settings
525 593
526 stub_blob = BufferBlob::create("getPsrInfo_stub", stub_size); 594 stub_blob = BufferBlob::create("getPsrInfo_stub", stub_size);
527 if (stub_blob == NULL) { 595 if (stub_blob == NULL) {
528 vm_exit_during_initialization("Unable to allocate getPsrInfo_stub"); 596 vm_exit_during_initialization("Unable to allocate getPsrInfo_stub");
529 } 597 }
530 CodeBuffer c(stub_blob->instructions_begin(), 598 CodeBuffer c(stub_blob);
531 stub_blob->instructions_size());
532 VM_Version_StubGenerator g(&c); 599 VM_Version_StubGenerator g(&c);
533 getPsrInfo_stub = CAST_TO_FN_PTR(getPsrInfo_stub_t, 600 getPsrInfo_stub = CAST_TO_FN_PTR(getPsrInfo_stub_t,
534 g.generate_getPsrInfo()); 601 g.generate_getPsrInfo());
535 602
536 get_processor_features(); 603 get_processor_features();