Chromium Code Reviews| 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 1404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1415 HValue* result = HBitNot::cast(value())->value(); | 1415 HValue* result = HBitNot::cast(value())->value(); |
| 1416 ASSERT(result->representation().IsInteger32()); | 1416 ASSERT(result->representation().IsInteger32()); |
| 1417 if (!result->CheckFlag(kUint32)) { | 1417 if (!result->CheckFlag(kUint32)) { |
| 1418 return result; | 1418 return result; |
| 1419 } | 1419 } |
| 1420 } | 1420 } |
| 1421 return this; | 1421 return this; |
| 1422 } | 1422 } |
| 1423 | 1423 |
| 1424 | 1424 |
| 1425 HValue* HAdd::Canonicalize() { | 1425 HValue* HArithmeticBinaryOperation::Canonicalize() { |
| 1426 if (!representation().IsInteger32()) return this; | 1426 if (representation().IsInteger32() && CheckUsesForFlag(kTruncatingToInt32)) { |
| 1427 if (CheckUsesForFlag(kTruncatingToInt32)) ClearFlag(kCanOverflow); | 1427 ClearFlag(kCanOverflow); |
| 1428 } | |
| 1428 return this; | 1429 return this; |
| 1429 } | 1430 } |
| 1430 | 1431 |
| 1431 | 1432 |
| 1432 HValue* HSub::Canonicalize() { | |
| 1433 if (!representation().IsInteger32()) return this; | |
| 1434 if (CheckUsesForFlag(kTruncatingToInt32)) ClearFlag(kCanOverflow); | |
| 1435 return this; | |
| 1436 } | |
| 1437 | |
| 1438 | |
| 1439 // TODO(svenpanne) Use this in other Canonicalize() functions. | |
| 1440 static bool IsIdentityOperation(HValue* arg1, HValue* arg2, int32_t identity) { | 1433 static bool IsIdentityOperation(HValue* arg1, HValue* arg2, int32_t identity) { |
| 1441 return arg1->representation().IsSpecialization() && | 1434 return arg1->representation().IsSpecialization() && |
| 1442 arg2->IsInteger32Constant() && | 1435 arg2->IsInteger32Constant() && |
| 1443 arg2->GetInteger32Constant() == identity; | 1436 arg2->GetInteger32Constant() == identity; |
| 1444 } | 1437 } |
| 1445 | 1438 |
| 1446 | 1439 |
| 1440 HValue* HAdd::Canonicalize() { | |
| 1441 if (IsIdentityOperation(left(), right(), 0)) return left(); | |
| 1442 if (IsIdentityOperation(right(), left(), 0)) return right(); | |
| 1443 HArithmeticBinaryOperation::Canonicalize(); | |
| 1444 return this; | |
|
Jakob Kummerow
2013/04/18 09:11:06
Instead of:
HArithmeticBinaryOperation::Canoni
Sven Panne
2013/04/18 09:19:18
Good point, I even think I had something similar i
| |
| 1445 } | |
| 1446 | |
| 1447 | |
| 1448 HValue* HSub::Canonicalize() { | |
| 1449 if (IsIdentityOperation(left(), right(), 0)) return left(); | |
| 1450 HArithmeticBinaryOperation::Canonicalize(); | |
| 1451 return this; | |
| 1452 } | |
| 1453 | |
| 1454 | |
| 1447 HValue* HMul::Canonicalize() { | 1455 HValue* HMul::Canonicalize() { |
| 1448 if (IsIdentityOperation(left(), right(), 1)) return left(); | 1456 if (IsIdentityOperation(left(), right(), 1)) return left(); |
| 1449 if (IsIdentityOperation(right(), left(), 1)) return right(); | 1457 if (IsIdentityOperation(right(), left(), 1)) return right(); |
| 1458 HArithmeticBinaryOperation::Canonicalize(); | |
| 1450 return this; | 1459 return this; |
| 1451 } | 1460 } |
| 1452 | 1461 |
| 1453 | 1462 |
| 1454 HValue* HChange::Canonicalize() { | 1463 HValue* HChange::Canonicalize() { |
| 1455 return (from().Equals(to())) ? value() : this; | 1464 return (from().Equals(to())) ? value() : this; |
| 1456 } | 1465 } |
| 1457 | 1466 |
| 1458 | 1467 |
| 1459 HValue* HWrapReceiver::Canonicalize() { | 1468 HValue* HWrapReceiver::Canonicalize() { |
| (...skipping 2125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3585 | 3594 |
| 3586 | 3595 |
| 3587 void HCheckFunction::Verify() { | 3596 void HCheckFunction::Verify() { |
| 3588 HInstruction::Verify(); | 3597 HInstruction::Verify(); |
| 3589 ASSERT(HasNoUses()); | 3598 ASSERT(HasNoUses()); |
| 3590 } | 3599 } |
| 3591 | 3600 |
| 3592 #endif | 3601 #endif |
| 3593 | 3602 |
| 3594 } } // namespace v8::internal | 3603 } } // namespace v8::internal |
| OLD | NEW |