tcg: Use tcg_malloc to allocate TCGLabelQemuLdst

Pre-allocating 640 of them per TB is a waste.

Backports commit 686461c96254f34bcce67a949c72867ab6ec3fcf from qemu
This commit is contained in:
Richard Henderson 2018-03-04 21:59:15 -05:00 committed by Lioncash
parent 31b8b67cd3
commit 3c8cdb237a
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7

View file

@ -21,7 +21,6 @@
*/ */
#ifdef CONFIG_SOFTMMU #ifdef CONFIG_SOFTMMU
#define TCG_MAX_QEMU_LDST 640
typedef struct TCGLabelQemuLdst { typedef struct TCGLabelQemuLdst {
bool is_ld; /* qemu_ld: true, qemu_st: false */ bool is_ld; /* qemu_ld: true, qemu_st: false */
@ -33,11 +32,11 @@ typedef struct TCGLabelQemuLdst {
TCGReg datahi_reg; /* reg index for high word to be loaded or stored */ TCGReg datahi_reg; /* reg index for high word to be loaded or stored */
tcg_insn_unit *raddr; /* gen code addr of the next IR of qemu_ld/st IR */ tcg_insn_unit *raddr; /* gen code addr of the next IR of qemu_ld/st IR */
tcg_insn_unit *label_ptr[2]; /* label pointers to be updated */ tcg_insn_unit *label_ptr[2]; /* label pointers to be updated */
struct TCGLabelQemuLdst *next;
} TCGLabelQemuLdst; } TCGLabelQemuLdst;
typedef struct TCGBackendData { typedef struct TCGBackendData {
int nb_ldst_labels; TCGLabelQemuLdst *labels;
TCGLabelQemuLdst ldst_labels[TCG_MAX_QEMU_LDST];
} TCGBackendData; } TCGBackendData;
@ -47,7 +46,7 @@ typedef struct TCGBackendData {
static inline void tcg_out_tb_init(TCGContext *s) static inline void tcg_out_tb_init(TCGContext *s)
{ {
s->be->nb_ldst_labels = 0; s->be->labels = NULL;
} }
/* /*
@ -59,15 +58,14 @@ static void tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l);
static bool tcg_out_tb_finalize(TCGContext *s) static bool tcg_out_tb_finalize(TCGContext *s)
{ {
TCGLabelQemuLdst *lb = s->be->ldst_labels; TCGLabelQemuLdst *lb;
int i, n = s->be->nb_ldst_labels;
/* qemu_ld/st slow paths */ /* qemu_ld/st slow paths */
for (i = 0; i < n; i++) { for (lb = s->be->labels; lb != NULL; lb = lb->next) {
if (lb[i].is_ld) { if (lb->is_ld) {
tcg_out_qemu_ld_slow_path(s, lb + i); tcg_out_qemu_ld_slow_path(s, lb);
} else { } else {
tcg_out_qemu_st_slow_path(s, lb + i); tcg_out_qemu_st_slow_path(s, lb);
} }
/* Test for (pending) buffer overflow. The assumption is that any /* Test for (pending) buffer overflow. The assumption is that any
@ -88,11 +86,11 @@ static bool tcg_out_tb_finalize(TCGContext *s)
static inline TCGLabelQemuLdst *new_ldst_label(TCGContext *s) static inline TCGLabelQemuLdst *new_ldst_label(TCGContext *s)
{ {
TCGBackendData *be = s->be; TCGBackendData *be = s->be;
int n = be->nb_ldst_labels; TCGLabelQemuLdst *l = tcg_malloc(s, sizeof(*l));
assert(n < TCG_MAX_QEMU_LDST); l->next = be->labels;
be->nb_ldst_labels = n + 1; be->labels = l;
return &be->ldst_labels[n]; return l;
} }
#else #else
#include "tcg-be-null.h" #include "tcg-be-null.h"