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

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

Issue 14244023: Inline isUint32() method from HConstant, which was only used in one place. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Use IsInteger32Constant() and GetInteger32Constant() Created 7 years, 8 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-instructions.h ('k') | no next file » | 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 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 bool HValue::IsInteger32Constant() { 641 bool HValue::IsInteger32Constant() {
642 return IsConstant() && HConstant::cast(this)->HasInteger32Value(); 642 return IsConstant() && HConstant::cast(this)->HasInteger32Value();
643 } 643 }
644 644
645 645
646 int32_t HValue::GetInteger32Constant() { 646 int32_t HValue::GetInteger32Constant() {
647 return HConstant::cast(this)->Integer32Value(); 647 return HConstant::cast(this)->Integer32Value();
648 } 648 }
649 649
650 650
651 bool HValue::EqualsInteger32Constant(int32_t value) {
652 return IsInteger32Constant() && GetInteger32Constant() == value;
653 }
654
655
651 void HValue::SetOperandAt(int index, HValue* value) { 656 void HValue::SetOperandAt(int index, HValue* value) {
652 RegisterUse(index, value); 657 RegisterUse(index, value);
653 InternalSetOperandAt(index, value); 658 InternalSetOperandAt(index, value);
654 } 659 }
655 660
656 661
657 void HValue::DeleteAndReplaceWith(HValue* other) { 662 void HValue::DeleteAndReplaceWith(HValue* other) {
658 // We replace all uses first, so Delete can assert that there are none. 663 // We replace all uses first, so Delete can assert that there are none.
659 if (other != NULL) ReplaceAllUsesWith(other); 664 if (other != NULL) ReplaceAllUsesWith(other);
660 ASSERT(HasNoUses()); 665 ASSERT(HasNoUses());
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after
1386 object()->PrintNameTo(stream); 1391 object()->PrintNameTo(stream);
1387 stream->Add(" "); 1392 stream->Add(" ");
1388 index()->PrintNameTo(stream); 1393 index()->PrintNameTo(stream);
1389 } 1394 }
1390 1395
1391 1396
1392 HValue* HBitwise::Canonicalize() { 1397 HValue* HBitwise::Canonicalize() {
1393 if (!representation().IsInteger32()) return this; 1398 if (!representation().IsInteger32()) return this;
1394 // If x is an int32, then x & -1 == x, x | 0 == x and x ^ 0 == x. 1399 // If x is an int32, then x & -1 == x, x | 0 == x and x ^ 0 == x.
1395 int32_t nop_constant = (op() == Token::BIT_AND) ? -1 : 0; 1400 int32_t nop_constant = (op() == Token::BIT_AND) ? -1 : 0;
1396 if (left()->IsConstant() && 1401 if (left()->EqualsInteger32Constant(nop_constant) &&
1397 HConstant::cast(left())->HasInteger32Value() &&
1398 HConstant::cast(left())->Integer32Value() == nop_constant &&
1399 !right()->CheckFlag(kUint32)) { 1402 !right()->CheckFlag(kUint32)) {
1400 return right(); 1403 return right();
1401 } 1404 }
1402 if (right()->IsConstant() && 1405 if (right()->EqualsInteger32Constant(nop_constant) &&
1403 HConstant::cast(right())->HasInteger32Value() &&
1404 HConstant::cast(right())->Integer32Value() == nop_constant &&
1405 !left()->CheckFlag(kUint32)) { 1406 !left()->CheckFlag(kUint32)) {
1406 return left(); 1407 return left();
1407 } 1408 }
1408 return this; 1409 return this;
1409 } 1410 }
1410 1411
1411 1412
1412 HValue* HBitNot::Canonicalize() { 1413 HValue* HBitNot::Canonicalize() {
1413 // Optimize ~~x, a common pattern used for ToInt32(x). 1414 // Optimize ~~x, a common pattern used for ToInt32(x).
1414 if (value()->IsBitNot()) { 1415 if (value()->IsBitNot()) {
(...skipping 17 matching lines...) Expand all
1432 HValue* HSub::Canonicalize() { 1433 HValue* HSub::Canonicalize() {
1433 if (!representation().IsInteger32()) return this; 1434 if (!representation().IsInteger32()) return this;
1434 if (CheckUsesForFlag(kTruncatingToInt32)) ClearFlag(kCanOverflow); 1435 if (CheckUsesForFlag(kTruncatingToInt32)) ClearFlag(kCanOverflow);
1435 return this; 1436 return this;
1436 } 1437 }
1437 1438
1438 1439
1439 // TODO(svenpanne) Use this in other Canonicalize() functions. 1440 // TODO(svenpanne) Use this in other Canonicalize() functions.
1440 static bool IsIdentityOperation(HValue* arg1, HValue* arg2, int32_t identity) { 1441 static bool IsIdentityOperation(HValue* arg1, HValue* arg2, int32_t identity) {
1441 return arg1->representation().IsSpecialization() && 1442 return arg1->representation().IsSpecialization() &&
1442 arg2->IsInteger32Constant() && 1443 arg2->EqualsInteger32Constant(identity);
1443 arg2->GetInteger32Constant() == identity;
1444 } 1444 }
1445 1445
1446 1446
1447 HValue* HMul::Canonicalize() { 1447 HValue* HMul::Canonicalize() {
1448 if (IsIdentityOperation(left(), right(), 1)) return left(); 1448 if (IsIdentityOperation(left(), right(), 1)) return left();
1449 if (IsIdentityOperation(right(), left(), 1)) return right(); 1449 if (IsIdentityOperation(right(), left(), 1)) return right();
1450 return this; 1450 return this;
1451 } 1451 }
1452 1452
1453 1453
(...skipping 2131 matching lines...) Expand 10 before | Expand all | Expand 10 after
3585 3585
3586 3586
3587 void HCheckFunction::Verify() { 3587 void HCheckFunction::Verify() {
3588 HInstruction::Verify(); 3588 HInstruction::Verify();
3589 ASSERT(HasNoUses()); 3589 ASSERT(HasNoUses());
3590 } 3590 }
3591 3591
3592 #endif 3592 #endif
3593 3593
3594 } } // namespace v8::internal 3594 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen-instructions.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698