tcg: Use tcg_malloc to allocate TCGLabel
Pre-allocating 512 of them per TB is a waste. Reviewed-by: Bastian Koppelmann <kbastian@mail.uni-paderborn.de> Signed-off-by: Richard Henderson <rth@twiddle.net>
This commit is contained in:
parent
bec1631100
commit
51e3972c41
31
tcg/tcg.c
31
tcg/tcg.c
|
@ -246,15 +246,11 @@ static void tcg_out_label(TCGContext *s, TCGLabel *l, tcg_insn_unit *ptr)
|
||||||
TCGLabel *gen_new_label(void)
|
TCGLabel *gen_new_label(void)
|
||||||
{
|
{
|
||||||
TCGContext *s = &tcg_ctx;
|
TCGContext *s = &tcg_ctx;
|
||||||
int idx;
|
TCGLabel *l = tcg_malloc(sizeof(TCGLabel));
|
||||||
TCGLabel *l;
|
|
||||||
|
|
||||||
if (s->nb_labels >= TCG_MAX_LABELS)
|
*l = (TCGLabel){
|
||||||
tcg_abort();
|
.id = s->nb_labels++
|
||||||
idx = s->nb_labels++;
|
};
|
||||||
l = &s->labels[idx];
|
|
||||||
l->has_value = 0;
|
|
||||||
l->u.first_reloc = NULL;
|
|
||||||
|
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
@ -1086,11 +1082,20 @@ void tcg_dump_ops(TCGContext *s)
|
||||||
i = 0;
|
i = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
for (; i < nb_cargs; i++) {
|
switch (c) {
|
||||||
if (k != 0) {
|
case INDEX_op_set_label:
|
||||||
qemu_log(",");
|
case INDEX_op_br:
|
||||||
}
|
case INDEX_op_brcond_i32:
|
||||||
qemu_log("$0x%" TCG_PRIlx, args[k++]);
|
case INDEX_op_brcond_i64:
|
||||||
|
case INDEX_op_brcond2_i32:
|
||||||
|
qemu_log("%s$L%d", k ? "," : "", arg_label(args[k])->id);
|
||||||
|
i++, k++;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
for (; i < nb_cargs; i++, k++) {
|
||||||
|
qemu_log("%s$0x%" TCG_PRIlx, k ? "," : "", args[k]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
qemu_log("\n");
|
qemu_log("\n");
|
||||||
|
|
16
tcg/tcg.h
16
tcg/tcg.h
|
@ -167,7 +167,8 @@ typedef struct TCGRelocation {
|
||||||
} TCGRelocation;
|
} TCGRelocation;
|
||||||
|
|
||||||
typedef struct TCGLabel {
|
typedef struct TCGLabel {
|
||||||
int has_value;
|
unsigned has_value : 1;
|
||||||
|
unsigned id : 31;
|
||||||
union {
|
union {
|
||||||
uintptr_t value;
|
uintptr_t value;
|
||||||
tcg_insn_unit *value_ptr;
|
tcg_insn_unit *value_ptr;
|
||||||
|
@ -183,8 +184,6 @@ typedef struct TCGPool {
|
||||||
|
|
||||||
#define TCG_POOL_CHUNK_SIZE 32768
|
#define TCG_POOL_CHUNK_SIZE 32768
|
||||||
|
|
||||||
#define TCG_MAX_LABELS 512
|
|
||||||
|
|
||||||
#define TCG_MAX_TEMPS 512
|
#define TCG_MAX_TEMPS 512
|
||||||
|
|
||||||
/* when the size of the arguments of a called function is smaller than
|
/* when the size of the arguments of a called function is smaller than
|
||||||
|
@ -556,8 +555,6 @@ struct TCGContext {
|
||||||
target_ulong gen_opc_pc[OPC_BUF_SIZE];
|
target_ulong gen_opc_pc[OPC_BUF_SIZE];
|
||||||
uint16_t gen_opc_icount[OPC_BUF_SIZE];
|
uint16_t gen_opc_icount[OPC_BUF_SIZE];
|
||||||
uint8_t gen_opc_instr_start[OPC_BUF_SIZE];
|
uint8_t gen_opc_instr_start[OPC_BUF_SIZE];
|
||||||
|
|
||||||
TCGLabel labels[TCG_MAX_LABELS];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern TCGContext tcg_ctx;
|
extern TCGContext tcg_ctx;
|
||||||
|
@ -766,9 +763,7 @@ TCGLabel *gen_new_label(void);
|
||||||
|
|
||||||
static inline TCGArg label_arg(TCGLabel *l)
|
static inline TCGArg label_arg(TCGLabel *l)
|
||||||
{
|
{
|
||||||
ptrdiff_t idx = l - tcg_ctx.labels;
|
return (uintptr_t)l;
|
||||||
tcg_debug_assert(idx >= 0 && idx < tcg_ctx.nb_labels);
|
|
||||||
return idx;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -779,10 +774,9 @@ static inline TCGArg label_arg(TCGLabel *l)
|
||||||
* encoding of the TCG opcode stream.
|
* encoding of the TCG opcode stream.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static inline TCGLabel *arg_label(TCGArg idx)
|
static inline TCGLabel *arg_label(TCGArg i)
|
||||||
{
|
{
|
||||||
tcg_debug_assert(idx < tcg_ctx.nb_labels);
|
return (TCGLabel *)(uintptr_t)i;
|
||||||
return &tcg_ctx.labels[idx];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue