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

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

Issue 453043002: MIPS: Add support for arch. revision 6 to mips32 port. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments. Created 6 years, 4 months 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 | Annotate | Revision Log
« no previous file with comments | « src/base/cpu.h ('k') | src/globals.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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 break; 108 break;
109 } 109 }
110 } 110 }
111 fclose(fp); 111 fclose(fp);
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
119 int __detect_fp64_mode(void) {
120 double result = 0;
121 // Bit representation of (double)1 is 0x3FF0000000000000.
122 asm(
123 "lui $t0, 0x3FF0\n\t"
124 "ldc1 $f0, %0\n\t"
125 "mtc1 $t0, $f1\n\t"
126 "sdc1 $f0, %0\n\t"
127 : "+m" (result)
128 : : "t0", "$f0", "$f1", "memory");
129
130 return !(result == 1);
131 }
132
133
134 int __detect_mips_arch_revision(void) {
135 // 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
137 // mips32 revision 1.
138 return 1;
139 }
140 #endif
141
118 // Extract the information exposed by the kernel via /proc/cpuinfo. 142 // Extract the information exposed by the kernel via /proc/cpuinfo.
119 class CPUInfo V8_FINAL { 143 class CPUInfo V8_FINAL {
120 public: 144 public:
121 CPUInfo() : datalen_(0) { 145 CPUInfo() : datalen_(0) {
122 // Get the size of the cpuinfo file by reading it until the end. This is 146 // Get the size of the cpuinfo file by reading it until the end. This is
123 // required because files under /proc do not always return a valid size 147 // required because files under /proc do not always return a valid size
124 // when using fseek(0, SEEK_END) + ftell(). Nor can the be mmap()-ed. 148 // when using fseek(0, SEEK_END) + ftell(). Nor can the be mmap()-ed.
125 static const char PATHNAME[] = "/proc/cpuinfo"; 149 static const char PATHNAME[] = "/proc/cpuinfo";
126 FILE* fp = fopen(PATHNAME, "r"); 150 FILE* fp = fopen(PATHNAME, "r");
127 if (fp != NULL) { 151 if (fp != NULL) {
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 483
460 // Simple detection of FPU at runtime for Linux. 484 // Simple detection of FPU at runtime for Linux.
461 // It is based on /proc/cpuinfo, which reveals hardware configuration 485 // It is based on /proc/cpuinfo, which reveals hardware configuration
462 // to user-space applications. According to MIPS (early 2010), no similar 486 // to user-space applications. According to MIPS (early 2010), no similar
463 // facility is universally available on the MIPS architectures, 487 // facility is universally available on the MIPS architectures,
464 // so it's up to individual OSes to provide such. 488 // so it's up to individual OSes to provide such.
465 CPUInfo cpu_info; 489 CPUInfo cpu_info;
466 char* cpu_model = cpu_info.ExtractField("cpu model"); 490 char* cpu_model = cpu_info.ExtractField("cpu model");
467 has_fpu_ = HasListItem(cpu_model, "FPU"); 491 has_fpu_ = HasListItem(cpu_model, "FPU");
468 delete[] cpu_model; 492 delete[] cpu_model;
493 #ifdef V8_HOST_ARCH_MIPS
494 is_fp64_mode_ = __detect_fp64_mode();
495 architecture_ = __detect_mips_arch_revision();
496 #endif
469 497
470 #elif V8_HOST_ARCH_ARM64 498 #elif V8_HOST_ARCH_ARM64
471 499
472 CPUInfo cpu_info; 500 CPUInfo cpu_info;
473 501
474 // Extract implementor from the "CPU implementer" field. 502 // Extract implementor from the "CPU implementer" field.
475 char* implementer = cpu_info.ExtractField("CPU implementer"); 503 char* implementer = cpu_info.ExtractField("CPU implementer");
476 if (implementer != NULL) { 504 if (implementer != NULL) {
477 char* end ; 505 char* end ;
478 implementer_ = strtol(implementer, &end, 0); 506 implementer_ = strtol(implementer, &end, 0);
(...skipping 11 matching lines...) Expand all
490 if (end == part) { 518 if (end == part) {
491 part_ = 0; 519 part_ = 0;
492 } 520 }
493 delete[] part; 521 delete[] part;
494 } 522 }
495 523
496 #endif 524 #endif
497 } 525 }
498 526
499 } } // namespace v8::base 527 } } // namespace v8::base
OLDNEW
« no previous file with comments | « src/base/cpu.h ('k') | src/globals.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698