qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v5 0/3] tcg: enhance code generation quality for


From: Yeongkyoon Lee
Subject: Re: [Qemu-devel] [PATCH v5 0/3] tcg: enhance code generation quality for qemu_ld/st IRs
Date: Wed, 10 Oct 2012 13:17:36 +0900
User-agent: Mozilla/5.0 (X11; Linux i686; rv:15.0) Gecko/20120827 Thunderbird/15.0

On 2012년 10월 10일 02:09, Aurelien Jarno wrote:
On Tue, Oct 09, 2012 at 06:55:58PM +0200, Paolo Bonzini wrote:
Il 09/10/2012 18:19, Aurelien Jarno ha scritto:
Instead of calling the MMU helper with an additional argument (7), and
then jump back (8) to the next code (4), what about pushing the address
of the next code (4) on the stack and use a jmp instead of the call. In
that case you don't need the extra argument to the helpers.

Maybe it wasn't very clear. This is based on the fact that call is
basically push %rip + jmp. Therefore we can fake the return address by
putting the value we want, here the address of the next code. This mean
that we don't need to pass the extra argument to the helper for the
return address, as GET_PC() would work correctly (it basically reads the
return address on the stack).

For other architectures, it might not be a push, but rather a move to
link register, basically put the return address where the calling
convention asks for.

OTOH I just realized it only works if the end of the slow path (moving
the value from the return address to the correct register). It might be
something doable.
Branch predictors will not oldschool tricks like this one. :)

Given it is only used in the slow path (ie the exception more than the
rule), branch prediction isn't that important there.


I had already considered the approach of using jmp and removing extra argument for helper call. However, the problem is that the helper needs the gen code addr used by tb_find_pc() and cpu_restore_state(). That means the code addr in the helper can be actually said the addr corresponding to QEMU_ld/st IR rather than the return addr. In my LDST optimization, the helper call site is not in the code of IR but in the end of TB. So, if the code addr is not explicitly given as a helper argument, it is too difficult to calculate it using such GETPC() manner.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]