Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(122)

Side by Side Diff: base/cpu.cc

Issue 13583007: Create a field trial to test if we can detect good QPC implementations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/cpu.h ('k') | chrome/browser/metrics/metrics_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/cpu.h" 5 #include "base/cpu.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 14 matching lines...) Expand all
25 stepping_(0), 25 stepping_(0),
26 ext_model_(0), 26 ext_model_(0),
27 ext_family_(0), 27 ext_family_(0),
28 has_mmx_(false), 28 has_mmx_(false),
29 has_sse_(false), 29 has_sse_(false),
30 has_sse2_(false), 30 has_sse2_(false),
31 has_sse3_(false), 31 has_sse3_(false),
32 has_ssse3_(false), 32 has_ssse3_(false),
33 has_sse41_(false), 33 has_sse41_(false),
34 has_sse42_(false), 34 has_sse42_(false),
35 has_non_stop_time_stamp_counter_(false),
35 cpu_vendor_("unknown") { 36 cpu_vendor_("unknown") {
36 Initialize(); 37 Initialize();
37 } 38 }
38 39
39 #if defined(ARCH_CPU_X86_FAMILY) 40 #if defined(ARCH_CPU_X86_FAMILY)
40 #ifndef _MSC_VER 41 #ifndef _MSC_VER
41 42
42 #if defined(__pic__) && defined(__i386__) 43 #if defined(__pic__) && defined(__i386__)
43 44
44 void __cpuid(int cpu_info[4], int info_type) { 45 void __cpuid(int cpu_info[4], int info_type) {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 has_sse3_ = (cpu_info[2] & 0x00000001) != 0; 117 has_sse3_ = (cpu_info[2] & 0x00000001) != 0;
117 has_ssse3_ = (cpu_info[2] & 0x00000200) != 0; 118 has_ssse3_ = (cpu_info[2] & 0x00000200) != 0;
118 has_sse41_ = (cpu_info[2] & 0x00080000) != 0; 119 has_sse41_ = (cpu_info[2] & 0x00080000) != 0;
119 has_sse42_ = (cpu_info[2] & 0x00100000) != 0; 120 has_sse42_ = (cpu_info[2] & 0x00100000) != 0;
120 has_avx_ = (cpu_info[2] & 0x10000000) != 0; 121 has_avx_ = (cpu_info[2] & 0x10000000) != 0;
121 } 122 }
122 123
123 // Get the brand string of the cpu. 124 // Get the brand string of the cpu.
124 __cpuid(cpu_info, 0x80000000); 125 __cpuid(cpu_info, 0x80000000);
125 const int parameter_end = 0x80000004; 126 const int parameter_end = 0x80000004;
127 int max_parameter = cpu_info[0];
126 128
127 if (cpu_info[0] >= parameter_end) { 129 if (cpu_info[0] >= parameter_end) {
128 char* cpu_string_ptr = cpu_string; 130 char* cpu_string_ptr = cpu_string;
129 131
130 for (int parameter = 0x80000002; parameter <= parameter_end && 132 for (int parameter = 0x80000002; parameter <= parameter_end &&
131 cpu_string_ptr < &cpu_string[sizeof(cpu_string)]; parameter++) { 133 cpu_string_ptr < &cpu_string[sizeof(cpu_string)]; parameter++) {
132 __cpuid(cpu_info, parameter); 134 __cpuid(cpu_info, parameter);
133 memcpy(cpu_string_ptr, cpu_info, sizeof(cpu_info)); 135 memcpy(cpu_string_ptr, cpu_info, sizeof(cpu_info));
134 cpu_string_ptr += sizeof(cpu_info); 136 cpu_string_ptr += sizeof(cpu_info);
135 } 137 }
136 cpu_brand_.assign(cpu_string, cpu_string_ptr - cpu_string); 138 cpu_brand_.assign(cpu_string, cpu_string_ptr - cpu_string);
137 } 139 }
140
141 const int parameter_containing_non_stop_time_stamp_counter = 0x80000007;
142 if (max_parameter >= parameter_containing_non_stop_time_stamp_counter) {
143 __cpuid(cpu_info, parameter_containing_non_stop_time_stamp_counter);
144 has_non_stop_time_stamp_counter_ = (cpu_info[3] & (1 << 8)) != 0;
145 }
138 #endif 146 #endif
139 } 147 }
140 148
141 CPU::IntelMicroArchitecture CPU::GetIntelMicroArchitecture() const { 149 CPU::IntelMicroArchitecture CPU::GetIntelMicroArchitecture() const {
142 if (has_avx()) return AVX; 150 if (has_avx()) return AVX;
143 if (has_sse42()) return SSE42; 151 if (has_sse42()) return SSE42;
144 if (has_sse41()) return SSE41; 152 if (has_sse41()) return SSE41;
145 if (has_ssse3()) return SSSE3; 153 if (has_ssse3()) return SSSE3;
146 if (has_sse3()) return SSE3; 154 if (has_sse3()) return SSE3;
147 if (has_sse2()) return SSE2; 155 if (has_sse2()) return SSE2;
148 if (has_sse()) return SSE; 156 if (has_sse()) return SSE;
149 return PENTIUM; 157 return PENTIUM;
150 } 158 }
151 159
152 } // namespace base 160 } // namespace base
OLDNEW
« no previous file with comments | « base/cpu.h ('k') | chrome/browser/metrics/metrics_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698