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 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 if (end == architecture) { | 449 if (end == architecture) { |
450 architecture_ = 0; | 450 architecture_ = 0; |
451 } | 451 } |
452 delete[] architecture; | 452 delete[] architecture; |
453 | 453 |
454 // Unfortunately, it seems that certain ARMv6-based CPUs | 454 // Unfortunately, it seems that certain ARMv6-based CPUs |
455 // report an incorrect architecture number of 7! | 455 // report an incorrect architecture number of 7! |
456 // | 456 // |
457 // See http://code.google.com/p/android/issues/detail?id=10812 | 457 // See http://code.google.com/p/android/issues/detail?id=10812 |
458 // | 458 // |
459 // We try to correct this by looking at the 'elf_format' | 459 // We try to correct this by looking at the 'elf_platform' |
460 // field reported by the 'Processor' field, which is of the | 460 // field reported by the 'Processor' field, which is of the |
461 // form of "(v7l)" for an ARMv7-based CPU, and "(v6l)" for | 461 // form of "(v7l)" for an ARMv7-based CPU, and "(v6l)" for |
462 // an ARMv6-one. For example, the Raspberry Pi is one popular | 462 // an ARMv6-one. For example, the Raspberry Pi is one popular |
463 // ARMv6 device that reports architecture 7. | 463 // ARMv6 device that reports architecture 7. |
464 if (architecture_ == 7) { | 464 if (architecture_ == 7) { |
465 char* processor = cpu_info.ExtractField("Processor"); | 465 char* processor = cpu_info.ExtractField("Processor"); |
466 if (HasListItem(processor, "(v6l)")) { | 466 if (HasListItem(processor, "(v6l)")) { |
467 architecture_ = 6; | 467 architecture_ = 6; |
468 } | 468 } |
469 delete[] processor; | 469 delete[] processor; |
470 } | 470 } |
| 471 |
| 472 // elf_platform moved to the model name field in Linux v3.8. |
| 473 if (architecture_ == 7) { |
| 474 char* processor = cpu_info.ExtractField("model name"); |
| 475 if (HasListItem(processor, "(v6l)")) { |
| 476 architecture_ = 6; |
| 477 } |
| 478 delete[] processor; |
| 479 } |
471 } | 480 } |
472 | 481 |
473 // Try to extract the list of CPU features from ELF hwcaps. | 482 // Try to extract the list of CPU features from ELF hwcaps. |
474 uint32_t hwcaps = ReadELFHWCaps(); | 483 uint32_t hwcaps = ReadELFHWCaps(); |
475 if (hwcaps != 0) { | 484 if (hwcaps != 0) { |
476 has_idiva_ = (hwcaps & HWCAP_IDIVA) != 0; | 485 has_idiva_ = (hwcaps & HWCAP_IDIVA) != 0; |
477 has_neon_ = (hwcaps & HWCAP_NEON) != 0; | 486 has_neon_ = (hwcaps & HWCAP_NEON) != 0; |
478 has_vfp_ = (hwcaps & HWCAP_VFP) != 0; | 487 has_vfp_ = (hwcaps & HWCAP_VFP) != 0; |
479 has_vfp3_ = (hwcaps & (HWCAP_VFPv3 | HWCAP_VFPv3D16 | HWCAP_VFPv4)) != 0; | 488 has_vfp3_ = (hwcaps & (HWCAP_VFPv3 | HWCAP_VFPv3D16 | HWCAP_VFPv4)) != 0; |
480 has_vfp3_d32_ = (has_vfp3_ && ((hwcaps & HWCAP_VFPv3D16) == 0 || | 489 has_vfp3_d32_ = (has_vfp3_ && ((hwcaps & HWCAP_VFPv3D16) == 0 || |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 part_ = PPC_PA6T; | 651 part_ = PPC_PA6T; |
643 } | 652 } |
644 } | 653 } |
645 | 654 |
646 #endif // V8_OS_LINUX | 655 #endif // V8_OS_LINUX |
647 #endif // !USE_SIMULATOR | 656 #endif // !USE_SIMULATOR |
648 #endif // V8_HOST_ARCH_PPC | 657 #endif // V8_HOST_ARCH_PPC |
649 } | 658 } |
650 | 659 |
651 } } // namespace v8::base | 660 } } // namespace v8::base |
OLD | NEW |