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

Side by Side Diff: src/compiler/machine-operator.cc

Issue 763963002: [turbofan] Add checked load/store operators. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Reapply fix. 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 | « src/compiler/machine-operator.h ('k') | src/compiler/machine-operator-reducer.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/compiler/machine-operator.h" 5 #include "src/compiler/machine-operator.h"
6 6
7 #include "src/base/lazy-instance.h" 7 #include "src/base/lazy-instance.h"
8 #include "src/compiler/opcodes.h" 8 #include "src/compiler/opcodes.h"
9 #include "src/compiler/operator.h" 9 #include "src/compiler/operator.h"
10 #include "src/v8.h" 10 #include "src/v8.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 << ")"; 47 << ")";
48 } 48 }
49 49
50 50
51 StoreRepresentation const& StoreRepresentationOf(Operator const* op) { 51 StoreRepresentation const& StoreRepresentationOf(Operator const* op) {
52 DCHECK_EQ(IrOpcode::kStore, op->opcode()); 52 DCHECK_EQ(IrOpcode::kStore, op->opcode());
53 return OpParameter<StoreRepresentation>(op); 53 return OpParameter<StoreRepresentation>(op);
54 } 54 }
55 55
56 56
57 CheckedLoadRepresentation CheckedLoadRepresentationOf(Operator const* op) {
58 DCHECK_EQ(IrOpcode::kCheckedLoad, op->opcode());
59 return OpParameter<CheckedLoadRepresentation>(op);
60 }
61
62
63 CheckedStoreRepresentation CheckedStoreRepresentationOf(Operator const* op) {
64 DCHECK_EQ(IrOpcode::kCheckedStore, op->opcode());
65 return OpParameter<CheckedStoreRepresentation>(op);
66 }
67
68
57 #define PURE_OP_LIST(V) \ 69 #define PURE_OP_LIST(V) \
58 V(Word32And, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \ 70 V(Word32And, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
59 V(Word32Or, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \ 71 V(Word32Or, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
60 V(Word32Xor, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \ 72 V(Word32Xor, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
61 V(Word32Shl, Operator::kNoProperties, 2, 0, 1) \ 73 V(Word32Shl, Operator::kNoProperties, 2, 0, 1) \
62 V(Word32Shr, Operator::kNoProperties, 2, 0, 1) \ 74 V(Word32Shr, Operator::kNoProperties, 2, 0, 1) \
63 V(Word32Sar, Operator::kNoProperties, 2, 0, 1) \ 75 V(Word32Sar, Operator::kNoProperties, 2, 0, 1) \
64 V(Word32Ror, Operator::kNoProperties, 2, 0, 1) \ 76 V(Word32Ror, Operator::kNoProperties, 2, 0, 1) \
65 V(Word32Equal, Operator::kCommutative, 2, 0, 1) \ 77 V(Word32Equal, Operator::kCommutative, 2, 0, 1) \
66 V(Word64And, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \ 78 V(Word64And, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 struct Name##Operator FINAL : public Operator { \ 163 struct Name##Operator FINAL : public Operator { \
152 Name##Operator() \ 164 Name##Operator() \
153 : Operator(IrOpcode::k##Name, Operator::kPure | properties, #Name, \ 165 : Operator(IrOpcode::k##Name, Operator::kPure | properties, #Name, \
154 value_input_count, 0, control_input_count, output_count, 0, \ 166 value_input_count, 0, control_input_count, output_count, 0, \
155 0) {} \ 167 0) {} \
156 }; \ 168 }; \
157 Name##Operator k##Name; 169 Name##Operator k##Name;
158 PURE_OP_LIST(PURE) 170 PURE_OP_LIST(PURE)
159 #undef PURE 171 #undef PURE
160 172
161 #define LOAD(Type) \ 173 #define LOAD(Type) \
162 struct Load##Type##Operator FINAL : public Operator1<LoadRepresentation> { \ 174 struct Load##Type##Operator FINAL : public Operator1<LoadRepresentation> { \
163 Load##Type##Operator() \ 175 Load##Type##Operator() \
164 : Operator1<LoadRepresentation>( \ 176 : Operator1<LoadRepresentation>( \
165 IrOpcode::kLoad, Operator::kNoThrow | Operator::kNoWrite, \ 177 IrOpcode::kLoad, Operator::kNoThrow | Operator::kNoWrite, \
166 "Load", 2, 1, 1, 1, 1, 0, k##Type) {} \ 178 "Load", 2, 1, 1, 1, 1, 0, k##Type) {} \
167 }; \ 179 }; \
168 Load##Type##Operator k##Load##Type; 180 struct CheckedLoad##Type##Operator FINAL \
181 : public Operator1<CheckedLoadRepresentation> { \
182 CheckedLoad##Type##Operator() \
183 : Operator1<CheckedLoadRepresentation>( \
184 IrOpcode::kCheckedLoad, Operator::kNoThrow | Operator::kNoWrite, \
185 "CheckedLoad", 3, 1, 1, 1, 1, 0, k##Type) {} \
186 }; \
187 Load##Type##Operator kLoad##Type; \
188 CheckedLoad##Type##Operator kCheckedLoad##Type;
169 MACHINE_TYPE_LIST(LOAD) 189 MACHINE_TYPE_LIST(LOAD)
170 #undef LOAD 190 #undef LOAD
171 191
172 #define STORE(Type) \ 192 #define STORE(Type) \
173 struct Store##Type##Operator : public Operator1<StoreRepresentation> { \ 193 struct Store##Type##Operator : public Operator1<StoreRepresentation> { \
174 explicit Store##Type##Operator(WriteBarrierKind write_barrier_kind) \ 194 explicit Store##Type##Operator(WriteBarrierKind write_barrier_kind) \
175 : Operator1<StoreRepresentation>( \ 195 : Operator1<StoreRepresentation>( \
176 IrOpcode::kStore, Operator::kNoRead | Operator::kNoThrow, \ 196 IrOpcode::kStore, Operator::kNoRead | Operator::kNoThrow, \
177 "Store", 3, 1, 1, 0, 1, 0, \ 197 "Store", 3, 1, 1, 0, 1, 0, \
178 StoreRepresentation(k##Type, write_barrier_kind)) {} \ 198 StoreRepresentation(k##Type, write_barrier_kind)) {} \
179 }; \ 199 }; \
180 struct Store##Type##NoWriteBarrier##Operator FINAL \ 200 struct Store##Type##NoWriteBarrier##Operator FINAL \
181 : public Store##Type##Operator { \ 201 : public Store##Type##Operator { \
182 Store##Type##NoWriteBarrier##Operator() \ 202 Store##Type##NoWriteBarrier##Operator() \
183 : Store##Type##Operator(kNoWriteBarrier) {} \ 203 : Store##Type##Operator(kNoWriteBarrier) {} \
184 }; \ 204 }; \
185 struct Store##Type##FullWriteBarrier##Operator FINAL \ 205 struct Store##Type##FullWriteBarrier##Operator FINAL \
186 : public Store##Type##Operator { \ 206 : public Store##Type##Operator { \
187 Store##Type##FullWriteBarrier##Operator() \ 207 Store##Type##FullWriteBarrier##Operator() \
188 : Store##Type##Operator(kFullWriteBarrier) {} \ 208 : Store##Type##Operator(kFullWriteBarrier) {} \
189 }; \ 209 }; \
190 Store##Type##NoWriteBarrier##Operator k##Store##Type##NoWriteBarrier; \ 210 struct CheckedStore##Type##Operator FINAL \
191 Store##Type##FullWriteBarrier##Operator k##Store##Type##FullWriteBarrier; 211 : public Operator1<CheckedStoreRepresentation> { \
212 CheckedStore##Type##Operator() \
213 : Operator1<CheckedStoreRepresentation>( \
214 IrOpcode::kCheckedStore, Operator::kNoRead | Operator::kNoThrow, \
215 "CheckedStore", 4, 1, 1, 0, 1, 0, k##Type) {} \
216 }; \
217 Store##Type##NoWriteBarrier##Operator kStore##Type##NoWriteBarrier; \
218 Store##Type##FullWriteBarrier##Operator kStore##Type##FullWriteBarrier; \
219 CheckedStore##Type##Operator kCheckedStore##Type;
192 MACHINE_TYPE_LIST(STORE) 220 MACHINE_TYPE_LIST(STORE)
193 #undef STORE 221 #undef STORE
194 }; 222 };
195 223
196 224
197 static base::LazyInstance<MachineOperatorGlobalCache>::type kCache = 225 static base::LazyInstance<MachineOperatorGlobalCache>::type kCache =
198 LAZY_INSTANCE_INITIALIZER; 226 LAZY_INSTANCE_INITIALIZER;
199 227
200 228
201 MachineOperatorBuilder::MachineOperatorBuilder(Zone* zone, MachineType word, 229 MachineOperatorBuilder::MachineOperatorBuilder(Zone* zone, MachineType word,
202 Flags flags) 230 Flags flags)
203 : zone_(zone), cache_(kCache.Get()), word_(word), flags_(flags) { 231 : zone_(zone), cache_(kCache.Get()), word_(word), flags_(flags) {
204 DCHECK(word == kRepWord32 || word == kRepWord64); 232 DCHECK(word == kRepWord32 || word == kRepWord64);
205 } 233 }
206 234
207 235
208 #define PURE(Name, properties, value_input_count, control_input_count, \ 236 #define PURE(Name, properties, value_input_count, control_input_count, \
209 output_count) \ 237 output_count) \
210 const Operator* MachineOperatorBuilder::Name() { return &cache_.k##Name; } 238 const Operator* MachineOperatorBuilder::Name() { return &cache_.k##Name; }
211 PURE_OP_LIST(PURE) 239 PURE_OP_LIST(PURE)
212 #undef PURE 240 #undef PURE
213 241
214 242
215 const Operator* MachineOperatorBuilder::Load(LoadRepresentation rep) { 243 const Operator* MachineOperatorBuilder::Load(LoadRepresentation rep) {
216 switch (rep) { 244 switch (rep) {
217 #define LOAD(Type) \ 245 #define LOAD(Type) \
218 case k##Type: \ 246 case k##Type: \
219 return &cache_.k##Load##Type; 247 return &cache_.kLoad##Type;
220 MACHINE_TYPE_LIST(LOAD) 248 MACHINE_TYPE_LIST(LOAD)
221 #undef LOAD 249 #undef LOAD
222
223 default: 250 default:
224 break; 251 break;
225 } 252 }
226 // Uncached. 253 // Uncached.
227 return new (zone_) Operator1<LoadRepresentation>( // -- 254 return new (zone_) Operator1<LoadRepresentation>( // --
228 IrOpcode::kLoad, Operator::kNoThrow | Operator::kNoWrite, "Load", 2, 1, 1, 255 IrOpcode::kLoad, Operator::kNoThrow | Operator::kNoWrite, "Load", 2, 1, 1,
229 1, 1, 0, rep); 256 1, 1, 0, rep);
230 } 257 }
231 258
232 259
(...skipping 12 matching lines...) Expand all
245 #undef STORE 272 #undef STORE
246 273
247 default: 274 default:
248 break; 275 break;
249 } 276 }
250 // Uncached. 277 // Uncached.
251 return new (zone_) Operator1<StoreRepresentation>( // -- 278 return new (zone_) Operator1<StoreRepresentation>( // --
252 IrOpcode::kStore, Operator::kNoRead | Operator::kNoThrow, "Store", 3, 1, 279 IrOpcode::kStore, Operator::kNoRead | Operator::kNoThrow, "Store", 3, 1,
253 1, 0, 1, 0, rep); 280 1, 0, 1, 0, rep);
254 } 281 }
282
283
284 const Operator* MachineOperatorBuilder::CheckedLoad(
285 CheckedLoadRepresentation rep) {
286 switch (rep) {
287 #define LOAD(Type) \
288 case k##Type: \
289 return &cache_.kCheckedLoad##Type;
290 MACHINE_TYPE_LIST(LOAD)
291 #undef LOAD
292 default:
293 break;
294 }
295 // Uncached.
296 return new (zone_) Operator1<CheckedLoadRepresentation>(
297 IrOpcode::kCheckedLoad, Operator::kNoThrow | Operator::kNoWrite,
298 "CheckedLoad", 3, 1, 1, 1, 1, 0, rep);
299 }
300
301
302 const Operator* MachineOperatorBuilder::CheckedStore(
303 CheckedStoreRepresentation rep) {
304 switch (rep) {
305 #define STORE(Type) \
306 case k##Type: \
307 return &cache_.kCheckedStore##Type;
308 MACHINE_TYPE_LIST(STORE)
309 #undef STORE
310 default:
311 break;
312 }
313 // Uncached.
314 return new (zone_) Operator1<CheckedStoreRepresentation>(
315 IrOpcode::kCheckedStore, Operator::kNoRead | Operator::kNoThrow,
316 "CheckedStore", 4, 1, 1, 0, 1, 0, rep);
317 }
318
255 } // namespace compiler 319 } // namespace compiler
256 } // namespace internal 320 } // namespace internal
257 } // namespace v8 321 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/machine-operator.h ('k') | src/compiler/machine-operator-reducer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698