Revision: 4942
Author: [email protected]
Date: Thu Jun 24 07:02:36 2010
Log: Fix error in for-in on x64 platform using full compiler with keyed store IC.

BUG=v8:748

http://code.google.com/p/v8/issues/detail?id=748

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

Modified:
 /branches/bleeding_edge/src/x64/full-codegen-x64.cc
 /branches/bleeding_edge/test/mjsunit/for-in.js

=======================================
--- /branches/bleeding_edge/src/x64/full-codegen-x64.cc Wed Jun 16 03:03:47 2010 +++ /branches/bleeding_edge/src/x64/full-codegen-x64.cc Thu Jun 24 07:02:36 2010
@@ -1518,12 +1518,13 @@
     case KEYED_PROPERTY: {
       __ push(rax);  // Preserve value.
       VisitForValue(prop->obj(), kStack);
-      VisitForValue(prop->key(), kStack);
-      __ movq(rax, Operand(rsp, 2 * kPointerSize));
+      VisitForValue(prop->key(), kAccumulator);
+      __ movq(rcx, rax);
+      __ pop(rdx);
+      __ pop(rax);
Handle<Code> ic(Builtins::builtin(Builtins::KeyedStoreIC_Initialize));
       __ call(ic, RelocInfo::CODE_TARGET);
       __ nop();  // Signal no inlined code.
-      __ Drop(3);  // Receiver, key, and extra copy of value.
       break;
     }
   }
=======================================
--- /branches/bleeding_edge/test/mjsunit/for-in.js      Thu Oct  8 05:36:12 2009
+++ /branches/bleeding_edge/test/mjsunit/for-in.js      Thu Jun 24 07:02:36 2010
@@ -84,3 +84,38 @@
 for (var p in { get a() {}, set a(x) {}, b : 1}) { result += p; }
 assertEquals('ab', result, "abgetset");

+
+// Test that for-in in the global scope works with a keyed property as "each".
+// Test outside a loop and in a loop for multiple iterations.
+a = [1,2,3,4];
+x = {foo:5, bar:6, zip:7, glep:9, 10:11};
+delete x.bar;
+y = {}
+
+for (a[2] in x) {
+  y[a[2]] = x[a[2]];
+}
+
+assertEquals(5, y.foo, "y.foo");
+assertEquals("undefined", typeof y.bar, "y.bar");
+assertEquals(7, y.zip, "y.zip");
+assertEquals(9, y.glep, "y.glep");
+assertEquals(11, y[10], "y[10]");
+assertEquals("undefined", typeof y[2], "y[2]");
+assertEquals("undefined", typeof y[0], "y[0]");
+
+for (i=0 ; i < 3; ++i) {
+  y = {}
+
+  for (a[2] in x) {
+    y[a[2]] = x[a[2]];
+  }
+
+  assertEquals(5, y.foo, "y.foo");
+  assertEquals("undefined", typeof y.bar, "y.bar");
+  assertEquals(7, y.zip, "y.zip");
+  assertEquals(9, y.glep, "y.glep");
+  assertEquals(11, y[10], "y[10]");
+  assertEquals("undefined", typeof y[2], "y[2]");
+  assertEquals("undefined", typeof y[0], "y[0]");
+}

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

Reply via email to