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

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

Issue 7634022: Insert representation changes before doing range analysis. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 4 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
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 : lower_(lower), 220 : lower_(lower),
221 upper_(upper), 221 upper_(upper),
222 next_(NULL), 222 next_(NULL),
223 can_be_minus_zero_(false) { } 223 can_be_minus_zero_(false) { }
224 224
225 int32_t upper() const { return upper_; } 225 int32_t upper() const { return upper_; }
226 int32_t lower() const { return lower_; } 226 int32_t lower() const { return lower_; }
227 Range* next() const { return next_; } 227 Range* next() const { return next_; }
228 Range* CopyClearLower() const { return new Range(kMinInt, upper_); } 228 Range* CopyClearLower() const { return new Range(kMinInt, upper_); }
229 Range* CopyClearUpper() const { return new Range(lower_, kMaxInt); } 229 Range* CopyClearUpper() const { return new Range(lower_, kMaxInt); }
230 Range* Copy() const { return new Range(lower_, upper_); } 230 Range* Copy() const {
231 Range* result = new Range(lower_, upper_);
232 result->set_can_be_minus_zero(CanBeMinusZero());
233 return result;
234 }
231 int32_t Mask() const; 235 int32_t Mask() const;
232 void set_can_be_minus_zero(bool b) { can_be_minus_zero_ = b; } 236 void set_can_be_minus_zero(bool b) { can_be_minus_zero_ = b; }
233 bool CanBeMinusZero() const { return CanBeZero() && can_be_minus_zero_; } 237 bool CanBeMinusZero() const { return CanBeZero() && can_be_minus_zero_; }
234 bool CanBeZero() const { return upper_ >= 0 && lower_ <= 0; } 238 bool CanBeZero() const { return upper_ >= 0 && lower_ <= 0; }
235 bool CanBeNegative() const { return lower_ < 0; } 239 bool CanBeNegative() const { return lower_ < 0; }
236 bool Includes(int value) const { return lower_ <= value && upper_ >= value; } 240 bool Includes(int value) const { return lower_ <= value && upper_ >= value; }
237 bool IsMostGeneric() const { return lower_ == kMinInt && upper_ == kMaxInt; } 241 bool IsMostGeneric() const {
242 return lower_ == kMinInt && upper_ == kMaxInt && CanBeMinusZero();
243 }
238 bool IsInSmiRange() const { 244 bool IsInSmiRange() const {
239 return lower_ >= Smi::kMinValue && upper_ <= Smi::kMaxValue; 245 return lower_ >= Smi::kMinValue && upper_ <= Smi::kMaxValue;
240 } 246 }
241 void KeepOrder(); 247 void KeepOrder();
242 void Verify() const; 248 void Verify() const;
243 249
244 void StackUpon(Range* other) { 250 void StackUpon(Range* other) {
245 Intersect(other); 251 Intersect(other);
246 next_ = other; 252 next_ = other;
247 } 253 }
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 ASSERT(!r.IsNone()); 577 ASSERT(!r.IsNone());
572 ASSERT(CheckFlag(kFlexibleRepresentation)); 578 ASSERT(CheckFlag(kFlexibleRepresentation));
573 RepresentationChanged(r); 579 RepresentationChanged(r);
574 representation_ = r; 580 representation_ = r;
575 } 581 }
576 void AssumeRepresentation(Representation r); 582 void AssumeRepresentation(Representation r);
577 583
578 virtual bool IsConvertibleToInteger() const { return true; } 584 virtual bool IsConvertibleToInteger() const { return true; }
579 585
580 HType type() const { return type_; } 586 HType type() const { return type_; }
581 void set_type(HType type) { 587 void set_type(HType new_type) {
582 ASSERT(HasNoUses()); 588 ASSERT(new_type.IsSubtypeOf(type_));
583 type_ = type; 589 type_ = new_type;
584 } 590 }
585 591
586 // An operation needs to override this function iff: 592 // An operation needs to override this function iff:
587 // 1) it can produce an int32 output. 593 // 1) it can produce an int32 output.
588 // 2) the true value of its output can potentially be minus zero. 594 // 2) the true value of its output can potentially be minus zero.
589 // The implementation must set a flag so that it bails out in the case where 595 // The implementation must set a flag so that it bails out in the case where
590 // it would otherwise output what should be a minus zero as an int32 zero. 596 // it would otherwise output what should be a minus zero as an int32 zero.
591 // If the operation also exists in a form that takes int32 and outputs int32 597 // If the operation also exists in a form that takes int32 and outputs int32
592 // then the operation should return its input value so that we can propagate 598 // then the operation should return its input value so that we can propagate
593 // back. There are three operations that need to propagate back to more than 599 // back. There are three operations that need to propagate back to more than
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
1093 bool is_truncating, 1099 bool is_truncating,
1094 bool deoptimize_on_undefined) 1100 bool deoptimize_on_undefined)
1095 : HUnaryOperation(value), 1101 : HUnaryOperation(value),
1096 from_(from), 1102 from_(from),
1097 deoptimize_on_undefined_(deoptimize_on_undefined) { 1103 deoptimize_on_undefined_(deoptimize_on_undefined) {
1098 ASSERT(!from.IsNone() && !to.IsNone()); 1104 ASSERT(!from.IsNone() && !to.IsNone());
1099 ASSERT(!from.Equals(to)); 1105 ASSERT(!from.Equals(to));
1100 set_representation(to); 1106 set_representation(to);
1101 SetFlag(kUseGVN); 1107 SetFlag(kUseGVN);
1102 if (is_truncating) SetFlag(kTruncatingToInt32); 1108 if (is_truncating) SetFlag(kTruncatingToInt32);
1103 if (from.IsInteger32() && to.IsTagged() && value->range() != NULL &&
1104 value->range()->IsInSmiRange()) {
1105 set_type(HType::Smi());
1106 }
1107 } 1109 }
1108 1110
1109 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); 1111 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited);
1110 1112
1111 Representation from() const { return from_; } 1113 Representation from() const { return from_; }
1112 Representation to() const { return representation(); } 1114 Representation to() const { return representation(); }
1113 bool deoptimize_on_undefined() const { return deoptimize_on_undefined_; } 1115 bool deoptimize_on_undefined() const { return deoptimize_on_undefined_; }
1114 virtual Representation RequiredInputRepresentation(int index) const { 1116 virtual Representation RequiredInputRepresentation(int index) const {
1115 return from_; 1117 return from_;
1116 } 1118 }
1117 1119
1120 virtual Range* InferRange();
1121
1118 virtual void PrintDataTo(StringStream* stream); 1122 virtual void PrintDataTo(StringStream* stream);
1119 1123
1120 DECLARE_CONCRETE_INSTRUCTION(Change) 1124 DECLARE_CONCRETE_INSTRUCTION(Change)
1121 1125
1122 protected: 1126 protected:
1123 virtual bool DataEquals(HValue* other) { 1127 virtual bool DataEquals(HValue* other) {
1124 if (!other->IsChange()) return false; 1128 if (!other->IsChange()) return false;
1125 HChange* change = HChange::cast(other); 1129 HChange* change = HChange::cast(other);
1126 return to().Equals(change->to()) 1130 return to().Equals(change->to())
1127 && deoptimize_on_undefined() == change->deoptimize_on_undefined(); 1131 && deoptimize_on_undefined() == change->deoptimize_on_undefined();
(...skipping 3059 matching lines...) Expand 10 before | Expand all | Expand 10 after
4187 4191
4188 DECLARE_CONCRETE_INSTRUCTION(In) 4192 DECLARE_CONCRETE_INSTRUCTION(In)
4189 }; 4193 };
4190 4194
4191 #undef DECLARE_INSTRUCTION 4195 #undef DECLARE_INSTRUCTION
4192 #undef DECLARE_CONCRETE_INSTRUCTION 4196 #undef DECLARE_CONCRETE_INSTRUCTION
4193 4197
4194 } } // namespace v8::internal 4198 } } // namespace v8::internal
4195 4199
4196 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ 4200 #endif // V8_HYDROGEN_INSTRUCTIONS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698