Reviewers: William Hesse,

Description:
Emit a load of the elements array only before the first store.

This avoid emitting the load for empty and constant array literals.


Please review this at http://codereview.chromium.org/5697006/

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

Affected files:
  M     src/hydrogen.cc


Index: src/hydrogen.cc
===================================================================
--- src/hydrogen.cc     (revision 6029)
+++ src/hydrogen.cc     (working copy)
@@ -3023,8 +3023,9 @@
   // The array is expected in the bailout environment during computation
   // of the property values and is the value of the entire expression.
   PushAndAdd(literal);
-  HValue* elements = AddInstruction(new HLoadElements(literal));

+  HLoadElements* elements = NULL;
+
   for (int i = 0; i < length; i++) {
     Expression* subexpr = subexprs->at(i);
// If the subexpression is a literal or a simple materialized literal it
@@ -3034,6 +3035,13 @@
     VISIT_FOR_VALUE(subexpr);
     HValue* value = Pop();
     if (!Smi::IsValid(i)) BAILOUT("Non-smi key in array literal");
+
+    // Load the elements array before the first store.
+    if (elements == NULL)  {
+     elements = new HLoadElements(literal);
+     AddInstruction(elements);
+    }
+
HValue* key = AddInstruction(new HConstant(Handle<Object>(Smi::FromInt(i)), Representation::Integer32()));
     AddInstruction(new HStoreKeyedFastElement(elements, key, value));


--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to