Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(287)

Side by Side Diff: src/base/cpu.cc

Issue 1806853002: Revert "Detect cache line size on Linux for PPC hosts." (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/base/cpu.h ('k') | src/ppc/assembler-ppc.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 "=d"(cpu_info[3]) 70 "=d"(cpu_info[3])
71 : "a"(info_type), "c"(0)); 71 : "a"(info_type), "c"(0));
72 #endif // defined(__i386__) && defined(__pic__) 72 #endif // defined(__i386__) && defined(__pic__)
73 } 73 }
74 74
75 #endif // !V8_LIBC_MSVCRT 75 #endif // !V8_LIBC_MSVCRT
76 76
77 #elif V8_HOST_ARCH_ARM || V8_HOST_ARCH_ARM64 \ 77 #elif V8_HOST_ARCH_ARM || V8_HOST_ARCH_ARM64 \
78 || V8_HOST_ARCH_MIPS || V8_HOST_ARCH_MIPS64 78 || V8_HOST_ARCH_MIPS || V8_HOST_ARCH_MIPS64
79 79
80 #if V8_HOST_ARCH_ARM64
81 class CacheLineSizes {
82 public:
83 CacheLineSizes() {
84 #ifdef USE_SIMULATOR
85 cache_type_register_ = 0;
86 #else
87 // Copy the content of the cache type register to a core register.
88 __asm__ __volatile__("mrs %x[ctr], ctr_el0" // NOLINT
89 : [ctr] "=r"(cache_type_register_));
90 #endif
91 }
92
93 uint32_t icache_line_size() const { return ExtractCacheLineSize(0); }
94 uint32_t dcache_line_size() const { return ExtractCacheLineSize(16); }
95
96 private:
97 uint32_t ExtractCacheLineSize(int cache_line_size_shift) const {
98 // The cache type register holds the size of cache lines in words as a
99 // power of two.
100 return 4 << ((cache_type_register_ >> cache_line_size_shift) & 0xf);
101 }
102
103 uint32_t cache_type_register_;
104 };
105 #endif // V8_HOST_ARCH_ARM64
106
107 #if V8_OS_LINUX 80 #if V8_OS_LINUX
108 81
109 #if V8_HOST_ARCH_ARM 82 #if V8_HOST_ARCH_ARM
110 83
111 // See <uapi/asm/hwcap.h> kernel header. 84 // See <uapi/asm/hwcap.h> kernel header.
112 /* 85 /*
113 * HWCAP flags - for elf_hwcap (in kernel) and AT_HWCAP 86 * HWCAP flags - for elf_hwcap (in kernel) and AT_HWCAP
114 */ 87 */
115 #define HWCAP_SWP (1 << 0) 88 #define HWCAP_SWP (1 << 0)
116 #define HWCAP_HALF (1 << 1) 89 #define HWCAP_HALF (1 << 1)
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 : stepping_(0), 305 : stepping_(0),
333 model_(0), 306 model_(0),
334 ext_model_(0), 307 ext_model_(0),
335 family_(0), 308 family_(0),
336 ext_family_(0), 309 ext_family_(0),
337 type_(0), 310 type_(0),
338 implementer_(0), 311 implementer_(0),
339 architecture_(0), 312 architecture_(0),
340 variant_(-1), 313 variant_(-1),
341 part_(0), 314 part_(0),
342 icache_line_size_(UNKNOWN_CACHE_LINE_SIZE),
343 dcache_line_size_(UNKNOWN_CACHE_LINE_SIZE),
344 has_fpu_(false), 315 has_fpu_(false),
345 has_cmov_(false), 316 has_cmov_(false),
346 has_sahf_(false), 317 has_sahf_(false),
347 has_mmx_(false), 318 has_mmx_(false),
348 has_sse_(false), 319 has_sse_(false),
349 has_sse2_(false), 320 has_sse2_(false),
350 has_sse3_(false), 321 has_sse3_(false),
351 has_ssse3_(false), 322 has_ssse3_(false),
352 has_sse41_(false), 323 has_sse41_(false),
353 has_sse42_(false), 324 has_sse42_(false),
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 char* part = cpu_info.ExtractField("CPU part"); 619 char* part = cpu_info.ExtractField("CPU part");
649 if (part != NULL) { 620 if (part != NULL) {
650 char* end; 621 char* end;
651 part_ = strtol(part, &end, 0); 622 part_ = strtol(part, &end, 0);
652 if (end == part) { 623 if (end == part) {
653 part_ = 0; 624 part_ = 0;
654 } 625 }
655 delete[] part; 626 delete[] part;
656 } 627 }
657 628
658 CacheLineSizes sizes;
659 icache_line_size_ = sizes.icache_line_size();
660 dcache_line_size_ = sizes.dcache_line_size();
661
662 #elif V8_HOST_ARCH_PPC 629 #elif V8_HOST_ARCH_PPC
663 630
664 #ifndef USE_SIMULATOR 631 #ifndef USE_SIMULATOR
665 #if V8_OS_LINUX 632 #if V8_OS_LINUX
666 // Read processor info from /proc/self/auxv. 633 // Read processor info from /proc/self/auxv.
667 char* auxv_cpu_type = NULL; 634 char* auxv_cpu_type = NULL;
668 FILE* fp = fopen("/proc/self/auxv", "r"); 635 FILE* fp = fopen("/proc/self/auxv", "r");
669 if (fp != NULL) { 636 if (fp != NULL) {
670 #if V8_TARGET_ARCH_PPC64 637 #if V8_TARGET_ARCH_PPC64
671 Elf64_auxv_t entry; 638 Elf64_auxv_t entry;
672 #else 639 #else
673 Elf32_auxv_t entry; 640 Elf32_auxv_t entry;
674 #endif 641 #endif
675 for (;;) { 642 for (;;) {
676 size_t n = fread(&entry, sizeof(entry), 1, fp); 643 size_t n = fread(&entry, sizeof(entry), 1, fp);
677 if (n == 0 || entry.a_type == AT_NULL) { 644 if (n == 0 || entry.a_type == AT_NULL) {
678 break; 645 break;
679 } 646 }
680 switch (entry.a_type) { 647 if (entry.a_type == AT_PLATFORM) {
681 case AT_PLATFORM: 648 auxv_cpu_type = reinterpret_cast<char*>(entry.a_un.a_val);
682 auxv_cpu_type = reinterpret_cast<char*>(entry.a_un.a_val); 649 break;
683 break;
684 case AT_ICACHEBSIZE:
685 icache_line_size_ = entry.a_un.a_val;
686 break;
687 case AT_DCACHEBSIZE:
688 dcache_line_size_ = entry.a_un.a_val;
689 break;
690 } 650 }
691 } 651 }
692 fclose(fp); 652 fclose(fp);
693 } 653 }
694 654
695 part_ = -1; 655 part_ = -1;
696 if (auxv_cpu_type) { 656 if (auxv_cpu_type) {
697 if (strcmp(auxv_cpu_type, "power8") == 0) { 657 if (strcmp(auxv_cpu_type, "power8") == 0) {
698 part_ = PPC_POWER8; 658 part_ = PPC_POWER8;
699 } else if (strcmp(auxv_cpu_type, "power7") == 0) { 659 } else if (strcmp(auxv_cpu_type, "power7") == 0) {
(...skipping 26 matching lines...) Expand all
726 part_ = PPC_POWER5; 686 part_ = PPC_POWER5;
727 break; 687 break;
728 } 688 }
729 #endif // V8_OS_AIX 689 #endif // V8_OS_AIX
730 #endif // !USE_SIMULATOR 690 #endif // !USE_SIMULATOR
731 #endif // V8_HOST_ARCH_PPC 691 #endif // V8_HOST_ARCH_PPC
732 } 692 }
733 693
734 } // namespace base 694 } // namespace base
735 } // namespace v8 695 } // namespace v8
OLDNEW
« no previous file with comments | « src/base/cpu.h ('k') | src/ppc/assembler-ppc.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698