Skip to content

Commit f7b9ded

Browse files
committed
Migrate JIT-cache
1 parent 37daa23 commit f7b9ded

File tree

2 files changed

+25
-25
lines changed

2 files changed

+25
-25
lines changed

src/jit.c

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2026,28 +2026,3 @@ void jit_state_exit(struct jit_state *state)
20262026
free(state->jumps);
20272027
free(state);
20282028
}
2029-
2030-
#if RV32_HAS(JIT_CACHE)
2031-
struct jit_cache *jit_cache_init()
2032-
{
2033-
return calloc(MAX_JIT_CACHE_TABLE_ENTRIES, sizeof(struct jit_cache));
2034-
}
2035-
2036-
void jit_cache_exit(struct jit_cache *cache)
2037-
{
2038-
free(cache);
2039-
}
2040-
2041-
void jit_cache_update(struct jit_cache *cache, uint32_t pc, void *entry)
2042-
{
2043-
uint32_t pos = pc & (MAX_JIT_CACHE_TABLE_ENTRIES - 1);
2044-
2045-
cache[pos].pc = pc;
2046-
cache[pos].entry = entry;
2047-
}
2048-
2049-
void jit_cache_clear(struct jit_cache *cache)
2050-
{
2051-
memset(cache, 0, MAX_JIT_CACHE_TABLE_ENTRIES * sizeof(struct jit_cache));
2052-
}
2053-
#endif

src/t2c.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,3 +314,28 @@ void t2c_compile(riscv_t *rv, block_t *block)
314314
jit_cache_update(rv->jit_cache, block->pc_start, block->func);
315315
block->hot2 = true;
316316
}
317+
318+
#if RV32_HAS(JIT_CACHE)
319+
struct jit_cache *jit_cache_init()
320+
{
321+
return calloc(MAX_JIT_CACHE_TABLE_ENTRIES, sizeof(struct jit_cache));
322+
}
323+
324+
void jit_cache_exit(struct jit_cache *cache)
325+
{
326+
free(cache);
327+
}
328+
329+
void jit_cache_update(struct jit_cache *cache, uint32_t pc, void *entry)
330+
{
331+
uint32_t pos = pc & (MAX_JIT_CACHE_TABLE_ENTRIES - 1);
332+
333+
cache[pos].pc = pc;
334+
cache[pos].entry = entry;
335+
}
336+
337+
void jit_cache_clear(struct jit_cache *cache)
338+
{
339+
memset(cache, 0, MAX_JIT_CACHE_TABLE_ENTRIES * sizeof(struct jit_cache));
340+
}
341+
#endif

0 commit comments

Comments
 (0)