Reviewers: danno,

Message:
PTAL

Description:
Support grow-stub by >1 if the target is holey.

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

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

Affected files:
  M src/hydrogen.cc


Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index 8587e30f557ce460d104e673dc5e5488ee48ab8d..8a1023b1e43fc57b6de1b0921a99977322f0af9f 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -1145,21 +1145,22 @@ HValue* HGraphBuilder::BuildCheckForCapacityGrow(HValue* object,
   Zone* zone = this->zone();
   IfBuilder length_checker(this);

-  length_checker.If<HCompareNumericAndBranch>(length, key, Token::EQ);
+  Token::Value token = IsHoleyElementsKind(kind) ? Token::GTE : Token::EQ;
+  length_checker.If<HCompareNumericAndBranch>(key, length, token);
+
   length_checker.Then();

   HValue* current_capacity = AddLoadFixedArrayLength(elements);

   IfBuilder capacity_checker(this);

-  capacity_checker.If<HCompareNumericAndBranch>(length, current_capacity,
-                                                Token::EQ);
+  capacity_checker.If<HCompareNumericAndBranch>(key, current_capacity,
+                                                Token::GTE);
   capacity_checker.Then();

   HValue* context = environment()->LookupContext();

-  HValue* new_capacity =
-      BuildNewElementsCapacity(context, current_capacity);
+  HValue* new_capacity = BuildNewElementsCapacity(context, key);

   HValue* new_elements = BuildGrowElementsCapacity(object, elements,
                                                    kind, kind, length,
@@ -1173,7 +1174,7 @@ HValue* HGraphBuilder::BuildCheckForCapacityGrow(HValue* object,

   if (is_js_array) {
     HValue* new_length = AddInstruction(
-        HAdd::New(zone, context, length, graph_->GetConstant1()));
+        HAdd::New(zone, context, key, graph_->GetConstant1()));
     new_length->ClearFlag(HValue::kCanOverflow);

     Representation representation = IsFastElementsKind(kind)
@@ -1183,10 +1184,9 @@ HValue* HGraphBuilder::BuildCheckForCapacityGrow(HValue* object,
   }

   length_checker.Else();
-
   Add<HBoundsCheck>(key, length);
-  environment()->Push(elements);

+  environment()->Push(elements);
   length_checker.End();

   return environment()->Pop();


--
--
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