mirror of
https://github.com/yuzu-emu/unicorn
synced 2024-11-25 19:36:23 +00:00
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:
parent
31b8b67cd3
commit
3c8cdb237a
1 changed files with 12 additions and 14 deletions
|
@ -21,7 +21,6 @@
|
|||
*/
|
||||
|
||||
#ifdef CONFIG_SOFTMMU
|
||||
#define TCG_MAX_QEMU_LDST 640
|
||||
|
||||
typedef struct TCGLabelQemuLdst {
|
||||
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 */
|
||||
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 */
|
||||
struct TCGLabelQemuLdst *next;
|
||||
} TCGLabelQemuLdst;
|
||||
|
||||
typedef struct TCGBackendData {
|
||||
int nb_ldst_labels;
|
||||
TCGLabelQemuLdst ldst_labels[TCG_MAX_QEMU_LDST];
|
||||
TCGLabelQemuLdst *labels;
|
||||
} TCGBackendData;
|
||||
|
||||
|
||||
|
@ -47,7 +46,7 @@ typedef struct TCGBackendData {
|
|||
|
||||
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)
|
||||
{
|
||||
TCGLabelQemuLdst *lb = s->be->ldst_labels;
|
||||
int i, n = s->be->nb_ldst_labels;
|
||||
TCGLabelQemuLdst *lb;
|
||||
|
||||
/* qemu_ld/st slow paths */
|
||||
for (i = 0; i < n; i++) {
|
||||
if (lb[i].is_ld) {
|
||||
tcg_out_qemu_ld_slow_path(s, lb + i);
|
||||
for (lb = s->be->labels; lb != NULL; lb = lb->next) {
|
||||
if (lb->is_ld) {
|
||||
tcg_out_qemu_ld_slow_path(s, lb);
|
||||
} 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
|
||||
|
@ -88,11 +86,11 @@ static bool tcg_out_tb_finalize(TCGContext *s)
|
|||
static inline TCGLabelQemuLdst *new_ldst_label(TCGContext *s)
|
||||
{
|
||||
TCGBackendData *be = s->be;
|
||||
int n = be->nb_ldst_labels;
|
||||
TCGLabelQemuLdst *l = tcg_malloc(s, sizeof(*l));
|
||||
|
||||
assert(n < TCG_MAX_QEMU_LDST);
|
||||
be->nb_ldst_labels = n + 1;
|
||||
return &be->ldst_labels[n];
|
||||
l->next = be->labels;
|
||||
be->labels = l;
|
||||
return l;
|
||||
}
|
||||
#else
|
||||
#include "tcg-be-null.h"
|
||||
|
|
Loading…
Reference in a new issue