Chromium Code Reviews| 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_POSIX | 10 #if V8_OS_POSIX |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 112 } | 112 } |
| 113 return result; | 113 return result; |
| 114 } | 114 } |
| 115 | 115 |
| 116 #endif // V8_HOST_ARCH_ARM | 116 #endif // V8_HOST_ARCH_ARM |
| 117 | 117 |
| 118 #if V8_HOST_ARCH_MIPS | 118 #if V8_HOST_ARCH_MIPS |
| 119 int __detect_fp64_mode(void) { | 119 int __detect_fp64_mode(void) { |
| 120 double result = 0; | 120 double result = 0; |
| 121 // Bit representation of (double)1 is 0x3FF0000000000000. | 121 // Bit representation of (double)1 is 0x3FF0000000000000. |
| 122 asm( | 122 __asm__ volatile( |
| 123 "lui $t0, 0x3FF0\n\t" | 123 ".set push\n\t" |
| 124 "ldc1 $f0, %0\n\t" | 124 ".set noreorder\n\t" |
| 125 "mtc1 $t0, $f1\n\t" | 125 ".set oddspreg\n\t" |
| 126 "sdc1 $f0, %0\n\t" | 126 "lui $t0, 0x3FF0\n\t" |
| 127 : "+m" (result) | 127 "ldc1 $f0, %0\n\t" |
| 128 : : "t0", "$f0", "$f1", "memory"); | 128 "mtc1 $t0, $f1\n\t" |
| 129 "sdc1 $f0, %0\n\t" | |
| 130 ".set pop\n\t" | |
| 131 : "+m"(result) | |
| 132 : | |
| 133 : "t0", "$f0", "$f1", "memory"); | |
| 129 | 134 |
| 130 return !(result == 1); | 135 return !(result == 1); |
| 131 } | 136 } |
| 132 | 137 |
| 133 | 138 |
| 134 int __detect_mips_arch_revision(void) { | 139 int __detect_mips_arch_revision(void) { |
| 135 // TODO(dusmil): Do the specific syscall as soon as it is implemented in mips | 140 // TODO(dusmil): Do the specific syscall as soon as it is implemented in mips |
| 136 // kernel. Currently fail-back to the least common denominator which is | 141 // kernel. |
| 137 // mips32 revision 1. | 142 // Detect r6 architectures through QNaN representation. |
| 138 return 1; | 143 // The r6 variant uses IEEE2008 QNaN representation which is 7ff8xxxxxxxxxxxx, |
| 144 // the same encoding for QNaN on x86, ARM. | |
| 145 // Non r6 variants uses 7ff7fxxxxxxxxxxx for QNaN which is SNaN on x86, ARM. | |
| 146 double result = 0; | |
| 147 uint64_t check, mask = 0x8000000000000LLU; | |
| 148 union { | |
| 149 double d; | |
| 150 uint64_t ull; | |
| 151 } conv; | |
| 152 | |
| 153 __asm__ volatile( | |
| 154 ".set push\n\t" | |
| 155 ".set noreorder\n\t" | |
| 156 "ldc1 $f0, %0\n\t" | |
| 157 "div.d $f0, $f0, $f0\n\t" | |
| 158 "sdc1 $f0, %0\n\t" | |
| 159 ".set pop\n\t" | |
| 160 : "+m"(result) | |
| 161 : | |
| 162 : "$f0", "memory"); | |
| 163 conv.d = result; | |
| 164 // Check bit 50 of NaN value. | |
| 165 // Fail-back to the least common denominator which is mips32 revision 1. | |
|
paul.l...
2014/10/02 16:26:47
nit: this should probably be "fall-back"
dusmil.imgtec
2014/10/02 17:02:09
Done.
| |
| 166 check = conv.ull & mask; | |
| 167 return check ? 6 : 1; | |
| 139 } | 168 } |
| 140 #endif | 169 #endif |
| 141 | 170 |
| 142 // Extract the information exposed by the kernel via /proc/cpuinfo. | 171 // Extract the information exposed by the kernel via /proc/cpuinfo. |
| 143 class CPUInfo FINAL { | 172 class CPUInfo FINAL { |
| 144 public: | 173 public: |
| 145 CPUInfo() : datalen_(0) { | 174 CPUInfo() : datalen_(0) { |
| 146 // Get the size of the cpuinfo file by reading it until the end. This is | 175 // Get the size of the cpuinfo file by reading it until the end. This is |
| 147 // required because files under /proc do not always return a valid size | 176 // required because files under /proc do not always return a valid size |
| 148 // when using fseek(0, SEEK_END) + ftell(). Nor can the be mmap()-ed. | 177 // when using fseek(0, SEEK_END) + ftell(). Nor can the be mmap()-ed. |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 519 if (end == part) { | 548 if (end == part) { |
| 520 part_ = 0; | 549 part_ = 0; |
| 521 } | 550 } |
| 522 delete[] part; | 551 delete[] part; |
| 523 } | 552 } |
| 524 | 553 |
| 525 #endif | 554 #endif |
| 526 } | 555 } |
| 527 | 556 |
| 528 } } // namespace v8::base | 557 } } // namespace v8::base |
| OLD | NEW |