mirror of
https://github.com/micropython/micropython.git
synced 2026-01-05 03:30:14 +01:00
py/emitglue: Flush caches when loading native code without emitters.
This commit forces a data/instruction cache flush after loading native code blocks even if there's no emitter available. Caches flush upon native code load was still tied to the presence of a native emitter, but this assumption is no longer valid due to previous commits decoupling native code loading from code generation availability. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This commit is contained in:
@@ -107,14 +107,14 @@ void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, cons
|
||||
// Some architectures require flushing/invalidation of the I/D caches,
|
||||
// so that the generated native code which was created in data RAM will
|
||||
// be available for execution from instruction RAM.
|
||||
#if MICROPY_EMIT_THUMB || MICROPY_EMIT_INLINE_THUMB
|
||||
#if MICROPY_EMIT_THUMB || MICROPY_EMIT_INLINE_THUMB || (MP_NATIVE_ARCH_ARMV6M <= MPY_FEATURE_ARCH && MPY_FEATURE_ARCH <= MP_NATIVE_ARCH_ARMV7EMDP)
|
||||
#if __ICACHE_PRESENT == 1
|
||||
// Flush D-cache, so the code emitted is stored in RAM.
|
||||
MP_HAL_CLEAN_DCACHE(fun_data, fun_len);
|
||||
// Invalidate I-cache, so the newly-created code is reloaded from RAM.
|
||||
SCB_InvalidateICache();
|
||||
#endif
|
||||
#elif MICROPY_EMIT_ARM
|
||||
#elif MICROPY_EMIT_ARM || (MPY_FEATURE_ARCH == MP_NATIVE_ARCH_ARMV6)
|
||||
#if (defined(__linux__) && defined(__GNUC__)) || __ARM_ARCH == 7
|
||||
__builtin___clear_cache((void *)fun_data, (char *)fun_data + fun_len);
|
||||
#elif defined(__arm__)
|
||||
@@ -127,7 +127,7 @@ void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, cons
|
||||
"mcr p15, 0, r0, c7, c7, 0\n" // invalidate I-cache and D-cache
|
||||
: : : "r0", "cc");
|
||||
#endif
|
||||
#elif (MICROPY_EMIT_RV32 || MICROPY_EMIT_INLINE_RV32) && defined(MP_HAL_CLEAN_DCACHE)
|
||||
#elif (MICROPY_EMIT_RV32 || MICROPY_EMIT_INLINE_RV32 || (MPY_FEATURE_ARCH == MP_NATIVE_ARCH_RV32IMC)) && defined(MP_HAL_CLEAN_DCACHE)
|
||||
// Flush the D-cache.
|
||||
MP_HAL_CLEAN_DCACHE(fun_data, fun_len);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user