| 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 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 has_bmi1_(false), | 331 has_bmi1_(false), |
| 332 has_bmi2_(false), | 332 has_bmi2_(false), |
| 333 has_lzcnt_(false), | 333 has_lzcnt_(false), |
| 334 has_popcnt_(false), | 334 has_popcnt_(false), |
| 335 has_idiva_(false), | 335 has_idiva_(false), |
| 336 has_neon_(false), | 336 has_neon_(false), |
| 337 has_thumb2_(false), | 337 has_thumb2_(false), |
| 338 has_vfp_(false), | 338 has_vfp_(false), |
| 339 has_vfp3_(false), | 339 has_vfp3_(false), |
| 340 has_vfp3_d32_(false), | 340 has_vfp3_d32_(false), |
| 341 is_fp64_mode_(false) { | 341 is_fp64_mode_(false), |
| 342 has_non_stop_time_stamp_counter_(false) { |
| 342 memcpy(vendor_, "Unknown", 8); | 343 memcpy(vendor_, "Unknown", 8); |
| 343 #if V8_OS_NACL | 344 #if V8_OS_NACL |
| 344 // Portable host shouldn't do feature detection. | 345 // Portable host shouldn't do feature detection. |
| 345 // TODO(jfb): Remove the hardcoded ARM simulator flags in the build, and | 346 // TODO(jfb): Remove the hardcoded ARM simulator flags in the build, and |
| 346 // hardcode them here instead. | 347 // hardcode them here instead. |
| 347 #elif V8_HOST_ARCH_IA32 || V8_HOST_ARCH_X64 | 348 #elif V8_HOST_ARCH_IA32 || V8_HOST_ARCH_X64 |
| 348 int cpu_info[4]; | 349 int cpu_info[4]; |
| 349 | 350 |
| 350 // __cpuid with an InfoType argument of 0 returns the number of | 351 // __cpuid with an InfoType argument of 0 returns the number of |
| 351 // valid Ids in CPUInfo[0] and the CPU identification string in | 352 // valid Ids in CPUInfo[0] and the CPU identification string in |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 unsigned num_ext_ids = cpu_info[0]; | 413 unsigned num_ext_ids = cpu_info[0]; |
| 413 | 414 |
| 414 // Interpret extended CPU feature information. | 415 // Interpret extended CPU feature information. |
| 415 if (num_ext_ids > 0x80000000) { | 416 if (num_ext_ids > 0x80000000) { |
| 416 __cpuid(cpu_info, 0x80000001); | 417 __cpuid(cpu_info, 0x80000001); |
| 417 has_lzcnt_ = (cpu_info[2] & 0x00000020) != 0; | 418 has_lzcnt_ = (cpu_info[2] & 0x00000020) != 0; |
| 418 // SAHF must be probed in long mode. | 419 // SAHF must be probed in long mode. |
| 419 has_sahf_ = (cpu_info[2] & 0x00000001) != 0; | 420 has_sahf_ = (cpu_info[2] & 0x00000001) != 0; |
| 420 } | 421 } |
| 421 | 422 |
| 423 // Check if CPU has non stoppable time stamp counter. |
| 424 const int parameter_containing_non_stop_time_stamp_counter = 0x80000007; |
| 425 if (num_ext_ids >= parameter_containing_non_stop_time_stamp_counter) { |
| 426 __cpuid(cpu_info, parameter_containing_non_stop_time_stamp_counter); |
| 427 has_non_stop_time_stamp_counter_ = (cpu_info[3] & (1 << 8)) != 0; |
| 428 } |
| 429 |
| 422 #elif V8_HOST_ARCH_ARM | 430 #elif V8_HOST_ARCH_ARM |
| 423 | 431 |
| 424 #if V8_OS_LINUX | 432 #if V8_OS_LINUX |
| 425 | 433 |
| 426 CPUInfo cpu_info; | 434 CPUInfo cpu_info; |
| 427 | 435 |
| 428 // Extract implementor from the "CPU implementer" field. | 436 // Extract implementor from the "CPU implementer" field. |
| 429 char* implementer = cpu_info.ExtractField("CPU implementer"); | 437 char* implementer = cpu_info.ExtractField("CPU implementer"); |
| 430 if (implementer != NULL) { | 438 if (implementer != NULL) { |
| 431 char* end; | 439 char* end; |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 part_ = PPC_POWER5; | 708 part_ = PPC_POWER5; |
| 701 break; | 709 break; |
| 702 } | 710 } |
| 703 #endif // V8_OS_AIX | 711 #endif // V8_OS_AIX |
| 704 #endif // !USE_SIMULATOR | 712 #endif // !USE_SIMULATOR |
| 705 #endif // V8_HOST_ARCH_PPC | 713 #endif // V8_HOST_ARCH_PPC |
| 706 } | 714 } |
| 707 | 715 |
| 708 } // namespace base | 716 } // namespace base |
| 709 } // namespace v8 | 717 } // namespace v8 |
| OLD | NEW |