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/compiler/types.h" | 10 #include "src/compiler/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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 V(NumberSilenceNaN, Operator::kNoProperties, 1, 0) \ | 392 V(NumberSilenceNaN, Operator::kNoProperties, 1, 0) \ |
392 V(StringCharCodeAt, Operator::kNoProperties, 2, 1) \ | 393 V(StringCharCodeAt, Operator::kNoProperties, 2, 1) \ |
393 V(StringFromCharCode, Operator::kNoProperties, 1, 0) \ | 394 V(StringFromCharCode, Operator::kNoProperties, 1, 0) \ |
394 V(PlainPrimitiveToNumber, Operator::kNoProperties, 1, 0) \ | 395 V(PlainPrimitiveToNumber, Operator::kNoProperties, 1, 0) \ |
395 V(PlainPrimitiveToWord32, Operator::kNoProperties, 1, 0) \ | 396 V(PlainPrimitiveToWord32, Operator::kNoProperties, 1, 0) \ |
396 V(PlainPrimitiveToFloat64, Operator::kNoProperties, 1, 0) \ | 397 V(PlainPrimitiveToFloat64, Operator::kNoProperties, 1, 0) \ |
397 V(ChangeTaggedSignedToInt32, Operator::kNoProperties, 1, 0) \ | 398 V(ChangeTaggedSignedToInt32, Operator::kNoProperties, 1, 0) \ |
398 V(ChangeTaggedToInt32, Operator::kNoProperties, 1, 0) \ | 399 V(ChangeTaggedToInt32, Operator::kNoProperties, 1, 0) \ |
399 V(ChangeTaggedToUint32, Operator::kNoProperties, 1, 0) \ | 400 V(ChangeTaggedToUint32, Operator::kNoProperties, 1, 0) \ |
400 V(ChangeTaggedToFloat64, Operator::kNoProperties, 1, 0) \ | 401 V(ChangeTaggedToFloat64, Operator::kNoProperties, 1, 0) \ |
401 V(ChangeFloat64ToTagged, Operator::kNoProperties, 1, 0) \ | |
402 V(ChangeInt31ToTaggedSigned, Operator::kNoProperties, 1, 0) \ | 402 V(ChangeInt31ToTaggedSigned, Operator::kNoProperties, 1, 0) \ |
403 V(ChangeInt32ToTagged, Operator::kNoProperties, 1, 0) \ | 403 V(ChangeInt32ToTagged, Operator::kNoProperties, 1, 0) \ |
404 V(ChangeUint32ToTagged, Operator::kNoProperties, 1, 0) \ | 404 V(ChangeUint32ToTagged, Operator::kNoProperties, 1, 0) \ |
405 V(ChangeTaggedToBit, Operator::kNoProperties, 1, 0) \ | 405 V(ChangeTaggedToBit, Operator::kNoProperties, 1, 0) \ |
406 V(ChangeBitToTagged, Operator::kNoProperties, 1, 0) \ | 406 V(ChangeBitToTagged, Operator::kNoProperties, 1, 0) \ |
407 V(TruncateTaggedToBit, Operator::kNoProperties, 1, 0) \ | 407 V(TruncateTaggedToBit, Operator::kNoProperties, 1, 0) \ |
408 V(TruncateTaggedToWord32, Operator::kNoProperties, 1, 0) \ | 408 V(TruncateTaggedToWord32, Operator::kNoProperties, 1, 0) \ |
409 V(TruncateTaggedToFloat64, Operator::kNoProperties, 1, 0) \ | 409 V(TruncateTaggedToFloat64, Operator::kNoProperties, 1, 0) \ |
410 V(ObjectIsCallable, Operator::kNoProperties, 1, 0) \ | 410 V(ObjectIsCallable, Operator::kNoProperties, 1, 0) \ |
411 V(ObjectIsNumber, Operator::kNoProperties, 1, 0) \ | 411 V(ObjectIsNumber, Operator::kNoProperties, 1, 0) \ |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 #undef CHECKED | 466 #undef CHECKED |
467 | 467 |
468 struct ArrayBufferWasNeuteredOperator final : public Operator { | 468 struct ArrayBufferWasNeuteredOperator final : public Operator { |
469 ArrayBufferWasNeuteredOperator() | 469 ArrayBufferWasNeuteredOperator() |
470 : Operator(IrOpcode::kArrayBufferWasNeutered, Operator::kEliminatable, | 470 : Operator(IrOpcode::kArrayBufferWasNeutered, Operator::kEliminatable, |
471 "ArrayBufferWasNeutered", 1, 1, 1, 1, 1, 0) {} | 471 "ArrayBufferWasNeutered", 1, 1, 1, 1, 1, 0) {} |
472 }; | 472 }; |
473 ArrayBufferWasNeuteredOperator kArrayBufferWasNeutered; | 473 ArrayBufferWasNeuteredOperator kArrayBufferWasNeutered; |
474 | 474 |
475 template <CheckForMinusZeroMode kMode> | 475 template <CheckForMinusZeroMode kMode> |
| 476 struct ChangeFloat64ToTaggedOperator final |
| 477 : public Operator1<CheckForMinusZeroMode> { |
| 478 ChangeFloat64ToTaggedOperator() |
| 479 : Operator1<CheckForMinusZeroMode>( |
| 480 IrOpcode::kChangeFloat64ToTagged, Operator::kPure, |
| 481 "ChangeFloat64ToTagged", 1, 0, 0, 1, 0, 0, kMode) {} |
| 482 }; |
| 483 ChangeFloat64ToTaggedOperator<CheckForMinusZeroMode::kCheckForMinusZero> |
| 484 kChangeFloat64ToTaggedCheckForMinusZeroOperator; |
| 485 ChangeFloat64ToTaggedOperator<CheckForMinusZeroMode::kDontCheckForMinusZero> |
| 486 kChangeFloat64ToTaggedDontCheckForMinusZeroOperator; |
| 487 |
| 488 template <CheckForMinusZeroMode kMode> |
476 struct CheckedInt32MulOperator final | 489 struct CheckedInt32MulOperator final |
477 : public Operator1<CheckForMinusZeroMode> { | 490 : public Operator1<CheckForMinusZeroMode> { |
478 CheckedInt32MulOperator() | 491 CheckedInt32MulOperator() |
479 : Operator1<CheckForMinusZeroMode>( | 492 : Operator1<CheckForMinusZeroMode>( |
480 IrOpcode::kCheckedInt32Mul, | 493 IrOpcode::kCheckedInt32Mul, |
481 Operator::kFoldable | Operator::kNoThrow, "CheckedInt32Mul", 2, 1, | 494 Operator::kFoldable | Operator::kNoThrow, "CheckedInt32Mul", 2, 1, |
482 1, 1, 1, 0, kMode) {} | 495 1, 1, 1, 0, kMode) {} |
483 }; | 496 }; |
484 CheckedInt32MulOperator<CheckForMinusZeroMode::kCheckForMinusZero> | 497 CheckedInt32MulOperator<CheckForMinusZeroMode::kCheckForMinusZero> |
485 kCheckedInt32MulCheckForMinusZeroOperator; | 498 kCheckedInt32MulCheckForMinusZeroOperator; |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 SimplifiedOperatorBuilder::SimplifiedOperatorBuilder(Zone* zone) | 624 SimplifiedOperatorBuilder::SimplifiedOperatorBuilder(Zone* zone) |
612 : cache_(kCache.Get()), zone_(zone) {} | 625 : cache_(kCache.Get()), zone_(zone) {} |
613 | 626 |
614 #define GET_FROM_CACHE(Name, ...) \ | 627 #define GET_FROM_CACHE(Name, ...) \ |
615 const Operator* SimplifiedOperatorBuilder::Name() { return &cache_.k##Name; } | 628 const Operator* SimplifiedOperatorBuilder::Name() { return &cache_.k##Name; } |
616 PURE_OP_LIST(GET_FROM_CACHE) | 629 PURE_OP_LIST(GET_FROM_CACHE) |
617 CHECKED_OP_LIST(GET_FROM_CACHE) | 630 CHECKED_OP_LIST(GET_FROM_CACHE) |
618 GET_FROM_CACHE(ArrayBufferWasNeutered) | 631 GET_FROM_CACHE(ArrayBufferWasNeutered) |
619 #undef GET_FROM_CACHE | 632 #undef GET_FROM_CACHE |
620 | 633 |
| 634 const Operator* SimplifiedOperatorBuilder::ChangeFloat64ToTagged( |
| 635 CheckForMinusZeroMode mode) { |
| 636 switch (mode) { |
| 637 case CheckForMinusZeroMode::kCheckForMinusZero: |
| 638 return &cache_.kChangeFloat64ToTaggedCheckForMinusZeroOperator; |
| 639 case CheckForMinusZeroMode::kDontCheckForMinusZero: |
| 640 return &cache_.kChangeFloat64ToTaggedDontCheckForMinusZeroOperator; |
| 641 } |
| 642 UNREACHABLE(); |
| 643 return nullptr; |
| 644 } |
| 645 |
621 const Operator* SimplifiedOperatorBuilder::CheckedInt32Mul( | 646 const Operator* SimplifiedOperatorBuilder::CheckedInt32Mul( |
622 CheckForMinusZeroMode mode) { | 647 CheckForMinusZeroMode mode) { |
623 switch (mode) { | 648 switch (mode) { |
624 case CheckForMinusZeroMode::kCheckForMinusZero: | 649 case CheckForMinusZeroMode::kCheckForMinusZero: |
625 return &cache_.kCheckedInt32MulCheckForMinusZeroOperator; | 650 return &cache_.kCheckedInt32MulCheckForMinusZeroOperator; |
626 case CheckForMinusZeroMode::kDontCheckForMinusZero: | 651 case CheckForMinusZeroMode::kDontCheckForMinusZero: |
627 return &cache_.kCheckedInt32MulDontCheckForMinusZeroOperator; | 652 return &cache_.kCheckedInt32MulDontCheckForMinusZeroOperator; |
628 } | 653 } |
629 UNREACHABLE(); | 654 UNREACHABLE(); |
630 return nullptr; | 655 return nullptr; |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
785 Operator::kNoDeopt | Operator::kNoThrow | properties, \ | 810 Operator::kNoDeopt | Operator::kNoThrow | properties, \ |
786 #Name, value_input_count, 1, control_input_count, \ | 811 #Name, value_input_count, 1, control_input_count, \ |
787 output_count, 1, 0, access); \ | 812 output_count, 1, 0, access); \ |
788 } | 813 } |
789 ACCESS_OP_LIST(ACCESS) | 814 ACCESS_OP_LIST(ACCESS) |
790 #undef ACCESS | 815 #undef ACCESS |
791 | 816 |
792 } // namespace compiler | 817 } // namespace compiler |
793 } // namespace internal | 818 } // namespace internal |
794 } // namespace v8 | 819 } // namespace v8 |
OLD | NEW |