Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: src/compiler/simplified-operator.cc

Issue 2815283002: [turbofan] Let ChangeFloat64ToTagged canonicalize to Smi if possible. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 UNREACHABLE(); 206 UNREACHABLE();
207 return os; 207 return os;
208 } 208 }
209 209
210 CheckFloat64HoleMode CheckFloat64HoleModeOf(const Operator* op) { 210 CheckFloat64HoleMode CheckFloat64HoleModeOf(const Operator* op) {
211 DCHECK_EQ(IrOpcode::kCheckFloat64Hole, op->opcode()); 211 DCHECK_EQ(IrOpcode::kCheckFloat64Hole, op->opcode());
212 return OpParameter<CheckFloat64HoleMode>(op); 212 return OpParameter<CheckFloat64HoleMode>(op);
213 } 213 }
214 214
215 CheckForMinusZeroMode CheckMinusZeroModeOf(const Operator* op) { 215 CheckForMinusZeroMode CheckMinusZeroModeOf(const Operator* op) {
216 DCHECK(op->opcode() == IrOpcode::kCheckedInt32Mul || 216 DCHECK(op->opcode() == IrOpcode::kChangeFloat64ToTagged ||
217 op->opcode() == IrOpcode::kCheckedInt32Mul ||
217 op->opcode() == IrOpcode::kCheckedFloat64ToInt32 || 218 op->opcode() == IrOpcode::kCheckedFloat64ToInt32 ||
218 op->opcode() == IrOpcode::kCheckedTaggedToInt32); 219 op->opcode() == IrOpcode::kCheckedTaggedToInt32);
219 return OpParameter<CheckForMinusZeroMode>(op); 220 return OpParameter<CheckForMinusZeroMode>(op);
220 } 221 }
221 222
222 size_t hash_value(CheckForMinusZeroMode mode) { 223 size_t hash_value(CheckForMinusZeroMode mode) {
223 return static_cast<size_t>(mode); 224 return static_cast<size_t>(mode);
224 } 225 }
225 226
226 std::ostream& operator<<(std::ostream& os, CheckForMinusZeroMode mode) { 227 std::ostream& operator<<(std::ostream& os, CheckForMinusZeroMode mode) {
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 V(StringFromCharCode, Operator::kNoProperties, 1, 0) \ 482 V(StringFromCharCode, Operator::kNoProperties, 1, 0) \
482 V(StringIndexOf, Operator::kNoProperties, 3, 0) \ 483 V(StringIndexOf, Operator::kNoProperties, 3, 0) \
483 V(PlainPrimitiveToNumber, Operator::kNoProperties, 1, 0) \ 484 V(PlainPrimitiveToNumber, Operator::kNoProperties, 1, 0) \
484 V(PlainPrimitiveToWord32, Operator::kNoProperties, 1, 0) \ 485 V(PlainPrimitiveToWord32, Operator::kNoProperties, 1, 0) \
485 V(PlainPrimitiveToFloat64, Operator::kNoProperties, 1, 0) \ 486 V(PlainPrimitiveToFloat64, Operator::kNoProperties, 1, 0) \
486 V(ChangeTaggedSignedToInt32, Operator::kNoProperties, 1, 0) \ 487 V(ChangeTaggedSignedToInt32, Operator::kNoProperties, 1, 0) \
487 V(ChangeTaggedToInt32, Operator::kNoProperties, 1, 0) \ 488 V(ChangeTaggedToInt32, Operator::kNoProperties, 1, 0) \
488 V(ChangeTaggedToUint32, Operator::kNoProperties, 1, 0) \ 489 V(ChangeTaggedToUint32, Operator::kNoProperties, 1, 0) \
489 V(ChangeTaggedToFloat64, Operator::kNoProperties, 1, 0) \ 490 V(ChangeTaggedToFloat64, Operator::kNoProperties, 1, 0) \
490 V(ChangeTaggedToTaggedSigned, Operator::kNoProperties, 1, 0) \ 491 V(ChangeTaggedToTaggedSigned, Operator::kNoProperties, 1, 0) \
491 V(ChangeFloat64ToTagged, Operator::kNoProperties, 1, 0) \
492 V(ChangeFloat64ToTaggedPointer, Operator::kNoProperties, 1, 0) \ 492 V(ChangeFloat64ToTaggedPointer, Operator::kNoProperties, 1, 0) \
493 V(ChangeInt31ToTaggedSigned, Operator::kNoProperties, 1, 0) \ 493 V(ChangeInt31ToTaggedSigned, Operator::kNoProperties, 1, 0) \
494 V(ChangeInt32ToTagged, Operator::kNoProperties, 1, 0) \ 494 V(ChangeInt32ToTagged, Operator::kNoProperties, 1, 0) \
495 V(ChangeUint32ToTagged, Operator::kNoProperties, 1, 0) \ 495 V(ChangeUint32ToTagged, Operator::kNoProperties, 1, 0) \
496 V(ChangeTaggedToBit, Operator::kNoProperties, 1, 0) \ 496 V(ChangeTaggedToBit, Operator::kNoProperties, 1, 0) \
497 V(ChangeBitToTagged, Operator::kNoProperties, 1, 0) \ 497 V(ChangeBitToTagged, Operator::kNoProperties, 1, 0) \
498 V(TruncateTaggedToBit, Operator::kNoProperties, 1, 0) \ 498 V(TruncateTaggedToBit, Operator::kNoProperties, 1, 0) \
499 V(TruncateTaggedPointerToBit, Operator::kNoProperties, 1, 0) \ 499 V(TruncateTaggedPointerToBit, Operator::kNoProperties, 1, 0) \
500 V(TruncateTaggedToWord32, Operator::kNoProperties, 1, 0) \ 500 V(TruncateTaggedToWord32, Operator::kNoProperties, 1, 0) \
501 V(TruncateTaggedToFloat64, Operator::kNoProperties, 1, 0) \ 501 V(TruncateTaggedToFloat64, Operator::kNoProperties, 1, 0) \
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 594
595 struct NewUnmappedArgumentsElementsOperator final : public Operator { 595 struct NewUnmappedArgumentsElementsOperator final : public Operator {
596 NewUnmappedArgumentsElementsOperator() 596 NewUnmappedArgumentsElementsOperator()
597 : Operator(IrOpcode::kNewUnmappedArgumentsElements, 597 : Operator(IrOpcode::kNewUnmappedArgumentsElements,
598 Operator::kEliminatable, "NewUnmappedArgumentsElements", 2, 598 Operator::kEliminatable, "NewUnmappedArgumentsElements", 2,
599 1, 0, 1, 1, 0) {} 599 1, 0, 1, 1, 0) {}
600 }; 600 };
601 NewUnmappedArgumentsElementsOperator kNewUnmappedArgumentsElements; 601 NewUnmappedArgumentsElementsOperator kNewUnmappedArgumentsElements;
602 602
603 template <CheckForMinusZeroMode kMode> 603 template <CheckForMinusZeroMode kMode>
604 struct ChangeFloat64ToTaggedOperator final
605 : public Operator1<CheckForMinusZeroMode> {
606 ChangeFloat64ToTaggedOperator()
607 : Operator1<CheckForMinusZeroMode>(
608 IrOpcode::kChangeFloat64ToTagged, Operator::kPure,
609 "ChangeFloat64ToTagged", 1, 0, 0, 1, 0, 0, kMode) {}
610 };
611 ChangeFloat64ToTaggedOperator<CheckForMinusZeroMode::kCheckForMinusZero>
612 kChangeFloat64ToTaggedCheckForMinusZeroOperator;
613 ChangeFloat64ToTaggedOperator<CheckForMinusZeroMode::kDontCheckForMinusZero>
614 kChangeFloat64ToTaggedDontCheckForMinusZeroOperator;
615
616 template <CheckForMinusZeroMode kMode>
604 struct CheckedInt32MulOperator final 617 struct CheckedInt32MulOperator final
605 : public Operator1<CheckForMinusZeroMode> { 618 : public Operator1<CheckForMinusZeroMode> {
606 CheckedInt32MulOperator() 619 CheckedInt32MulOperator()
607 : Operator1<CheckForMinusZeroMode>( 620 : Operator1<CheckForMinusZeroMode>(
608 IrOpcode::kCheckedInt32Mul, 621 IrOpcode::kCheckedInt32Mul,
609 Operator::kFoldable | Operator::kNoThrow, "CheckedInt32Mul", 2, 1, 622 Operator::kFoldable | Operator::kNoThrow, "CheckedInt32Mul", 2, 1,
610 1, 1, 1, 0, kMode) {} 623 1, 1, 1, 0, kMode) {}
611 }; 624 };
612 CheckedInt32MulOperator<CheckForMinusZeroMode::kCheckForMinusZero> 625 CheckedInt32MulOperator<CheckForMinusZeroMode::kCheckForMinusZero>
613 kCheckedInt32MulCheckForMinusZeroOperator; 626 kCheckedInt32MulCheckForMinusZeroOperator;
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 763
751 #define GET_FROM_CACHE(Name, ...) \ 764 #define GET_FROM_CACHE(Name, ...) \
752 const Operator* SimplifiedOperatorBuilder::Name() { return &cache_.k##Name; } 765 const Operator* SimplifiedOperatorBuilder::Name() { return &cache_.k##Name; }
753 PURE_OP_LIST(GET_FROM_CACHE) 766 PURE_OP_LIST(GET_FROM_CACHE)
754 CHECKED_OP_LIST(GET_FROM_CACHE) 767 CHECKED_OP_LIST(GET_FROM_CACHE)
755 GET_FROM_CACHE(ArrayBufferWasNeutered) 768 GET_FROM_CACHE(ArrayBufferWasNeutered)
756 GET_FROM_CACHE(ArgumentsFrame) 769 GET_FROM_CACHE(ArgumentsFrame)
757 GET_FROM_CACHE(NewUnmappedArgumentsElements) 770 GET_FROM_CACHE(NewUnmappedArgumentsElements)
758 #undef GET_FROM_CACHE 771 #undef GET_FROM_CACHE
759 772
773 const Operator* SimplifiedOperatorBuilder::ChangeFloat64ToTagged(
774 CheckForMinusZeroMode mode) {
775 switch (mode) {
776 case CheckForMinusZeroMode::kCheckForMinusZero:
777 return &cache_.kChangeFloat64ToTaggedCheckForMinusZeroOperator;
778 case CheckForMinusZeroMode::kDontCheckForMinusZero:
779 return &cache_.kChangeFloat64ToTaggedDontCheckForMinusZeroOperator;
780 }
781 UNREACHABLE();
782 return nullptr;
783 }
784
760 const Operator* SimplifiedOperatorBuilder::CheckedInt32Mul( 785 const Operator* SimplifiedOperatorBuilder::CheckedInt32Mul(
761 CheckForMinusZeroMode mode) { 786 CheckForMinusZeroMode mode) {
762 switch (mode) { 787 switch (mode) {
763 case CheckForMinusZeroMode::kCheckForMinusZero: 788 case CheckForMinusZeroMode::kCheckForMinusZero:
764 return &cache_.kCheckedInt32MulCheckForMinusZeroOperator; 789 return &cache_.kCheckedInt32MulCheckForMinusZeroOperator;
765 case CheckForMinusZeroMode::kDontCheckForMinusZero: 790 case CheckForMinusZeroMode::kDontCheckForMinusZero:
766 return &cache_.kCheckedInt32MulDontCheckForMinusZeroOperator; 791 return &cache_.kCheckedInt32MulDontCheckForMinusZeroOperator;
767 } 792 }
768 UNREACHABLE(); 793 UNREACHABLE();
769 return nullptr; 794 return nullptr;
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 Operator::kNoDeopt | Operator::kNoThrow | properties, \ 1018 Operator::kNoDeopt | Operator::kNoThrow | properties, \
994 #Name, value_input_count, 1, control_input_count, \ 1019 #Name, value_input_count, 1, control_input_count, \
995 output_count, 1, 0, access); \ 1020 output_count, 1, 0, access); \
996 } 1021 }
997 ACCESS_OP_LIST(ACCESS) 1022 ACCESS_OP_LIST(ACCESS)
998 #undef ACCESS 1023 #undef ACCESS
999 1024
1000 } // namespace compiler 1025 } // namespace compiler
1001 } // namespace internal 1026 } // namespace internal
1002 } // namespace v8 1027 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/simplified-operator.h ('k') | test/unittests/compiler/simplified-operator-reducer-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698