OLD | NEW |
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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 | 278 |
279 HUseListNode* HUseListNode::tail() { | 279 HUseListNode* HUseListNode::tail() { |
280 // Skip and remove dead items in the use list. | 280 // Skip and remove dead items in the use list. |
281 while (tail_ != NULL && tail_->value()->CheckFlag(HValue::kIsDead)) { | 281 while (tail_ != NULL && tail_->value()->CheckFlag(HValue::kIsDead)) { |
282 tail_ = tail_->tail_; | 282 tail_ = tail_->tail_; |
283 } | 283 } |
284 return tail_; | 284 return tail_; |
285 } | 285 } |
286 | 286 |
287 | 287 |
| 288 bool HValue::CheckUsesForFlag(Flag f) { |
| 289 for (HUseIterator it(uses()); !it.Done(); it.Advance()) { |
| 290 if (!it.value()->CheckFlag(f)) return false; |
| 291 } |
| 292 return true; |
| 293 } |
| 294 |
| 295 |
288 HUseIterator::HUseIterator(HUseListNode* head) : next_(head) { | 296 HUseIterator::HUseIterator(HUseListNode* head) : next_(head) { |
289 Advance(); | 297 Advance(); |
290 } | 298 } |
291 | 299 |
292 | 300 |
293 void HUseIterator::Advance() { | 301 void HUseIterator::Advance() { |
294 current_ = next_; | 302 current_ = next_; |
295 if (current_ != NULL) { | 303 if (current_ != NULL) { |
296 next_ = current_->tail(); | 304 next_ = current_->tail(); |
297 value_ = current_->value(); | 305 value_ = current_->value(); |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
824 | 832 |
825 | 833 |
826 void HLoadFieldByIndex::PrintDataTo(StringStream* stream) { | 834 void HLoadFieldByIndex::PrintDataTo(StringStream* stream) { |
827 object()->PrintNameTo(stream); | 835 object()->PrintNameTo(stream); |
828 stream->Add(" "); | 836 stream->Add(" "); |
829 index()->PrintNameTo(stream); | 837 index()->PrintNameTo(stream); |
830 } | 838 } |
831 | 839 |
832 | 840 |
833 HValue* HConstant::Canonicalize() { | 841 HValue* HConstant::Canonicalize() { |
834 return HasNoUses() && !IsBlockEntry() ? NULL : this; | 842 return HasNoUses() ? NULL : this; |
835 } | 843 } |
836 | 844 |
837 | 845 |
838 HValue* HTypeof::Canonicalize() { | 846 HValue* HTypeof::Canonicalize() { |
839 return HasNoUses() && !IsBlockEntry() ? NULL : this; | 847 return HasNoUses() ? NULL : this; |
840 } | 848 } |
841 | 849 |
842 | 850 |
843 HValue* HBitwise::Canonicalize() { | 851 HValue* HBitwise::Canonicalize() { |
844 if (!representation().IsInteger32()) return this; | 852 if (!representation().IsInteger32()) return this; |
845 // If x is an int32, then x & -1 == x, x | 0 == x and x ^ 0 == x. | 853 // If x is an int32, then x & -1 == x, x | 0 == x and x ^ 0 == x. |
846 int32_t nop_constant = (op() == Token::BIT_AND) ? -1 : 0; | 854 int32_t nop_constant = (op() == Token::BIT_AND) ? -1 : 0; |
847 if (left()->IsConstant() && | 855 if (left()->IsConstant() && |
848 HConstant::cast(left())->HasInteger32Value() && | 856 HConstant::cast(left())->HasInteger32Value() && |
849 HConstant::cast(left())->Integer32Value() == nop_constant) { | 857 HConstant::cast(left())->Integer32Value() == nop_constant) { |
850 return right(); | 858 return right(); |
851 } | 859 } |
852 if (right()->IsConstant() && | 860 if (right()->IsConstant() && |
853 HConstant::cast(right())->HasInteger32Value() && | 861 HConstant::cast(right())->HasInteger32Value() && |
854 HConstant::cast(right())->Integer32Value() == nop_constant) { | 862 HConstant::cast(right())->Integer32Value() == nop_constant) { |
855 return left(); | 863 return left(); |
856 } | 864 } |
857 return this; | 865 return this; |
858 } | 866 } |
859 | 867 |
860 | 868 |
| 869 HValue* HAdd::Canonicalize() { |
| 870 if (!representation().IsInteger32()) return this; |
| 871 if (CheckUsesForFlag(kTruncatingToInt32)) ClearFlag(kCanOverflow); |
| 872 return this; |
| 873 } |
| 874 |
| 875 |
| 876 HValue* HSub::Canonicalize() { |
| 877 if (!representation().IsInteger32()) return this; |
| 878 if (CheckUsesForFlag(kTruncatingToInt32)) ClearFlag(kCanOverflow); |
| 879 return this; |
| 880 } |
| 881 |
| 882 |
861 HValue* HChange::Canonicalize() { | 883 HValue* HChange::Canonicalize() { |
862 return (from().Equals(to())) ? value() : this; | 884 return (from().Equals(to())) ? value() : this; |
863 } | 885 } |
864 | 886 |
865 | 887 |
866 void HTypeof::PrintDataTo(StringStream* stream) { | 888 void HTypeof::PrintDataTo(StringStream* stream) { |
867 value()->PrintNameTo(stream); | 889 value()->PrintNameTo(stream); |
868 } | 890 } |
869 | 891 |
870 | 892 |
(...skipping 1379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2250 | 2272 |
2251 | 2273 |
2252 void HCheckPrototypeMaps::Verify() { | 2274 void HCheckPrototypeMaps::Verify() { |
2253 HInstruction::Verify(); | 2275 HInstruction::Verify(); |
2254 ASSERT(HasNoUses()); | 2276 ASSERT(HasNoUses()); |
2255 } | 2277 } |
2256 | 2278 |
2257 #endif | 2279 #endif |
2258 | 2280 |
2259 } } // namespace v8::internal | 2281 } } // namespace v8::internal |
OLD | NEW |