| Index: src/base/cpu.cc
|
| diff --git a/src/base/cpu.cc b/src/base/cpu.cc
|
| index 6abfe4a26035516d36ce1885a33bf0ca19190c05..7125353009569cb26fbf8c16d1906b2a5414069b 100644
|
| --- a/src/base/cpu.cc
|
| +++ b/src/base/cpu.cc
|
| @@ -13,6 +13,9 @@
|
| #if V8_OS_QNX
|
| #include <sys/syspage.h> // cpuinfo
|
| #endif
|
| +#if V8_OS_LINUX && V8_HOST_ARCH_PPC
|
| +#include <elf.h>
|
| +#endif
|
|
|
| #include <ctype.h>
|
| #include <limits.h>
|
| @@ -263,32 +266,36 @@ static bool HasListItem(const char* list, const char* item) {
|
|
|
| #endif // V8_HOST_ARCH_IA32 || V8_HOST_ARCH_X64
|
|
|
| -CPU::CPU() : stepping_(0),
|
| - model_(0),
|
| - ext_model_(0),
|
| - family_(0),
|
| - ext_family_(0),
|
| - type_(0),
|
| - implementer_(0),
|
| - architecture_(0),
|
| - part_(0),
|
| - has_fpu_(false),
|
| - has_cmov_(false),
|
| - has_sahf_(false),
|
| - has_mmx_(false),
|
| - has_sse_(false),
|
| - has_sse2_(false),
|
| - has_sse3_(false),
|
| - has_ssse3_(false),
|
| - has_sse41_(false),
|
| - has_sse42_(false),
|
| - has_idiva_(false),
|
| - has_neon_(false),
|
| - has_thumb2_(false),
|
| - has_vfp_(false),
|
| - has_vfp3_(false),
|
| - has_vfp3_d32_(false),
|
| - is_fp64_mode_(false) {
|
| +#define UNKNOWN_CACHE_LINE_SIZE 0
|
| +
|
| +CPU::CPU()
|
| + : stepping_(0),
|
| + model_(0),
|
| + ext_model_(0),
|
| + family_(0),
|
| + ext_family_(0),
|
| + type_(0),
|
| + implementer_(0),
|
| + architecture_(0),
|
| + part_(0),
|
| + cache_line_size_(UNKNOWN_CACHE_LINE_SIZE),
|
| + has_fpu_(false),
|
| + has_cmov_(false),
|
| + has_sahf_(false),
|
| + has_mmx_(false),
|
| + has_sse_(false),
|
| + has_sse2_(false),
|
| + has_sse3_(false),
|
| + has_ssse3_(false),
|
| + has_sse41_(false),
|
| + has_sse42_(false),
|
| + has_idiva_(false),
|
| + has_neon_(false),
|
| + has_thumb2_(false),
|
| + has_vfp_(false),
|
| + has_vfp3_(false),
|
| + has_vfp3_d32_(false),
|
| + is_fp64_mode_(false) {
|
| memcpy(vendor_, "Unknown", 8);
|
| #if V8_HOST_ARCH_IA32 || V8_HOST_ARCH_X64
|
| int cpu_info[4];
|
| @@ -522,7 +529,66 @@ CPU::CPU() : stepping_(0),
|
| 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
|
| +#endif // !USE_SIMULATOR
|
| +#endif // V8_HOST_ARCH_PPC
|
| }
|
|
|
| } } // namespace v8::base
|
|
|