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

Side by Side Diff: src/assembler.h

Issue 2360243002: [arm] Clean up use of IsSupported and IsEnabled. (Closed)
Patch Set: Created 4 years, 2 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
« no previous file with comments | « src/arm/macro-assembler-arm.cc ('k') | src/assembler.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 (c) 1994-2006 Sun Microsystems Inc. 1 // Copyright (c) 1994-2006 Sun Microsystems Inc.
2 // All Rights Reserved. 2 // All Rights Reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // - Redistributions of source code must retain the above copyright notice, 8 // - Redistributions of source code must retain the above copyright notice,
9 // this list of conditions and the following disclaimer. 9 // this list of conditions and the following disclaimer.
10 // 10 //
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 bool serializer_enabled() const { return serializer_enabled_; } 73 bool serializer_enabled() const { return serializer_enabled_; }
74 void enable_serializer() { serializer_enabled_ = true; } 74 void enable_serializer() { serializer_enabled_ = true; }
75 75
76 bool predictable_code_size() const { return predictable_code_size_; } 76 bool predictable_code_size() const { return predictable_code_size_; }
77 void set_predictable_code_size(bool value) { predictable_code_size_ = value; } 77 void set_predictable_code_size(bool value) { predictable_code_size_ = value; }
78 78
79 uint64_t enabled_cpu_features() const { return enabled_cpu_features_; } 79 uint64_t enabled_cpu_features() const { return enabled_cpu_features_; }
80 void set_enabled_cpu_features(uint64_t features) { 80 void set_enabled_cpu_features(uint64_t features) {
81 enabled_cpu_features_ = features; 81 enabled_cpu_features_ = features;
82 } 82 }
83 // Features are usually enabled by CpuFeatureScope, which also asserts that
84 // the features are supported before they are enabled.
83 bool IsEnabled(CpuFeature f) { 85 bool IsEnabled(CpuFeature f) {
84 return (enabled_cpu_features_ & (static_cast<uint64_t>(1) << f)) != 0; 86 return (enabled_cpu_features_ & (static_cast<uint64_t>(1) << f)) != 0;
85 } 87 }
88 void EnableCpuFeature(CpuFeature f) {
89 enabled_cpu_features_ |= (static_cast<uint64_t>(1) << f);
90 }
86 91
87 bool is_constant_pool_available() const { 92 bool is_constant_pool_available() const {
88 if (FLAG_enable_embedded_constant_pool) { 93 if (FLAG_enable_embedded_constant_pool) {
89 return constant_pool_available_; 94 return constant_pool_available_;
90 } else { 95 } else {
91 // Embedded constant pool not supported on this architecture. 96 // Embedded constant pool not supported on this architecture.
92 UNREACHABLE(); 97 UNREACHABLE();
93 return false; 98 return false;
94 } 99 }
95 } 100 }
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 AssemblerBase* assembler_; 182 AssemblerBase* assembler_;
178 int expected_size_; 183 int expected_size_;
179 int start_offset_; 184 int start_offset_;
180 bool old_value_; 185 bool old_value_;
181 }; 186 };
182 187
183 188
184 // Enable a specified feature within a scope. 189 // Enable a specified feature within a scope.
185 class CpuFeatureScope BASE_EMBEDDED { 190 class CpuFeatureScope BASE_EMBEDDED {
186 public: 191 public:
192 enum CheckPolicy {
193 kCheckSupported,
194 kDontCheckSupported,
195 };
196
187 #ifdef DEBUG 197 #ifdef DEBUG
188 CpuFeatureScope(AssemblerBase* assembler, CpuFeature f); 198 CpuFeatureScope(AssemblerBase* assembler, CpuFeature f,
199 CheckPolicy check = kCheckSupported);
189 ~CpuFeatureScope(); 200 ~CpuFeatureScope();
190 201
191 private: 202 private:
192 AssemblerBase* assembler_; 203 AssemblerBase* assembler_;
193 uint64_t old_enabled_; 204 uint64_t old_enabled_;
194 #else 205 #else
195 CpuFeatureScope(AssemblerBase* assembler, CpuFeature f) {} 206 CpuFeatureScope(AssemblerBase* assembler, CpuFeature f,
207 CheckPolicy check = kCheckSupported) {}
196 #endif 208 #endif
197 }; 209 };
198 210
199 211
200 // CpuFeatures keeps track of which features are supported by the target CPU. 212 // CpuFeatures keeps track of which features are supported by the target CPU.
201 // Supported features must be enabled by a CpuFeatureScope before use. 213 // Supported features must be enabled by a CpuFeatureScope before use.
202 // Example: 214 // Example:
203 // if (assembler->IsSupported(SSE3)) { 215 // if (assembler->IsSupported(SSE3)) {
204 // CpuFeatureScope fscope(assembler, SSE3); 216 // CpuFeatureScope fscope(assembler, SSE3);
205 // // Generate code containing SSE3 instructions. 217 // // Generate code containing SSE3 instructions.
(...skipping 1066 matching lines...) Expand 10 before | Expand all | Expand 10 after
1272 std::vector<ConstantPoolEntry> shared_entries; 1284 std::vector<ConstantPoolEntry> shared_entries;
1273 }; 1285 };
1274 1286
1275 Label emitted_label_; // Records pc_offset of emitted pool 1287 Label emitted_label_; // Records pc_offset of emitted pool
1276 PerTypeEntryInfo info_[ConstantPoolEntry::NUMBER_OF_TYPES]; 1288 PerTypeEntryInfo info_[ConstantPoolEntry::NUMBER_OF_TYPES];
1277 }; 1289 };
1278 1290
1279 } // namespace internal 1291 } // namespace internal
1280 } // namespace v8 1292 } // namespace v8
1281 #endif // V8_ASSEMBLER_H_ 1293 #endif // V8_ASSEMBLER_H_
OLDNEW
« no previous file with comments | « src/arm/macro-assembler-arm.cc ('k') | src/assembler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698