| 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 | 156 |
| 157 ~CPUInfo() { | 157 ~CPUInfo() { |
| 158 delete[] data_; | 158 delete[] data_; |
| 159 } | 159 } |
| 160 | 160 |
| 161 // Extract the content of a the first occurence of a given field in | 161 // Extract the content of a the first occurence of a given field in |
| 162 // the content of the cpuinfo file and return it as a heap-allocated | 162 // the content of the cpuinfo file and return it as a heap-allocated |
| 163 // string that must be freed by the caller using delete[]. | 163 // string that must be freed by the caller using delete[]. |
| 164 // Return NULL if not found. | 164 // Return NULL if not found. |
| 165 char* ExtractField(const char* field) const { | 165 char* ExtractField(const char* field) const { |
| 166 ASSERT(field != NULL); | 166 DCHECK(field != NULL); |
| 167 | 167 |
| 168 // Look for first field occurence, and ensure it starts the line. | 168 // Look for first field occurence, and ensure it starts the line. |
| 169 size_t fieldlen = strlen(field); | 169 size_t fieldlen = strlen(field); |
| 170 char* p = data_; | 170 char* p = data_; |
| 171 for (;;) { | 171 for (;;) { |
| 172 p = strstr(p, field); | 172 p = strstr(p, field); |
| 173 if (p == NULL) { | 173 if (p == NULL) { |
| 174 return NULL; | 174 return NULL; |
| 175 } | 175 } |
| 176 if (p == data_ || p[-1] == '\n') { | 176 if (p == data_ || p[-1] == '\n') { |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 | 434 |
| 435 uint32_t cpu_flags = SYSPAGE_ENTRY(cpuinfo)->flags; | 435 uint32_t cpu_flags = SYSPAGE_ENTRY(cpuinfo)->flags; |
| 436 if (cpu_flags & ARM_CPU_FLAG_V7) { | 436 if (cpu_flags & ARM_CPU_FLAG_V7) { |
| 437 architecture_ = 7; | 437 architecture_ = 7; |
| 438 has_thumb2_ = true; | 438 has_thumb2_ = true; |
| 439 } else if (cpu_flags & ARM_CPU_FLAG_V6) { | 439 } else if (cpu_flags & ARM_CPU_FLAG_V6) { |
| 440 architecture_ = 6; | 440 architecture_ = 6; |
| 441 // QNX doesn't say if Thumb2 is available. | 441 // QNX doesn't say if Thumb2 is available. |
| 442 // Assume false for the architectures older than ARMv7. | 442 // Assume false for the architectures older than ARMv7. |
| 443 } | 443 } |
| 444 ASSERT(architecture_ >= 6); | 444 DCHECK(architecture_ >= 6); |
| 445 has_fpu_ = (cpu_flags & CPU_FLAG_FPU) != 0; | 445 has_fpu_ = (cpu_flags & CPU_FLAG_FPU) != 0; |
| 446 has_vfp_ = has_fpu_; | 446 has_vfp_ = has_fpu_; |
| 447 if (cpu_flags & ARM_CPU_FLAG_NEON) { | 447 if (cpu_flags & ARM_CPU_FLAG_NEON) { |
| 448 has_neon_ = true; | 448 has_neon_ = true; |
| 449 has_vfp3_ = has_vfp_; | 449 has_vfp3_ = has_vfp_; |
| 450 #ifdef ARM_CPU_FLAG_VFP_D32 | 450 #ifdef ARM_CPU_FLAG_VFP_D32 |
| 451 has_vfp3_d32_ = (cpu_flags & ARM_CPU_FLAG_VFP_D32) != 0; | 451 has_vfp3_d32_ = (cpu_flags & ARM_CPU_FLAG_VFP_D32) != 0; |
| 452 #endif | 452 #endif |
| 453 } | 453 } |
| 454 has_idiva_ = (cpu_flags & ARM_CPU_FLAG_IDIV) != 0; | 454 has_idiva_ = (cpu_flags & ARM_CPU_FLAG_IDIV) != 0; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 if (end == part) { | 490 if (end == part) { |
| 491 part_ = 0; | 491 part_ = 0; |
| 492 } | 492 } |
| 493 delete[] part; | 493 delete[] part; |
| 494 } | 494 } |
| 495 | 495 |
| 496 #endif | 496 #endif |
| 497 } | 497 } |
| 498 | 498 |
| 499 } } // namespace v8::base | 499 } } // namespace v8::base |
| OLD | NEW |