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

Unified Diff: src/base/cpu.cc

Issue 817143002: Contribution of PowerPC port (continuation of 422063005) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years 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 side-by-side diff with in-line comments
Download patch
Index: src/base/cpu.cc
diff --git a/src/base/cpu.cc b/src/base/cpu.cc
index e188406f1a21ff72226b17c2332eb7ccd942dd49..16b586366156a0befcb507156ed5c6ba12560ec6 100644
--- a/src/base/cpu.cc
+++ b/src/base/cpu.cc
@@ -16,6 +16,9 @@
#if V8_OS_QNX
#include <sys/syspage.h> // cpuinfo
#endif
+#if V8_OS_LINUX && V8_HOST_ARCH_PPC
+#include <elf.h>
+#endif
#if V8_OS_POSIX
#include <unistd.h> // sysconf()
#endif
@@ -291,6 +294,8 @@ static bool HasListItem(const char* list, const char* item) {
#endif // V8_HOST_ARCH_IA32 || V8_HOST_ARCH_X64
+#define UNKNOWN_CACHE_LINE_SIZE 0
+
CPU::CPU()
: stepping_(0),
model_(0),
@@ -301,6 +306,7 @@ CPU::CPU()
implementer_(0),
architecture_(0),
part_(0),
+ cache_line_size_(UNKNOWN_CACHE_LINE_SIZE),
has_fpu_(false),
has_cmov_(false),
has_sahf_(false),
@@ -559,7 +565,66 @@ CPU::CPU()
delete[] part;
}
+#elif V8_HOST_ARCH_PPC
+
+#ifndef USE_SIMULATOR
+#if V8_OS_LINUX
+ // Read processor info from /proc/self/auxv.
+ char* auxv_cpu_type = NULL;
+ unsigned auxv_cache_line_size = 0;
+ FILE* fp = fopen("/proc/self/auxv", "r");
+ if (fp != NULL) {
+#if V8_TARGET_ARCH_PPC64
+ Elf64_auxv_t entry;
+#else
+ Elf32_auxv_t entry;
#endif
+ for (;;) {
+ size_t n = fread(&entry, sizeof(entry), 1, fp);
+ if (n == 0 || entry.a_type == AT_NULL) {
+ break;
+ }
+ if (entry.a_type == AT_PLATFORM) {
+ auxv_cpu_type = reinterpret_cast<char*>(entry.a_un.a_val);
+ break;
+ } else if (entry.a_type == AT_DCACHEBSIZE ||
+ entry.a_type == AT_ICACHEBSIZE ||
+ entry.a_type == AT_UCACHEBSIZE) {
+ unsigned cachebsize = entry.a_un.a_val;
+ if (cachebsize > 0 &&
+ (auxv_cache_line_size == 0 || cachebsize < auxv_cache_line_size)) {
+ auxv_cache_line_size = cachebsize;
+ }
+ }
+ }
+ fclose(fp);
+ }
+
+ part_ = -1;
+ if (auxv_cpu_type) {
+ if (strcmp(auxv_cpu_type, "power8") == 0) {
+ part_ = PPC_POWER8;
+ } else if (strcmp(auxv_cpu_type, "power7") == 0) {
+ part_ = PPC_POWER7;
+ } else if (strcmp(auxv_cpu_type, "power6") == 0) {
+ part_ = PPC_POWER6;
+ } else if (strcmp(auxv_cpu_type, "power5") == 0) {
+ part_ = PPC_POWER5;
+ } else if (strcmp(auxv_cpu_type, "ppc970") == 0) {
+ part_ = PPC_G5;
+ } else if (strcmp(auxv_cpu_type, "ppc7450") == 0) {
+ part_ = PPC_G4;
+ } else if (strcmp(auxv_cpu_type, "pa6t") == 0) {
+ part_ = PPC_PA6T;
+ }
+ }
+
+ if (auxv_cache_line_size > 0) {
+ cache_line_size_ = auxv_cache_line_size;
+ }
+#endif // V8_OS_LINUX
+#endif // !USE_SIMULATOR
+#endif // V8_HOST_ARCH_PPC
}
} } // namespace v8::base

Powered by Google App Engine
This is Rietveld 408576698