Commit 07ea28b4 authored by Richard Henderson's avatar Richard Henderson
Browse files

tcg: Pass tb and index to tcg_gen_exit_tb separately



Do the cast to uintptr_t within the helper, so that the compiler
can type check the pointer argument.  We can also do some more
sanity checking of the index argument.

Reviewed-by: default avatarLaurent Vivier <laurent@vivier.eu>
Signed-off-by: default avatarRichard Henderson <richard.henderson@linaro.org>
parent 392fba9f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -52,7 +52,7 @@ static inline void gen_tb_end(TranslationBlock *tb, int num_insns)
    }

    gen_set_label(tcg_ctx->exitreq_label);
    tcg_gen_exit_tb((uintptr_t)tb + TB_EXIT_REQUESTED);
    tcg_gen_exit_tb(tb, TB_EXIT_REQUESTED);
}

static inline void gen_io_start(void)
+6 −6
Original line number Diff line number Diff line
@@ -488,7 +488,7 @@ static DisasJumpType gen_bdirect(DisasContext *ctx, int ra, int32_t disp)
    } else if (use_goto_tb(ctx, dest)) {
        tcg_gen_goto_tb(0);
        tcg_gen_movi_i64(cpu_pc, dest);
        tcg_gen_exit_tb((uintptr_t)ctx->base.tb);
        tcg_gen_exit_tb(ctx->base.tb, 0);
        return DISAS_NORETURN;
    } else {
        tcg_gen_movi_i64(cpu_pc, dest);
@@ -507,12 +507,12 @@ static DisasJumpType gen_bcond_internal(DisasContext *ctx, TCGCond cond,

        tcg_gen_goto_tb(0);
        tcg_gen_movi_i64(cpu_pc, ctx->base.pc_next);
        tcg_gen_exit_tb((uintptr_t)ctx->base.tb);
        tcg_gen_exit_tb(ctx->base.tb, 0);

        gen_set_label(lab_true);
        tcg_gen_goto_tb(1);
        tcg_gen_movi_i64(cpu_pc, dest);
        tcg_gen_exit_tb((uintptr_t)ctx->base.tb + 1);
        tcg_gen_exit_tb(ctx->base.tb, 1);

        return DISAS_NORETURN;
    } else {
@@ -1273,7 +1273,7 @@ static DisasJumpType gen_call_pal(DisasContext *ctx, int palcode)
        if (!use_exit_tb(ctx)) {
            tcg_gen_goto_tb(0);
            tcg_gen_movi_i64(cpu_pc, entry);
            tcg_gen_exit_tb((uintptr_t)ctx->base.tb);
            tcg_gen_exit_tb(ctx->base.tb, 0);
            return DISAS_NORETURN;
        } else {
            tcg_gen_movi_i64(cpu_pc, entry);
@@ -3009,7 +3009,7 @@ static void alpha_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu)
        if (use_goto_tb(ctx, ctx->base.pc_next)) {
            tcg_gen_goto_tb(0);
            tcg_gen_movi_i64(cpu_pc, ctx->base.pc_next);
            tcg_gen_exit_tb((uintptr_t)ctx->base.tb);
            tcg_gen_exit_tb(ctx->base.tb, 0);
        }
        /* FALLTHRU */
    case DISAS_PC_STALE:
@@ -3025,7 +3025,7 @@ static void alpha_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu)
        if (ctx->base.singlestep_enabled) {
            gen_excp_1(EXCP_DEBUG, 0);
        } else {
            tcg_gen_exit_tb(0);
            tcg_gen_exit_tb(NULL, 0);
        }
        break;
    default:
+3 −3
Original line number Diff line number Diff line
@@ -383,7 +383,7 @@ static inline void gen_goto_tb(DisasContext *s, int n, uint64_t dest)
    if (use_goto_tb(s, n, dest)) {
        tcg_gen_goto_tb(n);
        gen_a64_set_pc_im(dest);
        tcg_gen_exit_tb((intptr_t)tb + n);
        tcg_gen_exit_tb(tb, n);
        s->base.is_jmp = DISAS_NORETURN;
    } else {
        gen_a64_set_pc_im(dest);
@@ -13883,7 +13883,7 @@ static void aarch64_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu)
            gen_a64_set_pc_im(dc->pc);
            /* fall through */
        case DISAS_EXIT:
            tcg_gen_exit_tb(0);
            tcg_gen_exit_tb(NULL, 0);
            break;
        case DISAS_JUMP:
            tcg_gen_lookup_and_goto_ptr();
@@ -13912,7 +13912,7 @@ static void aarch64_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu)
            /* The helper doesn't necessarily throw an exception, but we
             * must go back to the main loop to check for interrupts anyway.
             */
            tcg_gen_exit_tb(0);
            tcg_gen_exit_tb(NULL, 0);
            break;
        }
        }
+4 −4
Original line number Diff line number Diff line
@@ -995,7 +995,7 @@ static inline void gen_bx_excret_final_code(DisasContext *s)
    if (is_singlestepping(s)) {
        gen_singlestep_exception(s);
    } else {
        tcg_gen_exit_tb(0);
        tcg_gen_exit_tb(NULL, 0);
    }
    gen_set_label(excret_label);
    /* Yes: this is an exception return.
@@ -4263,7 +4263,7 @@ static void gen_goto_tb(DisasContext *s, int n, target_ulong dest)
    if (use_goto_tb(s, dest)) {
        tcg_gen_goto_tb(n);
        gen_set_pc_im(s, dest);
        tcg_gen_exit_tb((uintptr_t)s->base.tb + n);
        tcg_gen_exit_tb(s->base.tb, n);
    } else {
        gen_set_pc_im(s, dest);
        gen_goto_ptr();
@@ -12699,7 +12699,7 @@ static void arm_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu)
            /* fall through */
        default:
            /* indicate that the hash table must be used to find the next TB */
            tcg_gen_exit_tb(0);
            tcg_gen_exit_tb(NULL, 0);
            break;
        case DISAS_NORETURN:
            /* nothing more to generate */
@@ -12714,7 +12714,7 @@ static void arm_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu)
            /* The helper doesn't necessarily throw an exception, but we
             * must go back to the main loop to check for interrupts anyway.
             */
            tcg_gen_exit_tb(0);
            tcg_gen_exit_tb(NULL, 0);
            break;
        }
        case DISAS_WFE:
+3 −3
Original line number Diff line number Diff line
@@ -540,10 +540,10 @@ static void gen_goto_tb(DisasContext *dc, int n, target_ulong dest)
    if (use_goto_tb(dc, dest)) {
        tcg_gen_goto_tb(n);
        tcg_gen_movi_tl(env_pc, dest);
                tcg_gen_exit_tb((uintptr_t)dc->tb + n);
        tcg_gen_exit_tb(dc->tb, n);
    } else {
        tcg_gen_movi_tl(env_pc, dest);
        tcg_gen_exit_tb(0);
        tcg_gen_exit_tb(NULL, 0);
    }
}

@@ -3276,7 +3276,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb)
        case DISAS_UPDATE:
            /* indicate that the hash table must be used
                   to find the next TB */
            tcg_gen_exit_tb(0);
            tcg_gen_exit_tb(NULL, 0);
            break;
        case DISAS_SWI:
        case DISAS_TB_JUMP:
Loading