Revision: 6034
Author: [email protected]
Date: Wed Dec 15 08:12:55 2010
Log: Emit a load of the elements array only before the first store.

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

Review URL: http://codereview.chromium.org/5697006
http://code.google.com/p/v8/source/detail?r=6034

Modified:
 /branches/bleeding_edge/src/hydrogen.cc

=======================================
--- /branches/bleeding_edge/src/hydrogen.cc     Wed Dec 15 04:32:19 2010
+++ /branches/bleeding_edge/src/hydrogen.cc     Wed Dec 15 08:12:55 2010
@@ -3023,7 +3023,8 @@
   // 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);
@@ -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