Commit d0a9f762 authored by whesse@chromium.org's avatar whesse@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4942 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 8ab68322
......@@ -1518,12 +1518,13 @@ void FullCodeGenerator::EmitAssignment(Expression* expr) {
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;
}
}
......
......@@ -84,3 +84,38 @@ var result = '';
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]");
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment