From 1924bdfb5a0d1337fad2172348a3560e14fe614e Mon Sep 17 00:00:00 2001 From: Vacantron Chen Date: Wed, 21 Aug 2024 01:46:33 +0800 Subject: [PATCH] Fix jit-cache without T2C enabled Fix #475 --- src/jit.c | 4 +++- src/riscv.c | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/jit.c b/src/jit.c index c0a895bc..30a868bf 100644 --- a/src/jit.c +++ b/src/jit.c @@ -1864,8 +1864,10 @@ static void code_cache_flush(struct jit_state *state, riscv_t *rv) state->offset = state->org_size; state->n_blocks = 0; set_reset(&state->set); - jit_cache_clear(rv->jit_cache); clear_cache_hot(rv->block_cache, (clear_func_t) clear_hot); +#if RV32_HAS(T2C) + jit_cache_clear(rv->jit_cache); +#endif return; } diff --git a/src/riscv.c b/src/riscv.c index 231911f2..f163e854 100644 --- a/src/riscv.c +++ b/src/riscv.c @@ -290,11 +290,11 @@ riscv_t *rv_create(riscv_user_t rv_attr) mpool_create(sizeof(chain_entry_t) << BLOCK_IR_MAP_CAPACITY_BITS, sizeof(chain_entry_t)); rv->jit_state = jit_state_init(CODE_CACHE_SIZE); - rv->jit_cache = jit_cache_init(); rv->block_cache = cache_create(BLOCK_MAP_CAPACITY_BITS); assert(rv->block_cache); #if RV32_HAS(T2C) rv->quit = false; + rv->jit_cache = jit_cache_init(); /* prepare wait queue. */ pthread_mutex_init(&rv->wait_queue_lock, NULL); INIT_LIST_HEAD(&rv->wait_queue); @@ -389,10 +389,10 @@ void rv_delete(riscv_t *rv) rv->quit = true; pthread_join(t2c_thread, NULL); pthread_mutex_destroy(&rv->wait_queue_lock); + jit_cache_exit(rv->jit_cache); #endif mpool_destroy(rv->chain_entry_mp); jit_state_exit(rv->jit_state); - jit_cache_exit(rv->jit_cache); cache_free(rv->block_cache); #endif free(rv);