From: Richard Henderson <rth@twiddle.net>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org
Subject: [Qemu-devel] [PULL 5/6] tcg: Use tcg_malloc to allocate TCGLabel
Date: Fri, 13 Mar 2015 13:23:12 -0700 [thread overview]
Message-ID: <1426278193-15317-6-git-send-email-rth@twiddle.net> (raw)
In-Reply-To: <1426278193-15317-1-git-send-email-rth@twiddle.net>
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>
---
tcg/tcg.c | 31 ++++++++++++++++++-------------
tcg/tcg.h | 16 +++++-----------
2 files changed, 23 insertions(+), 24 deletions(-)
diff --git a/tcg/tcg.c b/tcg/tcg.c
index 97aa512..f1558b7 100644
--- a/tcg/tcg.c
+++ b/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)
{
TCGContext *s = &tcg_ctx;
- int idx;
- TCGLabel *l;
+ TCGLabel *l = tcg_malloc(sizeof(TCGLabel));
- 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;
+ *l = (TCGLabel){
+ .id = s->nb_labels++
+ };
return l;
}
@@ -1086,11 +1082,20 @@ void tcg_dump_ops(TCGContext *s)
i = 0;
break;
}
- for (; i < nb_cargs; i++) {
- if (k != 0) {
- qemu_log(",");
- }
- qemu_log("$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(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");
diff --git a/tcg/tcg.h b/tcg/tcg.h
index 1987d24..add7f75 100644
--- a/tcg/tcg.h
+++ b/tcg/tcg.h
@@ -167,7 +167,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;
@@ -183,8 +184,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
@@ -556,8 +555,6 @@ struct TCGContext {
target_ulong gen_opc_pc[OPC_BUF_SIZE];
uint16_t gen_opc_icount[OPC_BUF_SIZE];
uint8_t gen_opc_instr_start[OPC_BUF_SIZE];
-
- TCGLabel labels[TCG_MAX_LABELS];
};
extern TCGContext tcg_ctx;
@@ -766,9 +763,7 @@ TCGLabel *gen_new_label(void);
static inline TCGArg label_arg(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;
}
/**
@@ -779,10 +774,9 @@ static inline TCGArg label_arg(TCGLabel *l)
* 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 &tcg_ctx.labels[idx];
+ return (TCGLabel *)(uintptr_t)i;
}
/**
--
2.1.0
next prev parent reply other threads:[~2015-03-13 20:37 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-13 20:23 [Qemu-devel] [PULL 0/6] Use tcg_malloc more; tcg_cond_always fix Richard Henderson
2015-03-13 20:23 ` [Qemu-devel] [PULL 1/6] tcg: Use tcg_malloc to allocate TCGLabelQemuLdst Richard Henderson
2015-03-13 20:23 ` [Qemu-devel] [PULL 2/6] tcg-ia64: " Richard Henderson
2015-03-13 20:23 ` [Qemu-devel] [PULL 3/6] tcg: Change translator-side labels to a pointer Richard Henderson
2015-03-13 20:23 ` [Qemu-devel] [PULL 4/6] tcg: Change generator-side " Richard Henderson
2015-03-13 20:23 ` Richard Henderson [this message]
2015-03-13 20:23 ` [Qemu-devel] [PULL 6/6] tcg: Complete handling of ALWAYS and NEVER Richard Henderson
2015-03-13 20:50 ` [Qemu-devel] [PULL 0/6] Use tcg_malloc more; tcg_cond_always fix Patchew Tool
2015-03-16 9:53 ` Peter Maydell
2015-03-16 10:57 ` Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1426278193-15317-6-git-send-email-rth@twiddle.net \
--to=rth@twiddle.net \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).