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

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

Issue 9286002: Eliminate overflow check after integer add and sub if result is truncated to int32. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Eliminate overflow check after integer add and sub if result is truncated to int32. Created 8 years, 9 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 | « src/hydrogen.cc ('k') | src/hydrogen-instructions.cc » ('j') | no next file with comments »
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 627 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 int UseCount() const; 638 int UseCount() const;
639 639
640 // Mark this HValue as dead and to be removed from other HValues' use lists. 640 // Mark this HValue as dead and to be removed from other HValues' use lists.
641 void Kill(); 641 void Kill();
642 642
643 int flags() const { return flags_; } 643 int flags() const { return flags_; }
644 void SetFlag(Flag f) { flags_ |= (1 << f); } 644 void SetFlag(Flag f) { flags_ |= (1 << f); }
645 void ClearFlag(Flag f) { flags_ &= ~(1 << f); } 645 void ClearFlag(Flag f) { flags_ &= ~(1 << f); }
646 bool CheckFlag(Flag f) const { return (flags_ & (1 << f)) != 0; } 646 bool CheckFlag(Flag f) const { return (flags_ & (1 << f)) != 0; }
647 647
648 // Returns true if the flag specified is set for all uses, false otherwise.
649 bool CheckUsesForFlag(Flag f);
650
648 GVNFlagSet gvn_flags() const { return gvn_flags_; } 651 GVNFlagSet gvn_flags() const { return gvn_flags_; }
649 void SetGVNFlag(GVNFlag f) { gvn_flags_.Add(f); } 652 void SetGVNFlag(GVNFlag f) { gvn_flags_.Add(f); }
650 void ClearGVNFlag(GVNFlag f) { gvn_flags_.Remove(f); } 653 void ClearGVNFlag(GVNFlag f) { gvn_flags_.Remove(f); }
651 bool CheckGVNFlag(GVNFlag f) const { return gvn_flags_.Contains(f); } 654 bool CheckGVNFlag(GVNFlag f) const { return gvn_flags_.Contains(f); }
652 void SetAllSideEffects() { gvn_flags_.Add(AllSideEffectsFlagSet()); } 655 void SetAllSideEffects() { gvn_flags_.Add(AllSideEffectsFlagSet()); }
653 void ClearAllSideEffects() { 656 void ClearAllSideEffects() {
654 gvn_flags_.Remove(AllSideEffectsFlagSet()); 657 gvn_flags_.Remove(AllSideEffectsFlagSet());
655 } 658 }
656 bool HasSideEffects() const { 659 bool HasSideEffects() const {
657 return gvn_flags_.ContainsAnyOf(AllSideEffectsFlagSet()); 660 return gvn_flags_.ContainsAnyOf(AllSideEffectsFlagSet());
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 820
818 bool IsLinked() const { return block() != NULL; } 821 bool IsLinked() const { return block() != NULL; }
819 void Unlink(); 822 void Unlink();
820 void InsertBefore(HInstruction* next); 823 void InsertBefore(HInstruction* next);
821 void InsertAfter(HInstruction* previous); 824 void InsertAfter(HInstruction* previous);
822 825
823 int position() const { return position_; } 826 int position() const { return position_; }
824 bool has_position() const { return position_ != RelocInfo::kNoPosition; } 827 bool has_position() const { return position_ != RelocInfo::kNoPosition; }
825 void set_position(int position) { position_ = position; } 828 void set_position(int position) { position_ = position; }
826 829
830 bool CanTruncateToInt32() const { return CheckFlag(kTruncatingToInt32); }
831
827 virtual LInstruction* CompileToLithium(LChunkBuilder* builder) = 0; 832 virtual LInstruction* CompileToLithium(LChunkBuilder* builder) = 0;
828 833
829 #ifdef DEBUG 834 #ifdef DEBUG
830 virtual void Verify(); 835 virtual void Verify();
831 #endif 836 #endif
832 837
833 virtual bool IsCall() { return false; } 838 virtual bool IsCall() { return false; }
834 839
835 DECLARE_ABSTRACT_INSTRUCTION(Instruction) 840 DECLARE_ABSTRACT_INSTRUCTION(Instruction)
836 841
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
1114 class HUnaryOperation: public HTemplateInstruction<1> { 1119 class HUnaryOperation: public HTemplateInstruction<1> {
1115 public: 1120 public:
1116 explicit HUnaryOperation(HValue* value) { 1121 explicit HUnaryOperation(HValue* value) {
1117 SetOperandAt(0, value); 1122 SetOperandAt(0, value);
1118 } 1123 }
1119 1124
1120 static HUnaryOperation* cast(HValue* value) { 1125 static HUnaryOperation* cast(HValue* value) {
1121 return reinterpret_cast<HUnaryOperation*>(value); 1126 return reinterpret_cast<HUnaryOperation*>(value);
1122 } 1127 }
1123 1128
1124 virtual bool CanTruncateToInt32() const {
1125 return CheckFlag(kTruncatingToInt32);
1126 }
1127
1128 HValue* value() { return OperandAt(0); } 1129 HValue* value() { return OperandAt(0); }
1129 virtual void PrintDataTo(StringStream* stream); 1130 virtual void PrintDataTo(StringStream* stream);
1130 }; 1131 };
1131 1132
1132 1133
1133 class HThrow: public HTemplateInstruction<2> { 1134 class HThrow: public HTemplateInstruction<2> {
1134 public: 1135 public:
1135 HThrow(HValue* context, HValue* value) { 1136 HThrow(HValue* context, HValue* value) {
1136 SetOperandAt(0, context); 1137 SetOperandAt(0, context);
1137 SetOperandAt(1, value); 1138 SetOperandAt(1, value);
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1241 virtual bool DataEquals(HValue* other) { return true; } 1242 virtual bool DataEquals(HValue* other) { return true; }
1242 }; 1243 };
1243 1244
1244 1245
1245 class HToInt32: public HUnaryOperation { 1246 class HToInt32: public HUnaryOperation {
1246 public: 1247 public:
1247 explicit HToInt32(HValue* value) 1248 explicit HToInt32(HValue* value)
1248 : HUnaryOperation(value) { 1249 : HUnaryOperation(value) {
1249 set_representation(Representation::Integer32()); 1250 set_representation(Representation::Integer32());
1250 SetFlag(kUseGVN); 1251 SetFlag(kUseGVN);
1252 SetFlag(kTruncatingToInt32);
1251 } 1253 }
1252 1254
1253 virtual Representation RequiredInputRepresentation(int index) { 1255 virtual Representation RequiredInputRepresentation(int index) {
1254 return Representation::None(); 1256 return Representation::None();
1255 } 1257 }
1256 1258
1257 virtual bool CanTruncateToInt32() const {
1258 return true;
1259 }
1260
1261 virtual HValue* Canonicalize() { 1259 virtual HValue* Canonicalize() {
1262 if (value()->representation().IsInteger32()) { 1260 if (value()->representation().IsInteger32()) {
1263 return value(); 1261 return value();
1264 } else { 1262 } else {
1265 return this; 1263 return this;
1266 } 1264 }
1267 } 1265 }
1268 1266
1269 DECLARE_CONCRETE_INSTRUCTION(ToInt32) 1267 DECLARE_CONCRETE_INSTRUCTION(ToInt32)
1270 1268
(...skipping 1876 matching lines...) Expand 10 before | Expand all | Expand 10 after
3147 3145
3148 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); 3146 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited);
3149 3147
3150 static HInstruction* NewHAdd(Zone* zone, 3148 static HInstruction* NewHAdd(Zone* zone,
3151 HValue* context, 3149 HValue* context,
3152 HValue* left, 3150 HValue* left,
3153 HValue* right); 3151 HValue* right);
3154 3152
3155 virtual HType CalculateInferredType(); 3153 virtual HType CalculateInferredType();
3156 3154
3155 virtual HValue* Canonicalize();
3156
3157 DECLARE_CONCRETE_INSTRUCTION(Add) 3157 DECLARE_CONCRETE_INSTRUCTION(Add)
3158 3158
3159 protected: 3159 protected:
3160 virtual bool DataEquals(HValue* other) { return true; } 3160 virtual bool DataEquals(HValue* other) { return true; }
3161 3161
3162 virtual Range* InferRange(Zone* zone); 3162 virtual Range* InferRange(Zone* zone);
3163 }; 3163 };
3164 3164
3165 3165
3166 class HSub: public HArithmeticBinaryOperation { 3166 class HSub: public HArithmeticBinaryOperation {
3167 public: 3167 public:
3168 HSub(HValue* context, HValue* left, HValue* right) 3168 HSub(HValue* context, HValue* left, HValue* right)
3169 : HArithmeticBinaryOperation(context, left, right) { 3169 : HArithmeticBinaryOperation(context, left, right) {
3170 SetFlag(kCanOverflow); 3170 SetFlag(kCanOverflow);
3171 } 3171 }
3172 3172
3173 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); 3173 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited);
3174 3174
3175 virtual HValue* Canonicalize();
3176
3175 static HInstruction* NewHSub(Zone* zone, 3177 static HInstruction* NewHSub(Zone* zone,
3176 HValue* context, 3178 HValue* context,
3177 HValue* left, 3179 HValue* left,
3178 HValue* right); 3180 HValue* right);
3179 3181
3180 DECLARE_CONCRETE_INSTRUCTION(Sub) 3182 DECLARE_CONCRETE_INSTRUCTION(Sub)
3181 3183
3182 protected: 3184 protected:
3183 virtual bool DataEquals(HValue* other) { return true; } 3185 virtual bool DataEquals(HValue* other) { return true; }
3184 3186
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
3250 class HDiv: public HArithmeticBinaryOperation { 3252 class HDiv: public HArithmeticBinaryOperation {
3251 public: 3253 public:
3252 HDiv(HValue* context, HValue* left, HValue* right) 3254 HDiv(HValue* context, HValue* left, HValue* right)
3253 : HArithmeticBinaryOperation(context, left, right) { 3255 : HArithmeticBinaryOperation(context, left, right) {
3254 SetFlag(kCanBeDivByZero); 3256 SetFlag(kCanBeDivByZero);
3255 SetFlag(kCanOverflow); 3257 SetFlag(kCanOverflow);
3256 } 3258 }
3257 3259
3258 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); 3260 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited);
3259 3261
3260
3261 static HInstruction* NewHDiv(Zone* zone, 3262 static HInstruction* NewHDiv(Zone* zone,
3262 HValue* context, 3263 HValue* context,
3263 HValue* left, 3264 HValue* left,
3264 HValue* right); 3265 HValue* right);
3265 3266
3266 DECLARE_CONCRETE_INSTRUCTION(Div) 3267 DECLARE_CONCRETE_INSTRUCTION(Div)
3267 3268
3268 protected: 3269 protected:
3269 virtual bool DataEquals(HValue* other) { return true; } 3270 virtual bool DataEquals(HValue* other) { return true; }
3270 3271
(...skipping 1532 matching lines...) Expand 10 before | Expand all | Expand 10 after
4803 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex); 4804 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex);
4804 }; 4805 };
4805 4806
4806 4807
4807 #undef DECLARE_INSTRUCTION 4808 #undef DECLARE_INSTRUCTION
4808 #undef DECLARE_CONCRETE_INSTRUCTION 4809 #undef DECLARE_CONCRETE_INSTRUCTION
4809 4810
4810 } } // namespace v8::internal 4811 } } // namespace v8::internal
4811 4812
4812 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ 4813 #endif // V8_HYDROGEN_INSTRUCTIONS_H_
OLDNEW
« no previous file with comments | « src/hydrogen.cc ('k') | src/hydrogen-instructions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698