OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project 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 "src/base/cpu.h" | 5 #include "src/base/cpu.h" |
6 | 6 |
7 #if V8_LIBC_MSVCRT | 7 #if V8_LIBC_MSVCRT |
8 #include <intrin.h> // __cpuid() | 8 #include <intrin.h> // __cpuid() |
9 #endif | 9 #endif |
10 #if V8_OS_LINUX | 10 #if V8_OS_LINUX |
(...skipping 26 matching lines...) Expand all Loading... |
37 #include <algorithm> | 37 #include <algorithm> |
38 | 38 |
39 #include "src/base/logging.h" | 39 #include "src/base/logging.h" |
40 #if V8_OS_WIN | 40 #if V8_OS_WIN |
41 #include "src/base/win32-headers.h" // NOLINT | 41 #include "src/base/win32-headers.h" // NOLINT |
42 #endif | 42 #endif |
43 | 43 |
44 namespace v8 { | 44 namespace v8 { |
45 namespace base { | 45 namespace base { |
46 | 46 |
47 #if defined(__pnacl__) | 47 #if V8_HOST_ARCH_IA32 || V8_HOST_ARCH_X64 |
48 // Portable host shouldn't do feature detection. | |
49 #elif V8_HOST_ARCH_IA32 || V8_HOST_ARCH_X64 | |
50 | 48 |
51 // Define __cpuid() for non-MSVC libraries. | 49 // Define __cpuid() for non-MSVC libraries. |
52 #if !V8_LIBC_MSVCRT | 50 #if !V8_LIBC_MSVCRT |
53 | 51 |
54 static V8_INLINE void __cpuid(int cpu_info[4], int info_type) { | 52 static V8_INLINE void __cpuid(int cpu_info[4], int info_type) { |
55 // Clear ecx to align with __cpuid() of MSVC: | 53 // Clear ecx to align with __cpuid() of MSVC: |
56 // https://msdn.microsoft.com/en-us/library/hskdteyh.aspx | 54 // https://msdn.microsoft.com/en-us/library/hskdteyh.aspx |
57 #if defined(__i386__) && defined(__pic__) | 55 #if defined(__i386__) && defined(__pic__) |
58 // Make sure to preserve ebx, which contains the pointer | 56 // Make sure to preserve ebx, which contains the pointer |
59 // to the GOT in case we're generating PIC. | 57 // to the GOT in case we're generating PIC. |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 has_popcnt_(false), | 332 has_popcnt_(false), |
335 has_idiva_(false), | 333 has_idiva_(false), |
336 has_neon_(false), | 334 has_neon_(false), |
337 has_thumb2_(false), | 335 has_thumb2_(false), |
338 has_vfp_(false), | 336 has_vfp_(false), |
339 has_vfp3_(false), | 337 has_vfp3_(false), |
340 has_vfp3_d32_(false), | 338 has_vfp3_d32_(false), |
341 is_fp64_mode_(false), | 339 is_fp64_mode_(false), |
342 has_non_stop_time_stamp_counter_(false) { | 340 has_non_stop_time_stamp_counter_(false) { |
343 memcpy(vendor_, "Unknown", 8); | 341 memcpy(vendor_, "Unknown", 8); |
344 #if V8_OS_NACL | 342 #if V8_HOST_ARCH_IA32 || V8_HOST_ARCH_X64 |
345 // Portable host shouldn't do feature detection. | |
346 // TODO(jfb): Remove the hardcoded ARM simulator flags in the build, and | |
347 // hardcode them here instead. | |
348 #elif V8_HOST_ARCH_IA32 || V8_HOST_ARCH_X64 | |
349 int cpu_info[4]; | 343 int cpu_info[4]; |
350 | 344 |
351 // __cpuid with an InfoType argument of 0 returns the number of | 345 // __cpuid with an InfoType argument of 0 returns the number of |
352 // valid Ids in CPUInfo[0] and the CPU identification string in | 346 // valid Ids in CPUInfo[0] and the CPU identification string in |
353 // the other three array elements. The CPU identification string is | 347 // the other three array elements. The CPU identification string is |
354 // not in linear order. The code below arranges the information | 348 // not in linear order. The code below arranges the information |
355 // in a human readable form. The human readable order is CPUInfo[1] | | 349 // in a human readable form. The human readable order is CPUInfo[1] | |
356 // CPUInfo[3] | CPUInfo[2]. CPUInfo[2] and CPUInfo[3] are swapped | 350 // CPUInfo[3] | CPUInfo[2]. CPUInfo[2] and CPUInfo[3] are swapped |
357 // before using memcpy to copy these three array elements to cpu_string. | 351 // before using memcpy to copy these three array elements to cpu_string. |
358 __cpuid(cpu_info, 0); | 352 __cpuid(cpu_info, 0); |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
708 part_ = PPC_POWER5; | 702 part_ = PPC_POWER5; |
709 break; | 703 break; |
710 } | 704 } |
711 #endif // V8_OS_AIX | 705 #endif // V8_OS_AIX |
712 #endif // !USE_SIMULATOR | 706 #endif // !USE_SIMULATOR |
713 #endif // V8_HOST_ARCH_PPC | 707 #endif // V8_HOST_ARCH_PPC |
714 } | 708 } |
715 | 709 |
716 } // namespace base | 710 } // namespace base |
717 } // namespace v8 | 711 } // namespace v8 |
OLD | NEW |