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

Side by Side Diff: src/hydrogen-instructions.h

Issue 12189006: Suggestions for iDef infrastructure classes. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/hydrogen-instructions.cc » ('j') | src/hydrogen-instructions.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 V(LoadKeyed) \ 138 V(LoadKeyed) \
139 V(LoadKeyedGeneric) \ 139 V(LoadKeyedGeneric) \
140 V(LoadNamedField) \ 140 V(LoadNamedField) \
141 V(LoadNamedFieldPolymorphic) \ 141 V(LoadNamedFieldPolymorphic) \
142 V(LoadNamedGeneric) \ 142 V(LoadNamedGeneric) \
143 V(MapEnumLength) \ 143 V(MapEnumLength) \
144 V(MathFloorOfDiv) \ 144 V(MathFloorOfDiv) \
145 V(MathMinMax) \ 145 V(MathMinMax) \
146 V(Mod) \ 146 V(Mod) \
147 V(Mul) \ 147 V(Mul) \
148 V(NumericConstraint) \
148 V(ObjectLiteral) \ 149 V(ObjectLiteral) \
149 V(OsrEntry) \ 150 V(OsrEntry) \
150 V(OuterContext) \ 151 V(OuterContext) \
151 V(Parameter) \ 152 V(Parameter) \
152 V(Power) \ 153 V(Power) \
153 V(PushArgument) \ 154 V(PushArgument) \
154 V(Random) \ 155 V(Random) \
155 V(RegExpLiteral) \ 156 V(RegExpLiteral) \
156 V(Return) \ 157 V(Return) \
157 V(Ror) \ 158 V(Ror) \
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 } 830 }
830 831
831 bool IsDead() const { 832 bool IsDead() const {
832 return HasNoUses() && !HasObservableSideEffects() && IsDeletable(); 833 return HasNoUses() && !HasObservableSideEffects() && IsDeletable();
833 } 834 }
834 835
835 #ifdef DEBUG 836 #ifdef DEBUG
836 virtual void Verify() = 0; 837 virtual void Verify() = 0;
837 #endif 838 #endif
838 839
840 class NumericRelation {
841 public:
842 enum Kind { NONE, EQ, GT, GE, LT, LE, NE };
843 static const char* MnemonicFromKind(Kind kind) {
844 switch (kind) {
845 case NONE: return "NONE";
846 case EQ: return "EQ";
847 case GT: return "GT";
848 case GE: return "GE";
849 case LT: return "LT";
850 case LE: return "LE";
851 case NE: return "NE";
852 default:
Jakob Kummerow 2013/02/04 17:06:09 default case not necessary (and not desirable)
853 UNREACHABLE();
854 return "UNREACHABLE";
855 }
856 }
857 const char* Mnemonic() const { return MnemonicFromKind((Kind) kind_); }
Jakob Kummerow 2013/02/04 17:06:09 no C-style casts, please. Also, no casting necessa
858
859 explicit NumericRelation(Kind kind) : kind_(kind) {}
860
861 static NumericRelation None() { return NumericRelation(NONE); }
Jakob Kummerow 2013/02/04 17:06:09 Why do we need all of these when we have the gener
862 static NumericRelation Eq() { return NumericRelation(EQ); }
863 static NumericRelation Gt() { return NumericRelation(GT); }
864 static NumericRelation Ge() { return NumericRelation(GE); }
865 static NumericRelation Lt() { return NumericRelation(LT); }
866 static NumericRelation Le() { return NumericRelation(LE); }
867 static NumericRelation Ne() { return NumericRelation(NE); }
868
869 bool operator=(const NumericRelation& other) {
Jakob Kummerow 2013/02/04 17:06:09 I think you mean "operator==". But regardless, a .
870 return kind_ == other.kind_;
871 }
872 bool operator!=(const NumericRelation& other) {
873 return kind_ != other.kind_;
874 }
875
876 // The semantics of "Reversed" is that if "x rel y" is true then also
877 // "y rel.Reversed x" is true.
878 NumericRelation Reversed() {
879 switch (kind_) {
880 case NONE: return None();
881 case EQ: return Ne();
Jakob Kummerow 2013/02/04 17:06:09 No.
882 case GT: return Le();
883 case GE: return Lt();
884 case LT: return Ge();
885 case LE: return Gt();
886 case NE: return Eq();
Jakob Kummerow 2013/02/04 17:06:09 No.
887 default:
Jakob Kummerow 2013/02/04 17:06:09 no default case please
888 UNREACHABLE();
889 return None();
890 }
891 }
892
893 // The semantics of "Implies" is that if "x rel y" is true then also
894 // "(x + delta) other (y + offset)" is true.
895 bool Implies(NumericRelation other, int32_t offset = 0, int delta = 0) {
Jakob Kummerow 2013/02/04 17:06:09 Why do |offset| and |delta| have different types?
896 switch (kind_) {
897 case NONE: return false;
898 case EQ: return (other.kind_ == EQ && offset == delta) ||
899 (other.kind_ == EQ && offset == delta) ||
Jakob Kummerow 2013/02/04 17:06:09 duplicate condition
900 (other.kind_ == GT && offset > delta) ||
Jakob Kummerow 2013/02/04 17:06:09 No. And many of the conditions below are mixed up
901 (other.kind_ == GE && offset <= delta) ||
902 (other.kind_ == LT && offset < delta) ||
903 (other.kind_ == LE && offset <= delta) ||
904 (other.kind_ == NE && offset != delta);
905 case GT: return (other.kind_ == GT && offset >= delta) ||
906 (other.kind_ == GE && offset > delta);
907 case GE: return (other.kind_ == GE && offset >= delta) ||
908 (other.kind_ == GT && offset >= delta + 1);
Jakob Kummerow 2013/02/04 17:06:09 Why the sudden change from "a > b" to "a >= b+1"?
909 case LT: return (other.kind_ == LT && offset <= delta) ||
910 (other.kind_ == LE && offset < delta);
911 case LE: return (other.kind_ == LE && offset <= delta) ||
912 (other.kind_ == LT && offset <= delta - 1);
913 case NE: return (other.kind_ == NE && offset == delta);
914 default:
Jakob Kummerow 2013/02/04 17:06:09 no default case please
915 UNREACHABLE();
916 return false;
917 }
918 }
919
920 private:
921 int8_t kind_;
Jakob Kummerow 2013/02/04 17:06:09 Why not "Kind kind_;"?
922 };
923
924 bool IsInteger32ConstantValue();
Jakob Kummerow 2013/02/04 17:06:09 Where are these implemented?
925 int32_t GetInteger32ConstantValue();
926 bool DecomposeValuePlusConstant(HValue** value, int32_t* constant);
927
928 bool IsRelationTrue(NumericRelation relation,
929 HValue* other,
930 int32_t offset = 0) {
931 bool result = CheckRelation(relation, other, offset) ||
Jakob Kummerow 2013/02/04 17:06:09 "this->CheckRelation" won't compile, because |this
932 other->CheckRelation(relation.Reversed(), this, -offset);
933 return result;
934 }
935
936 HValue* InsertNumericConstraint(HInstruction* insertion_point,
937 NumericRelation relation,
938 HValue* other,
939 int32_t offset = 0);
940
839 protected: 941 protected:
840 // This function must be overridden for instructions with flag kUseGVN, to 942 // This function must be overridden for instructions with flag kUseGVN, to
841 // compare the non-Operand parts of the instruction. 943 // compare the non-Operand parts of the instruction.
842 virtual bool DataEquals(HValue* other) { 944 virtual bool DataEquals(HValue* other) {
843 UNREACHABLE(); 945 UNREACHABLE();
844 return false; 946 return false;
845 } 947 }
846 948
847 virtual Representation RepresentationFromInputs() { 949 virtual Representation RepresentationFromInputs() {
848 return representation(); 950 return representation();
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
1115 virtual Representation RequiredInputRepresentation(int index) { 1217 virtual Representation RequiredInputRepresentation(int index) {
1116 return Representation::None(); 1218 return Representation::None();
1117 } 1219 }
1118 1220
1119 virtual void PrintDataTo(StringStream* stream); 1221 virtual void PrintDataTo(StringStream* stream);
1120 1222
1121 DECLARE_CONCRETE_INSTRUCTION(DummyUse); 1223 DECLARE_CONCRETE_INSTRUCTION(DummyUse);
1122 }; 1224 };
1123 1225
1124 1226
1227 class HNumericConstraint : public HTemplateInstruction<2> {
1228 public:
1229 static void AddImpliedConstraints(HInstruction* insertion_point,
Jakob Kummerow 2013/02/04 17:06:09 I don't see an implementation for this.
1230 HValue* input,
Jakob Kummerow 2013/02/04 17:06:09 I'd like a more descriptive name here. "constraine
1231 NumericRelation constraint,
Jakob Kummerow 2013/02/04 17:06:09 Since we have classes calld [H]NumericConstraint a
1232 HValue* value,
Jakob Kummerow 2013/02/04 17:06:09 "value" is a bit too generic. How about "reference
1233 int delta = 0);
1234
1235 static HNumericConstraint* New(HInstruction* insertion_point,
Jakob Kummerow 2013/02/04 17:06:09 So, we have five method with almost equal signatur
1236 HValue* input,
1237 NumericRelation constraint,
1238 HValue* value,
1239 int delta = 0);
1240
1241 HValue* input() { return OperandAt(0); }
1242 HValue* value() { return OperandAt(1); }
1243 NumericRelation constraint() { return constraint_; }
1244 int delta() { return delta_; }
1245
1246 virtual int RedefinedOperandIndex() { return 0; }
1247
1248 virtual Representation RequiredInputRepresentation(int index) {
1249 return input()->RequiredInputRepresentation(index);
1250 }
1251
1252 virtual void PrintDataTo(StringStream* stream);
1253 //virtual void AddInformativeDefinitions();
Jakob Kummerow 2013/02/04 17:06:09 ?
1254 virtual bool CheckRelation(NumericRelation relation,
1255 HValue* other,
1256 int32_t offset);
1257
1258
1259 DECLARE_CONCRETE_INSTRUCTION(NumericConstraint)
1260
1261 private:
1262 explicit HNumericConstraint(HInstruction* insertion_point,
1263 HValue* input,
1264 NumericRelation constraint,
1265 HValue* value,
1266 int delta);
1267
1268 static HNumericConstraint* Create(HInstruction* insertion_point,
1269 HValue* input,
1270 NumericRelation constraint,
1271 HValue* value,
1272 int delta = 0);
1273 NumericRelation constraint_;
1274 int delta_;
1275 };
1276
1277
1125 // We insert soft-deoptimize when we hit code with unknown typefeedback, 1278 // We insert soft-deoptimize when we hit code with unknown typefeedback,
1126 // so that we get a chance of re-optimizing with useful typefeedback. 1279 // so that we get a chance of re-optimizing with useful typefeedback.
1127 // HSoftDeoptimize does not end a basic block as opposed to HDeoptimize. 1280 // HSoftDeoptimize does not end a basic block as opposed to HDeoptimize.
1128 class HSoftDeoptimize: public HTemplateInstruction<0> { 1281 class HSoftDeoptimize: public HTemplateInstruction<0> {
1129 public: 1282 public:
1130 virtual Representation RequiredInputRepresentation(int index) { 1283 virtual Representation RequiredInputRepresentation(int index) {
1131 return Representation::None(); 1284 return Representation::None();
1132 } 1285 }
1133 1286
1134 DECLARE_CONCRETE_INSTRUCTION(SoftDeoptimize) 1287 DECLARE_CONCRETE_INSTRUCTION(SoftDeoptimize)
(...skipping 4474 matching lines...) Expand 10 before | Expand all | Expand 10 after
5609 virtual bool IsDeletable() const { return true; } 5762 virtual bool IsDeletable() const { return true; }
5610 }; 5763 };
5611 5764
5612 5765
5613 #undef DECLARE_INSTRUCTION 5766 #undef DECLARE_INSTRUCTION
5614 #undef DECLARE_CONCRETE_INSTRUCTION 5767 #undef DECLARE_CONCRETE_INSTRUCTION
5615 5768
5616 } } // namespace v8::internal 5769 } } // namespace v8::internal
5617 5770
5618 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ 5771 #endif // V8_HYDROGEN_INSTRUCTIONS_H_
OLDNEW
« no previous file with comments | « no previous file | src/hydrogen-instructions.cc » ('j') | src/hydrogen-instructions.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698