Reviewers: mvstanton,

Message:
PTAL

Description:
Extend ArrayPop hydrogen support to COW arrays and popping from empty arrays.

[email protected]

BUG=

Please review this at https://codereview.chromium.org/148093009/

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

Affected files (+21, -7 lines):
  M src/hydrogen.cc


Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index 142c92171048e44b92b22998da9be366c4ae9cec..368ce429787a5fd5333d7ac3425c10070fe92666 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -7632,19 +7632,29 @@ bool HOptimizedGraphBuilder::TryInlineBuiltinMethodCall(

       Drop(expr->arguments()->length());
       HValue* result;
-      HValue* checked_object;
       HValue* reduced_length;
       HValue* receiver = Pop();
+
+      HValue* checked_object = AddCheckMap(receiver, receiver_map);
+      HValue* length = Add<HLoadNamedField>(
+          checked_object, HObjectAccess::ForArrayLength(elements_kind));
+
+      IfBuilder length_checker(this);
+
+      length_checker.If<HCompareNumericAndBranch>(
+          length, graph()->GetConstant0(), Token::EQ);
+      length_checker.Then();
+
+      Push(graph()->GetConstantUndefined());
+
+      length_checker.Else();
       { NoObservableSideEffectsScope scope(this);
-        checked_object = AddCheckMap(receiver, receiver_map);
         HValue* elements = AddLoadElements(checked_object);
         // Ensure that we aren't popping from a copy-on-write array.
         if (IsFastSmiOrObjectElementsKind(elements_kind)) {
-          Add<HCheckMaps>(
- elements, isolate()->factory()->fixed_array_map(), top_info());
+          elements = BuildCopyElementsOnWrite(checked_object, elements,
+                                              elements_kind, length);
         }
-        HValue* length = Add<HLoadNamedField>(
-            checked_object, HObjectAccess::ForArrayLength(elements_kind));
reduced_length = AddUncasted<HSub>(length, graph()->GetConstant1());
         HValue* bounds_check = Add<HBoundsCheck>(
             graph()->GetConstant0(), length);
@@ -7667,7 +7677,11 @@ bool HOptimizedGraphBuilder::TryInlineBuiltinMethodCall(
       if (!ast_context()->IsEffect()) Push(result);
       Add<HSimulate>(expr->id(), REMOVABLE_SIMULATE);
       if (!ast_context()->IsEffect()) Drop(1);
-      ast_context()->ReturnValue(result);
+      Push(result);
+
+      length_checker.End();
+
+      ast_context()->ReturnValue(Pop());
       return true;
     }
     case kArrayPush: {


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