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(op->opcode() == IrOpcode::kCheckedInt32Mul || | 211 DCHECK(op->opcode() == IrOpcode::kChangeFloat64ToTagged || |
| 212 op->opcode() == IrOpcode::kCheckedInt32Mul || |
212 op->opcode() == IrOpcode::kCheckedFloat64ToInt32 || | 213 op->opcode() == IrOpcode::kCheckedFloat64ToInt32 || |
213 op->opcode() == IrOpcode::kCheckedTaggedToInt32); | 214 op->opcode() == IrOpcode::kCheckedTaggedToInt32); |
214 return OpParameter<CheckForMinusZeroMode>(op); | 215 return OpParameter<CheckForMinusZeroMode>(op); |
215 } | 216 } |
216 | 217 |
217 size_t hash_value(CheckForMinusZeroMode mode) { | 218 size_t hash_value(CheckForMinusZeroMode mode) { |
218 return static_cast<size_t>(mode); | 219 return static_cast<size_t>(mode); |
219 } | 220 } |
220 | 221 |
221 std::ostream& operator<<(std::ostream& os, CheckForMinusZeroMode mode) { | 222 std::ostream& operator<<(std::ostream& os, CheckForMinusZeroMode mode) { |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 V(PlainPrimitiveToNumber, Operator::kNoProperties, 1, 0) \ | 389 V(PlainPrimitiveToNumber, Operator::kNoProperties, 1, 0) \ |
389 V(PlainPrimitiveToWord32, Operator::kNoProperties, 1, 0) \ | 390 V(PlainPrimitiveToWord32, Operator::kNoProperties, 1, 0) \ |
390 V(PlainPrimitiveToFloat64, Operator::kNoProperties, 1, 0) \ | 391 V(PlainPrimitiveToFloat64, Operator::kNoProperties, 1, 0) \ |
391 V(ChangeTaggedSignedToInt32, Operator::kNoProperties, 1, 0) \ | 392 V(ChangeTaggedSignedToInt32, Operator::kNoProperties, 1, 0) \ |
392 V(ChangeTaggedToInt32, Operator::kNoProperties, 1, 0) \ | 393 V(ChangeTaggedToInt32, Operator::kNoProperties, 1, 0) \ |
393 V(ChangeTaggedToUint32, Operator::kNoProperties, 1, 0) \ | 394 V(ChangeTaggedToUint32, Operator::kNoProperties, 1, 0) \ |
394 V(ChangeTaggedToFloat64, Operator::kNoProperties, 1, 0) \ | 395 V(ChangeTaggedToFloat64, Operator::kNoProperties, 1, 0) \ |
395 V(ChangeInt31ToTaggedSigned, Operator::kNoProperties, 1, 0) \ | 396 V(ChangeInt31ToTaggedSigned, Operator::kNoProperties, 1, 0) \ |
396 V(ChangeInt32ToTagged, Operator::kNoProperties, 1, 0) \ | 397 V(ChangeInt32ToTagged, Operator::kNoProperties, 1, 0) \ |
397 V(ChangeUint32ToTagged, Operator::kNoProperties, 1, 0) \ | 398 V(ChangeUint32ToTagged, Operator::kNoProperties, 1, 0) \ |
398 V(ChangeFloat64ToTagged, Operator::kNoProperties, 1, 0) \ | |
399 V(ChangeTaggedToBit, Operator::kNoProperties, 1, 0) \ | 399 V(ChangeTaggedToBit, Operator::kNoProperties, 1, 0) \ |
400 V(ChangeBitToTagged, Operator::kNoProperties, 1, 0) \ | 400 V(ChangeBitToTagged, Operator::kNoProperties, 1, 0) \ |
401 V(TruncateTaggedToWord32, Operator::kNoProperties, 1, 0) \ | 401 V(TruncateTaggedToWord32, Operator::kNoProperties, 1, 0) \ |
402 V(TruncateTaggedToFloat64, Operator::kNoProperties, 1, 0) \ | 402 V(TruncateTaggedToFloat64, Operator::kNoProperties, 1, 0) \ |
403 V(ObjectIsCallable, Operator::kNoProperties, 1, 0) \ | 403 V(ObjectIsCallable, Operator::kNoProperties, 1, 0) \ |
404 V(ObjectIsNumber, Operator::kNoProperties, 1, 0) \ | 404 V(ObjectIsNumber, Operator::kNoProperties, 1, 0) \ |
405 V(ObjectIsReceiver, Operator::kNoProperties, 1, 0) \ | 405 V(ObjectIsReceiver, Operator::kNoProperties, 1, 0) \ |
406 V(ObjectIsSmi, Operator::kNoProperties, 1, 0) \ | 406 V(ObjectIsSmi, Operator::kNoProperties, 1, 0) \ |
407 V(ObjectIsString, Operator::kNoProperties, 1, 0) \ | 407 V(ObjectIsString, Operator::kNoProperties, 1, 0) \ |
408 V(ObjectIsUndetectable, Operator::kNoProperties, 1, 0) \ | 408 V(ObjectIsUndetectable, Operator::kNoProperties, 1, 0) \ |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 Name##Operator() \ | 452 Name##Operator() \ |
453 : Operator(IrOpcode::k##Name, \ | 453 : Operator(IrOpcode::k##Name, \ |
454 Operator::kFoldable | Operator::kNoThrow, #Name, \ | 454 Operator::kFoldable | Operator::kNoThrow, #Name, \ |
455 value_input_count, 1, 1, value_output_count, 1, 0) {} \ | 455 value_input_count, 1, 1, value_output_count, 1, 0) {} \ |
456 }; \ | 456 }; \ |
457 Name##Operator k##Name; | 457 Name##Operator k##Name; |
458 CHECKED_OP_LIST(CHECKED) | 458 CHECKED_OP_LIST(CHECKED) |
459 #undef CHECKED | 459 #undef CHECKED |
460 | 460 |
461 template <CheckForMinusZeroMode kMode> | 461 template <CheckForMinusZeroMode kMode> |
| 462 struct ChangeFloat64ToTaggedOperator final |
| 463 : public Operator1<CheckForMinusZeroMode> { |
| 464 ChangeFloat64ToTaggedOperator() |
| 465 : Operator1<CheckForMinusZeroMode>( |
| 466 IrOpcode::kChangeFloat64ToTagged, Operator::kPure, |
| 467 "ChangeFloat64ToTagged", 1, 0, 0, 1, 0, 0, kMode) {} |
| 468 }; |
| 469 ChangeFloat64ToTaggedOperator<CheckForMinusZeroMode::kCheckForMinusZero> |
| 470 kChangeFloat64ToTaggedCheckForMinusZeroOperator; |
| 471 ChangeFloat64ToTaggedOperator<CheckForMinusZeroMode::kDontCheckForMinusZero> |
| 472 kChangeFloat64ToTaggedDontCheckForMinusZeroOperator; |
| 473 |
| 474 template <CheckForMinusZeroMode kMode> |
462 struct CheckedInt32MulOperator final | 475 struct CheckedInt32MulOperator final |
463 : public Operator1<CheckForMinusZeroMode> { | 476 : public Operator1<CheckForMinusZeroMode> { |
464 CheckedInt32MulOperator() | 477 CheckedInt32MulOperator() |
465 : Operator1<CheckForMinusZeroMode>( | 478 : Operator1<CheckForMinusZeroMode>( |
466 IrOpcode::kCheckedInt32Mul, | 479 IrOpcode::kCheckedInt32Mul, |
467 Operator::kFoldable | Operator::kNoThrow, "CheckedInt32Mul", 2, 1, | 480 Operator::kFoldable | Operator::kNoThrow, "CheckedInt32Mul", 2, 1, |
468 1, 1, 1, 0, kMode) {} | 481 1, 1, 1, 0, kMode) {} |
469 }; | 482 }; |
470 CheckedInt32MulOperator<CheckForMinusZeroMode::kCheckForMinusZero> | 483 CheckedInt32MulOperator<CheckForMinusZeroMode::kCheckForMinusZero> |
471 kCheckedInt32MulCheckForMinusZeroOperator; | 484 kCheckedInt32MulCheckForMinusZeroOperator; |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
596 | 609 |
597 SimplifiedOperatorBuilder::SimplifiedOperatorBuilder(Zone* zone) | 610 SimplifiedOperatorBuilder::SimplifiedOperatorBuilder(Zone* zone) |
598 : cache_(kCache.Get()), zone_(zone) {} | 611 : cache_(kCache.Get()), zone_(zone) {} |
599 | 612 |
600 #define GET_FROM_CACHE(Name, ...) \ | 613 #define GET_FROM_CACHE(Name, ...) \ |
601 const Operator* SimplifiedOperatorBuilder::Name() { return &cache_.k##Name; } | 614 const Operator* SimplifiedOperatorBuilder::Name() { return &cache_.k##Name; } |
602 PURE_OP_LIST(GET_FROM_CACHE) | 615 PURE_OP_LIST(GET_FROM_CACHE) |
603 CHECKED_OP_LIST(GET_FROM_CACHE) | 616 CHECKED_OP_LIST(GET_FROM_CACHE) |
604 #undef GET_FROM_CACHE | 617 #undef GET_FROM_CACHE |
605 | 618 |
| 619 const Operator* SimplifiedOperatorBuilder::ChangeFloat64ToTagged( |
| 620 CheckForMinusZeroMode mode) { |
| 621 switch (mode) { |
| 622 case CheckForMinusZeroMode::kCheckForMinusZero: |
| 623 return &cache_.kChangeFloat64ToTaggedCheckForMinusZeroOperator; |
| 624 case CheckForMinusZeroMode::kDontCheckForMinusZero: |
| 625 return &cache_.kChangeFloat64ToTaggedDontCheckForMinusZeroOperator; |
| 626 } |
| 627 UNREACHABLE(); |
| 628 return nullptr; |
| 629 } |
| 630 |
606 const Operator* SimplifiedOperatorBuilder::CheckedInt32Mul( | 631 const Operator* SimplifiedOperatorBuilder::CheckedInt32Mul( |
607 CheckForMinusZeroMode mode) { | 632 CheckForMinusZeroMode mode) { |
608 switch (mode) { | 633 switch (mode) { |
609 case CheckForMinusZeroMode::kCheckForMinusZero: | 634 case CheckForMinusZeroMode::kCheckForMinusZero: |
610 return &cache_.kCheckedInt32MulCheckForMinusZeroOperator; | 635 return &cache_.kCheckedInt32MulCheckForMinusZeroOperator; |
611 case CheckForMinusZeroMode::kDontCheckForMinusZero: | 636 case CheckForMinusZeroMode::kDontCheckForMinusZero: |
612 return &cache_.kCheckedInt32MulDontCheckForMinusZeroOperator; | 637 return &cache_.kCheckedInt32MulDontCheckForMinusZeroOperator; |
613 } | 638 } |
614 UNREACHABLE(); | 639 UNREACHABLE(); |
615 return nullptr; | 640 return nullptr; |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
770 Operator::kNoDeopt | Operator::kNoThrow | properties, \ | 795 Operator::kNoDeopt | Operator::kNoThrow | properties, \ |
771 #Name, value_input_count, 1, control_input_count, \ | 796 #Name, value_input_count, 1, control_input_count, \ |
772 output_count, 1, 0, access); \ | 797 output_count, 1, 0, access); \ |
773 } | 798 } |
774 ACCESS_OP_LIST(ACCESS) | 799 ACCESS_OP_LIST(ACCESS) |
775 #undef ACCESS | 800 #undef ACCESS |
776 | 801 |
777 } // namespace compiler | 802 } // namespace compiler |
778 } // namespace internal | 803 } // namespace internal |
779 } // namespace v8 | 804 } // namespace v8 |
OLD | NEW |