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::kChangeFloat64ToTagged || | 211 DCHECK(op->opcode() == IrOpcode::kCheckedInt32Mul || |
212 op->opcode() == IrOpcode::kCheckedInt32Mul || | |
213 op->opcode() == IrOpcode::kCheckedFloat64ToInt32 || | 212 op->opcode() == IrOpcode::kCheckedFloat64ToInt32 || |
214 op->opcode() == IrOpcode::kCheckedTaggedToInt32); | 213 op->opcode() == IrOpcode::kCheckedTaggedToInt32); |
215 return OpParameter<CheckForMinusZeroMode>(op); | 214 return OpParameter<CheckForMinusZeroMode>(op); |
216 } | 215 } |
217 | 216 |
218 size_t hash_value(CheckForMinusZeroMode mode) { | 217 size_t hash_value(CheckForMinusZeroMode mode) { |
219 return static_cast<size_t>(mode); | 218 return static_cast<size_t>(mode); |
220 } | 219 } |
221 | 220 |
222 std::ostream& operator<<(std::ostream& os, CheckForMinusZeroMode mode) { | 221 std::ostream& operator<<(std::ostream& os, CheckForMinusZeroMode mode) { |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 V(NumberSilenceNaN, Operator::kNoProperties, 1, 0) \ | 391 V(NumberSilenceNaN, Operator::kNoProperties, 1, 0) \ |
393 V(StringCharCodeAt, Operator::kNoProperties, 2, 1) \ | 392 V(StringCharCodeAt, Operator::kNoProperties, 2, 1) \ |
394 V(StringFromCharCode, Operator::kNoProperties, 1, 0) \ | 393 V(StringFromCharCode, Operator::kNoProperties, 1, 0) \ |
395 V(PlainPrimitiveToNumber, Operator::kNoProperties, 1, 0) \ | 394 V(PlainPrimitiveToNumber, Operator::kNoProperties, 1, 0) \ |
396 V(PlainPrimitiveToWord32, Operator::kNoProperties, 1, 0) \ | 395 V(PlainPrimitiveToWord32, Operator::kNoProperties, 1, 0) \ |
397 V(PlainPrimitiveToFloat64, Operator::kNoProperties, 1, 0) \ | 396 V(PlainPrimitiveToFloat64, Operator::kNoProperties, 1, 0) \ |
398 V(ChangeTaggedSignedToInt32, Operator::kNoProperties, 1, 0) \ | 397 V(ChangeTaggedSignedToInt32, Operator::kNoProperties, 1, 0) \ |
399 V(ChangeTaggedToInt32, Operator::kNoProperties, 1, 0) \ | 398 V(ChangeTaggedToInt32, Operator::kNoProperties, 1, 0) \ |
400 V(ChangeTaggedToUint32, Operator::kNoProperties, 1, 0) \ | 399 V(ChangeTaggedToUint32, Operator::kNoProperties, 1, 0) \ |
401 V(ChangeTaggedToFloat64, Operator::kNoProperties, 1, 0) \ | 400 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 #undef CHECKED | 469 #undef CHECKED |
470 | 470 |
471 struct ArrayBufferWasNeuteredOperator final : public Operator { | 471 struct ArrayBufferWasNeuteredOperator final : public Operator { |
472 ArrayBufferWasNeuteredOperator() | 472 ArrayBufferWasNeuteredOperator() |
473 : Operator(IrOpcode::kArrayBufferWasNeutered, Operator::kEliminatable, | 473 : Operator(IrOpcode::kArrayBufferWasNeutered, Operator::kEliminatable, |
474 "ArrayBufferWasNeutered", 1, 1, 1, 1, 1, 0) {} | 474 "ArrayBufferWasNeutered", 1, 1, 1, 1, 1, 0) {} |
475 }; | 475 }; |
476 ArrayBufferWasNeuteredOperator kArrayBufferWasNeutered; | 476 ArrayBufferWasNeuteredOperator kArrayBufferWasNeutered; |
477 | 477 |
478 template <CheckForMinusZeroMode kMode> | 478 template <CheckForMinusZeroMode kMode> |
479 struct ChangeFloat64ToTaggedOperator final | |
480 : public Operator1<CheckForMinusZeroMode> { | |
481 ChangeFloat64ToTaggedOperator() | |
482 : Operator1<CheckForMinusZeroMode>( | |
483 IrOpcode::kChangeFloat64ToTagged, Operator::kPure, | |
484 "ChangeFloat64ToTagged", 1, 0, 0, 1, 0, 0, kMode) {} | |
485 }; | |
486 ChangeFloat64ToTaggedOperator<CheckForMinusZeroMode::kCheckForMinusZero> | |
487 kChangeFloat64ToTaggedCheckForMinusZeroOperator; | |
488 ChangeFloat64ToTaggedOperator<CheckForMinusZeroMode::kDontCheckForMinusZero> | |
489 kChangeFloat64ToTaggedDontCheckForMinusZeroOperator; | |
490 | |
491 template <CheckForMinusZeroMode kMode> | |
492 struct CheckedInt32MulOperator final | 479 struct CheckedInt32MulOperator final |
493 : public Operator1<CheckForMinusZeroMode> { | 480 : public Operator1<CheckForMinusZeroMode> { |
494 CheckedInt32MulOperator() | 481 CheckedInt32MulOperator() |
495 : Operator1<CheckForMinusZeroMode>( | 482 : Operator1<CheckForMinusZeroMode>( |
496 IrOpcode::kCheckedInt32Mul, | 483 IrOpcode::kCheckedInt32Mul, |
497 Operator::kFoldable | Operator::kNoThrow, "CheckedInt32Mul", 2, 1, | 484 Operator::kFoldable | Operator::kNoThrow, "CheckedInt32Mul", 2, 1, |
498 1, 1, 1, 0, kMode) {} | 485 1, 1, 1, 0, kMode) {} |
499 }; | 486 }; |
500 CheckedInt32MulOperator<CheckForMinusZeroMode::kCheckForMinusZero> | 487 CheckedInt32MulOperator<CheckForMinusZeroMode::kCheckForMinusZero> |
501 kCheckedInt32MulCheckForMinusZeroOperator; | 488 kCheckedInt32MulCheckForMinusZeroOperator; |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
627 SimplifiedOperatorBuilder::SimplifiedOperatorBuilder(Zone* zone) | 614 SimplifiedOperatorBuilder::SimplifiedOperatorBuilder(Zone* zone) |
628 : cache_(kCache.Get()), zone_(zone) {} | 615 : cache_(kCache.Get()), zone_(zone) {} |
629 | 616 |
630 #define GET_FROM_CACHE(Name, ...) \ | 617 #define GET_FROM_CACHE(Name, ...) \ |
631 const Operator* SimplifiedOperatorBuilder::Name() { return &cache_.k##Name; } | 618 const Operator* SimplifiedOperatorBuilder::Name() { return &cache_.k##Name; } |
632 PURE_OP_LIST(GET_FROM_CACHE) | 619 PURE_OP_LIST(GET_FROM_CACHE) |
633 CHECKED_OP_LIST(GET_FROM_CACHE) | 620 CHECKED_OP_LIST(GET_FROM_CACHE) |
634 GET_FROM_CACHE(ArrayBufferWasNeutered) | 621 GET_FROM_CACHE(ArrayBufferWasNeutered) |
635 #undef GET_FROM_CACHE | 622 #undef GET_FROM_CACHE |
636 | 623 |
637 const Operator* SimplifiedOperatorBuilder::ChangeFloat64ToTagged( | |
638 CheckForMinusZeroMode mode) { | |
639 switch (mode) { | |
640 case CheckForMinusZeroMode::kCheckForMinusZero: | |
641 return &cache_.kChangeFloat64ToTaggedCheckForMinusZeroOperator; | |
642 case CheckForMinusZeroMode::kDontCheckForMinusZero: | |
643 return &cache_.kChangeFloat64ToTaggedDontCheckForMinusZeroOperator; | |
644 } | |
645 UNREACHABLE(); | |
646 return nullptr; | |
647 } | |
648 | |
649 const Operator* SimplifiedOperatorBuilder::CheckedInt32Mul( | 624 const Operator* SimplifiedOperatorBuilder::CheckedInt32Mul( |
650 CheckForMinusZeroMode mode) { | 625 CheckForMinusZeroMode mode) { |
651 switch (mode) { | 626 switch (mode) { |
652 case CheckForMinusZeroMode::kCheckForMinusZero: | 627 case CheckForMinusZeroMode::kCheckForMinusZero: |
653 return &cache_.kCheckedInt32MulCheckForMinusZeroOperator; | 628 return &cache_.kCheckedInt32MulCheckForMinusZeroOperator; |
654 case CheckForMinusZeroMode::kDontCheckForMinusZero: | 629 case CheckForMinusZeroMode::kDontCheckForMinusZero: |
655 return &cache_.kCheckedInt32MulDontCheckForMinusZeroOperator; | 630 return &cache_.kCheckedInt32MulDontCheckForMinusZeroOperator; |
656 } | 631 } |
657 UNREACHABLE(); | 632 UNREACHABLE(); |
658 return nullptr; | 633 return nullptr; |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
813 Operator::kNoDeopt | Operator::kNoThrow | properties, \ | 788 Operator::kNoDeopt | Operator::kNoThrow | properties, \ |
814 #Name, value_input_count, 1, control_input_count, \ | 789 #Name, value_input_count, 1, control_input_count, \ |
815 output_count, 1, 0, access); \ | 790 output_count, 1, 0, access); \ |
816 } | 791 } |
817 ACCESS_OP_LIST(ACCESS) | 792 ACCESS_OP_LIST(ACCESS) |
818 #undef ACCESS | 793 #undef ACCESS |
819 | 794 |
820 } // namespace compiler | 795 } // namespace compiler |
821 } // namespace internal | 796 } // namespace internal |
822 } // namespace v8 | 797 } // namespace v8 |
OLD | NEW |