Chromium Code Reviews| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 411 __cpuid(cpu_info, 0x80000000); | 412 __cpuid(cpu_info, 0x80000000); | 
| 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 | 
| 
 
fmeawad
2016/05/25 23:40:31
nit: Add a small comment to explain what happens h
 
lpy
2016/05/26 16:25:22
Done.
 
 | |
| 423 const int parameter_containing_non_stop_time_stamp_counter = 0x80000007; | |
| 424 if (num_ext_ids >= parameter_containing_non_stop_time_stamp_counter) { | |
| 425 __cpuid(cpu_info, parameter_containing_non_stop_time_stamp_counter); | |
| 426 has_non_stop_time_stamp_counter_ = (cpu_info[3] & (1 << 8)) != 0; | |
| 427 } | |
| 428 | |
| 422 #elif V8_HOST_ARCH_ARM | 429 #elif V8_HOST_ARCH_ARM | 
| 423 | 430 | 
| 424 #if V8_OS_LINUX | 431 #if V8_OS_LINUX | 
| 425 | 432 | 
| 426 CPUInfo cpu_info; | 433 CPUInfo cpu_info; | 
| 427 | 434 | 
| 428 // Extract implementor from the "CPU implementer" field. | 435 // Extract implementor from the "CPU implementer" field. | 
| 429 char* implementer = cpu_info.ExtractField("CPU implementer"); | 436 char* implementer = cpu_info.ExtractField("CPU implementer"); | 
| 430 if (implementer != NULL) { | 437 if (implementer != NULL) { | 
| 431 char* end; | 438 char* end; | 
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 700 part_ = PPC_POWER5; | 707 part_ = PPC_POWER5; | 
| 701 break; | 708 break; | 
| 702 } | 709 } | 
| 703 #endif // V8_OS_AIX | 710 #endif // V8_OS_AIX | 
| 704 #endif // !USE_SIMULATOR | 711 #endif // !USE_SIMULATOR | 
| 705 #endif // V8_HOST_ARCH_PPC | 712 #endif // V8_HOST_ARCH_PPC | 
| 706 } | 713 } | 
| 707 | 714 | 
| 708 } // namespace base | 715 } // namespace base | 
| 709 } // namespace v8 | 716 } // namespace v8 | 
| OLD | NEW |