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

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

Issue 766273004: Version 3.29.88.18 (cherry-pick) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@3.29
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 unified diff | Download patch
« no previous file with comments | « build/toolchain.gypi ('k') | src/mips/constants-mips.h » ('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_POSIX 10 #if V8_OS_POSIX
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 uint32_t result = 0;
138 return 1; 143 __asm__ volatile(
144 "move $v0, $zero\n\t"
145 // Encoding for "addi $v0, $v0, 1" on non-r6,
146 // which is encoding for "bovc $v0, %v0, 1" on r6.
147 // Use machine code directly to avoid compilation errors with different
148 // toolchains and maintain compatibility.
149 ".word 0x20420001\n\t"
150 "sw $v0, %0\n\t"
151 : "=m"(result)
152 :
153 : "v0", "memory");
154 // Result is 0 on r6 architectures, 1 on other architecture revisions.
155 // Fall-back to the least common denominator which is mips32 revision 1.
156 return result ? 1 : 6;
139 } 157 }
140 #endif 158 #endif
141 159
142 // Extract the information exposed by the kernel via /proc/cpuinfo. 160 // Extract the information exposed by the kernel via /proc/cpuinfo.
143 class CPUInfo FINAL { 161 class CPUInfo FINAL {
144 public: 162 public:
145 CPUInfo() : datalen_(0) { 163 CPUInfo() : datalen_(0) {
146 // Get the size of the cpuinfo file by reading it until the end. This is 164 // 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 165 // 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. 166 // 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
519 if (end == part) { 537 if (end == part) {
520 part_ = 0; 538 part_ = 0;
521 } 539 }
522 delete[] part; 540 delete[] part;
523 } 541 }
524 542
525 #endif 543 #endif
526 } 544 }
527 545
528 } } // namespace v8::base 546 } } // namespace v8::base
OLDNEW
« no previous file with comments | « build/toolchain.gypi ('k') | src/mips/constants-mips.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698