[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v6 18/50] tcg: Reserve temporary index 0
From: |
Emilio G. Cota |
Subject: |
Re: [Qemu-devel] [PATCH v6 18/50] tcg: Reserve temporary index 0 |
Date: |
Tue, 17 Oct 2017 19:19:54 -0400 |
User-agent: |
Mutt/1.5.24 (2015-08-30) |
On Mon, Oct 16, 2017 at 10:25:37 -0700, Richard Henderson wrote:
> Since we cast indicies to pointers, reserving 0 allows
s/indicies/indices/
> us to use NULL for unused/dummy instead of (T *)-1.
>
> Signed-off-by: Richard Henderson <address@hidden>
> ---
(snip)
> @@ -737,7 +737,7 @@ extern bool parallel_cpus;
> static inline size_t temp_idx(TCGTemp *ts)
> {
> ptrdiff_t n = ts - tcg_ctx.temps;
> - tcg_debug_assert(n >= 0 && n < tcg_ctx.nb_temps);
> + tcg_debug_assert(n > 0 && n < tcg_ctx.nb_temps);
> return n;
> }
>
> diff --git a/tcg/tcg.c b/tcg/tcg.c
> index 129aecca60..7cf39f7067 100644
> --- a/tcg/tcg.c
> +++ b/tcg/tcg.c
> @@ -333,7 +333,10 @@ void tcg_context_init(TCGContext *s)
> int *sorted_args;
>
> memset(s, 0, sizeof(*s));
> - s->nb_globals = 0;
> + /* Reserve temp index 0 so that, with the funny casting that we do,
> + the first one doesn't look like NULL. */
> + s->nb_globals = 1;
> + s->nb_temps = 1;
>
> /* Count total number of arguments and allocate the corresponding
> space */
I like this change, although operating on the 0th element makes
me uneasy.
For instance, I managed to trigger the above assert by manually calling
dump_regs
(it is otherwise called before aborting, which is why you missed it.)
This fixes it:
diff --git a/tcg/tcg.c b/tcg/tcg.c
index 7cf39f7..49176e0 100644
--- a/tcg/tcg.c
+++ b/tcg/tcg.c
@@ -2034,7 +2034,7 @@ static void dump_regs(TCGContext *s)
int i;
char buf[64];
- for(i = 0; i < s->nb_temps; i++) {
+ for (i = 1; i < s->nb_temps; i++) {
ts = &s->temps[i];
printf(" %10s: ", tcg_get_arg_str_ptr(s, buf, sizeof(buf), ts));
switch(ts->val_type) {
Is it worth changing other [0, nb_temps/globals) loops to start from 1?
Thanks,
E.
- Re: [Qemu-devel] [PATCH v6 12/50] tcg: Remove unused TCG_CALL_DUMMY_TCGV, (continued)
- [Qemu-devel] [PATCH v6 09/50] tcg: Use per-temp state data in liveness, Richard Henderson, 2017/10/16
- [Qemu-devel] [PATCH v6 13/50] tcg: Export temp_idx, Richard Henderson, 2017/10/16
- [Qemu-devel] [PATCH v6 15/50] tcg: Push tcg_ctx into generator functions, Richard Henderson, 2017/10/16
- [Qemu-devel] [PATCH v6 16/50] tcg: Push tcg_ctx into tcg_gen_callN, Richard Henderson, 2017/10/16
- [Qemu-devel] [PATCH v6 18/50] tcg: Reserve temporary index 0, Richard Henderson, 2017/10/16
- Re: [Qemu-devel] [PATCH v6 18/50] tcg: Reserve temporary index 0,
Emilio G. Cota <=
- [Qemu-devel] [PATCH v6 17/50] tcg: Introduce index_arg, Richard Henderson, 2017/10/16
- [Qemu-devel] [PATCH v6 19/50] target/alpha: Avoid translate_init unless tcg_enabled, Richard Henderson, 2017/10/16
- [Qemu-devel] [PATCH v6 14/50] tcg: Use per-temp state data in optimize, Richard Henderson, 2017/10/16
- [Qemu-devel] [PATCH v6 21/50] tcg: Use pointers in TCGOp->args, Richard Henderson, 2017/10/16
- [Qemu-devel] [PATCH v6 20/50] qom: Introduce CPUClass.tcg_initialize, Richard Henderson, 2017/10/16