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 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
515 | 515 |
516 | 516 |
517 void HValue::RemoveLastAddedRange() { | 517 void HValue::RemoveLastAddedRange() { |
518 ASSERT(HasRange()); | 518 ASSERT(HasRange()); |
519 ASSERT(range_->next() != NULL); | 519 ASSERT(range_->next() != NULL); |
520 range_ = range_->next(); | 520 range_ = range_->next(); |
521 } | 521 } |
522 | 522 |
523 | 523 |
524 void HValue::ComputeInitialRange(Zone* zone) { | 524 void HValue::ComputeInitialRange(Zone* zone) { |
525 ASSERT(!HasRange()); | 525 ASSERT(CheckFlag(kHasPreinitializedRange) || !HasRange()); |
526 range_ = InferRange(zone); | 526 Range* new_range = InferRange(zone); |
527 if (CheckFlag(kHasPreinitializedRange)) { | |
528 range_->Intersect(new_range); | |
529 ClearFlag(kHasPreinitializedRange); | |
530 } else { | |
531 range_ = new_range; | |
532 } | |
527 ASSERT(HasRange()); | 533 ASSERT(HasRange()); |
528 } | 534 } |
529 | 535 |
536 | |
537 void HValue::PreinitializeRange(Zone* zone) { | |
538 ASSERT(!HasRange()); | |
539 range_ = new(zone) Range(); | |
540 range_->set_can_be_minus_zero(true); | |
541 SetFlag(kHasPreinitializedRange); | |
542 ASSERT(HasRange()); | |
543 } | |
544 | |
530 | 545 |
531 void HInstruction::PrintTo(StringStream* stream) { | 546 void HInstruction::PrintTo(StringStream* stream) { |
532 PrintMnemonicTo(stream); | 547 PrintMnemonicTo(stream); |
533 PrintDataTo(stream); | 548 PrintDataTo(stream); |
534 PrintRangeTo(stream); | 549 PrintRangeTo(stream); |
535 PrintChangesTo(stream); | 550 PrintChangesTo(stream); |
536 PrintTypeTo(stream); | 551 PrintTypeTo(stream); |
537 } | 552 } |
538 | 553 |
539 | 554 |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
854 } | 869 } |
855 | 870 |
856 | 871 |
857 HValue* HBitwise::Canonicalize() { | 872 HValue* HBitwise::Canonicalize() { |
858 if (!representation().IsInteger32()) return this; | 873 if (!representation().IsInteger32()) return this; |
859 // If x is an int32, then x & -1 == x, x | 0 == x and x ^ 0 == x. | 874 // If x is an int32, then x & -1 == x, x | 0 == x and x ^ 0 == x. |
860 int32_t nop_constant = (op() == Token::BIT_AND) ? -1 : 0; | 875 int32_t nop_constant = (op() == Token::BIT_AND) ? -1 : 0; |
861 if (left()->IsConstant() && | 876 if (left()->IsConstant() && |
862 HConstant::cast(left())->HasInteger32Value() && | 877 HConstant::cast(left())->HasInteger32Value() && |
863 HConstant::cast(left())->Integer32Value() == nop_constant) { | 878 HConstant::cast(left())->Integer32Value() == nop_constant) { |
879 right()->PreinitializeRange(block()->zone()); | |
880 right()->range()->set_can_be_minus_zero(false); | |
Vyacheslav Egorov (Chromium)
2012/05/18 17:39:05
I don't think this is correct. Consider code like:
| |
864 return right(); | 881 return right(); |
865 } | 882 } |
866 if (right()->IsConstant() && | 883 if (right()->IsConstant() && |
867 HConstant::cast(right())->HasInteger32Value() && | 884 HConstant::cast(right())->HasInteger32Value() && |
868 HConstant::cast(right())->Integer32Value() == nop_constant) { | 885 HConstant::cast(right())->Integer32Value() == nop_constant) { |
886 left()->PreinitializeRange(block()->zone()); | |
887 left()->range()->set_can_be_minus_zero(false); | |
869 return left(); | 888 return left(); |
870 } | 889 } |
871 return this; | 890 return this; |
872 } | 891 } |
873 | 892 |
874 | 893 |
875 HValue* HBitNot::Canonicalize() { | 894 HValue* HBitNot::Canonicalize() { |
876 // Optimize ~~x, a common pattern used for ToInt32(x). | 895 // Optimize ~~x, a common pattern used for ToInt32(x). |
877 if (value()->IsBitNot()) { | 896 if (value()->IsBitNot()) { |
878 HValue* result = HBitNot::cast(value())->value(); | 897 HValue* result = HBitNot::cast(value())->value(); |
(...skipping 1557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2436 | 2455 |
2437 | 2456 |
2438 void HCheckPrototypeMaps::Verify() { | 2457 void HCheckPrototypeMaps::Verify() { |
2439 HInstruction::Verify(); | 2458 HInstruction::Verify(); |
2440 ASSERT(HasNoUses()); | 2459 ASSERT(HasNoUses()); |
2441 } | 2460 } |
2442 | 2461 |
2443 #endif | 2462 #endif |
2444 | 2463 |
2445 } } // namespace v8::internal | 2464 } } // namespace v8::internal |
OLD | NEW |