Revision: 14329
Author:   [email protected]
Date:     Thu Apr 18 04:22:29 2013
Log: Inline isUint32() method from HConstant, which was only used in one place. Add utility method for checking whether an HValue is a given int32_t constant.

BUG=

Review URL: https://codereview.chromium.org/14244023
http://code.google.com/p/v8/source/detail?r=14329

Modified:
 /branches/bleeding_edge/src/hydrogen-instructions.cc
 /branches/bleeding_edge/src/hydrogen-instructions.h
 /branches/bleeding_edge/src/hydrogen.cc

=======================================
--- /branches/bleeding_edge/src/hydrogen-instructions.cc Thu Apr 18 02:24:29 2013 +++ /branches/bleeding_edge/src/hydrogen-instructions.cc Thu Apr 18 04:22:29 2013
@@ -646,6 +646,11 @@
 int32_t HValue::GetInteger32Constant() {
   return HConstant::cast(this)->Integer32Value();
 }
+
+
+bool HValue::EqualsInteger32Constant(int32_t value) {
+  return IsInteger32Constant() && GetInteger32Constant() == value;
+}


 void HValue::SetOperandAt(int index, HValue* value) {
@@ -1393,15 +1398,11 @@
   if (!representation().IsInteger32()) return this;
   // If x is an int32, then x & -1 == x, x | 0 == x and x ^ 0 == x.
   int32_t nop_constant = (op() == Token::BIT_AND) ? -1 : 0;
-  if (left()->IsConstant() &&
-      HConstant::cast(left())->HasInteger32Value() &&
-      HConstant::cast(left())->Integer32Value() == nop_constant &&
+  if (left()->EqualsInteger32Constant(nop_constant) &&
       !right()->CheckFlag(kUint32)) {
     return right();
   }
-  if (right()->IsConstant() &&
-      HConstant::cast(right())->HasInteger32Value() &&
-      HConstant::cast(right())->Integer32Value() == nop_constant &&
+  if (right()->EqualsInteger32Constant(nop_constant) &&
       !left()->CheckFlag(kUint32)) {
     return left();
   }
@@ -1432,8 +1433,7 @@

static bool IsIdentityOperation(HValue* arg1, HValue* arg2, int32_t identity) {
   return arg1->representation().IsSpecialization() &&
-      arg2->IsInteger32Constant() &&
-      arg2->GetInteger32Constant() == identity;
+    arg2->EqualsInteger32Constant(identity);
 }


=======================================
--- /branches/bleeding_edge/src/hydrogen-instructions.h Thu Apr 18 02:24:29 2013 +++ /branches/bleeding_edge/src/hydrogen-instructions.h Thu Apr 18 04:22:29 2013
@@ -1001,6 +1001,7 @@

   bool IsInteger32Constant();
   int32_t GetInteger32Constant();
+  bool EqualsInteger32Constant(int32_t value);

   bool IsDefinedAfter(HBasicBlock* other) const;

@@ -3327,10 +3328,6 @@
   }

   bool BooleanValue() const { return boolean_value_; }
-
-  bool IsUint32() {
-    return HasInteger32Value() && (Integer32Value() >= 0);
-  }

   virtual intptr_t Hashcode() {
     if (has_int32_value_) {
=======================================
--- /branches/bleeding_edge/src/hydrogen.cc     Thu Apr 18 03:51:24 2013
+++ /branches/bleeding_edge/src/hydrogen.cc     Thu Apr 18 04:22:29 2013
@@ -3977,8 +3977,8 @@
     HValue* operand = phi->OperandAt(j);
     if (!operand->CheckFlag(HInstruction::kUint32)) {
// Lazyly mark constants that fit into uint32 range with kUint32 flag.
-      if (operand->IsConstant() &&
-          HConstant::cast(operand)->IsUint32()) {
+      if (operand->IsInteger32Constant() &&
+          operand->GetInteger32Constant() >= 0) {
         operand->SetFlag(HInstruction::kUint32);
         continue;
       }
@@ -8801,9 +8801,7 @@
           } else if (exponent == 2.0) {
             result = HMul::New(zone(), context, left, left);
           }
-        } else if (right->IsConstant() &&
-                   HConstant::cast(right)->HasInteger32Value() &&
-                   HConstant::cast(right)->Integer32Value() == 2) {
+        } else if (right->EqualsInteger32Constant(2)) {
           result = HMul::New(zone(), context, left, left);
         }

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to