| 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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 } | 284 } |
| 285 return false; | 285 return false; |
| 286 } | 286 } |
| 287 | 287 |
| 288 #endif // V8_HOST_ARCH_ARM || V8_HOST_ARCH_MIPS || V8_HOST_ARCH_MIPS64 | 288 #endif // V8_HOST_ARCH_ARM || V8_HOST_ARCH_MIPS || V8_HOST_ARCH_MIPS64 |
| 289 | 289 |
| 290 #endif // V8_OS_LINUX | 290 #endif // V8_OS_LINUX |
| 291 | 291 |
| 292 #endif // V8_HOST_ARCH_IA32 || V8_HOST_ARCH_X64 | 292 #endif // V8_HOST_ARCH_IA32 || V8_HOST_ARCH_X64 |
| 293 | 293 |
| 294 CPU::CPU() : stepping_(0), | 294 CPU::CPU() |
| 295 model_(0), | 295 : stepping_(0), |
| 296 ext_model_(0), | 296 model_(0), |
| 297 family_(0), | 297 ext_model_(0), |
| 298 ext_family_(0), | 298 family_(0), |
| 299 type_(0), | 299 ext_family_(0), |
| 300 implementer_(0), | 300 type_(0), |
| 301 architecture_(0), | 301 implementer_(0), |
| 302 part_(0), | 302 architecture_(0), |
| 303 has_fpu_(false), | 303 part_(0), |
| 304 has_cmov_(false), | 304 has_fpu_(false), |
| 305 has_sahf_(false), | 305 has_cmov_(false), |
| 306 has_mmx_(false), | 306 has_sahf_(false), |
| 307 has_sse_(false), | 307 has_mmx_(false), |
| 308 has_sse2_(false), | 308 has_sse_(false), |
| 309 has_sse3_(false), | 309 has_sse2_(false), |
| 310 has_ssse3_(false), | 310 has_sse3_(false), |
| 311 has_sse41_(false), | 311 has_ssse3_(false), |
| 312 has_sse42_(false), | 312 has_sse41_(false), |
| 313 has_idiva_(false), | 313 has_sse42_(false), |
| 314 has_neon_(false), | 314 has_avx_(false), |
| 315 has_thumb2_(false), | 315 has_fma3_(false), |
| 316 has_vfp_(false), | 316 has_idiva_(false), |
| 317 has_vfp3_(false), | 317 has_neon_(false), |
| 318 has_vfp3_d32_(false), | 318 has_thumb2_(false), |
| 319 is_fp64_mode_(false) { | 319 has_vfp_(false), |
| 320 has_vfp3_(false), |
| 321 has_vfp3_d32_(false), |
| 322 is_fp64_mode_(false) { |
| 320 memcpy(vendor_, "Unknown", 8); | 323 memcpy(vendor_, "Unknown", 8); |
| 321 #if V8_OS_NACL | 324 #if V8_OS_NACL |
| 322 // Portable host shouldn't do feature detection. | 325 // Portable host shouldn't do feature detection. |
| 323 // TODO(jfb): Remove the hardcoded ARM simulator flags in the build, and | 326 // TODO(jfb): Remove the hardcoded ARM simulator flags in the build, and |
| 324 // hardcode them here instead. | 327 // hardcode them here instead. |
| 325 #elif V8_HOST_ARCH_IA32 || V8_HOST_ARCH_X64 | 328 #elif V8_HOST_ARCH_IA32 || V8_HOST_ARCH_X64 |
| 326 int cpu_info[4]; | 329 int cpu_info[4]; |
| 327 | 330 |
| 328 // __cpuid with an InfoType argument of 0 returns the number of | 331 // __cpuid with an InfoType argument of 0 returns the number of |
| 329 // valid Ids in CPUInfo[0] and the CPU identification string in | 332 // valid Ids in CPUInfo[0] and the CPU identification string in |
| (...skipping 19 matching lines...) Expand all Loading... |
| 349 ext_family_ = (cpu_info[0] >> 20) & 0xff; | 352 ext_family_ = (cpu_info[0] >> 20) & 0xff; |
| 350 has_fpu_ = (cpu_info[3] & 0x00000001) != 0; | 353 has_fpu_ = (cpu_info[3] & 0x00000001) != 0; |
| 351 has_cmov_ = (cpu_info[3] & 0x00008000) != 0; | 354 has_cmov_ = (cpu_info[3] & 0x00008000) != 0; |
| 352 has_mmx_ = (cpu_info[3] & 0x00800000) != 0; | 355 has_mmx_ = (cpu_info[3] & 0x00800000) != 0; |
| 353 has_sse_ = (cpu_info[3] & 0x02000000) != 0; | 356 has_sse_ = (cpu_info[3] & 0x02000000) != 0; |
| 354 has_sse2_ = (cpu_info[3] & 0x04000000) != 0; | 357 has_sse2_ = (cpu_info[3] & 0x04000000) != 0; |
| 355 has_sse3_ = (cpu_info[2] & 0x00000001) != 0; | 358 has_sse3_ = (cpu_info[2] & 0x00000001) != 0; |
| 356 has_ssse3_ = (cpu_info[2] & 0x00000200) != 0; | 359 has_ssse3_ = (cpu_info[2] & 0x00000200) != 0; |
| 357 has_sse41_ = (cpu_info[2] & 0x00080000) != 0; | 360 has_sse41_ = (cpu_info[2] & 0x00080000) != 0; |
| 358 has_sse42_ = (cpu_info[2] & 0x00100000) != 0; | 361 has_sse42_ = (cpu_info[2] & 0x00100000) != 0; |
| 362 has_avx_ = (cpu_info[2] & 0x18000000) != 0; |
| 363 if (has_avx_) has_fma3_ = (cpu_info[2] & 0x00001000) != 0; |
| 359 } | 364 } |
| 360 | 365 |
| 361 #if V8_HOST_ARCH_IA32 | 366 #if V8_HOST_ARCH_IA32 |
| 362 // SAHF is always available in compat/legacy mode, | 367 // SAHF is always available in compat/legacy mode, |
| 363 has_sahf_ = true; | 368 has_sahf_ = true; |
| 364 #else | 369 #else |
| 365 // Query extended IDs. | 370 // Query extended IDs. |
| 366 __cpuid(cpu_info, 0x80000000); | 371 __cpuid(cpu_info, 0x80000000); |
| 367 unsigned num_ext_ids = cpu_info[0]; | 372 unsigned num_ext_ids = cpu_info[0]; |
| 368 | 373 |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 if (end == part) { | 556 if (end == part) { |
| 552 part_ = 0; | 557 part_ = 0; |
| 553 } | 558 } |
| 554 delete[] part; | 559 delete[] part; |
| 555 } | 560 } |
| 556 | 561 |
| 557 #endif | 562 #endif |
| 558 } | 563 } |
| 559 | 564 |
| 560 } } // namespace v8::base | 565 } } // namespace v8::base |
| OLD | NEW |