| 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_POSIX | 10 #if V8_OS_POSIX |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include <algorithm> | 22 #include <algorithm> |
| 23 | 23 |
| 24 #include "src/base/logging.h" | 24 #include "src/base/logging.h" |
| 25 #if V8_OS_WIN | 25 #if V8_OS_WIN |
| 26 #include "src/base/win32-headers.h" // NOLINT | 26 #include "src/base/win32-headers.h" // NOLINT |
| 27 #endif | 27 #endif |
| 28 | 28 |
| 29 namespace v8 { | 29 namespace v8 { |
| 30 namespace base { | 30 namespace base { |
| 31 | 31 |
| 32 #if V8_HOST_ARCH_IA32 || V8_HOST_ARCH_X64 | 32 #if defined(__pnacl__) |
| 33 // Portable host shouldn't do feature detection. |
| 34 #elif V8_HOST_ARCH_IA32 || V8_HOST_ARCH_X64 |
| 33 | 35 |
| 34 // Define __cpuid() for non-MSVC libraries. | 36 // Define __cpuid() for non-MSVC libraries. |
| 35 #if !V8_LIBC_MSVCRT | 37 #if !V8_LIBC_MSVCRT |
| 36 | 38 |
| 37 static V8_INLINE void __cpuid(int cpu_info[4], int info_type) { | 39 static V8_INLINE void __cpuid(int cpu_info[4], int info_type) { |
| 38 #if defined(__i386__) && defined(__pic__) | 40 #if defined(__i386__) && defined(__pic__) |
| 39 // Make sure to preserve ebx, which contains the pointer | 41 // Make sure to preserve ebx, which contains the pointer |
| 40 // to the GOT in case we're generating PIC. | 42 // to the GOT in case we're generating PIC. |
| 41 __asm__ volatile ( | 43 __asm__ volatile ( |
| 42 "mov %%ebx, %%edi\n\t" | 44 "mov %%ebx, %%edi\n\t" |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 has_sse41_(false), | 285 has_sse41_(false), |
| 284 has_sse42_(false), | 286 has_sse42_(false), |
| 285 has_idiva_(false), | 287 has_idiva_(false), |
| 286 has_neon_(false), | 288 has_neon_(false), |
| 287 has_thumb2_(false), | 289 has_thumb2_(false), |
| 288 has_vfp_(false), | 290 has_vfp_(false), |
| 289 has_vfp3_(false), | 291 has_vfp3_(false), |
| 290 has_vfp3_d32_(false), | 292 has_vfp3_d32_(false), |
| 291 is_fp64_mode_(false) { | 293 is_fp64_mode_(false) { |
| 292 memcpy(vendor_, "Unknown", 8); | 294 memcpy(vendor_, "Unknown", 8); |
| 293 #if V8_HOST_ARCH_IA32 || V8_HOST_ARCH_X64 | 295 #if defined(__pnacl__) |
| 296 // Portable host shouldn't do feature detection. |
| 297 // TODO(jfb): Remove the hardcoded ARM simulator flags in the build, and |
| 298 // hardcode them here instead. |
| 299 #elif V8_HOST_ARCH_IA32 || V8_HOST_ARCH_X64 |
| 294 int cpu_info[4]; | 300 int cpu_info[4]; |
| 295 | 301 |
| 296 // __cpuid with an InfoType argument of 0 returns the number of | 302 // __cpuid with an InfoType argument of 0 returns the number of |
| 297 // valid Ids in CPUInfo[0] and the CPU identification string in | 303 // valid Ids in CPUInfo[0] and the CPU identification string in |
| 298 // the other three array elements. The CPU identification string is | 304 // the other three array elements. The CPU identification string is |
| 299 // not in linear order. The code below arranges the information | 305 // not in linear order. The code below arranges the information |
| 300 // in a human readable form. The human readable order is CPUInfo[1] | | 306 // in a human readable form. The human readable order is CPUInfo[1] | |
| 301 // CPUInfo[3] | CPUInfo[2]. CPUInfo[2] and CPUInfo[3] are swapped | 307 // CPUInfo[3] | CPUInfo[2]. CPUInfo[2] and CPUInfo[3] are swapped |
| 302 // before using memcpy to copy these three array elements to cpu_string. | 308 // before using memcpy to copy these three array elements to cpu_string. |
| 303 __cpuid(cpu_info, 0); | 309 __cpuid(cpu_info, 0); |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 if (end == part) { | 525 if (end == part) { |
| 520 part_ = 0; | 526 part_ = 0; |
| 521 } | 527 } |
| 522 delete[] part; | 528 delete[] part; |
| 523 } | 529 } |
| 524 | 530 |
| 525 #endif | 531 #endif |
| 526 } | 532 } |
| 527 | 533 |
| 528 } } // namespace v8::base | 534 } } // namespace v8::base |
| OLD | NEW |