diff --git a/qemu/tcg/tcg.c b/qemu/tcg/tcg.c index 83834f68..c3e8b353 100644 --- a/qemu/tcg/tcg.c +++ b/qemu/tcg/tcg.c @@ -238,15 +238,10 @@ static void tcg_out_label(TCGContext *s, TCGLabel *l, tcg_insn_unit *ptr) TCGLabel *gen_new_label(TCGContext *s) { - int idx; - TCGLabel *l; - - if (s->nb_labels >= TCG_MAX_LABELS) - tcg_abort(); - idx = s->nb_labels++; - l = &s->labels[idx]; - l->has_value = 0; - l->u.first_reloc = NULL; + TCGLabel *l = tcg_malloc(s, sizeof(TCGLabel)); + TCGLabel ltmp = {0}; + ltmp.id = s->nb_labels++; + *l = ltmp; return l; } @@ -1125,12 +1120,20 @@ void tcg_dump_ops(TCGContext *s) i = 0; break; } - for (; i < nb_cargs; i++) { - if (k != 0) { - printf(","); - } - - printf("$0x%" TCG_PRIlx, args[k++]); + switch (c) { + case INDEX_op_set_label: + case INDEX_op_br: + case INDEX_op_brcond_i32: + case INDEX_op_brcond_i64: + case INDEX_op_brcond2_i32: + qemu_log("%s$L%d", k ? "," : "", arg_label(s, args[k])->id); + i++, k++; + break; + default: + break; + } + for (; i < nb_cargs; i++, k++) { + qemu_log("%s$0x%" TCG_PRIlx, k ? "," : "", args[k]); } } printf("\n"); diff --git a/qemu/tcg/tcg.h b/qemu/tcg/tcg.h index b0fdd5b2..0f3af973 100644 --- a/qemu/tcg/tcg.h +++ b/qemu/tcg/tcg.h @@ -170,7 +170,8 @@ typedef struct TCGRelocation { } TCGRelocation; typedef struct TCGLabel { - int has_value; + unsigned has_value : 1; + unsigned id : 31; union { uintptr_t value; tcg_insn_unit *value_ptr; @@ -186,8 +187,6 @@ typedef struct TCGPool { #define TCG_POOL_CHUNK_SIZE 32768 -#define TCG_MAX_LABELS 512 - #define TCG_MAX_TEMPS 512 /* when the size of the arguments of a called function is smaller than @@ -696,8 +695,6 @@ struct TCGContext { uint16_t gen_opc_icount[OPC_BUF_SIZE]; uint8_t gen_opc_instr_start[OPC_BUF_SIZE]; - TCGLabel labels[TCG_MAX_LABELS]; - // Unicorn engine variables struct uc_struct *uc; /* qemu/target-i386/translate.c: global register indexes */ @@ -903,9 +900,7 @@ TCGLabel *gen_new_label(TCGContext* s); static inline TCGArg label_arg(TCGContext *tcg_ctx, TCGLabel *l) { - ptrdiff_t idx = l - tcg_ctx->labels; - tcg_debug_assert(idx >= 0 && idx < tcg_ctx->nb_labels); - return idx; + return (uintptr_t)l; } /** @@ -916,10 +911,9 @@ static inline TCGArg label_arg(TCGContext *tcg_ctx, TCGLabel *l) * encoding of the TCG opcode stream. */ -static inline TCGLabel *arg_label(TCGContext *tcg_ctx, TCGArg idx) +static inline TCGLabel *arg_label(TCGContext *tcg_ctx, TCGArg i) { - tcg_debug_assert(idx < tcg_ctx->nb_labels); - return &tcg_ctx->labels[idx]; + return (TCGLabel *)(uintptr_t)i; } /**