tcg: introduce **tcg_ctxs to keep track of all TCGContext's

Groundwork for supporting multiple TCG contexts.

Note that having n_tcg_ctxs is unnecessary. However, it is
convenient to have it, since it will simplify iterating over the
array: we'll have just a for loop instead of having to iterate
over a NULL-terminated array (which would require n+1 elems)
or having to check with ifdef's for usermode/softmmu.

Backports commit df2cce2968069526553d82331ce9817eaca6b03a from qemu
This commit is contained in:
Emilio G. Cota 2018-03-14 09:49:41 -04:00 committed by Lioncash
parent 9d5b378475
commit 1be7b55bb4
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7
4 changed files with 15 additions and 7 deletions

View file

@ -217,10 +217,15 @@ struct uc_struct {
intptr_t qemu_host_page_mask;
/* code generation context */
void *tcg_ctx; // for "TCGContext tcg_ctx" in translate-all.c
void *tcg_init_ctx; // for "TCGContext init_tcg_contex" in translate-all.c
// translate-all.c
void *tcg_ctx; // actually "TCGContext *tcg_ctx"
void *tcg_init_ctx; // actually "TCGContext *init_tcg_contex"
TBContext tb_ctx;
bool parallel_cpus; // for "bool parallel_cpus" in translate-all.c
bool parallel_cpus;
// tcg.c
void *tcg_ctxs; // actually "TCGContext **tcg_ctxs"
unsigned int n_tcg_ctxs;
/* memory.c */
unsigned memory_region_transaction_depth;

View file

@ -169,7 +169,7 @@ static void cpu_gen_init(struct uc_struct *uc)
{
uc->tcg_init_ctx = g_malloc0(sizeof(TCGContext));;
tcg_context_init(uc->tcg_init_ctx);
tcg_context_init(uc, uc->tcg_init_ctx);
}
static void tb_clean_internal(struct uc_struct *uc, int i, void** lp)
@ -880,7 +880,6 @@ void tcg_exec_init(struct uc_struct *uc, unsigned long tb_size)
TCGContext *tcg_ctx;
cpu_gen_init(uc);
uc->tcg_ctx = uc->tcg_init_ctx;
tcg_ctx = uc->tcg_ctx;
tcg_ctx->uc = uc;
page_init(uc);

View file

@ -325,7 +325,7 @@ static const TCGHelperInfo all_helpers[] = {
static void process_op_defs(TCGContext *s);
void tcg_context_init(TCGContext *s)
void tcg_context_init(struct uc_struct *uc, TCGContext *s)
{
int op, total_args, n, i;
TCGOpDef *def;
@ -387,6 +387,10 @@ void tcg_context_init(TCGContext *s)
for (; i < ARRAY_SIZE(tcg_target_reg_alloc_order); ++i) {
s->indirect_reg_alloc_order[i] = tcg_target_reg_alloc_order[i];
}
uc->tcg_ctx = s;
uc->tcg_ctxs = &uc->tcg_ctx;
uc->n_tcg_ctxs = 1;
}
/*

View file

@ -639,7 +639,7 @@ void *tcg_malloc_internal(TCGContext *s, int size);
void tcg_pool_reset(TCGContext *s);
TranslationBlock *tcg_tb_alloc(TCGContext *s);
void tcg_context_init(TCGContext *s);
void tcg_context_init(struct uc_struct *uc, TCGContext *s);
void tcg_context_free(void *s); // free memory allocated for @s
void tcg_prologue_init(TCGContext *s);
void tcg_func_start(TCGContext *s);