This commit is contained in:
Nguyen Anh Quynh 2016-07-11 23:37:12 +08:00
commit 579560e712
13 changed files with 35 additions and 3 deletions

View file

@ -14,6 +14,7 @@
#define memory_map_ptr memory_map_ptr_aarch64
#define memory_unmap memory_unmap_aarch64
#define memory_free memory_free_aarch64
#define free_code_gen_buffer free_code_gen_buffer_aarch64
#define helper_raise_exception helper_raise_exception_aarch64
#define tcg_enabled tcg_enabled_aarch64
#define tcg_exec_init tcg_exec_init_aarch64

View file

@ -14,6 +14,7 @@
#define memory_map_ptr memory_map_ptr_arm
#define memory_unmap memory_unmap_arm
#define memory_free memory_free_arm
#define free_code_gen_buffer free_code_gen_buffer_arm
#define helper_raise_exception helper_raise_exception_arm
#define tcg_enabled tcg_enabled_arm
#define tcg_exec_init tcg_exec_init_arm

View file

@ -20,6 +20,7 @@ symbols = (
'memory_map_ptr',
'memory_unmap',
'memory_free',
'free_code_gen_buffer',
'helper_raise_exception',
'tcg_enabled',
'tcg_exec_init',

View file

@ -14,6 +14,7 @@
#define memory_map_ptr memory_map_ptr_m68k
#define memory_unmap memory_unmap_m68k
#define memory_free memory_free_m68k
#define free_code_gen_buffer free_code_gen_buffer_m68k
#define helper_raise_exception helper_raise_exception_m68k
#define tcg_enabled tcg_enabled_m68k
#define tcg_exec_init tcg_exec_init_m68k

View file

@ -14,6 +14,7 @@
#define memory_map_ptr memory_map_ptr_mips
#define memory_unmap memory_unmap_mips
#define memory_free memory_free_mips
#define free_code_gen_buffer free_code_gen_buffer_mips
#define helper_raise_exception helper_raise_exception_mips
#define tcg_enabled tcg_enabled_mips
#define tcg_exec_init tcg_exec_init_mips

View file

@ -14,6 +14,7 @@
#define memory_map_ptr memory_map_ptr_mips64
#define memory_unmap memory_unmap_mips64
#define memory_free memory_free_mips64
#define free_code_gen_buffer free_code_gen_buffer_mips64
#define helper_raise_exception helper_raise_exception_mips64
#define tcg_enabled tcg_enabled_mips64
#define tcg_exec_init tcg_exec_init_mips64

View file

@ -14,6 +14,7 @@
#define memory_map_ptr memory_map_ptr_mips64el
#define memory_unmap memory_unmap_mips64el
#define memory_free memory_free_mips64el
#define free_code_gen_buffer free_code_gen_buffer_mips64el
#define helper_raise_exception helper_raise_exception_mips64el
#define tcg_enabled tcg_enabled_mips64el
#define tcg_exec_init tcg_exec_init_mips64el

View file

@ -14,6 +14,7 @@
#define memory_map_ptr memory_map_ptr_mipsel
#define memory_unmap memory_unmap_mipsel
#define memory_free memory_free_mipsel
#define free_code_gen_buffer free_code_gen_buffer_mipsel
#define helper_raise_exception helper_raise_exception_mipsel
#define tcg_enabled tcg_enabled_mipsel
#define tcg_exec_init tcg_exec_init_mipsel

View file

@ -14,6 +14,7 @@
#define memory_map_ptr memory_map_ptr_sparc
#define memory_unmap memory_unmap_sparc
#define memory_free memory_free_sparc
#define free_code_gen_buffer free_code_gen_buffer_sparc
#define helper_raise_exception helper_raise_exception_sparc
#define tcg_enabled tcg_enabled_sparc
#define tcg_exec_init tcg_exec_init_sparc

View file

@ -14,6 +14,7 @@
#define memory_map_ptr memory_map_ptr_sparc64
#define memory_unmap memory_unmap_sparc64
#define memory_free memory_free_sparc64
#define free_code_gen_buffer free_code_gen_buffer_sparc64
#define helper_raise_exception helper_raise_exception_sparc64
#define tcg_enabled tcg_enabled_sparc64
#define tcg_exec_init tcg_exec_init_sparc64

View file

@ -126,6 +126,9 @@ static void tb_link_page(struct uc_struct *uc, TranslationBlock *tb,
tb_page_addr_t phys_pc, tb_page_addr_t phys_page2);
static TranslationBlock *tb_find_pc(struct uc_struct *uc, uintptr_t tc_ptr);
// Unicorn: for cleaning up memory later.
void free_code_gen_buffer(struct uc_struct *uc);
static void cpu_gen_init(struct uc_struct *uc)
{
uc->tcg_ctx = g_malloc(sizeof(TCGContext));
@ -563,6 +566,11 @@ static inline void *split_cross_256mb(struct uc_struct *uc, void *buf1, size_t s
static uint8_t static_code_gen_buffer[DEFAULT_CODE_GEN_BUFFER_SIZE]
__attribute__((aligned(CODE_GEN_ALIGN)));
void free_code_gen_buffer(struct uc_struct *uc)
{
// Do nothing, we use a static buffer.
}
static inline void *alloc_code_gen_buffer(struct uc_struct *uc)
{
TCGContext *tcg_ctx = uc->tcg_ctx;
@ -576,6 +584,13 @@ static inline void *alloc_code_gen_buffer(struct uc_struct *uc)
return buf;
}
#elif defined(USE_MMAP)
void free_code_gen_buffer(struct uc_struct *uc)
{
TCGContext *tcg_ctx = uc->tcg_ctx;
if (tcg_ctx->code_gen_buffer)
munmap(tcg_ctx->code_gen_buffer, tcg_ctx->code_gen_buffer_size);
}
static inline void *alloc_code_gen_buffer(struct uc_struct *uc)
{
int flags = MAP_PRIVATE | MAP_ANONYMOUS;
@ -648,6 +663,13 @@ static inline void *alloc_code_gen_buffer(struct uc_struct *uc)
return buf;
}
#else
void free_code_gen_buffer(struct uc_struct *uc)
{
TCGContext *tcg_ctx = uc->tcg_ctx;
if (tcg_ctx->code_gen_buffer)
g_free(tcg_ctx->code_gen_buffer);
}
static inline void *alloc_code_gen_buffer(struct uc_struct *uc)
{
TCGContext *tcg_ctx = uc->tcg_ctx;

View file

@ -21,6 +21,7 @@ static inline bool cpu_physical_mem_write(AddressSpace *as, hwaddr addr,
}
void tb_cleanup(struct uc_struct *uc);
void free_code_gen_buffer(struct uc_struct *uc);
/** Freeing common resources */
static void release_common(void *t)
@ -35,9 +36,6 @@ static void release_common(void *t)
g_free(def->args_ct);
g_free(def->sorted_args);
g_free(s->tcg_op_defs);
if (s->code_gen_buffer) {
munmap(s->code_gen_buffer, s->code_gen_buffer_size);
}
TCGPool *po, *to;
for (po = s->pool_first; po; po = to) {
@ -53,6 +51,7 @@ static void release_common(void *t)
address_space_destroy(&(s->uc->as));
memory_free(s->uc);
tb_cleanup(s->uc);
free_code_gen_buffer(s->uc);
#if TCG_TARGET_REG_BITS == 32
for(i = 0; i < s->nb_globals; i++) {

View file

@ -14,6 +14,7 @@
#define memory_map_ptr memory_map_ptr_x86_64
#define memory_unmap memory_unmap_x86_64
#define memory_free memory_free_x86_64
#define free_code_gen_buffer free_code_gen_buffer_x86_64
#define helper_raise_exception helper_raise_exception_x86_64
#define tcg_enabled tcg_enabled_x86_64
#define tcg_exec_init tcg_exec_init_x86_64