Skip to content

Commit

Permalink
tcg: Create tcg_init
Browse files Browse the repository at this point in the history
Perform both tcg_context_init and tcg_region_init.
Do not leave this split to the caller.

Reviewed-by: Luis Pires <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
  • Loading branch information
rth7680 committed Jun 11, 2021
1 parent 7109ef1 commit a76aabd
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
3 changes: 1 addition & 2 deletions accel/tcg/translate-all.c
Original file line number Diff line number Diff line change
Expand Up @@ -920,10 +920,9 @@ static void tb_htable_init(void)
void tcg_exec_init(unsigned long tb_size, int splitwx)
{
tcg_allowed = true;
tcg_context_init(&tcg_init_ctx);
page_init();
tb_htable_init();
tcg_region_init(tb_size, splitwx);
tcg_init(tb_size, splitwx);

#if defined(CONFIG_SOFTMMU)
/* There's no guest base to take into account, so go ahead and
Expand Down
3 changes: 1 addition & 2 deletions include/tcg/tcg.h
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,6 @@ void *tcg_malloc_internal(TCGContext *s, int size);
void tcg_pool_reset(TCGContext *s);
TranslationBlock *tcg_tb_alloc(TCGContext *s);

void tcg_region_init(size_t tb_size, int splitwx);
void tb_destroy(TranslationBlock *tb);
void tcg_region_reset_all(void);

Expand Down Expand Up @@ -906,7 +905,7 @@ static inline void *tcg_malloc(int size)
}
}

void tcg_context_init(TCGContext *s);
void tcg_init(size_t tb_size, int splitwx);
void tcg_register_thread(void);
void tcg_prologue_init(TCGContext *s);
void tcg_func_start(TCGContext *s);
Expand Down
1 change: 1 addition & 0 deletions tcg/tcg-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
extern TCGContext **tcg_ctxs;
extern unsigned int n_tcg_ctxs;

void tcg_region_init(size_t tb_size, int splitwx);
bool tcg_region_alloc(TCGContext *s);
void tcg_region_initial_alloc(TCGContext *s);
void tcg_region_prologue_set(TCGContext *s);
Expand Down
9 changes: 8 additions & 1 deletion tcg/tcg.c
Original file line number Diff line number Diff line change
Expand Up @@ -576,8 +576,9 @@ static void process_op_defs(TCGContext *s);
static TCGTemp *tcg_global_reg_new_internal(TCGContext *s, TCGType type,
TCGReg reg, const char *name);

void tcg_context_init(TCGContext *s)
static void tcg_context_init(void)
{
TCGContext *s = &tcg_init_ctx;
int op, total_args, n, i;
TCGOpDef *def;
TCGArgConstraint *args_ct;
Expand Down Expand Up @@ -654,6 +655,12 @@ void tcg_context_init(TCGContext *s)
cpu_env = temp_tcgv_ptr(ts);
}

void tcg_init(size_t tb_size, int splitwx)
{
tcg_context_init();
tcg_region_init(tb_size, splitwx);
}

/*
* Allocate TBs right before their corresponding translated code, making
* sure that TBs and code are on different cache lines.
Expand Down

0 comments on commit a76aabd

Please sign in to comment.