Skip to content

Commit dc2adfc

Browse files
authored
Merge pull request #476 from vacantron/develop
Fix jit-cache without T2C enabled
2 parents 4ed6317 + 1924bdf commit dc2adfc

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/jit.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1864,8 +1864,10 @@ static void code_cache_flush(struct jit_state *state, riscv_t *rv)
18641864
state->offset = state->org_size;
18651865
state->n_blocks = 0;
18661866
set_reset(&state->set);
1867-
jit_cache_clear(rv->jit_cache);
18681867
clear_cache_hot(rv->block_cache, (clear_func_t) clear_hot);
1868+
#if RV32_HAS(T2C)
1869+
jit_cache_clear(rv->jit_cache);
1870+
#endif
18691871
return;
18701872
}
18711873

src/riscv.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,11 +290,11 @@ riscv_t *rv_create(riscv_user_t rv_attr)
290290
mpool_create(sizeof(chain_entry_t) << BLOCK_IR_MAP_CAPACITY_BITS,
291291
sizeof(chain_entry_t));
292292
rv->jit_state = jit_state_init(CODE_CACHE_SIZE);
293-
rv->jit_cache = jit_cache_init();
294293
rv->block_cache = cache_create(BLOCK_MAP_CAPACITY_BITS);
295294
assert(rv->block_cache);
296295
#if RV32_HAS(T2C)
297296
rv->quit = false;
297+
rv->jit_cache = jit_cache_init();
298298
/* prepare wait queue. */
299299
pthread_mutex_init(&rv->wait_queue_lock, NULL);
300300
INIT_LIST_HEAD(&rv->wait_queue);
@@ -389,10 +389,10 @@ void rv_delete(riscv_t *rv)
389389
rv->quit = true;
390390
pthread_join(t2c_thread, NULL);
391391
pthread_mutex_destroy(&rv->wait_queue_lock);
392+
jit_cache_exit(rv->jit_cache);
392393
#endif
393394
mpool_destroy(rv->chain_entry_mp);
394395
jit_state_exit(rv->jit_state);
395-
jit_cache_exit(rv->jit_cache);
396396
cache_free(rv->block_cache);
397397
#endif
398398
free(rv);

0 commit comments

Comments
 (0)