From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60274) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YWWKr-0005TF-MM for qemu-devel@nongnu.org; Fri, 13 Mar 2015 16:37:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YWW7Y-0003C4-3c for qemu-devel@nongnu.org; Fri, 13 Mar 2015 16:23:52 -0400 Received: from mail-qc0-x22e.google.com ([2607:f8b0:400d:c01::22e]:39503) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YWW7X-0003C0-VN for qemu-devel@nongnu.org; Fri, 13 Mar 2015 16:23:48 -0400 Received: by qcvs11 with SMTP id s11so29546566qcv.6 for ; Fri, 13 Mar 2015 13:23:47 -0700 (PDT) Sender: Richard Henderson From: Richard Henderson Date: Fri, 13 Mar 2015 13:23:08 -0700 Message-Id: <1426278193-15317-2-git-send-email-rth@twiddle.net> In-Reply-To: <1426278193-15317-1-git-send-email-rth@twiddle.net> References: <1426278193-15317-1-git-send-email-rth@twiddle.net> Subject: [Qemu-devel] [PULL 1/6] tcg: Use tcg_malloc to allocate TCGLabelQemuLdst List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org Pre-allocating 640 of them per TB is a waste. Reviewed-by: Bastian Koppelmann Signed-off-by: Richard Henderson --- tcg/tcg-be-ldst.h | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/tcg/tcg-be-ldst.h b/tcg/tcg-be-ldst.h index 429cba2..4a45102 100644 --- a/tcg/tcg-be-ldst.h +++ b/tcg/tcg-be-ldst.h @@ -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 */ @@ -34,11 +33,11 @@ typedef struct TCGLabelQemuLdst { int mem_index; /* soft MMU memory index */ 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; @@ -48,7 +47,7 @@ typedef struct TCGBackendData { static inline void tcg_out_tb_init(TCGContext *s) { - s->be->nb_ldst_labels = 0; + s->be->labels = NULL; } /* @@ -60,15 +59,14 @@ static void tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l); static void 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); } } } @@ -80,11 +78,11 @@ static void 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(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" -- 2.1.0