Regression fix: HForceRepresentation shouldn't be an idef.
authormvstanton@chromium.org <mvstanton@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 15 Nov 2013 12:10:59 +0000 (12:10 +0000)
committermvstanton@chromium.org <mvstanton@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 15 Nov 2013 12:10:59 +0000 (12:10 +0000)
Instead, code sites that are interested in underlying constant integer values
should use HValue::IsInteger32Constant(). The issue is that the infer representation phase shouldn't "see through" HForceRepresentation nodes to an underlying, and less specific representation.

R=mstarzinger@chromium.org

Review URL: https://codereview.chromium.org/65643003

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17787 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/hydrogen-instructions.cc
src/hydrogen-instructions.h
src/hydrogen.cc

index 39d5958..f7a9569 100644 (file)
@@ -521,12 +521,19 @@ bool HValue::CanReplaceWithDummyUses() {
 
 
 bool HValue::IsInteger32Constant() {
-  return IsConstant() && HConstant::cast(this)->HasInteger32Value();
+  HValue* value_to_check = IsForceRepresentation()
+      ? HForceRepresentation::cast(this)->value()
+      : this;
+  return value_to_check->IsConstant() &&
+      HConstant::cast(value_to_check)->HasInteger32Value();
 }
 
 
 int32_t HValue::GetInteger32Constant() {
-  return HConstant::cast(this)->Integer32Value();
+  HValue* constant_value = IsForceRepresentation()
+      ? HForceRepresentation::cast(this)->value()
+      : this;
+  return HConstant::cast(constant_value)->Integer32Value();
 }
 
 
index adf088d..e336c49 100644 (file)
@@ -1579,9 +1579,6 @@ class HForceRepresentation V8_FINAL : public HTemplateInstruction<1> {
 
   DECLARE_CONCRETE_INSTRUCTION(ForceRepresentation)
 
- protected:
-  virtual int RedefinedOperandIndex() { return 0; }
-
  private:
   HForceRepresentation(HValue* value, Representation required_representation) {
     SetOperandAt(0, value);
index 3450115..5913902 100644 (file)
@@ -2209,15 +2209,12 @@ void HGraphBuilder::BuildFillElementsWithHole(HValue* elements,
   static const int kLoopUnfoldLimit = 8;
   STATIC_ASSERT(JSArray::kPreallocatedArrayElements <= kLoopUnfoldLimit);
   int initial_capacity = -1;
-  if (from->ActualValue()->IsConstant() && to->ActualValue()->IsConstant()) {
-    HConstant* constant_from = HConstant::cast(from->ActualValue());
-    HConstant* constant_to = HConstant::cast(to->ActualValue());
-
-    if (constant_from->HasInteger32Value() &&
-        constant_from->Integer32Value() == 0 &&
-        constant_to->HasInteger32Value() &&
-        constant_to->Integer32Value() <= kLoopUnfoldLimit) {
-      initial_capacity = constant_to->Integer32Value();
+  if (from->IsInteger32Constant() && to->IsInteger32Constant()) {
+    int constant_from = from->GetInteger32Constant();
+    int constant_to = to->GetInteger32Constant();
+
+    if (constant_from == 0 && constant_to <= kLoopUnfoldLimit) {
+      initial_capacity = constant_to;
     }
   }