OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/simplified-operator.h" | 5 #include "src/compiler/simplified-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/types.h" | 10 #include "src/types.h" |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 UNREACHABLE(); | 201 UNREACHABLE(); |
202 return os; | 202 return os; |
203 } | 203 } |
204 | 204 |
205 CheckFloat64HoleMode CheckFloat64HoleModeOf(const Operator* op) { | 205 CheckFloat64HoleMode CheckFloat64HoleModeOf(const Operator* op) { |
206 DCHECK_EQ(IrOpcode::kCheckFloat64Hole, op->opcode()); | 206 DCHECK_EQ(IrOpcode::kCheckFloat64Hole, op->opcode()); |
207 return OpParameter<CheckFloat64HoleMode>(op); | 207 return OpParameter<CheckFloat64HoleMode>(op); |
208 } | 208 } |
209 | 209 |
210 CheckForMinusZeroMode CheckMinusZeroModeOf(const Operator* op) { | 210 CheckForMinusZeroMode CheckMinusZeroModeOf(const Operator* op) { |
211 DCHECK_EQ(IrOpcode::kCheckedInt32Mul, op->opcode()); | 211 DCHECK(op->opcode() == IrOpcode::kCheckedInt32Mul || |
| 212 op->opcode() == IrOpcode::kCheckedFloat64ToInt32 || |
| 213 op->opcode() == IrOpcode::kCheckedTaggedToInt32); |
212 return OpParameter<CheckForMinusZeroMode>(op); | 214 return OpParameter<CheckForMinusZeroMode>(op); |
213 } | 215 } |
214 | 216 |
215 size_t hash_value(CheckForMinusZeroMode mode) { | 217 size_t hash_value(CheckForMinusZeroMode mode) { |
216 return static_cast<size_t>(mode); | 218 return static_cast<size_t>(mode); |
217 } | 219 } |
218 | 220 |
219 std::ostream& operator<<(std::ostream& os, CheckForMinusZeroMode mode) { | 221 std::ostream& operator<<(std::ostream& os, CheckForMinusZeroMode mode) { |
220 switch (mode) { | 222 switch (mode) { |
221 case CheckForMinusZeroMode::kCheckForMinusZero: | 223 case CheckForMinusZeroMode::kCheckForMinusZero: |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 V(CheckString, 1, 1) \ | 390 V(CheckString, 1, 1) \ |
389 V(CheckTaggedPointer, 1, 1) \ | 391 V(CheckTaggedPointer, 1, 1) \ |
390 V(CheckTaggedSigned, 1, 1) \ | 392 V(CheckTaggedSigned, 1, 1) \ |
391 V(CheckedInt32Add, 2, 1) \ | 393 V(CheckedInt32Add, 2, 1) \ |
392 V(CheckedInt32Sub, 2, 1) \ | 394 V(CheckedInt32Sub, 2, 1) \ |
393 V(CheckedInt32Div, 2, 1) \ | 395 V(CheckedInt32Div, 2, 1) \ |
394 V(CheckedInt32Mod, 2, 1) \ | 396 V(CheckedInt32Mod, 2, 1) \ |
395 V(CheckedUint32Div, 2, 1) \ | 397 V(CheckedUint32Div, 2, 1) \ |
396 V(CheckedUint32Mod, 2, 1) \ | 398 V(CheckedUint32Mod, 2, 1) \ |
397 V(CheckedUint32ToInt32, 1, 1) \ | 399 V(CheckedUint32ToInt32, 1, 1) \ |
398 V(CheckedFloat64ToInt32, 1, 1) \ | |
399 V(CheckedTaggedSignedToInt32, 1, 1) \ | 400 V(CheckedTaggedSignedToInt32, 1, 1) \ |
400 V(CheckedTaggedToInt32, 1, 1) \ | |
401 V(CheckedTaggedToFloat64, 1, 1) \ | 401 V(CheckedTaggedToFloat64, 1, 1) \ |
402 V(CheckedTruncateTaggedToWord32, 1, 1) | 402 V(CheckedTruncateTaggedToWord32, 1, 1) |
403 | 403 |
404 struct SimplifiedOperatorGlobalCache final { | 404 struct SimplifiedOperatorGlobalCache final { |
405 #define PURE(Name, properties, value_input_count, control_input_count) \ | 405 #define PURE(Name, properties, value_input_count, control_input_count) \ |
406 struct Name##Operator final : public Operator { \ | 406 struct Name##Operator final : public Operator { \ |
407 Name##Operator() \ | 407 Name##Operator() \ |
408 : Operator(IrOpcode::k##Name, Operator::kPure | properties, #Name, \ | 408 : Operator(IrOpcode::k##Name, Operator::kPure | properties, #Name, \ |
409 value_input_count, 0, control_input_count, 1, 0, 0) {} \ | 409 value_input_count, 0, control_input_count, 1, 0, 0) {} \ |
410 }; \ | 410 }; \ |
(...skipping 19 matching lines...) Expand all Loading... |
430 : Operator1<CheckForMinusZeroMode>( | 430 : Operator1<CheckForMinusZeroMode>( |
431 IrOpcode::kCheckedInt32Mul, | 431 IrOpcode::kCheckedInt32Mul, |
432 Operator::kFoldable | Operator::kNoThrow, "CheckedInt32Mul", 2, 1, | 432 Operator::kFoldable | Operator::kNoThrow, "CheckedInt32Mul", 2, 1, |
433 1, 1, 1, 0, kMode) {} | 433 1, 1, 1, 0, kMode) {} |
434 }; | 434 }; |
435 CheckedInt32MulOperator<CheckForMinusZeroMode::kCheckForMinusZero> | 435 CheckedInt32MulOperator<CheckForMinusZeroMode::kCheckForMinusZero> |
436 kCheckedInt32MulCheckForMinusZeroOperator; | 436 kCheckedInt32MulCheckForMinusZeroOperator; |
437 CheckedInt32MulOperator<CheckForMinusZeroMode::kDontCheckForMinusZero> | 437 CheckedInt32MulOperator<CheckForMinusZeroMode::kDontCheckForMinusZero> |
438 kCheckedInt32MulDontCheckForMinusZeroOperator; | 438 kCheckedInt32MulDontCheckForMinusZeroOperator; |
439 | 439 |
| 440 template <CheckForMinusZeroMode kMode> |
| 441 struct CheckedFloat64ToInt32Operator final |
| 442 : public Operator1<CheckForMinusZeroMode> { |
| 443 CheckedFloat64ToInt32Operator() |
| 444 : Operator1<CheckForMinusZeroMode>( |
| 445 IrOpcode::kCheckedFloat64ToInt32, |
| 446 Operator::kFoldable | Operator::kNoThrow, "CheckedFloat64ToInt32", |
| 447 1, 1, 1, 1, 1, 0, kMode) {} |
| 448 }; |
| 449 CheckedFloat64ToInt32Operator<CheckForMinusZeroMode::kCheckForMinusZero> |
| 450 kCheckedFloat64ToInt32CheckForMinusZeroOperator; |
| 451 CheckedFloat64ToInt32Operator<CheckForMinusZeroMode::kDontCheckForMinusZero> |
| 452 kCheckedFloat64ToInt32DontCheckForMinusZeroOperator; |
| 453 |
| 454 template <CheckForMinusZeroMode kMode> |
| 455 struct CheckedTaggedToInt32Operator final |
| 456 : public Operator1<CheckForMinusZeroMode> { |
| 457 CheckedTaggedToInt32Operator() |
| 458 : Operator1<CheckForMinusZeroMode>( |
| 459 IrOpcode::kCheckedTaggedToInt32, |
| 460 Operator::kFoldable | Operator::kNoThrow, "CheckedTaggedToInt32", |
| 461 1, 1, 1, 1, 1, 0, kMode) {} |
| 462 }; |
| 463 CheckedTaggedToInt32Operator<CheckForMinusZeroMode::kCheckForMinusZero> |
| 464 kCheckedTaggedToInt32CheckForMinusZeroOperator; |
| 465 CheckedTaggedToInt32Operator<CheckForMinusZeroMode::kDontCheckForMinusZero> |
| 466 kCheckedTaggedToInt32DontCheckForMinusZeroOperator; |
| 467 |
440 template <CheckFloat64HoleMode kMode> | 468 template <CheckFloat64HoleMode kMode> |
441 struct CheckFloat64HoleNaNOperator final | 469 struct CheckFloat64HoleNaNOperator final |
442 : public Operator1<CheckFloat64HoleMode> { | 470 : public Operator1<CheckFloat64HoleMode> { |
443 CheckFloat64HoleNaNOperator() | 471 CheckFloat64HoleNaNOperator() |
444 : Operator1<CheckFloat64HoleMode>( | 472 : Operator1<CheckFloat64HoleMode>( |
445 IrOpcode::kCheckFloat64Hole, | 473 IrOpcode::kCheckFloat64Hole, |
446 Operator::kFoldable | Operator::kNoThrow, "CheckFloat64Hole", 1, | 474 Operator::kFoldable | Operator::kNoThrow, "CheckFloat64Hole", 1, |
447 1, 1, 1, 1, 0, kMode) {} | 475 1, 1, 1, 1, 0, kMode) {} |
448 }; | 476 }; |
449 CheckFloat64HoleNaNOperator<CheckFloat64HoleMode::kAllowReturnHole> | 477 CheckFloat64HoleNaNOperator<CheckFloat64HoleMode::kAllowReturnHole> |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 switch (mode) { | 545 switch (mode) { |
518 case CheckForMinusZeroMode::kCheckForMinusZero: | 546 case CheckForMinusZeroMode::kCheckForMinusZero: |
519 return &cache_.kCheckedInt32MulCheckForMinusZeroOperator; | 547 return &cache_.kCheckedInt32MulCheckForMinusZeroOperator; |
520 case CheckForMinusZeroMode::kDontCheckForMinusZero: | 548 case CheckForMinusZeroMode::kDontCheckForMinusZero: |
521 return &cache_.kCheckedInt32MulDontCheckForMinusZeroOperator; | 549 return &cache_.kCheckedInt32MulDontCheckForMinusZeroOperator; |
522 } | 550 } |
523 UNREACHABLE(); | 551 UNREACHABLE(); |
524 return nullptr; | 552 return nullptr; |
525 } | 553 } |
526 | 554 |
| 555 const Operator* SimplifiedOperatorBuilder::CheckedFloat64ToInt32( |
| 556 CheckForMinusZeroMode mode) { |
| 557 switch (mode) { |
| 558 case CheckForMinusZeroMode::kCheckForMinusZero: |
| 559 return &cache_.kCheckedFloat64ToInt32CheckForMinusZeroOperator; |
| 560 case CheckForMinusZeroMode::kDontCheckForMinusZero: |
| 561 return &cache_.kCheckedFloat64ToInt32DontCheckForMinusZeroOperator; |
| 562 } |
| 563 UNREACHABLE(); |
| 564 return nullptr; |
| 565 } |
| 566 |
| 567 const Operator* SimplifiedOperatorBuilder::CheckedTaggedToInt32( |
| 568 CheckForMinusZeroMode mode) { |
| 569 switch (mode) { |
| 570 case CheckForMinusZeroMode::kCheckForMinusZero: |
| 571 return &cache_.kCheckedTaggedToInt32CheckForMinusZeroOperator; |
| 572 case CheckForMinusZeroMode::kDontCheckForMinusZero: |
| 573 return &cache_.kCheckedTaggedToInt32DontCheckForMinusZeroOperator; |
| 574 } |
| 575 UNREACHABLE(); |
| 576 return nullptr; |
| 577 } |
| 578 |
527 const Operator* SimplifiedOperatorBuilder::CheckMaps(int map_input_count) { | 579 const Operator* SimplifiedOperatorBuilder::CheckMaps(int map_input_count) { |
528 // TODO(bmeurer): Cache the most important versions of this operator. | 580 // TODO(bmeurer): Cache the most important versions of this operator. |
529 DCHECK_LT(0, map_input_count); | 581 DCHECK_LT(0, map_input_count); |
530 int const value_input_count = 1 + map_input_count; | 582 int const value_input_count = 1 + map_input_count; |
531 return new (zone()) Operator1<int>( // -- | 583 return new (zone()) Operator1<int>( // -- |
532 IrOpcode::kCheckMaps, // opcode | 584 IrOpcode::kCheckMaps, // opcode |
533 Operator::kNoThrow | Operator::kNoWrite, // flags | 585 Operator::kNoThrow | Operator::kNoWrite, // flags |
534 "CheckMaps", // name | 586 "CheckMaps", // name |
535 value_input_count, 1, 1, 0, 1, 0, // counts | 587 value_input_count, 1, 1, 0, 1, 0, // counts |
536 map_input_count); // parameter | 588 map_input_count); // parameter |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 Operator::kNoDeopt | Operator::kNoThrow | properties, \ | 715 Operator::kNoDeopt | Operator::kNoThrow | properties, \ |
664 #Name, value_input_count, 1, control_input_count, \ | 716 #Name, value_input_count, 1, control_input_count, \ |
665 output_count, 1, 0, access); \ | 717 output_count, 1, 0, access); \ |
666 } | 718 } |
667 ACCESS_OP_LIST(ACCESS) | 719 ACCESS_OP_LIST(ACCESS) |
668 #undef ACCESS | 720 #undef ACCESS |
669 | 721 |
670 } // namespace compiler | 722 } // namespace compiler |
671 } // namespace internal | 723 } // namespace internal |
672 } // namespace v8 | 724 } // namespace v8 |
OLD | NEW |