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

Side by Side Diff: src/cpu.h

Issue 23401002: Fix the CPU feature detection. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Improve cpuinfo parsing. Created 7 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/arm/assembler-arm.cc ('k') | src/cpu.cc » ('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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution. 11 // with the distribution.
(...skipping 25 matching lines...) Expand all
37 #define V8_CPU_H_ 37 #define V8_CPU_H_
38 38
39 #include "allocation.h" 39 #include "allocation.h"
40 40
41 namespace v8 { 41 namespace v8 {
42 namespace internal { 42 namespace internal {
43 43
44 // ---------------------------------------------------------------------------- 44 // ----------------------------------------------------------------------------
45 // CPU 45 // CPU
46 // 46 //
47 // This class has static methods for the architecture specific functions. Add 47 // Query information about the processor.
48 // methods here to cope with differences between the supported architectures.
49 // 48 //
50 // For each architecture the file cpu_<arch>.cc contains the implementation of 49 // This class also has static methods for the architecture specific functions.
51 // these functions. 50 // Add methods here to cope with differences between the supported
51 // architectures. For each architecture the file cpu_<arch>.cc contains the
52 // implementation of these static functions.
52 53
53 class CPU : public AllStatic { 54 class CPU V8_FINAL BASE_EMBEDDED {
54 public: 55 public:
56 CPU();
57
58 // x86 CPUID information
59 const char* vendor() const { return vendor_; }
60 int stepping() const { return stepping_; }
61 int model() const { return model_; }
62 int ext_model() const { return ext_model_; }
63 int family() const { return family_; }
64 int ext_family() const { return ext_family_; }
65 int type() const { return type_; }
66
67 // arm implementer/part information
68 int implementer() const { return implementer_; }
69 static const int ARM = 0x41;
70 static const int QUALCOMM = 0x51;
71 int architecture() const { return architecture_; }
72 int part() const { return part_; }
73 static const int ARM_CORTEX_A5 = 0xc05;
74 static const int ARM_CORTEX_A7 = 0xc07;
75 static const int ARM_CORTEX_A8 = 0xc08;
76 static const int ARM_CORTEX_A9 = 0xc09;
77 static const int ARM_CORTEX_A12 = 0xc0c;
78 static const int ARM_CORTEX_A15 = 0xc0f;
79
80 // General features
81 bool has_fpu() const { return has_fpu_; }
82
83 // x86 features
84 bool has_cmov() const { return has_cmov_; }
85 bool has_sahf() const { return has_sahf_; }
86 bool has_mmx() const { return has_mmx_; }
87 bool has_sse() const { return has_sse_; }
88 bool has_sse2() const { return has_sse2_; }
89 bool has_sse3() const { return has_sse3_; }
90 bool has_ssse3() const { return has_ssse3_; }
91 bool has_sse41() const { return has_sse41_; }
92 bool has_sse42() const { return has_sse42_; }
93
94 // arm features
95 bool has_idiva() const { return has_idiva_; }
96 bool has_neon() const { return has_neon_; }
97 bool has_thumbee() const { return has_thumbee_; }
98 bool has_vfp() const { return has_vfp_; }
99 bool has_vfp3() const { return has_vfp3_; }
100 bool has_vfp3_d32() const { return has_vfp3_d32_; }
101
55 // Initializes the cpu architecture support. Called once at VM startup. 102 // Initializes the cpu architecture support. Called once at VM startup.
56 static void SetUp(); 103 static void SetUp();
57 104
58 static bool SupportsCrankshaft(); 105 static bool SupportsCrankshaft();
59 106
60 // Flush instruction cache. 107 // Flush instruction cache.
61 static void FlushICache(void* start, size_t size); 108 static void FlushICache(void* start, size_t size);
109
110 private:
111 char vendor_[13];
112 int stepping_;
113 int model_;
114 int ext_model_;
115 int family_;
116 int ext_family_;
117 int type_;
118 int implementer_;
119 int architecture_;
120 int part_;
121 bool has_fpu_;
122 bool has_cmov_;
123 bool has_sahf_;
124 bool has_mmx_;
125 bool has_sse_;
126 bool has_sse2_;
127 bool has_sse3_;
128 bool has_ssse3_;
129 bool has_sse41_;
130 bool has_sse42_;
131 bool has_idiva_;
132 bool has_neon_;
133 bool has_thumbee_;
134 bool has_vfp_;
135 bool has_vfp3_;
136 bool has_vfp3_d32_;
62 }; 137 };
63 138
64 } } // namespace v8::internal 139 } } // namespace v8::internal
65 140
66 #endif // V8_CPU_H_ 141 #endif // V8_CPU_H_
OLDNEW
« no previous file with comments | « src/arm/assembler-arm.cc ('k') | src/cpu.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698