mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-03-24 22:15:07 +00:00
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:
parent
9d5b378475
commit
1be7b55bb4
|
@ -217,10 +217,15 @@ struct uc_struct {
|
||||||
intptr_t qemu_host_page_mask;
|
intptr_t qemu_host_page_mask;
|
||||||
|
|
||||||
/* code generation context */
|
/* code generation context */
|
||||||
void *tcg_ctx; // for "TCGContext tcg_ctx" in translate-all.c
|
// translate-all.c
|
||||||
void *tcg_init_ctx; // for "TCGContext init_tcg_contex" in translate-all.c
|
void *tcg_ctx; // actually "TCGContext *tcg_ctx"
|
||||||
|
void *tcg_init_ctx; // actually "TCGContext *init_tcg_contex"
|
||||||
TBContext tb_ctx;
|
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 */
|
/* memory.c */
|
||||||
unsigned memory_region_transaction_depth;
|
unsigned memory_region_transaction_depth;
|
||||||
|
|
|
@ -169,7 +169,7 @@ static void cpu_gen_init(struct uc_struct *uc)
|
||||||
{
|
{
|
||||||
uc->tcg_init_ctx = g_malloc0(sizeof(TCGContext));;
|
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)
|
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;
|
TCGContext *tcg_ctx;
|
||||||
|
|
||||||
cpu_gen_init(uc);
|
cpu_gen_init(uc);
|
||||||
uc->tcg_ctx = uc->tcg_init_ctx;
|
|
||||||
tcg_ctx = uc->tcg_ctx;
|
tcg_ctx = uc->tcg_ctx;
|
||||||
tcg_ctx->uc = uc;
|
tcg_ctx->uc = uc;
|
||||||
page_init(uc);
|
page_init(uc);
|
||||||
|
|
|
@ -325,7 +325,7 @@ static const TCGHelperInfo all_helpers[] = {
|
||||||
|
|
||||||
static void process_op_defs(TCGContext *s);
|
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;
|
int op, total_args, n, i;
|
||||||
TCGOpDef *def;
|
TCGOpDef *def;
|
||||||
|
@ -387,6 +387,10 @@ void tcg_context_init(TCGContext *s)
|
||||||
for (; i < ARRAY_SIZE(tcg_target_reg_alloc_order); ++i) {
|
for (; i < ARRAY_SIZE(tcg_target_reg_alloc_order); ++i) {
|
||||||
s->indirect_reg_alloc_order[i] = 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -639,7 +639,7 @@ void *tcg_malloc_internal(TCGContext *s, int size);
|
||||||
void tcg_pool_reset(TCGContext *s);
|
void tcg_pool_reset(TCGContext *s);
|
||||||
TranslationBlock *tcg_tb_alloc(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_context_free(void *s); // free memory allocated for @s
|
||||||
void tcg_prologue_init(TCGContext *s);
|
void tcg_prologue_init(TCGContext *s);
|
||||||
void tcg_func_start(TCGContext *s);
|
void tcg_func_start(TCGContext *s);
|
||||||
|
|
Loading…
Reference in a new issue