From: whesse@chromium.org Date: Thu, 25 Mar 2010 11:52:42 +0000 (+0000) Subject: Avoid calling ToRegister(register) when result is in register already, and register... X-Git-Tag: upstream/4.7.83~22138 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=244513555cb2f79c49d7cf65b418baf62cd7e138;p=platform%2Fupstream%2Fv8.git Avoid calling ToRegister(register) when result is in register already, and register is shared. Review URL: http://codereview.chromium.org/1325004 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4260 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/ia32/virtual-frame-ia32.cc b/src/ia32/virtual-frame-ia32.cc index de12b64..a8b0e8d 100644 --- a/src/ia32/virtual-frame-ia32.cc +++ b/src/ia32/virtual-frame-ia32.cc @@ -1040,18 +1040,23 @@ Result VirtualFrame::CallKeyedStoreIC() { PrepareForCall(0, 0); if (!cgen()->allocator()->is_used(eax) || (value.is_register() && value.reg().is(eax))) { - value.ToRegister(eax); // No effect if value is in eax already. + if (!cgen()->allocator()->is_used(eax)) { + value.ToRegister(eax); + } MoveResultsToRegisters(&key, &receiver, ecx, edx); value.Unuse(); } else if (!cgen()->allocator()->is_used(ecx) || (key.is_register() && key.reg().is(ecx))) { - // Receiver and/or key are in eax. - key.ToRegister(ecx); + if (!cgen()->allocator()->is_used(ecx)) { + key.ToRegister(ecx); + } MoveResultsToRegisters(&value, &receiver, eax, edx); key.Unuse(); } else if (!cgen()->allocator()->is_used(edx) || (receiver.is_register() && receiver.reg().is(edx))) { - receiver.ToRegister(edx); + if (!cgen()->allocator()->is_used(edx)) { + receiver.ToRegister(edx); + } MoveResultsToRegisters(&key, &value, ecx, eax); receiver.Unuse(); } else { diff --git a/test/mjsunit/codegen-coverage.js b/test/mjsunit/codegen-coverage.js index 42c371b..8e7f189 100644 --- a/test/mjsunit/codegen-coverage.js +++ b/test/mjsunit/codegen-coverage.js @@ -33,6 +33,13 @@ function identity(x) { return x; } +function lookup(w, a) { + // This function tests a code path in the generation of a keyed load IC + // where the key and the value are both in the same register. + a = a; + w[a] = a; +} + function cover_codegen_paths() { var x = 1; @@ -131,6 +138,12 @@ function cover_codegen_paths() { assertEquals(1073741824, 1 - di); x = 3; + var w = { }; + lookup(w, x); + lookup(w, x); + lookup(w, x); + + x = 3; // Terminate while loop. } }