Reviewers: Jakob,

Message:
PTAL

Description:
Allow boundscheck elimination to work on Smi keys.

Please review this at https://chromiumcodereview.appspot.com/16035016/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
  M src/hydrogen-instructions.h
  M src/hydrogen-instructions.cc
  M src/hydrogen.cc


Index: src/hydrogen-instructions.cc
diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc
index ff0791baaadacdf4a0766723cebbcbe3adfb9b70..073f7a1c7c2a198f94cb7e87a82fbe51b1803b0d 100644
--- a/src/hydrogen-instructions.cc
+++ b/src/hydrogen-instructions.cc
@@ -1058,6 +1058,7 @@ void HBoundsCheck::ApplyIndexChange() {
         block()->graph()->GetInvalidContext(), current_index, add_offset);
     add->InsertBefore(this);
     add->AssumeRepresentation(index()->representation());
+    add->ClearFlag(kCanOverflow);
     current_index = add;
   }

Index: src/hydrogen-instructions.h
diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h
index ee87024ab0da804baf5f86e83b19fdffd5905eab..4fe47e0d4069c84547f8e38f86b3d8503428a742 100644
--- a/src/hydrogen-instructions.h
+++ b/src/hydrogen-instructions.h
@@ -3661,7 +3661,7 @@ class HBoundsCheck: public HTemplateInstruction<2> {
     return representation();
   }
   virtual Representation observed_input_representation(int index) {
-    return Representation::Integer32();
+    return Representation::None();
   }

   virtual bool IsRelationTrueInternal(NumericRelation relation,
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index 8765cb9e2ff63c6a53bdf447b657bc20a0a8d412..14e0d4b7786650d86d5d0fb18bfd9c4ab625175d 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -4115,7 +4115,7 @@ class BoundsCheckKey : public ZoneObject {
   static BoundsCheckKey* Create(Zone* zone,
                                 HBoundsCheck* check,
                                 int32_t* offset) {
-    if (!check->index()->representation().IsInteger32()) return NULL;
+    if (!check->index()->representation().IsSmiOrInteger32()) return NULL;

     HValue* index_base = NULL;
     HConstant* constant = NULL;
@@ -4211,7 +4211,7 @@ class BoundsCheckBbData: public ZoneObject {
   // returns false, otherwise it returns true.
   bool CoverCheck(HBoundsCheck* new_check,
                   int32_t new_offset) {
-    ASSERT(new_check->index()->representation().IsInteger32());
+    ASSERT(new_check->index()->representation().IsSmiOrInteger32());
     bool keep_new_check = false;

     if (new_offset > upper_offset_) {
@@ -4320,8 +4320,8 @@ class BoundsCheckBbData: public ZoneObject {
     HValue* index_context = IndexContext(*add, check);
     if (index_context == NULL) return false;

-    HConstant* new_constant = new(BasicBlock()->zone())
-       HConstant(new_offset, Representation::Integer32());
+    HConstant* new_constant = new(BasicBlock()->zone()) HConstant(
+        new_offset, representation);
     if (*add == NULL) {
       new_constant->InsertBefore(check);
       (*add) = HAdd::New(
@@ -4453,7 +4453,7 @@ void HGraph::EliminateRedundantBoundsChecks() {

 static void DehoistArrayIndex(ArrayInstructionInterface* array_operation) {
   HValue* index = array_operation->GetKey()->ActualValue();
-  if (!index->representation().IsInteger32()) return;
+  if (!index->representation().IsSmiOrInteger32()) return;

   HConstant* constant;
   HValue* subexpression;


--
--
v8-dev mailing list
v8-dev@googlegroups.com
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 v8-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to