OLD | NEW |
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 | 10 |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 V(MachFloat32) \ | 176 V(MachFloat32) \ |
177 V(MachFloat64) \ | 177 V(MachFloat64) \ |
178 V(MachInt8) \ | 178 V(MachInt8) \ |
179 V(MachUint8) \ | 179 V(MachUint8) \ |
180 V(MachInt16) \ | 180 V(MachInt16) \ |
181 V(MachUint16) \ | 181 V(MachUint16) \ |
182 V(MachInt32) \ | 182 V(MachInt32) \ |
183 V(MachUint32) \ | 183 V(MachUint32) \ |
184 V(MachInt64) \ | 184 V(MachInt64) \ |
185 V(MachUint64) \ | 185 V(MachUint64) \ |
186 V(MachAnyTagged) \ | 186 V(MachPtr) \ |
187 V(RepBit) \ | 187 V(MachAnyTagged) |
188 V(RepWord8) \ | |
189 V(RepWord16) \ | |
190 V(RepWord32) \ | |
191 V(RepWord64) \ | |
192 V(RepFloat32) \ | |
193 V(RepFloat64) \ | |
194 V(RepTagged) | |
195 | 188 |
196 | 189 |
197 struct MachineOperatorGlobalCache { | 190 struct MachineOperatorGlobalCache { |
198 #define PURE(Name, properties, value_input_count, control_input_count, \ | 191 #define PURE(Name, properties, value_input_count, control_input_count, \ |
199 output_count) \ | 192 output_count) \ |
200 struct Name##Operator final : public Operator { \ | 193 struct Name##Operator final : public Operator { \ |
201 Name##Operator() \ | 194 Name##Operator() \ |
202 : Operator(IrOpcode::k##Name, Operator::kPure | properties, #Name, \ | 195 : Operator(IrOpcode::k##Name, Operator::kPure | properties, #Name, \ |
203 value_input_count, 0, control_input_count, output_count, 0, \ | 196 value_input_count, 0, control_input_count, output_count, 0, \ |
204 0) {} \ | 197 0) {} \ |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 #undef STORE | 265 #undef STORE |
273 }; | 266 }; |
274 | 267 |
275 | 268 |
276 static base::LazyInstance<MachineOperatorGlobalCache>::type kCache = | 269 static base::LazyInstance<MachineOperatorGlobalCache>::type kCache = |
277 LAZY_INSTANCE_INITIALIZER; | 270 LAZY_INSTANCE_INITIALIZER; |
278 | 271 |
279 | 272 |
280 MachineOperatorBuilder::MachineOperatorBuilder(Zone* zone, MachineType word, | 273 MachineOperatorBuilder::MachineOperatorBuilder(Zone* zone, MachineType word, |
281 Flags flags) | 274 Flags flags) |
282 : zone_(zone), cache_(kCache.Get()), word_(word), flags_(flags) { | 275 : cache_(kCache.Get()), word_(word), flags_(flags) { |
283 DCHECK(word == kRepWord32 || word == kRepWord64); | 276 DCHECK(word == kRepWord32 || word == kRepWord64); |
284 } | 277 } |
285 | 278 |
286 | 279 |
287 #define PURE(Name, properties, value_input_count, control_input_count, \ | 280 #define PURE(Name, properties, value_input_count, control_input_count, \ |
288 output_count) \ | 281 output_count) \ |
289 const Operator* MachineOperatorBuilder::Name() { return &cache_.k##Name; } | 282 const Operator* MachineOperatorBuilder::Name() { return &cache_.k##Name; } |
290 PURE_OP_LIST(PURE) | 283 PURE_OP_LIST(PURE) |
291 #undef PURE | 284 #undef PURE |
292 | 285 |
(...skipping 22 matching lines...) Expand all Loading... |
315 const Operator* MachineOperatorBuilder::Load(LoadRepresentation rep) { | 308 const Operator* MachineOperatorBuilder::Load(LoadRepresentation rep) { |
316 switch (rep) { | 309 switch (rep) { |
317 #define LOAD(Type) \ | 310 #define LOAD(Type) \ |
318 case k##Type: \ | 311 case k##Type: \ |
319 return &cache_.kLoad##Type; | 312 return &cache_.kLoad##Type; |
320 MACHINE_TYPE_LIST(LOAD) | 313 MACHINE_TYPE_LIST(LOAD) |
321 #undef LOAD | 314 #undef LOAD |
322 default: | 315 default: |
323 break; | 316 break; |
324 } | 317 } |
325 // Uncached. | 318 UNREACHABLE(); |
326 return new (zone_) Operator1<LoadRepresentation>( // -- | 319 return nullptr; |
327 IrOpcode::kLoad, Operator::kNoThrow | Operator::kNoWrite, "Load", 2, 1, 1, | |
328 1, 1, 0, rep); | |
329 } | 320 } |
330 | 321 |
331 | 322 |
332 const Operator* MachineOperatorBuilder::Store(StoreRepresentation rep) { | 323 const Operator* MachineOperatorBuilder::Store(StoreRepresentation rep) { |
333 switch (rep.machine_type()) { | 324 switch (rep.machine_type()) { |
334 #define STORE(Type) \ | 325 #define STORE(Type) \ |
335 case k##Type: \ | 326 case k##Type: \ |
336 switch (rep.write_barrier_kind()) { \ | 327 switch (rep.write_barrier_kind()) { \ |
337 case kNoWriteBarrier: \ | 328 case kNoWriteBarrier: \ |
338 return &cache_.k##Store##Type##NoWriteBarrier; \ | 329 return &cache_.k##Store##Type##NoWriteBarrier; \ |
339 case kFullWriteBarrier: \ | 330 case kFullWriteBarrier: \ |
340 return &cache_.k##Store##Type##FullWriteBarrier; \ | 331 return &cache_.k##Store##Type##FullWriteBarrier; \ |
341 } \ | 332 } \ |
342 break; | 333 break; |
343 MACHINE_TYPE_LIST(STORE) | 334 MACHINE_TYPE_LIST(STORE) |
344 #undef STORE | 335 #undef STORE |
345 | 336 |
346 default: | 337 default: |
347 break; | 338 break; |
348 } | 339 } |
349 // Uncached. | 340 UNREACHABLE(); |
350 return new (zone_) Operator1<StoreRepresentation>( // -- | 341 return nullptr; |
351 IrOpcode::kStore, Operator::kNoRead | Operator::kNoThrow, "Store", 3, 1, | |
352 1, 0, 1, 0, rep); | |
353 } | 342 } |
354 | 343 |
355 | 344 |
356 const Operator* MachineOperatorBuilder::CheckedLoad( | 345 const Operator* MachineOperatorBuilder::CheckedLoad( |
357 CheckedLoadRepresentation rep) { | 346 CheckedLoadRepresentation rep) { |
358 switch (rep) { | 347 switch (rep) { |
359 #define LOAD(Type) \ | 348 #define LOAD(Type) \ |
360 case k##Type: \ | 349 case k##Type: \ |
361 return &cache_.kCheckedLoad##Type; | 350 return &cache_.kCheckedLoad##Type; |
362 MACHINE_TYPE_LIST(LOAD) | 351 MACHINE_TYPE_LIST(LOAD) |
363 #undef LOAD | 352 #undef LOAD |
364 default: | 353 default: |
365 break; | 354 break; |
366 } | 355 } |
367 // Uncached. | 356 UNREACHABLE(); |
368 return new (zone_) Operator1<CheckedLoadRepresentation>( | 357 return nullptr; |
369 IrOpcode::kCheckedLoad, Operator::kNoThrow | Operator::kNoWrite, | |
370 "CheckedLoad", 3, 1, 1, 1, 1, 0, rep); | |
371 } | 358 } |
372 | 359 |
373 | 360 |
374 const Operator* MachineOperatorBuilder::CheckedStore( | 361 const Operator* MachineOperatorBuilder::CheckedStore( |
375 CheckedStoreRepresentation rep) { | 362 CheckedStoreRepresentation rep) { |
376 switch (rep) { | 363 switch (rep) { |
377 #define STORE(Type) \ | 364 #define STORE(Type) \ |
378 case k##Type: \ | 365 case k##Type: \ |
379 return &cache_.kCheckedStore##Type; | 366 return &cache_.kCheckedStore##Type; |
380 MACHINE_TYPE_LIST(STORE) | 367 MACHINE_TYPE_LIST(STORE) |
381 #undef STORE | 368 #undef STORE |
382 default: | 369 default: |
383 break; | 370 break; |
384 } | 371 } |
385 // Uncached. | 372 UNREACHABLE(); |
386 return new (zone_) Operator1<CheckedStoreRepresentation>( | 373 return nullptr; |
387 IrOpcode::kCheckedStore, Operator::kNoRead | Operator::kNoThrow, | |
388 "CheckedStore", 4, 1, 1, 0, 1, 0, rep); | |
389 } | 374 } |
390 | 375 |
391 } // namespace compiler | 376 } // namespace compiler |
392 } // namespace internal | 377 } // namespace internal |
393 } // namespace v8 | 378 } // namespace v8 |
OLD | NEW |