[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 4/7] exec: Use const alias for TARGET_PAGE_BITS_VARY
From: |
Peter Maydell |
Subject: |
Re: [PATCH v2 4/7] exec: Use const alias for TARGET_PAGE_BITS_VARY |
Date: |
Fri, 25 Oct 2019 15:51:33 +0100 |
On Wed, 23 Oct 2019 at 18:06, Richard Henderson
<address@hidden> wrote:
>
> Using a variable that is declared "const" for this tells the
> compiler that it may read the value once and assume that it
> does not change across function calls.
>
> For target_page_size, this means we have only one assert per
> function, and one read of the variable.
>
> This reduces the size of qemu-system-aarch64 by 8k.
>
> Reviewed-by: Paolo Bonzini <address@hidden>
> Signed-off-by: Richard Henderson <address@hidden>
> + * We want to declare the "target_page" variable as const, which tells
> + * the compiler that it can cache any value that it reads across calls.
> + * This avoids multiple assertions and multiple reads within any one user.
> + *
> + * This works because we initialize the target_page data very early, in a
> + * location far removed from the functions that require the final results.
I have to say that this feels like a worryingly large amount
of magic. Is this actually guaranteed to work by the compiler?
thanks
-- PMM
- [PATCH v2 6/7] exec: Promote TARGET_PAGE_MASK to target_long, (continued)
- [PATCH v2 6/7] exec: Promote TARGET_PAGE_MASK to target_long, Richard Henderson, 2019/10/23
- [PATCH v2 5/7] exec: Restrict TARGET_PAGE_BITS_VARY assert to CONFIG_DEBUG_TCG, Richard Henderson, 2019/10/23
- [PATCH v2 7/7] exec: Cache TARGET_PAGE_MASK for TARGET_PAGE_BITS_VARY, Richard Henderson, 2019/10/23
- [PATCH v2 3/7] configure: Detect compiler support for __attribute__((alias)), Richard Henderson, 2019/10/23
- [PATCH v2 2/7] exec: Split out variable page size support to exec-vary.c, Richard Henderson, 2019/10/23
- [PATCH v2 4/7] exec: Use const alias for TARGET_PAGE_BITS_VARY, Richard Henderson, 2019/10/23
Re: [PATCH v2 0/7] exec: Improve code for TARGET_PAGE_BITS_VARY, no-reply, 2019/10/24
Re: [PATCH v2 0/7] exec: Improve code for TARGET_PAGE_BITS_VARY, Alex Bennée, 2019/10/25